Feat:搜索插件支持搜索概要节点

This commit is contained in:
街角小林 2024-08-14 17:48:23 +08:00
parent 1dbcb71ec5
commit 1033447b9c

View File

@ -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
})
}
})
})
}