🐛 The parent block field of the blocks under the heading block is calculated incorrectly https://github.com/siyuan-note/siyuan/issues/9869

This commit is contained in:
Daniel 2024-01-03 10:18:53 +08:00
parent f8a5ca0aa6
commit 1864d0e4a6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 24 additions and 3 deletions

View file

@ -810,8 +810,7 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
fcontent = treenode.NodeStaticContent(fc, nil, true, false, true)
parentID = n.Parent.ID
// 将标题块作为父节点
if h := heading(n); nil != h {
if h := heading(n); nil != h { // 如果在标题块下方,则将标题块作为父节点
parentID = h.ID
}
length = utf8.RuneCountInString(fcontent)
@ -823,7 +822,6 @@ func buildBlockFromNode(n *ast.Node, tree *parse.Tree) (block *Block, attributes
content = treenode.NodeStaticContent(n, nil, true, indexAssetPath, true)
parentID = n.Parent.ID
// 将标题块作为父节点
if h := heading(n); nil != h {
parentID = h.ID
}
@ -909,6 +907,10 @@ func tagFromNode(node *ast.Node) (ret string) {
}
func heading(node *ast.Node) *ast.Node {
if nil == node {
return nil
}
currentLevel := 16
if ast.NodeHeading == node.Type {
currentLevel = node.HeadingLevel