2019-10-30 01:58:49 +00:00
|
|
|
import { importShowCopyDialog } from '../_components/dialog/asyncDialogs/importShowCopyDialog.js'
|
2018-12-22 23:37:51 +00:00
|
|
|
import { toast } from '../_components/toast/toast'
|
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)
|
|
|
|
toast.say('Copied to clipboard')
|
|
|
|
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)
|
|
|
|
}
|