mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Feat:搜索插件支持搜索概要节点
This commit is contained in:
parent
1dbcb71ec5
commit
1033447b9c
@ -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
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user