2018-08-26 16:40:48 -07:00
|
|
|
import { importShowCopyDialog } from '../_components/dialog/asyncDialogs'
|
2018-12-22 15:37:51 -08:00
|
|
|
import { toast } from '../_components/toast/toast'
|
2018-08-26 16:40:48 -07: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 13:49:37 -07:00
|
|
|
const showCopyDialog = await importShowCopyDialog()
|
2018-08-26 16:40:48 -07:00
|
|
|
showCopyDialog(text)
|
|
|
|
}
|