From dc27ca4ce8fea328b81946a6998217b097eae147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Thu, 22 Aug 2024 16:05:33 +0800 Subject: [PATCH] =?UTF-8?q?Quill=E5=8D=87=E7=BA=A7=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=B2=98=E8=B4=B4=E6=96=87=E6=9C=AC=E6=97=B6=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E4=BC=9A=E5=87=BA=E7=8E=B0=E6=8D=A2=E8=A1=8C=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E6=8D=A2=E8=A1=8C=EF=BC=8C=E7=9B=AE=E5=89=8D=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E5=AE=8C=E8=BF=98=E6=98=AF=E4=BC=9A=E6=96=B0=E5=BC=80?= =?UTF-8?q?=E4=B8=80=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/RichText.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index 199beb2d..5dd1ee52 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -391,7 +391,7 @@ class RichText { }, theme: 'snow' }) - // 拦截粘贴事件 + // 拦截复制事件,即Ctrl + c,去除多余的空行 this.quill.root.addEventListener('copy', event => { event.preventDefault() const sel = window.getSelection() @@ -455,16 +455,16 @@ class RichText { } }) // 拦截粘贴,只允许粘贴纯文本 - this.quill.clipboard.addMatcher(Node.TEXT_NODE, node => { - let style = this.getPasteTextStyle() - return new Delta().insert(this.formatPasteText(node.data), style) - }) + // this.quill.clipboard.addMatcher(Node.TEXT_NODE, node => { + // let style = this.getPasteTextStyle() + // return new Delta().insert(this.formatPasteText(node.data), style) + // }) this.quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => { let ops = [] let style = this.getPasteTextStyle() delta.ops.forEach(op => { // 过滤出文本内容,过滤掉换行 - if (op.insert && typeof op.insert === 'string' && op.insert !== '\n') { + if (op.insert && typeof op.insert === 'string') { ops.push({ attributes: { ...style }, insert: this.formatPasteText(op.insert)