mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
* tail logs * add cli * add FE * abstract http to shared * batch new logs * file download for logs * fix modal error when no config Co-authored-by: Chris Guida <chrisguida@users.noreply.github.com> Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: Matt Hill <matthewonthemoon@gmail.com> Co-authored-by: BluJ <mogulslayer@gmail.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
|
|
}
|