Feat:搜索插件支持搜索概要节点
This commit is contained in:
parent
1dbcb71ec5
commit
1033447b9c
@ -2,7 +2,8 @@ import {
|
|||||||
bfsWalk,
|
bfsWalk,
|
||||||
getTextFromHtml,
|
getTextFromHtml,
|
||||||
isUndef,
|
isUndef,
|
||||||
replaceHtmlText
|
replaceHtmlText,
|
||||||
|
formatGetNodeGeneralization
|
||||||
} from '../utils/index'
|
} from '../utils/index'
|
||||||
import Node from '../core/render/node/Node'
|
import Node from '../core/render/node/Node'
|
||||||
import { CONSTANTS } from '../constants/constant'
|
import { CONSTANTS } from '../constants/constant'
|
||||||
@ -109,7 +110,7 @@ class Search {
|
|||||||
: this.mindMap.renderer.renderTree
|
: this.mindMap.renderer.renderTree
|
||||||
if (!tree) return
|
if (!tree) return
|
||||||
bfsWalk(tree, node => {
|
bfsWalk(tree, node => {
|
||||||
let { richText, text } = isOnlySearchCurrentRenderNodes
|
let { richText, text, generalization } = isOnlySearchCurrentRenderNodes
|
||||||
? node.getData()
|
? node.getData()
|
||||||
: node.data
|
: node.data
|
||||||
if (richText) {
|
if (richText) {
|
||||||
@ -118,6 +119,27 @@ class Search {
|
|||||||
if (text.includes(this.searchText)) {
|
if (text.includes(this.searchText)) {
|
||||||
this.matchNodeList.push(node)
|
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…
x
Reference in New Issue
Block a user