feat: clip-liste mit schnell-eingabe und kopieren
- 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>
This commit is contained in:
1 parent
4caab7e657
commit
7b16940b96
13 files changed
+673
-42
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<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>
|
||||
Reference in new issue
Block a user