Files
flotilla/src/lib/html.ts
T
2024-08-08 16:32:46 -07:00

16 lines
359 B
TypeScript

export const copyToClipboard = (text: string) => {
const {activeElement} = document
const input = document.createElement("textarea")
input.innerHTML = text
document.body.appendChild(input)
input.select()
const result = document.execCommand("copy")
document.body.removeChild(input)
;(activeElement as HTMLElement).focus()
return result
}