mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
* rename frontend to web and update contributing guide * rename this time * fix build * restructure rust code * update documentation * update descriptions * Update CONTRIBUTING.md Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com> --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> Co-authored-by: J H <2364004+Blu-J@users.noreply.github.com>
20 lines
515 B
TypeScript
20 lines
515 B
TypeScript
export async function copyToClipboard(str: string): Promise<boolean> {
|
|
if (window.isSecureContext) {
|
|
return navigator.clipboard
|
|
.writeText(str)
|
|
.then(() => true)
|
|
.catch(() => false)
|
|
}
|
|
|
|
const el = document.createElement('textarea')
|
|
el.value = str
|
|
el.setAttribute('readonly', '')
|
|
el.style.position = 'absolute'
|
|
el.style.left = '-9999px'
|
|
document.body.appendChild(el)
|
|
el.select()
|
|
const didCopy = document.execCommand('copy')
|
|
document.body.removeChild(el)
|
|
return didCopy
|
|
}
|