mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Improve fold heading editing https://github.com/siyuan-note/siyuan/issues/15848
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
58f72678ae
commit
be233229a9
4 changed files with 73 additions and 29 deletions
|
|
@ -85,29 +85,31 @@ func GetHeadingFold(nodes []*ast.Node) (ret []*ast.Node) {
|
|||
return
|
||||
}
|
||||
|
||||
func IsUnderFoldedHeading(node *ast.Node) bool {
|
||||
func GetParentFoldedHeading(node *ast.Node) (parentFoldedHeading *ast.Node) {
|
||||
currentLevel := 7
|
||||
if ast.NodeHeading == node.Type {
|
||||
currentLevel = node.HeadingLevel
|
||||
}
|
||||
for n := node.Previous; nil != n; n = n.Previous {
|
||||
if ast.NodeHeading == n.Type {
|
||||
if n.HeadingLevel >= currentLevel {
|
||||
break
|
||||
}
|
||||
currentLevel = n.HeadingLevel
|
||||
if ast.NodeHeading != n.Type {
|
||||
continue
|
||||
}
|
||||
|
||||
if "1" == n.IALAttr("fold") {
|
||||
if ast.NodeHeading != node.Type {
|
||||
return true
|
||||
}
|
||||
if n.HeadingLevel > node.HeadingLevel {
|
||||
return true
|
||||
}
|
||||
if n.HeadingLevel >= currentLevel {
|
||||
break
|
||||
}
|
||||
currentLevel = n.HeadingLevel
|
||||
|
||||
if "1" == n.IALAttr("fold") {
|
||||
if ast.NodeHeading != node.Type {
|
||||
parentFoldedHeading = n
|
||||
}
|
||||
if n.HeadingLevel < node.HeadingLevel {
|
||||
parentFoldedHeading = n
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return
|
||||
}
|
||||
|
||||
func HeadingChildren(heading *ast.Node) (ret []*ast.Node) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue