From a72d2e6748100e91a33155edafba0c7ac5fe539a 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: Wed, 6 Mar 2024 09:22:17 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E5=8D=8F?= =?UTF-8?q?=E5=90=8C=E7=BC=96=E8=BE=91=E6=97=B6=E5=90=8C=E4=B8=80=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E4=B8=8D=E8=83=BD=E5=A4=9A=E4=BA=BA=E9=80=89=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/constants/defaultOptions.js | 4 +++- simple-mind-map/src/core/render/Render.js | 5 +++++ simple-mind-map/src/core/render/node/Node.js | 12 +++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 28050da3..b1c6a80e 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -277,5 +277,7 @@ export const defaultOpt = { // 接收svg path字符串,返回转换后的svg path字符串 customTransformNodeLinePath: null, // 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到 - isOnlySearchCurrentRenderNodes: false + isOnlySearchCurrentRenderNodes: false, + // 协同编辑时,同一个节点不能同时被多人选中 + onlyOneEnableActiveNodeOnCooperate: false } diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 73fb7e48..a0599896 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -505,6 +505,11 @@ class Render { // 添加节点到激活列表里 addNodeToActiveList(node) { + if ( + this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate && + node.userList.length > 0 + ) + return const index = this.findActiveNodeIndex(node) if (index === -1) { this.mindMap.execCommand('SET_NODE_ACTIVE', node, true) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 5ac1017f..f8c595c6 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -420,6 +420,12 @@ class Node { this.isMultipleChoice = false return } + if ( + this.mindMap.opt.onlyOneEnableActiveNodeOnCooperate && + this.userList.length > 0 + ) { + return + } this.active(e) }) this.group.on('mousedown', e => { @@ -486,10 +492,14 @@ class Node { }) // 双击事件 this.group.on('dblclick', e => { - if (this.mindMap.opt.readonly || e.ctrlKey) { + const { readonly, onlyOneEnableActiveNodeOnCooperate } = this.mindMap.opt + if (readonly || e.ctrlKey) { return } e.stopPropagation() + if (onlyOneEnableActiveNodeOnCooperate && this.userList.length > 0) { + return + } this.mindMap.emit('node_dblclick', this, e) }) // 右键菜单事件