Skip to content

Commit

Permalink
🎨 Improve display reference counts in the backlink panel #13678
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jan 1, 2025
1 parent 6d7feb4 commit 2d006a9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kernel/model/backlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func buildBacklink(refID string, refTree *parse.Tree, keywords []string, highlig
}

// 反链面板中显示块引用计数 Display reference counts in the backlink panel https://github.com/siyuan-note/siyuan/issues/13618
fillBlockRefCount(renderNodes)
fillBlockRefCount(renderNodes, 1)

dom := renderBlockDOMByNodes(renderNodes, luteEngine)
var blockPaths []*BlockPath
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
}

// 嵌入块查询结果中显示块引用计数 https://github.com/siyuan-note/siyuan/issues/7191
fillBlockRefCount(nodes)
fillBlockRefCount(nodes, 0)

luteEngine := NewLute()
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
Expand Down
4 changes: 2 additions & 2 deletions kernel/model/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func renderBlockText(node *ast.Node, excludeTypes []string) (ret string) {
return
}

func fillBlockRefCount(nodes []*ast.Node) {
func fillBlockRefCount(nodes []*ast.Node, minRefCount int) {
var defIDs []string
for _, n := range nodes {
ast.Walk(n, func(n *ast.Node, entering bool) ast.WalkStatus {
Expand All @@ -164,7 +164,7 @@ func fillBlockRefCount(nodes []*ast.Node) {
return ast.WalkContinue
}

if cnt := refCount[n.ID]; 0 < cnt {
if cnt := refCount[n.ID]; minRefCount < cnt {
n.SetIALAttr("refcount", strconv.Itoa(cnt))
}
return ast.WalkContinue
Expand Down

0 comments on commit 2d006a9

Please sign in to comment.