Skip to content

Commit

Permalink
fix copy to clipboard from dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
BuyOwnEx committed Apr 18, 2021
1 parent fe7adac commit 80b99e3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 16 deletions.
46 changes: 41 additions & 5 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"tiptap-extensions": "^1.29.1",
"vue": "^2.6.11",
"vue-apexcharts": "^1.5.3",
"vue-clipboard2": "^0.3.1",
"vue-echarts": "^5.0.0-beta.0",
"vue-emoji-picker": "^1.0.1",
"vue-gtag": "^1.8.0",
Expand Down
14 changes: 3 additions & 11 deletions resources/js/components/common/CommonCopyLabel.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<v-tooltip bottom>
<template v-slot:activator="{ on }">
<span class="clickable" v-on="on" @click.stop.prevent="copy">
<span class="clickable" v-on="on" @click="copy">
<v-icon v-if="icon" small>
{{ icon }}
</v-icon>

<span ref="copy-label" class="copy-label">
<span ref="copyLabel" class="copy-label">
{{ text }}
</span>
</span>
Expand Down Expand Up @@ -47,19 +47,11 @@ export default {
methods: {
copy() {
this.createTextareaAndCopy();
this.showSnackbar();
this.showTooltip();
},
createTextareaAndCopy() {
const el = document.createElement('textarea');
el.value = this.text;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
this.$copyText(this.text,this.$refs.copyLabel);
},
showSnackbar() {
this.$store.commit('snackbar/SHOW_MESSAGE', {
Expand Down
1 change: 1 addition & 0 deletions resources/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import store from './store';
import vuetify from './plugins/vuetify';
import i18n from './plugins/vue-i18n';
import './plugins/vue-head';
import './plugins/clipboard';

// STYLES
import '../sass/theme.scss';
Expand Down
4 changes: 4 additions & 0 deletions resources/js/plugins/clipboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true; // add this line
Vue.use(VueClipboard);

0 comments on commit 80b99e3

Please sign in to comment.