mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Prevent parent move into child https://github.com/siyuan-note/siyuan/issues/13131
This commit is contained in:
parent
3c31baaf04
commit
818d1746c0
1 changed files with 17 additions and 0 deletions
|
|
@ -358,6 +358,10 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isMovingParentIntoChild(srcNode, targetNode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for i := len(headingChildren) - 1; -1 < i; i-- {
|
for i := len(headingChildren) - 1; -1 < i; i-- {
|
||||||
c := headingChildren[i]
|
c := headingChildren[i]
|
||||||
targetNode.InsertAfter(c)
|
targetNode.InsertAfter(c)
|
||||||
|
|
@ -407,6 +411,10 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isMovingParentIntoChild(srcNode, targetNode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
processed := false
|
processed := false
|
||||||
if ast.NodeSuperBlock == targetNode.Type {
|
if ast.NodeSuperBlock == targetNode.Type {
|
||||||
// 在布局节点后插入
|
// 在布局节点后插入
|
||||||
|
|
@ -474,6 +482,15 @@ func isMovingFoldHeadingIntoSelf(targetNode *ast.Node, headingChildren []*ast.No
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isMovingParentIntoChild(srcNode, targetNode *ast.Node) bool {
|
||||||
|
for parent := targetNode.Parent; nil != parent; parent = parent.Parent {
|
||||||
|
if parent.ID == srcNode.ID {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
func (tx *Transaction) doPrependInsert(operation *Operation) (ret *TxErr) {
|
||||||
var err error
|
var err error
|
||||||
block := treenode.GetBlockTree(operation.ParentID)
|
block := treenode.GetBlockTree(operation.ParentID)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue