From c0ad18cff8bc5eb1e7bd5e4c4a5c8afba5472f8c Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Thu, 21 Sep 2023 09:53:35 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E5=AD=98=E5=9C=A8=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E8=8A=82=E7=82=B9=E6=97=B6=E7=82=B9=E5=87=BB=E5=85=B3?= =?UTF-8?q?=E8=81=94=E7=BA=BF=E5=8F=AF=E7=9B=B4=E6=8E=A5=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugins/AssociativeLine.js | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/simple-mind-map/src/plugins/AssociativeLine.js b/simple-mind-map/src/plugins/AssociativeLine.js index 4dbc4ed2..0225d2ca 100644 --- a/simple-mind-map/src/plugins/AssociativeLine.js +++ b/simple-mind-map/src/plugins/AssociativeLine.js @@ -257,28 +257,25 @@ class AssociativeLine { }) { let { associativeLineActiveColor } = this.mindMap.themeConfig // 如果当前存在激活节点,那么取消激活节点 - if (this.mindMap.renderer.activeNodeList.length > 0) { - this.clearActiveNodes() - } else { - // 否则清除当前的关联线的激活状态,如果有的话 - this.clearActiveLine() - // 保存当前激活的关联线信息 - this.activeLine = [path, clickPath, text, node, toNode] - // 让不可见的点击线显示 - clickPath.stroke({ color: associativeLineActiveColor }) - // 如果没有输入过关联线文字,那么显示默认文字 - if (!this.getText(node, toNode)) { - this.renderText(this.mindMap.opt.defaultAssociativeLineText, path, text) - } - // 渲染控制点和连线 - this.renderControls( - startPoint, - endPoint, - controlPoints[0], - controlPoints[1] - ) - this.mindMap.emit('associative_line_click', path, clickPath, node, toNode) + this.mindMap.execCommand('CLEAR_ACTIVE_NODE') + // 否则清除当前的关联线的激活状态,如果有的话 + this.clearActiveLine() + // 保存当前激活的关联线信息 + this.activeLine = [path, clickPath, text, node, toNode] + // 让不可见的点击线显示 + clickPath.stroke({ color: associativeLineActiveColor }) + // 如果没有输入过关联线文字,那么显示默认文字 + if (!this.getText(node, toNode)) { + this.renderText(this.mindMap.opt.defaultAssociativeLineText, path, text) } + // 渲染控制点和连线 + this.renderControls( + startPoint, + endPoint, + controlPoints[0], + controlPoints[1] + ) + this.mindMap.emit('associative_line_click', path, clickPath, node, toNode) } // 移除所有连接线 @@ -488,13 +485,6 @@ class AssociativeLine { }) } - // 清除当前激活的节点 - clearActiveNodes() { - if (this.mindMap.renderer.activeNodeList.length > 0) { - this.mindMap.execCommand('CLEAR_ACTIVE_NODE') - } - } - // 清除激活的线 clearActiveLine() { if (this.activeLine) {