From e8c4aad6907bebdef9075f306e63b09cc10a5b31 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: Mon, 24 Jun 2024 19:03:47 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E8=AF=BB=E5=8F=96=E5=92=8C=E5=86=99=E5=85=A5=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=89=AA=E8=B4=B4=E6=9D=BF=E7=9A=84=E5=AE=9E=E4=BE=8B?= =?UTF-8?q?=E5=8C=96=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/constants/defaultOptions.js | 2 ++ simple-mind-map/src/core/render/Render.js | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 70a7f4fc..67eab51d 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -221,6 +221,8 @@ export const defaultOpt = { createNodePrefixContent: null, // 添加附加的节点后置内容,后置内容指和文本同一行的区域中的后置内容,不包括节点图片部分 createNodePostfixContent: null, + // 禁止粘贴用户剪贴板中的数据,禁止将复制的数据写入用户的剪贴板中 + disabledClipboard: false, // 【Select插件】 // 多选节点时鼠标移动到边缘时的画布移动偏移量 diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 5e180d3c..347d3d63 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -1013,14 +1013,18 @@ class Render { copy() { this.beingCopyData = this.copyNode() if (!this.beingCopyData) return - setDataToClipboard(createSmmFormatData(this.beingCopyData)) + if (!this.mindMap.opt.disabledClipboard) { + setDataToClipboard(createSmmFormatData(this.beingCopyData)) + } } // 剪切节点 cut() { this.mindMap.execCommand('CUT_NODE', copyData => { this.beingCopyData = copyData - setDataToClipboard(createSmmFormatData(copyData)) + if (!this.mindMap.opt.disabledClipboard) { + setDataToClipboard(createSmmFormatData(copyData)) + } }) } @@ -1029,17 +1033,20 @@ class Render { const { errorHandler, handleIsSplitByWrapOnPasteCreateNewNode, - handleNodePasteImg + handleNodePasteImg, + disabledClipboard } = this.mindMap.opt // 读取剪贴板的文字和图片 - let text = null + let text = '' let img = null - try { - const res = await getDataFromClipboard() - text = res.text - img = res.img - } catch (error) { - errorHandler(ERROR_TYPES.READ_CLIPBOARD_ERROR, error) + if (!disabledClipboard) { + try { + const res = await getDataFromClipboard() + text = res.text || '' + img = res.img || null + } catch (error) { + errorHandler(ERROR_TYPES.READ_CLIPBOARD_ERROR, error) + } } // 检查剪切板数据是否有变化 // 通过图片大小来判断图片是否发生变化,可能是不准确的,但是目前没有其他好方法