vikunja-frontend/src/composables/useCopyToClipboard.ts
Dominik Pschenitschni 5ef939a230 feature/fix-vue-i18n-9.2.31 (#1994)
Co-authored-by: renovate <renovatebot@kolaente.de>
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/1994
Reviewed-by: konrad <k@knt.li>
Co-authored-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
Co-committed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
2022-05-23 05:23:59 +00:00

14 lines
No EOL
286 B
TypeScript

import {error} from '@/message'
import {useI18n} from 'vue-i18n'
export function useCopyToClipboard() {
const {t} = useI18n({useScope: 'global'})
return async (text: string) => {
try {
await navigator.clipboard.writeText(text)
} catch {
error(t('misc.copyError'))
}
}
}