mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Add statistics on selected blocks and total blocks https://github.com/siyuan-note/siyuan/issues/13235
This commit is contained in:
parent
adb942b4d5
commit
14bb85017f
15 changed files with 33 additions and 7 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue