Feat:搜索支持连续替换
This commit is contained in:
parent
1629bb7ccf
commit
ec7a8cdd43
@ -1171,6 +1171,8 @@ class Render {
|
|||||||
node.generalizationBelongNode.updateGeneralization()
|
node.generalizationBelongNode.updateGeneralization()
|
||||||
}
|
}
|
||||||
if (!notRender) this.mindMap.render()
|
if (!notRender) this.mindMap.render()
|
||||||
|
} else {
|
||||||
|
this.mindMap.emit('node_tree_render_end')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,19 @@ class Search {
|
|||||||
this.currentIndex = -1
|
this.currentIndex = -1
|
||||||
// 不要复位搜索文本
|
// 不要复位搜索文本
|
||||||
this.notResetSearchText = false
|
this.notResetSearchText = false
|
||||||
|
// 是否自动跳转下一个匹配节点
|
||||||
|
this.isJumpNext = false
|
||||||
this.onDataChange = this.onDataChange.bind(this)
|
this.onDataChange = this.onDataChange.bind(this)
|
||||||
this.mindMap.on('data_change', this.onDataChange)
|
this.mindMap.on('data_change', this.onDataChange)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 节点数据改变了,需要重新搜索
|
// 节点数据改变了,需要重新搜索
|
||||||
onDataChange() {
|
onDataChange() {
|
||||||
|
if (this.isJumpNext) {
|
||||||
|
this.isJumpNext = false
|
||||||
|
this.search(this.searchText)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.notResetSearchText) {
|
if (this.notResetSearchText) {
|
||||||
this.notResetSearchText = false
|
this.notResetSearchText = false
|
||||||
return
|
return
|
||||||
@ -29,7 +36,7 @@ class Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
search(text, callback) {
|
search(text, callback = () => {}) {
|
||||||
if (isUndef(text)) return this.endSearch()
|
if (isUndef(text)) return this.endSearch()
|
||||||
text = String(text)
|
text = String(text)
|
||||||
this.isSearching = true
|
this.isSearching = true
|
||||||
@ -88,7 +95,7 @@ class Search {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 替换当前节点
|
// 替换当前节点
|
||||||
replace(replaceText) {
|
replace(replaceText, jumpNext = false) {
|
||||||
if (
|
if (
|
||||||
replaceText === null ||
|
replaceText === null ||
|
||||||
replaceText === undefined ||
|
replaceText === undefined ||
|
||||||
@ -96,6 +103,8 @@ class Search {
|
|||||||
this.matchNodeList.length <= 0
|
this.matchNodeList.length <= 0
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
// 自动跳转下一个匹配节点
|
||||||
|
this.isJumpNext = jumpNext
|
||||||
replaceText = String(replaceText)
|
replaceText = String(replaceText)
|
||||||
let currentNode = this.matchNodeList[this.currentIndex]
|
let currentNode = this.matchNodeList[this.currentIndex]
|
||||||
if (!currentNode) return
|
if (!currentNode) return
|
||||||
|
|||||||
@ -117,7 +117,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
replace() {
|
replace() {
|
||||||
this.mindMap.search.replace(this.replaceText)
|
this.mindMap.search.replace(this.replaceText, true)
|
||||||
},
|
},
|
||||||
|
|
||||||
replaceAll() {
|
replaceAll() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user