Feat:搜索插件增加跳转指定搜索结果索引节点的方法
This commit is contained in:
parent
b8765bdd99
commit
83c9d16d2b
@ -156,13 +156,22 @@ class Search {
|
|||||||
return node instanceof MindMapNode
|
return node instanceof MindMapNode
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索下一个,定位到下一个匹配节点
|
// 搜索下一个或指定索引,定位到下一个匹配节点
|
||||||
searchNext(callback) {
|
searchNext(callback, index) {
|
||||||
if (!this.isSearching || this.matchNodeList.length <= 0) return
|
if (!this.isSearching || this.matchNodeList.length <= 0) return
|
||||||
if (this.currentIndex < this.matchNodeList.length - 1) {
|
if (
|
||||||
this.currentIndex++
|
index !== undefined &&
|
||||||
|
Number.isInteger(index) &&
|
||||||
|
index >= 0 &&
|
||||||
|
index < this.matchNodeList.length
|
||||||
|
) {
|
||||||
|
this.currentIndex = index
|
||||||
} else {
|
} else {
|
||||||
this.currentIndex = 0
|
if (this.currentIndex < this.matchNodeList.length - 1) {
|
||||||
|
this.currentIndex++
|
||||||
|
} else {
|
||||||
|
this.currentIndex = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const { readonly } = this.mindMap.opt
|
const { readonly } = this.mindMap.opt
|
||||||
// 只读模式下需要激活之前节点的高亮
|
// 只读模式下需要激活之前节点的高亮
|
||||||
@ -196,6 +205,11 @@ class Search {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 定位到指定搜索结果索引的节点
|
||||||
|
jump(index, callback) {
|
||||||
|
this.searchNext(callback, index)
|
||||||
|
}
|
||||||
|
|
||||||
// 替换当前节点
|
// 替换当前节点
|
||||||
replace(replaceText, jumpNext = false) {
|
replace(replaceText, jumpNext = false) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user