()
| 78 | } |
| 79 | |
| 80 | const onCopy = async () => { |
| 81 | try { |
| 82 | const target = anchor.element as HTMLElement |
| 83 | const preBlock = target.closest("pre") |
| 84 | const codeBlock = target.querySelector("code") |
| 85 | let textContent = "" |
| 86 | |
| 87 | if (codeBlock) { |
| 88 | textContent = codeBlock.innerText |
| 89 | } else { |
| 90 | textContent = preBlock && preBlock.innerText |
| 91 | } |
| 92 | |
| 93 | navigator.clipboard.writeText(textContent) |
| 94 | |
| 95 | setIsCopy(true) |
| 96 | setTimeout(() => { |
| 97 | setIsCopy(false) |
| 98 | }, 1000) |
| 99 | } catch (error) { |
| 100 | console.log(error) |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return ( |
| 105 | <> |
nothing calls this directly
no outgoing calls
no test coverage detected