diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 461256be..7dc6840f 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -421,16 +421,18 @@ class Render { addNodeToActiveList(node) { const index = this.findActiveNodeIndex(node) if (index === -1) { + this.mindMap.execCommand('SET_NODE_ACTIVE', node, true) this.activeNodeList.push(node) } } - // 在激活列表里移除某个节点 - removeActiveNode(node) { + // 在激活列表里移除某个节点 + removeNodeFromActiveList(node) { let index = this.findActiveNodeIndex(node) if (index === -1) { return } + this.mindMap.execCommand('SET_NODE_ACTIVE', node, false) this.activeNodeList.splice(index, 1) } @@ -448,13 +450,7 @@ class Render { null, node => { if (!node.nodeData.data.isActive) { - node.nodeData.data.isActive = true this.addNodeToActiveList(node) - // 激活节点需要显示展开收起按钮 - node.showExpandBtn() - setTimeout(() => { - node.updateNodeActive() - }, 0) } }, null, @@ -1017,10 +1013,10 @@ class Render { generalization: null }) node.generalizationBelongNode.update() - this.removeActiveNode(node) + this.removeNodeFromActiveList(node) i-- } else { - this.removeActiveNode(node) + this.removeNodeFromActiveList(node) this.removeOneNode(node) i-- } @@ -1139,7 +1135,7 @@ class Render { return copyNodeTree({}, node, true) }) nodeList.forEach(node => { - this.removeActiveNode(node) + this.removeNodeFromActiveList(node) this.removeOneNode(node) }) this.mindMap.emit('node_active', null, [...this.activeNodeList]) @@ -1157,7 +1153,7 @@ class Render { }) nodeList.forEach(item => { this.checkNodeLayerChange(item, toNode) - this.removeActiveNode(item) + this.removeNodeFromActiveList(item) this.removeOneNode(item) toNode.nodeData.children.push(item.nodeData) }) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 342c1482..95f823bc 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -437,8 +437,7 @@ class Node { this, this.renderer.activeNodeList ) - this.mindMap.execCommand('SET_NODE_ACTIVE', this, !isActive) - this.mindMap.renderer[isActive ? 'removeActiveNode' : 'addNodeToActiveList']( + this.mindMap.renderer[isActive ? 'removeNodeFromActiveList' : 'addNodeToActiveList']( this ) this.mindMap.emit('node_active', isActive ? null : this, [ @@ -516,7 +515,6 @@ class Node { } this.mindMap.emit('before_node_active', this, this.renderer.activeNodeList) this.renderer.clearActiveNodeList() - this.mindMap.execCommand('SET_NODE_ACTIVE', this, true) this.renderer.addNodeToActiveList(this) this.mindMap.emit('node_active', this, [...this.renderer.activeNodeList]) } diff --git a/simple-mind-map/src/core/render/node/nodeGeneralization.js b/simple-mind-map/src/core/render/node/nodeGeneralization.js index 462332a2..09de5d01 100644 --- a/simple-mind-map/src/core/render/node/nodeGeneralization.js +++ b/simple-mind-map/src/core/render/node/nodeGeneralization.js @@ -72,7 +72,7 @@ function removeGeneralization() { } if (this._generalizationNode) { // 删除概要节点时要同步从激活节点里删除 - this.renderer.removeActiveNode(this._generalizationNode) + this.renderer.removeNodeFromActiveList(this._generalizationNode) this._generalizationNode.remove() this._generalizationNode = null } diff --git a/simple-mind-map/src/plugins/Select.js b/simple-mind-map/src/plugins/Select.js index 8bacbe69..e910c3c0 100644 --- a/simple-mind-map/src/plugins/Select.js +++ b/simple-mind-map/src/plugins/Select.js @@ -221,14 +221,12 @@ class Select { if (node.nodeData.data.isActive) { return } - this.mindMap.execCommand('SET_NODE_ACTIVE', node, true) this.mindMap.renderer.addNodeToActiveList(node) } else if (node.nodeData.data.isActive) { if (!node.nodeData.data.isActive) { return } - this.mindMap.execCommand('SET_NODE_ACTIVE', node, false) - this.mindMap.renderer.removeActiveNode(node) + this.mindMap.renderer.removeNodeFromActiveList(node) } }) }