(event: MouseEvent)
| 290 | } |
| 291 | |
| 292 | const handleClick = async (event: MouseEvent) => { |
| 293 | const target = event.target |
| 294 | if (!(target instanceof Element)) return |
| 295 | |
| 296 | const button = target.closest('[data-slot="markdown-copy-button"]') |
| 297 | if (!(button instanceof HTMLElement)) return |
| 298 | const code = button.closest('[data-component="markdown-code"]')?.querySelector("code") |
| 299 | const content = code?.textContent ?? "" |
| 300 | if (!content) return |
| 301 | const clipboard = navigator?.clipboard |
| 302 | if (!clipboard) return |
| 303 | await clipboard.writeText(content) |
| 304 | const labels = getLabels() |
| 305 | setCopyState(button, labels, true) |
| 306 | const existing = timeouts.get(button) |
| 307 | if (existing) clearTimeout(existing) |
| 308 | const timeout = setTimeout(() => setCopyState(button, labels, false), 2000) |
| 309 | timeouts.set(button, timeout) |
| 310 | } |
| 311 | |
| 312 | const buttons = Array.from(root.querySelectorAll('[data-slot="markdown-copy-button"]')) |
| 313 | for (const button of buttons) { |
nothing calls this directly
no test coverage detected