diff --git a/index.html b/index.html index 2dd58c31..dae74bcc 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -一个简单的web思维导图实现
\ No newline at end of file +一个简单的web思维导图实现
\ No newline at end of file diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index 31eed1a7..ca7b54e3 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -76,7 +76,7 @@ class Render { this.mindMap.on('draw_click', () => { // 清除激活状态 if (this.activeNodeList.length > 0) { - this.clearActive() + this.mindMap.execCommand('CLEAR_ACTIVE_NODE') this.mindMap.emit('node_active', null, []) } }) @@ -222,7 +222,7 @@ class Render { */ clearActive() { this.activeNodeList.forEach((item) => { - this.mindMap.execCommand('SET_NODE_ACTIVE', item, false) + this.setNodeActive(item, false) }) this.activeNodeList = [] } @@ -290,6 +290,7 @@ class Render { * @Desc: 回退 */ back(step) { + this.clearAllActive() let data = this.mindMap.command.back(step) if (data) { this.renderTree = data @@ -304,6 +305,7 @@ class Render { * @Desc: 前进 */ forward(step) { + this.clearAllActive() let data = this.mindMap.command.forward(step) if (data) { this.renderTree = data @@ -324,6 +326,9 @@ class Render { if (first.isRoot) { this.insertChildNode() } else { + if (first.layerIndex === 1) { + first.parent.initRender = true + } let index = this.getNodeIndex(first) first.parent.nodeData.children.splice(index + 1, 0, { "data": { diff --git a/simple-mind-map/src/layouts/Base.js b/simple-mind-map/src/layouts/Base.js index ce127204..c8478e32 100644 --- a/simple-mind-map/src/layouts/Base.js +++ b/simple-mind-map/src/layouts/Base.js @@ -74,6 +74,9 @@ class Base { newNode.getSize() // 数据关联实际节点 data._node = newNode + if (data.data.isActive) { + this.renderer.addActiveNode(newNode) + } } // 根节点 if (isRoot) {