mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 14:28:49 +01:00
🎨 状态栏显示选中内容的字数 https://github.com/siyuan-note/siyuan/issues/4932
This commit is contained in:
parent
9630db264a
commit
50b76a8d9f
1 changed files with 13 additions and 2 deletions
|
|
@ -372,10 +372,21 @@ func ContentWordCount(content string) (runeCount, wordCount int) {
|
|||
}
|
||||
|
||||
func BlocksWordCount(ids []string) (runeCount, wordCount int) {
|
||||
trees := map[string]*parse.Tree{} // 缓存
|
||||
for _, id := range ids {
|
||||
tree, _ := loadTreeByBlockID(id)
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
util.LogWarnf("block tree not found [%s]", id)
|
||||
continue
|
||||
}
|
||||
|
||||
tree := trees[bt.RootID]
|
||||
if nil == tree {
|
||||
return
|
||||
tree, _ = LoadTree(bt.BoxID, bt.Path)
|
||||
if nil == tree {
|
||||
continue
|
||||
}
|
||||
trees[bt.RootID] = tree
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue