We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 180262e commit 327db44Copy full SHA for 327db44
src/runtime/composables/util.ts
@@ -0,0 +1,20 @@
1
+import { useToast } from '#imports'
2
+
3
+export const useCopyText = async (text: string, label = 'Text') => {
4
+ // STATE - GLOBAL
5
+ const toast = useToast()
6
7
+ if (!navigator.clipboard) {
8
+ // Clipboard API not available
9
+ toast.value.message = 'Error: Clipboard access is not available.'
10
+ toast.value.show = true
11
+ return
12
+ }
13
14
+ // Copy logic
15
+ await navigator.clipboard.writeText(text)
16
17
+ // Show success toast
18
+ toast.value.message = `${label} copied!`
19
20
+}
0 commit comments