- Startseite zeigt Clips, angeheftete zuerst, mit 'Weitere laden' - Schnell-Eingabe mit Text/Code, Spracherkennung und Einfügen aus der Zwischenablage - Kopieren-Button mit Clipboard API und Ausweichlösung - Syntax-Highlighting mit highlight.js (nur die 24 unterstützten Sprachen) - Pinia-Store für Clips als Grundlage für den Live-Sync Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
911 B
Vue
44 lines
911 B
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
|
|
import { copyText } from '@/utils/clipboard'
|
|
|
|
const props = defineProps<{ text: string }>()
|
|
|
|
const state = ref<'idle' | 'copied' | 'failed'>('idle')
|
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
|
|
async function copy(): Promise<void> {
|
|
try {
|
|
await copyText(props.text)
|
|
state.value = 'copied'
|
|
} catch {
|
|
state.value = 'failed'
|
|
}
|
|
clearTimeout(timer)
|
|
timer = setTimeout(() => (state.value = 'idle'), 1500)
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<button type="button" class="primary small copy" :class="state" @click="copy">
|
|
{{ state === 'copied' ? 'Kopiert ✓' : state === 'failed' ? 'Fehlgeschlagen' : 'Kopieren' }}
|
|
</button>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.copy {
|
|
min-width: 7.5rem;
|
|
}
|
|
|
|
.copy.copied {
|
|
background: var(--ok);
|
|
border-color: var(--ok);
|
|
}
|
|
|
|
.copy.failed {
|
|
background: var(--error);
|
|
border-color: var(--error);
|
|
}
|
|
</style>
|