Skip to content

Commit

Permalink
refactor: vueClipBoard to useClipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
thnaylor committed Sep 9, 2023
1 parent 6b4eb15 commit a41d5e7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 42 deletions.
1 change: 0 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ export default defineNuxtConfig({
// '~/plugins/filters',
// '~/plugins/pwa',
// '~/plugins/vueAudioVisual',
// '~/plugins/vueClipboard',
// '~/plugins/vueSocialSharing',
// '~/plugins/vueTippy',
// '~/plugins/safeHref',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
"vite": "*",
"vue-apollo": "^3.1.0",
"vue-audio-visual": "2.5.0",
"vue-clipboard2": "^0.3.3",
"vue-dompurify-html": "^4.1.4",
"vue-infinite-loading": "^2.4.5",
"vue-social-sharing": "^3.0.9",
Expand Down
29 changes: 25 additions & 4 deletions plugins/vueClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
// import Vue from 'vue'
// import VueClipboard from 'vue-clipboard2'
export default defineNuxtPlugin((nuxtApp) => {
const { text, copy, copied, isSupported } = useClipboard({ legacy: true })

// Vue.use(VueClipboard)
export default defineNuxtPlugin(() => undefined)
nuxtApp.vueApp.directive('clipboard', {
beforeMount(el, { value, arg }) {
useEventListener(el, 'click', () => {
switch (arg) {
case 'copy':
copy(value)
break
}
})
},
})

return {
provide: {
clipboard: {
text,
copy,
copied,
isSupported,
},
},
}
})
43 changes: 7 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a41d5e7

Please sign in to comment.