|
@@ -40,11 +40,19 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ operation.RetData = tree.Root.ID
|
|
|
|
+
|
|
heading := treenode.GetNodeInTree(tree, headingID)
|
|
heading := treenode.GetNodeInTree(tree, headingID)
|
|
if nil == heading {
|
|
if nil == heading {
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: headingID}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ast.NodeDocument != heading.Parent.Type {
|
|
|
|
+ // 仅支持文档根节点下第一层标题,不支持容器块内标题
|
|
|
|
+ util.PushMsg(Conf.language(240), 5000)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
headings := []*ast.Node{}
|
|
headings := []*ast.Node{}
|
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
|
if entering && ast.NodeHeading == n.Type && !n.ParentIs(ast.NodeBlockquote) {
|
|
if entering && ast.NodeHeading == n.Type && !n.ParentIs(ast.NodeBlockquote) {
|
|
@@ -71,6 +79,12 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: previousID}
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: previousID}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ast.NodeDocument != previousHeading.Parent.Type {
|
|
|
|
+ // 仅支持文档根节点下第一层标题,不支持容器块内标题
|
|
|
|
+ util.PushMsg(Conf.language(240), 5000)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
targetNode := previousHeading
|
|
targetNode := previousHeading
|
|
previousHeadingChildren := treenode.HeadingChildren(previousHeading)
|
|
previousHeadingChildren := treenode.HeadingChildren(previousHeading)
|
|
if 0 < len(previousHeadingChildren) {
|
|
if 0 < len(previousHeadingChildren) {
|
|
@@ -102,6 +116,12 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: parentID}
|
|
return &TxErr{code: TxErrCodeBlockNotFound, id: parentID}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ast.NodeDocument != parentHeading.Parent.Type {
|
|
|
|
+ // 仅支持文档根节点下第一层标题,不支持容器块内标题
|
|
|
|
+ util.PushMsg(Conf.language(240), 5000)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
targetNode := parentHeading
|
|
targetNode := parentHeading
|
|
parentHeadingChildren := treenode.HeadingChildren(parentHeading)
|
|
parentHeadingChildren := treenode.HeadingChildren(parentHeading)
|
|
|
|
|
|
@@ -153,8 +173,6 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
|
if err = tx.writeTree(tree); nil != err {
|
|
if err = tx.writeTree(tree); nil != err {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
- operation.RetData = tree.Root.ID
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|