()
| 147 | const { code } = useContext(CodeBlockContext); |
| 148 | |
| 149 | const copyToClipboard = async () => { |
| 150 | if (typeof window === "undefined" || !navigator?.clipboard?.writeText) { |
| 151 | onError?.(new Error("Clipboard API not available")); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | try { |
| 156 | await navigator.clipboard.writeText(code); |
| 157 | setIsCopied(true); |
| 158 | onCopy?.(); |
| 159 | setTimeout(() => setIsCopied(false), timeout); |
| 160 | } catch (error) { |
| 161 | onError?.(error as Error); |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | const Icon = isCopied ? CheckIcon : CopyIcon; |
| 166 |
nothing calls this directly
no outgoing calls
no test coverage detected