🎨 Improve display reference counts in embed blocks https://github.com/siyuan-note/siyuan/issues/14129

This commit is contained in:
Daniel 2025-02-18 11:54:03 +08:00
parent 7fecdf407f
commit d4349ea6d6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 4 additions and 4 deletions

View file

@ -230,7 +230,7 @@ func buildBacklink(refID string, refTree *parse.Tree, originalRefBlockIDs map[st
} }
// 反链面板中显示块引用计数 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618 // 反链面板中显示块引用计数 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618
fillBlockRefCount(renderNodes) fillBlockRefCount(renderNodes, 0)
dom := renderBlockDOMByNodes(renderNodes, luteEngine) dom := renderBlockDOMByNodes(renderNodes, luteEngine)
var blockPaths []*BlockPath var blockPaths []*BlockPath

View file

@ -902,7 +902,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
} }
// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191 // 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
fillBlockRefCount(nodes) fillBlockRefCount(nodes, 1)
luteEngine := NewLute() luteEngine := NewLute()
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑 luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑

View file

@ -144,7 +144,7 @@ func renderBlockText(node *ast.Node, excludeTypes []string, removeLineBreak bool
return return
} }
func fillBlockRefCount(nodes []*ast.Node) { func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
var defIDs []string var defIDs []string
for _, n := range nodes { for _, n := range nodes {
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus { ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
@ -166,7 +166,7 @@ func fillBlockRefCount(nodes []*ast.Node) {
return ast.WalkContinue return ast.WalkContinue
} }
if cnt := refCount[n.ID]; 0 < cnt { if cnt := refCount[n.ID]; minRefCount < cnt {
n.SetIALAttr("refcount", strconv.Itoa(cnt)) n.SetIALAttr("refcount", strconv.Itoa(cnt))
} }
return ast.WalkContinue return ast.WalkContinue