2019-10-30 01:58:49 +00:00
|
|
|
import { importShowCopyDialog } from '../_components/dialog/asyncDialogs/importShowCopyDialog.js'
|
2021-07-05 03:19:04 +00:00
|
|
|
import { toast } from '../_components/toast/toast.js'
|
2018-08-26 23:40:48 +00:00
|
|
|
|
|
|
|
export async function copyText (text) {
|
|
|
|
if (navigator.clipboard) { // not supported in all browsers
|
|
|
|
try {
|
|
|
|
await navigator.clipboard.writeText(text)
|
2020-11-29 22:13:27 +00:00
|
|
|
/* no await */ toast.say('intl.copiedToClipboard')
|
2018-08-26 23:40:48 +00:00
|
|
|
return
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-03 20:49:37 +00:00
|
|
|
const showCopyDialog = await importShowCopyDialog()
|
2018-08-26 23:40:48 +00:00
|
|
|
showCopyDialog(text)
|
|
|
|
}
|