Skip to content

Commit

Permalink
Feat:增加协同编辑时同一节点不能多人选中的配置选项
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglin2 committed Mar 6, 2024
1 parent 8c07209 commit a72d2e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion simple-mind-map/src/constants/defaultOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,7 @@ export const defaultOpt = {
// 接收svg path字符串,返回转换后的svg path字符串
customTransformNodeLinePath: null,
// 是否仅搜索当前渲染的节点,被收起的节点不会被搜索到
isOnlySearchCurrentRenderNodes: false
isOnlySearchCurrentRenderNodes: false,
// 协同编辑时,同一个节点不能同时被多人选中
onlyOneEnableActiveNodeOnCooperate: false
}
5 changes: 5 additions & 0 deletions simple-mind-map/src/core/render/Render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion simple-mind-map/src/core/render/node/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
})
// 右键菜单事件
Expand Down

0 comments on commit a72d2e6

Please sign in to comment.