PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / utils / clipboard.ts

clipboard.ts in The Innovative Form Builder – IvyForms 1.0, at frontend/src/utils/clipboard.ts

30 lines 713 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 export async function copyTextToClipboard(text: string): Promise<boolean> {
2 if (typeof window === 'undefined' || typeof document === 'undefined') {
3 return false
4 }
5
6 if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
7 try {
8 await navigator.clipboard.writeText(text)
9 return true
10 } catch {
11 // Fall through to legacy fallback
12 }
13 }
14
15 const textarea = document.createElement('textarea')
16 textarea.value = text
17 textarea.style.position = 'fixed'
18 textarea.style.opacity = '0'
19 document.body.appendChild(textarea)
20 textarea.select()
21
22 try {
23 return document.execCommand('copy')
24 } catch {
25 return false
26 } finally {
27 textarea.remove()
28 }
29 }
30