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) }) // 右键菜单事件