From 403aae4b3d261948beb17494946f028a406bb9ce 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, 26 Feb 2024 17:32:07 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A1.=E8=8A=82=E7=82=B9=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E6=96=B0=E5=A2=9E=E9=AB=98=E4=BA=AE=E5=92=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E9=AB=98=E4=BA=AE=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=9B?= =?UTF-8?q?2.=E8=B0=83=E6=95=B4=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=AB=98=E4=BA=AE=E8=8A=82=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=9BFix=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8F=AA=E8=AF=BB=E6=A8=A1=E5=BC=8F=E6=90=9C=E7=B4=A2=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E8=8A=82=E7=82=B9=E6=97=B6=E6=94=B6=E8=B5=B7=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E9=AB=98=E4=BA=AE=E6=A1=86=E6=9C=AA=E6=B6=88=E5=A4=B1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/constants/constant.js | 2 +- simple-mind-map/src/core/render/node/Node.js | 10 ++++++++++ simple-mind-map/src/plugins/Search.js | 8 ++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/simple-mind-map/src/constants/constant.js b/simple-mind-map/src/constants/constant.js index 02236a4e..32fc5c0b 100644 --- a/simple-mind-map/src/constants/constant.js +++ b/simple-mind-map/src/constants/constant.js @@ -346,7 +346,7 @@ export const cssContent = ` display: block; } - .smm-node.active .smm-hover-node{ + .smm-node.active .smm-hover-node, .smm-node-highlight .smm-hover-node{ display: block; opacity: 1; stroke-width: 2; diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 902af1bc..5ac1017f 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -1052,6 +1052,16 @@ class Node { height: height * scaleY } } + + // 高亮节点 + highlight() { + if (this.group) this.group.addClass('smm-node-highlight') + } + + // 取消高亮节点 + closeHighlight() { + if (this.group) this.group.removeClass('smm-node-highlight') + } } export default Node diff --git a/simple-mind-map/src/plugins/Search.js b/simple-mind-map/src/plugins/Search.js index 64c763dd..8d14b5f7 100644 --- a/simple-mind-map/src/plugins/Search.js +++ b/simple-mind-map/src/plugins/Search.js @@ -69,14 +69,14 @@ class Search { // 结束搜索 endSearch() { if (!this.isSearching) return + if (this.mindMap.opt.readonly && this.matchNodeList[this.currentIndex]) { + this.matchNodeList[this.currentIndex].closeHighlight() + } this.searchText = '' this.matchNodeList = [] this.currentIndex = -1 this.notResetSearchText = false this.isSearching = false - if (this.mindMap.opt.readonly) { - this.mindMap.renderer.closeHighlightNode() - } this.emitEvent() } @@ -110,7 +110,7 @@ class Search { callback() // 只读模式下节点无法激活,所以通过高亮的方式 if (this.mindMap.opt.readonly) { - this.mindMap.renderer.highlightNode(currentNode) + currentNode.highlight() } }) }