mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 16:26:09 +01:00
🎨 Improve priority of folding processing when headings and super blocks are mixed https://github.com/siyuan-note/siyuan/issues/9488
This commit is contained in:
parent
256e64e8b5
commit
5e6d94783b
5 changed files with 19 additions and 112 deletions
|
|
@ -848,12 +848,6 @@ func loadNodesByMode(node *ast.Node, inputIndex, mode, size int, isDoc, isHeadin
|
|||
if n.HeadingLevel <= level {
|
||||
break
|
||||
}
|
||||
} else if ast.NodeSuperBlock == n.Type {
|
||||
if h := treenode.SuperBlockHeading(n); nil != h {
|
||||
if level >= h.HeadingLevel {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes = append(nodes, n)
|
||||
count++
|
||||
|
|
|
|||
|
|
@ -46,11 +46,14 @@ func (tx *Transaction) doFoldHeading(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
||||
}
|
||||
|
||||
children := treenode.HeadingChildren4Folding(heading)
|
||||
children := treenode.HeadingChildren(heading)
|
||||
for _, child := range children {
|
||||
childrenIDs = append(childrenIDs, child.ID)
|
||||
child.SetIALAttr("fold", "1")
|
||||
child.SetIALAttr("heading-fold", "1")
|
||||
ast.Walk(child, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
n.SetIALAttr("fold", "1")
|
||||
n.SetIALAttr("heading-fold", "1")
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
heading.SetIALAttr("fold", "1")
|
||||
if err = tx.writeTree(tree); nil != err {
|
||||
|
|
@ -80,10 +83,13 @@ func (tx *Transaction) doUnfoldHeading(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
||||
}
|
||||
|
||||
children := treenode.HeadingChildren4Folding(heading)
|
||||
children := treenode.HeadingChildren(heading)
|
||||
for _, child := range children {
|
||||
child.RemoveIALAttr("heading-fold")
|
||||
child.RemoveIALAttr("fold")
|
||||
ast.Walk(child, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
n.RemoveIALAttr("heading-fold")
|
||||
n.RemoveIALAttr("fold")
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
heading.RemoveIALAttr("fold")
|
||||
heading.RemoveIALAttr("heading-fold")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue