diff --git a/simple-mind-map/package-lock.json b/simple-mind-map/package-lock.json index bf0c2f9a..762cfca1 100644 --- a/simple-mind-map/package-lock.json +++ b/simple-mind-map/package-lock.json @@ -1,11 +1,11 @@ { "name": "simple-mind-map", - "version": "0.4.4", + "version": "0.4.5", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "0.4.4", + "version": "0.4.5", "license": "MIT", "dependencies": { "@svgdotjs/svg.js": "^3.0.16", diff --git a/simple-mind-map/src/AssociativeLine.js b/simple-mind-map/src/AssociativeLine.js index 0d58fc0c..81e63efa 100644 --- a/simple-mind-map/src/AssociativeLine.js +++ b/simple-mind-map/src/AssociativeLine.js @@ -1,4 +1,4 @@ -import { walk, bfsWalk } from './utils/' +import { walk, bfsWalk, throttle } from './utils/' import { v4 as uuid } from 'uuid' // 关联线类 @@ -20,6 +20,8 @@ class AssociativeLine { // 箭头图标 this.markerPath = null this.marker = this.createMarker() + // 节流一下,不然很卡 + this.checkOverlapNode = throttle(this.checkOverlapNode, 100, this) this.bindEvent() } diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index 0ee6e456..386e9a71 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -675,6 +675,17 @@ class Node { if (!this.isRoot) { e.stopPropagation() } + // 多选和取消多选 + if (e.ctrlKey) { + let isActive = this.nodeData.data.isActive + this.mindMap.renderer.setNodeActive(this, !isActive) + this.mindMap.renderer[isActive ? 'removeActiveNode' : 'addActiveNode'](this) + this.mindMap.emit( + 'node_active', + isActive ? null : this, + this.mindMap.renderer.activeNodeList + ) + } this.mindMap.emit('node_mousedown', this, e) }) this.group.on('mouseup', e => { @@ -699,7 +710,8 @@ class Node { }) // 右键菜单事件 this.group.on('contextmenu', e => { - if (this.mindMap.opt.readonly || this.isGeneralization) { + // 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件 + if (this.mindMap.opt.readonly || this.isGeneralization || e.ctrlKey) { return } e.stopPropagation() diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index e71a2fdc..35f8f812 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -195,12 +195,12 @@ export const downloadFile = (file, fileName) => { // 节流函数 export const throttle = (fn, time = 300, ctx) => { let timer = null - return () => { + return (...args) => { if (timer) { return } timer = setTimeout(() => { - fn.call(ctx) + fn.call(ctx, ...args) timer = null }, time) }