From 8b90557f7034797fe7c470324e9443210f34c461 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: Tue, 27 Feb 2024 10:15:09 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E6=90=9C=E7=B4=A2=E6=97=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=94=B9=E5=8F=98=EF=BC=8C=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=B2=A1=E6=9C=89=E6=9B=B4=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Search.js | 33 +++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/simple-mind-map/src/plugins/Search.js b/simple-mind-map/src/plugins/Search.js index 7b6ba2e2..6c607ee6 100644 --- a/simple-mind-map/src/plugins/Search.js +++ b/simple-mind-map/src/plugins/Search.js @@ -112,22 +112,25 @@ class Search { } const currentNode = this.matchNodeList[this.currentIndex] this.notResetSearchText = true - this.mindMap.execCommand( - 'GO_TARGET_NODE', - currentNode instanceof Node ? currentNode : currentNode.data.uid, - node => { - if (!(currentNode instanceof Node)) { - this.matchNodeList[this.currentIndex] = node - } else { - this.notResetSearchText = false - } - callback() - // 只读模式下节点无法激活,所以通过高亮的方式 - if (this.mindMap.opt.readonly) { - node.highlight() - } + const uid = + currentNode instanceof Node + ? currentNode.getData('uid') + : currentNode.data.uid + const targetNode = this.mindMap.renderer.findNodeByUid(uid) + this.mindMap.execCommand('GO_TARGET_NODE', uid, node => { + if (!(currentNode instanceof Node)) { + this.matchNodeList[this.currentIndex] = node } - ) + callback() + // 只读模式下节点无法激活,所以通过高亮的方式 + if (this.mindMap.opt.readonly) { + node.highlight() + } + // 如果当前节点实例已经存在,则不会触发data_change事件,那么需要手动把标志复位 + if (targetNode) { + this.notResetSearchText = false + } + }) } // 替换当前节点