mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve find-replace for database block key text updating https://github.com/siyuan-note/siyuan/issues/13746
This commit is contained in:
parent
87c8db09a0
commit
d7ebe561f0
2 changed files with 17 additions and 8 deletions
|
|
@ -17,9 +17,6 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/88250/lute"
|
|
||||||
"github.com/88250/lute/render"
|
|
||||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -28,10 +25,13 @@ import (
|
||||||
|
|
||||||
"github.com/88250/go-humanize"
|
"github.com/88250/go-humanize"
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
|
"github.com/88250/lute"
|
||||||
"github.com/88250/lute/ast"
|
"github.com/88250/lute/ast"
|
||||||
"github.com/88250/lute/parse"
|
"github.com/88250/lute/parse"
|
||||||
|
"github.com/88250/lute/render"
|
||||||
"github.com/emirpasic/gods/sets/hashset"
|
"github.com/emirpasic/gods/sets/hashset"
|
||||||
"github.com/siyuan-note/siyuan/kernel/av"
|
"github.com/siyuan-note/siyuan/kernel/av"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/task"
|
"github.com/siyuan-note/siyuan/kernel/task"
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
|
|
@ -238,6 +238,15 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 更新属性视图主键内容
|
// 2. 更新属性视图主键内容
|
||||||
|
updateAttributeViewBlockText(updatedDefNodes)
|
||||||
|
|
||||||
|
// 3. 保存变更
|
||||||
|
for _, tree := range changedRefTree {
|
||||||
|
indexWriteTreeUpsertQueue(tree)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateAttributeViewBlockText(updatedDefNodes map[string]*ast.Node) {
|
||||||
var parents []*ast.Node
|
var parents []*ast.Node
|
||||||
for _, updatedDefNode := range updatedDefNodes {
|
for _, updatedDefNode := range updatedDefNodes {
|
||||||
for parent := updatedDefNode.Parent; nil != parent && ast.NodeDocument != parent.Type; parent = parent.Parent {
|
for parent := updatedDefNode.Parent; nil != parent && ast.NodeDocument != parent.Type; parent = parent.Parent {
|
||||||
|
|
@ -287,11 +296,6 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 保存变更
|
|
||||||
for _, tree := range changedRefTree {
|
|
||||||
indexWriteTreeUpsertQueue(tree)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReloadAttrView 用于重新加载属性视图。
|
// ReloadAttrView 用于重新加载属性视图。
|
||||||
|
|
|
||||||
|
|
@ -536,6 +536,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||||
|
|
||||||
luteEngine := util.NewLute()
|
luteEngine := util.NewLute()
|
||||||
var reloadTreeIDs []string
|
var reloadTreeIDs []string
|
||||||
|
updateNodes := map[string]*ast.Node{}
|
||||||
for i, id := range ids {
|
for i, id := range ids {
|
||||||
bt := treenode.GetBlockTree(id)
|
bt := treenode.GetBlockTree(id)
|
||||||
if nil == bt {
|
if nil == bt {
|
||||||
|
|
@ -863,6 +864,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateNodes[id] = node
|
||||||
|
|
||||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(206), i+1, len(ids)))
|
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(206), i+1, len(ids)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -880,6 +883,8 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||||
refreshProtyle(id)
|
refreshProtyle(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateAttributeViewBlockText(updateNodes)
|
||||||
|
|
||||||
sql.FlushQueue()
|
sql.FlushQueue()
|
||||||
util.PushClearProgress()
|
util.PushClearProgress()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue