Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Improve outline dnd https://github.com/siyuan-note/siyuan/issues/10828

Daniel6dff64f24641
diff --git a/kernel/model/outline.go b/kernel/model/outline.go
index 28e73a47b4..a5a3247c3e 100644
--- a/kernel/model/outline.go
+++ b/kernel/model/outline.go
@@ -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
}