From 7f0202e16e4e3b3374e7718c95330f452b87c5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Mon, 8 Apr 2024 18:06:34 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A1.=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E9=94=AE=E5=8E=BB=E9=99=A4=E6=89=80=E6=9C=89=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E4=B8=8D=E6=94=AF=E6=8C=81=E4=B8=8D=E4=B8=BA=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E6=A6=82=E8=A6=81=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?2.=E4=BF=AE=E5=A4=8D=E5=AF=8C=E6=96=87=E6=9C=AC=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=E5=88=9B=E5=BB=BA=E7=9A=84=E6=A6=82=E8=A6=81?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=B8=8D=E6=98=AF=E5=AF=8C=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9BFeat=EF=BC=9A=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E6=A6=82=E8=A6=81=E6=97=B6=E6=94=AF=E6=8C=81=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=81=9A=E7=84=A6=E5=92=8C=E8=BF=9B=E5=85=A5=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/render/Render.js | 35 ++++++++++++++----- .../core/render/node/nodeGeneralization.js | 2 ++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 4369036f..84b7a2b0 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -989,12 +989,18 @@ class Render { const _hasCustomStyles = this._handleRemoveCustomStyles(node.data) if (_hasCustomStyles) hasCustomStyles = true // 不要忘记概要节点 - if (node.data.generalization && node.data.generalization.length > 0) { - node.data.generalization.forEach(generalizationData => { - const _hasCustomStyles = - this._handleRemoveCustomStyles(generalizationData) - if (_hasCustomStyles) hasCustomStyles = true - }) + let generalization = node.data.generalization + if (generalization) { + generalization = Array.isArray(generalization) + ? generalization + : [generalization] + if (generalization.length > 0) { + generalization.forEach(generalizationData => { + const _hasCustomStyles = + this._handleRemoveCustomStyles(generalizationData) + if (_hasCustomStyles) hasCustomStyles = true + }) + } } }) } @@ -1632,7 +1638,7 @@ class Render { } // 添加节点概要 - addGeneralization(data) { + addGeneralization(data, openEdit = true) { if (this.activeNodeList.length <= 0) { return } @@ -1644,13 +1650,22 @@ class Render { ) }) const list = parseAddGeneralizationNodeList(nodeList) + const isRichText = !!this.mindMap.richText + const { focusNewNode, inserting } = this.getNewNodeBehavior( + openEdit, + list.length > 1 + ) list.forEach(item => { const newData = { + inserting, ...(data || { text: this.mindMap.opt.defaultGeneralizationText }), range: item.range || null, - uid: createUid() + uid: createUid(), + richText: isRichText, + resetRichText: isRichText, + isActive: focusNewNode } let generalization = item.node.getData('generalization') if (generalization) { @@ -1670,6 +1685,10 @@ class Render { expand: true }) }) + // 需要清除原来激活的节点 + if (focusNewNode) { + this.clearActiveNodeList() + } this.mindMap.render(() => { // 修复祖先节点存在概要时位置未更新的问题 // 修复同时给存在上下级关系的节点添加概要时重叠的问题 diff --git a/simple-mind-map/src/core/render/node/nodeGeneralization.js b/simple-mind-map/src/core/render/node/nodeGeneralization.js index 597f6454..24dd7793 100644 --- a/simple-mind-map/src/core/render/node/nodeGeneralization.js +++ b/simple-mind-map/src/core/render/node/nodeGeneralization.js @@ -51,6 +51,7 @@ function createGeneralizationNode() { if (!cur.generalizationNode) { cur.generalizationNode = new Node({ data: { + inserting: item.inserting, data: item }, uid: createUid(), @@ -59,6 +60,7 @@ function createGeneralizationNode() { isGeneralization: true }) } + delete item.inserting // 关联所属节点 cur.generalizationNode.generalizationBelongNode = this // 大小