From e6427d82cfa800404a3c1f99f619057f86216bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sat, 3 Sep 2022 16:29:38 +0200 Subject: [PATCH] Create a canCopyToCliboard composable --- composables/canCopyToClipboard.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 composables/canCopyToClipboard.ts diff --git a/composables/canCopyToClipboard.ts b/composables/canCopyToClipboard.ts new file mode 100644 index 0000000..8dc8674 --- /dev/null +++ b/composables/canCopyToClipboard.ts @@ -0,0 +1,12 @@ +const { isSupported } = useClipboard(); +const clipboardWirtePermission = usePermission('clipboard-write'); + +const canCopyToClipboard = computed( + () => isSupported.value && clipboardWirtePermission.value === 'granted' +); + +export const useCanCopyToClipboard = () => ({ + isSupported, + clipboardWirtePermission, + canCopyToClipboard +});