mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-20 15:26:09 +01:00
🐛 Improve outline dnd https://github.com/siyuan-note/siyuan/issues/10828
This commit is contained in:
parent
f5b7def958
commit
6dff64f246
1 changed files with 17 additions and 2 deletions
|
|
@ -40,11 +40,18 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
||||
}
|
||||
|
||||
operation.RetData = tree.Root.ID
|
||||
|
||||
heading := treenode.GetNodeInTree(tree, headingID)
|
||||
if nil == heading {
|
||||
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
||||
}
|
||||
|
||||
if ast.NodeDocument != heading.Parent.Type {
|
||||
// 仅支持文档根节点下第一层标题,不支持容器块内标题
|
||||
return
|
||||
}
|
||||
|
||||
headings := []*ast.Node{}
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if entering && ast.NodeHeading == n.Type && !n.ParentIs(ast.NodeBlockquote) {
|
||||
|
|
@ -71,6 +78,11 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: previousID}
|
||||
}
|
||||
|
||||
if ast.NodeDocument != previousHeading.Parent.Type {
|
||||
// 仅支持文档根节点下第一层标题,不支持容器块内标题
|
||||
return
|
||||
}
|
||||
|
||||
targetNode := previousHeading
|
||||
previousHeadingChildren := treenode.HeadingChildren(previousHeading)
|
||||
if 0 < len(previousHeadingChildren) {
|
||||
|
|
@ -102,6 +114,11 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|||
return &TxErr{code: TxErrCodeBlockNotFound, id: parentID}
|
||||
}
|
||||
|
||||
if ast.NodeDocument != parentHeading.Parent.Type {
|
||||
// 仅支持文档根节点下第一层标题,不支持容器块内标题
|
||||
return
|
||||
}
|
||||
|
||||
targetNode := parentHeading
|
||||
parentHeadingChildren := treenode.HeadingChildren(parentHeading)
|
||||
|
||||
|
|
@ -153,8 +170,6 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|||
if err = tx.writeTree(tree); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
operation.RetData = tree.Root.ID
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue