From 1033447b9c10d5f2d86ae79cd6441f036360a16e 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: Wed, 14 Aug 2024 17:48:23 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=90=9C=E7=B4=A2=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=94=AF=E6=8C=81=E6=90=9C=E7=B4=A2=E6=A6=82=E8=A6=81?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Search.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/plugins/Search.js b/simple-mind-map/src/plugins/Search.js index 722c4cc8..1c44285c 100644 --- a/simple-mind-map/src/plugins/Search.js +++ b/simple-mind-map/src/plugins/Search.js @@ -2,7 +2,8 @@ import { bfsWalk, getTextFromHtml, isUndef, - replaceHtmlText + replaceHtmlText, + formatGetNodeGeneralization } from '../utils/index' import Node from '../core/render/node/Node' import { CONSTANTS } from '../constants/constant' @@ -109,7 +110,7 @@ class Search { : this.mindMap.renderer.renderTree if (!tree) return bfsWalk(tree, node => { - let { richText, text } = isOnlySearchCurrentRenderNodes + let { richText, text, generalization } = isOnlySearchCurrentRenderNodes ? node.getData() : node.data if (richText) { @@ -118,6 +119,27 @@ class Search { if (text.includes(this.searchText)) { this.matchNodeList.push(node) } + // 概要节点 + const generalizationList = formatGetNodeGeneralization({ + generalization + }) + generalizationList.forEach(gNode => { + let { richText, text, uid } = gNode + if ( + isOnlySearchCurrentRenderNodes && + !this.mindMap.renderer.findNodeByUid(uid) + ) { + return + } + if (richText) { + text = getTextFromHtml(text) + } + if (text.includes(this.searchText)) { + this.matchNodeList.push({ + data: gNode + }) + } + }) }) }