Make sure that paste does not get executed multiple times

This commit is contained in:
Jan Oberhauser 2019-07-17 18:14:03 +02:00
parent f3d77412a6
commit 4bc21dfef5

View file

@ -3,8 +3,8 @@
* defined on the component which uses this mixin * defined on the component which uses this mixin
*/ */
import Vue from 'vue'; import Vue from 'vue';
import { debounce } from 'lodash';
// export const copyPaste = {
export const copyPaste = Vue.extend({ export const copyPaste = Vue.extend({
data () { data () {
return { return {
@ -92,7 +92,7 @@ export const copyPaste = Vue.extend({
// Set clipboard event listeners on the document. // Set clipboard event listeners on the document.
['paste'].forEach((event) => { ['paste'].forEach((event) => {
document.addEventListener(event, (e) => { document.addEventListener(event, debounce((e) => {
// Check if the event got emitted from a message box or from something // Check if the event got emitted from a message box or from something
// else which should ignore the copy/paste // else which should ignore the copy/paste
// @ts-ignore // @ts-ignore
@ -118,7 +118,7 @@ export const copyPaste = Vue.extend({
e.preventDefault(); e.preventDefault();
} }
} }
}); }, 1000, { leading: true }));
}); });
}, },
methods: { methods: {