Open joshStillerman opened 5 years ago
index.js 文件中修改为 handlePaste(evt) { if (evt.clipboardData && evt.clipboardData.items && evt.clipboardData.items.length) { this.readFiles(evt.clipboardData.items, dataUrl => { const userAgent = navigator.userAgent; if (userAgent.indexOf('Firefox') > -1) { const selection = this.quill.getSelection(); if (selection) { } else { setTimeout(() => this.insert(dataUrl), 0); } } else { setTimeout(() => this.insert(dataUrl), 0); } }); } }
This should be a PR, but I'll just paste it here: this is how I solved it - it disabled paste in firefox etc. and then handles everything the same. It might be better to do it only for some 'image/' data type but so far this seems to work.
handlePaste(evt) {
if (evt.clipboardData && evt.clipboardData.items && evt.clipboardData.items.length) {
for (const item of evt.clipboardData.items) {
if (item.kind === 'file') {
evt.preventDefault();
this.readFiles(evt.clipboardData.items, dataUrl => {
const selection = this.quill.getSelection();
this.insert(dataUrl);
// Move after the image
if (selection) {
this.quill.setSelection({index:selection.index + 2, length: 0});
}
});
break;
}
}
}
}
I have a vuejs2 project, and have embedded vue2-editor which is based on quill. I have added:
and
dropping images works fine resizing images works fine Paste appears to be a noop.
I am trying to enable the pasting of screenshots