mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-15 16:41:07 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
ff1d59a152
@ -70,11 +70,16 @@ func performTransactions(c *gin.Context) {
|
||||
|
||||
app := arg["app"].(string)
|
||||
session := arg["session"].(string)
|
||||
if model.IsFoldHeading(&transactions) || model.IsUnfoldHeading(&transactions) {
|
||||
model.WaitForWritingFiles()
|
||||
}
|
||||
pushTransactions(app, session, transactions)
|
||||
|
||||
if model.IsFoldHeading(&transactions) || model.IsUnfoldHeading(&transactions) || model.IsMoveOutlineHeading(&transactions) {
|
||||
if model.IsMoveOutlineHeading(&transactions) {
|
||||
if retData := transactions[0].DoOperations[0].RetData; nil != retData {
|
||||
util.PushReloadDoc(retData.(string))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elapsed := time.Now().Sub(start).Milliseconds()
|
||||
c.Header("Server-Timing", fmt.Sprintf("total;dur=%d", elapsed))
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
||||
})
|
||||
|
||||
headingChildren := treenode.HeadingChildren(heading)
|
||||
|
||||
// 过滤掉超级块结束节点
|
||||
var tmp []*ast.Node
|
||||
for _, child := range headingChildren {
|
||||
if ast.NodeSuperBlockCloseMarker == child.Type {
|
||||
continue
|
||||
}
|
||||
tmp = append(tmp, child)
|
||||
}
|
||||
headingChildren = tmp
|
||||
|
||||
if "" != previousID {
|
||||
previousHeading := treenode.GetNodeInTree(tree, previousID)
|
||||
if nil == previousHeading {
|
||||
@ -71,12 +82,6 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
||||
}
|
||||
}
|
||||
|
||||
if targetNode == heading.Previous {
|
||||
if previousHeading.HeadingLevel >= heading.HeadingLevel {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
diffLevel := heading.HeadingLevel - previousHeading.HeadingLevel
|
||||
heading.HeadingLevel = previousHeading.HeadingLevel
|
||||
|
||||
@ -99,6 +104,17 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
||||
|
||||
targetNode := parentHeading
|
||||
parentHeadingChildren := treenode.HeadingChildren(parentHeading)
|
||||
|
||||
// 找到下方第一个非标题节点
|
||||
tmp = nil
|
||||
for _, child := range parentHeadingChildren {
|
||||
if ast.NodeHeading == child.Type {
|
||||
break
|
||||
}
|
||||
tmp = append(tmp, child)
|
||||
}
|
||||
parentHeadingChildren = tmp
|
||||
|
||||
if 0 < len(parentHeadingChildren) {
|
||||
for _, child := range parentHeadingChildren {
|
||||
if child.ID == headingID {
|
||||
@ -108,12 +124,6 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
||||
}
|
||||
}
|
||||
|
||||
if targetNode == heading.Previous {
|
||||
if parentHeading.HeadingLevel < heading.HeadingLevel {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
diffLevel := 1
|
||||
heading.HeadingLevel = parentHeading.HeadingLevel + 1
|
||||
if 6 < heading.HeadingLevel {
|
||||
@ -144,7 +154,7 @@ func (tx *Transaction) doMoveOutlineHeading(operation *Operation) (ret *TxErr) {
|
||||
return
|
||||
}
|
||||
|
||||
util.PushReloadDoc(tree.Root.ID)
|
||||
operation.RetData = tree.Root.ID
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,17 @@ func IsUnfoldHeading(transactions *[]*Transaction) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func IsMoveOutlineHeading(transactions *[]*Transaction) bool {
|
||||
for _, tx := range *transactions {
|
||||
for _, op := range tx.DoOperations {
|
||||
if "moveOutlineHeading" == op.Action {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func WaitForWritingFiles() {
|
||||
var printLog bool
|
||||
var lastPrintLog bool
|
||||
|
Loading…
Reference in New Issue
Block a user