(text: string)
| 155 | * Copy text to clipboard |
| 156 | */ |
| 157 | export async function copyToClipboard(text: string): Promise<boolean> { |
| 158 | try { |
| 159 | await navigator.clipboard.writeText(text); |
| 160 | return true; |
| 161 | } catch { |
| 162 | // Deprecated fallback for older browsers that lack the async clipboard API. |
| 163 | const textarea = document.createElement("textarea"); |
| 164 | textarea.value = text; |
| 165 | textarea.style.position = "fixed"; |
| 166 | textarea.style.opacity = "0"; |
| 167 | document.body.appendChild(textarea); |
| 168 | textarea.select(); |
| 169 | const success = document.execCommand("copy"); |
| 170 | document.body.removeChild(textarea); |
| 171 | return success; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Generate VS Code install URL |
no outgoing calls
no test coverage detected