mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 20:43:41 +00:00
* feat: move all frontend projects under the same Angular workspace * Refactor/angular workspace (#1154) * update frontend build steps Co-authored-by: waterplea <alexander@inkin.ru> Co-authored-by: Matt Hill <matthewonthemoon@gmail.com> Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
23 lines
584 B
TypeScript
23 lines
584 B
TypeScript
export async function copyToClipboard (str: string): Promise<boolean> {
|
|
if (window.isSecureContext) {
|
|
return navigator.clipboard.writeText(str)
|
|
.then(() => {
|
|
return true
|
|
})
|
|
.catch(err => {
|
|
return false
|
|
})
|
|
} else {
|
|
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 copy = document.execCommand('copy')
|
|
document.body.removeChild(el)
|
|
return copy
|
|
}
|
|
}
|