mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-17 04:28:07 +01:00
🎨 Blocks below other non-folded headings are no longer moved when moving a folded heading Fix https://github.com/siyuan-note/siyuan/issues/8321
This commit is contained in:
parent
cc9dce106a
commit
feb4d7e0cd
2 changed files with 14 additions and 0 deletions
|
|
@ -257,7 +257,10 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||||
var headingChildren []*ast.Node
|
var headingChildren []*ast.Node
|
||||||
if isMovingFoldHeading := ast.NodeHeading == srcNode.Type && "1" == srcNode.IALAttr("fold"); isMovingFoldHeading {
|
if isMovingFoldHeading := ast.NodeHeading == srcNode.Type && "1" == srcNode.IALAttr("fold"); isMovingFoldHeading {
|
||||||
headingChildren = treenode.HeadingChildren(srcNode)
|
headingChildren = treenode.HeadingChildren(srcNode)
|
||||||
|
// Blocks below other non-folded headings are no longer moved when moving a folded heading https://github.com/siyuan-note/siyuan/issues/8321
|
||||||
|
headingChildren = treenode.GetHeadingFold(headingChildren)
|
||||||
}
|
}
|
||||||
|
|
||||||
var srcEmptyList *ast.Node
|
var srcEmptyList *ast.Node
|
||||||
if ast.NodeListItem == srcNode.Type && srcNode.Parent.FirstChild == srcNode && srcNode.Parent.LastChild == srcNode {
|
if ast.NodeListItem == srcNode.Type && srcNode.Parent.FirstChild == srcNode && srcNode.Parent.LastChild == srcNode {
|
||||||
// 列表中唯一的列表项被移除后,该列表就为空了
|
// 列表中唯一的列表项被移除后,该列表就为空了
|
||||||
|
|
@ -290,6 +293,8 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||||
|
|
||||||
if ast.NodeHeading == targetNode.Type && "1" == targetNode.IALAttr("fold") {
|
if ast.NodeHeading == targetNode.Type && "1" == targetNode.IALAttr("fold") {
|
||||||
targetChildren := treenode.HeadingChildren(targetNode)
|
targetChildren := treenode.HeadingChildren(targetNode)
|
||||||
|
targetChildren = treenode.GetHeadingFold(targetChildren)
|
||||||
|
|
||||||
if l := len(targetChildren); 0 < l {
|
if l := len(targetChildren); 0 < l {
|
||||||
targetNode = targetChildren[l-1]
|
targetNode = targetChildren[l-1]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,15 @@ func IsInFoldedHeading(node, currentHeading *ast.Node) bool {
|
||||||
return IsInFoldedHeading(heading, currentHeading)
|
return IsInFoldedHeading(heading, currentHeading)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetHeadingFold(nodes []*ast.Node) (ret []*ast.Node) {
|
||||||
|
for _, n := range nodes {
|
||||||
|
if "1" == n.IALAttr("heading-fold") {
|
||||||
|
ret = append(ret, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func HeadingChildren(heading *ast.Node) (ret []*ast.Node) {
|
func HeadingChildren(heading *ast.Node) (ret []*ast.Node) {
|
||||||
start := heading.Next
|
start := heading.Next
|
||||||
if nil == start {
|
if nil == start {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue