From 5ae8ebe590e48246e31ba0618f1101d532238331 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Fri, 17 Mar 2023 23:00:25 +0800 Subject: [PATCH] =?UTF-8?q?Feature:1.=E4=BC=98=E5=8C=96=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=BA=BF=E5=88=9B=E5=BB=BA,2.=E6=94=AF=E6=8C=81=E6=8C=89?= =?UTF-8?q?=E4=BD=8Fctrl=E9=94=AE=E5=A4=9A=E9=80=89=E5=92=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=A4=9A=E9=80=89=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/package-lock.json | 4 ++-- simple-mind-map/src/AssociativeLine.js | 4 +++- simple-mind-map/src/Node.js | 14 +++++++++++++- simple-mind-map/src/utils/index.js | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) 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) }