mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-05 20:30:15 +01:00
🎨 状态栏显示选中内容的字数 https://github.com/siyuan-note/siyuan/issues/4932
This commit is contained in:
parent
1b173ae421
commit
46c4d842f9
3 changed files with 62 additions and 0 deletions
|
|
@ -364,6 +364,28 @@ func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err
|
|||
return
|
||||
}
|
||||
|
||||
func ContentWordCount(content string) (runeCount, wordCount int) {
|
||||
luteEngine := NewLute()
|
||||
tree := luteEngine.BlockDOM2Tree(content)
|
||||
runeCount, wordCount = tree.Root.ContentLen()
|
||||
return
|
||||
}
|
||||
|
||||
func BlocksWordCount(ids []string) (runeCount, wordCount int) {
|
||||
for _, id := range ids {
|
||||
tree, _ := loadTreeByBlockID(id)
|
||||
if nil == tree {
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
blockRuneCount, blockWordCount := node.ContentLen()
|
||||
runeCount += blockRuneCount
|
||||
wordCount += blockWordCount
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func BlockWordCount(id string) (blockRuneCount, blockWordCount, rootBlockRuneCount, rootBlockWordCount int) {
|
||||
tree, _ := loadTreeByBlockID(id)
|
||||
if nil == tree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue