diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 016d3c7f..a9896812 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -449,13 +449,17 @@ class Node { }) // 右键菜单事件 this.group.on('contextmenu', e => { + const { readonly, useLeftKeySelectionRightKeyDrag } = this.mindMap.opt // 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件 - if (this.mindMap.opt.readonly || e.ctrlKey) { - // || this.isGeneralization + if (readonly || e.ctrlKey) { return } e.stopPropagation() e.preventDefault() + // 如果是多选节点结束,那么不要触发右键菜单事件 + if(!useLeftKeySelectionRightKeyDrag && this.mindMap.select.hasSelectRange()) { + return + } if (this.nodeData.data.isActive) { this.renderer.clearActive() } diff --git a/simple-mind-map/src/plugins/Select.js b/simple-mind-map/src/plugins/Select.js index bba83b0c..e3fba7bc 100644 --- a/simple-mind-map/src/plugins/Select.js +++ b/simple-mind-map/src/plugins/Select.js @@ -11,6 +11,7 @@ class Select { this.mouseDownY = 0 this.mouseMoveX = 0 this.mouseMoveY = 0 + this.isSelecting = false this.bindEvent() } @@ -70,11 +71,15 @@ class Select { this.isMousedown = false if (this.rect) this.rect.remove() this.rect = null + setTimeout(() => { + this.isSelecting = false + }, 0) }) } // 鼠标移动事件 onMove(x, y) { + this.isSelecting = true // 绘制矩形 this.rect.plot([ [this.mouseDownX, this.mouseDownY], @@ -172,6 +177,11 @@ class Select { } }) } + + // 是否存在选区 + hasSelectRange() { + return this.isSelecting + } } Select.instanceName = 'select'