Fix:修复只读模式下连续输入不同文字搜索,上一个搜索到的高亮节点没有清除的问题
This commit is contained in:
parent
c342fbbe75
commit
f490ac6f8d
@ -107,6 +107,7 @@ class Search {
|
|||||||
|
|
||||||
// 搜索匹配的节点
|
// 搜索匹配的节点
|
||||||
doSearch() {
|
doSearch() {
|
||||||
|
this.clearHighlightOnReadonly()
|
||||||
this.updateMatchNodeList([])
|
this.updateMatchNodeList([])
|
||||||
this.currentIndex = -1
|
this.currentIndex = -1
|
||||||
const { isOnlySearchCurrentRenderNodes } = this.mindMap.opt
|
const { isOnlySearchCurrentRenderNodes } = this.mindMap.opt
|
||||||
@ -174,14 +175,8 @@ class Search {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const { readonly } = this.mindMap.opt
|
const { readonly } = this.mindMap.opt
|
||||||
// 只读模式下需要激活之前节点的高亮
|
// 只读模式下需要清除之前节点的高亮
|
||||||
if (readonly) {
|
this.clearHighlightOnReadonly()
|
||||||
this.matchNodeList.forEach(node => {
|
|
||||||
if (this.isNodeInstance(node)) {
|
|
||||||
node.closeHighlight()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const currentNode = this.matchNodeList[this.currentIndex]
|
const currentNode = this.matchNodeList[this.currentIndex]
|
||||||
this.notResetSearchText = true
|
this.notResetSearchText = true
|
||||||
const uid = this.isNodeInstance(currentNode)
|
const uid = this.isNodeInstance(currentNode)
|
||||||
@ -205,6 +200,18 @@ class Search {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 只读模式下清除现有匹配节点的高亮
|
||||||
|
clearHighlightOnReadonly() {
|
||||||
|
const { readonly } = this.mindMap.opt
|
||||||
|
if (readonly) {
|
||||||
|
this.matchNodeList.forEach(node => {
|
||||||
|
if (this.isNodeInstance(node)) {
|
||||||
|
node.closeHighlight()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 定位到指定搜索结果索引的节点
|
// 定位到指定搜索结果索引的节点
|
||||||
jump(index, callback = () => {}) {
|
jump(index, callback = () => {}) {
|
||||||
this.searchNext(callback, index)
|
this.searchNext(callback, index)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user