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