MCPcopy Create free account
hub / github.com/anomalyco/opencode / handleClick

Function handleClick

packages/session-ui/src/components/markdown.tsx:292–310  ·  view source on GitHub ↗
(event: MouseEvent)

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 3

setCopyStateFunction · 0.85
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected