This commit is contained in:
c
2025-03-12 20:11:03 +08:00
commit 70b7c82c97
1178 changed files with 148185 additions and 0 deletions
@@ -0,0 +1,31 @@
export default function CustomClipboard (Quill) {
const Delta = Quill.import('delta')
const Clipboard = Quill.import('modules/clipboard')
class CustomClipboard extends Clipboard {
onPaste(e) {
const top = window.pageYOffset;
const left = window.pageXOffset;
if (e.defaultPrevented || !this.quill.isEnabled()) return;
let range = this.quill.getSelection();
let delta = new Delta().retain(range.index);
this.container.style.top = (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0).toString() + 'px';
this.container.focus();
setTimeout(() => {
this.quill.selection.update(Quill.sources.SILENT);
delta = delta.concat(this.convert()).delete(range.length);
this.quill.updateContents(delta, Quill.sources.USER);
this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT);
let bounds = this.quill.getBounds(delta.length() - range.length, Quill.sources.SILENT);
this.quill.scrollingContainer.scrollTop = bounds.top;
// scroll window to previous position after paste
window.scrollTo({top, left});
}, 1);
}
}
return {
'modules/clipboard': CustomClipboard
}
}