🎨 状态栏显示选中内容的字数 https://github.com/siyuan-note/siyuan/issues/4932

This commit is contained in:
Liang Ding 2022-06-28 22:15:32 +08:00
parent 9630db264a
commit 50b76a8d9f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -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)