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 a89338c commit 28e39b9Copy full SHA for 28e39b9
app/composables/useClipboardAsync.ts
@@ -18,16 +18,20 @@ export function useClipboardAsync(
18
immediate: false,
19
})
20
21
- function copy() {
+ async function copy() {
22
const asyncClipboard = new ClipboardItem({
23
'text/plain': fn().then(text => {
24
return new Blob([text], { type: 'text/plain' })
25
}),
26
27
28
- copied.value = true
29
- navigator.clipboard.write([asyncClipboard])
30
- timeout.start()
+ try {
+ await navigator.clipboard.write([asyncClipboard])
+ copied.value = true
31
+ timeout.start()
32
+ } catch {
33
+ copied.value = false
34
+ }
35
}
36
37
return {
0 commit comments