Spaces:
Paused
Paused
| function fallbackCopy(text: string): boolean { | |
| const ta = document.createElement("textarea"); | |
| ta.value = text; | |
| ta.style.cssText = "position:fixed;left:-9999px;opacity:0"; | |
| document.body.appendChild(ta); | |
| ta.select(); | |
| let ok = false; | |
| try { | |
| ok = document.execCommand("copy"); | |
| } catch {} | |
| document.body.removeChild(ta); | |
| return ok; | |
| } | |
| export async function clipboardCopy(text: string): Promise<boolean> { | |
| if (navigator.clipboard?.writeText) { | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| return true; | |
| } catch {} | |
| } | |
| return fallbackCopy(text); | |
| } | |