🎨 Add statistics on selected blocks and total blocks https://github.com/siyuan-note/siyuan/issues/13235

This commit is contained in:
Daniel 2024-11-23 20:57:17 +08:00
parent adb942b4d5
commit 14bb85017f
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
15 changed files with 33 additions and 7 deletions

View file

@ -480,6 +480,7 @@ func BlocksWordCount(ids []string) (ret *util.BlockStatResult) {
ret.ImageCount += imgCnt
ret.RefCount += refCnt
}
ret.BlockCount = len(ids)
return
}
@ -491,9 +492,18 @@ func StatTree(id string) (ret *util.BlockStatResult) {
return
}
blockCount := 0
var databaseBlockNodes []*ast.Node
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || ast.NodeAttributeView != n.Type {
if !entering {
return ast.WalkContinue
}
if n.IsBlock() {
blockCount++
}
if ast.NodeAttributeView != n.Type {
return ast.WalkContinue
}
@ -585,6 +595,7 @@ func StatTree(id string) (ret *util.BlockStatResult) {
LinkCount: linkCnt,
ImageCount: imgCnt,
RefCount: refCnt,
BlockCount: blockCount,
}
}