From f490ac6f8dc1f31c60c6ae47560d1d726c8e5969 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, 23 Dec 2024 09:33:00 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=8F=AA?= =?UTF-8?q?=E8=AF=BB=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=BF=9E=E7=BB=AD=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E4=B8=8D=E5=90=8C=E6=96=87=E5=AD=97=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=EF=BC=8C=E4=B8=8A=E4=B8=80=E4=B8=AA=E6=90=9C=E7=B4=A2=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=AB=98=E4=BA=AE=E8=8A=82=E7=82=B9=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E7=9A=84=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 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/simple-mind-map/src/plugins/Search.js b/simple-mind-map/src/plugins/Search.js index 0682bc26..47de8e98 100644 --- a/simple-mind-map/src/plugins/Search.js +++ b/simple-mind-map/src/plugins/Search.js @@ -107,6 +107,7 @@ class Search { // 搜索匹配的节点 doSearch() { + this.clearHighlightOnReadonly() this.updateMatchNodeList([]) this.currentIndex = -1 const { isOnlySearchCurrentRenderNodes } = this.mindMap.opt @@ -174,14 +175,8 @@ class Search { } } const { readonly } = this.mindMap.opt - // 只读模式下需要激活之前节点的高亮 - if (readonly) { - this.matchNodeList.forEach(node => { - if (this.isNodeInstance(node)) { - node.closeHighlight() - } - }) - } + // 只读模式下需要清除之前节点的高亮 + this.clearHighlightOnReadonly() const currentNode = this.matchNodeList[this.currentIndex] this.notResetSearchText = true const uid = this.isNodeInstance(currentNode) @@ -205,6 +200,18 @@ class Search { }) } + // 只读模式下清除现有匹配节点的高亮 + clearHighlightOnReadonly() { + const { readonly } = this.mindMap.opt + if (readonly) { + this.matchNodeList.forEach(node => { + if (this.isNodeInstance(node)) { + node.closeHighlight() + } + }) + } + } + // 定位到指定搜索结果索引的节点 jump(index, callback = () => {}) { this.searchNext(callback, index)