mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 18:10:12 +01:00
🧑💻 Improve editor refresh for kernel API /api/block/moveBlock https://github.com/siyuan-note/siyuan/issues/14559
This commit is contained in:
parent
87709cd5a1
commit
e24ff7d8c4
1 changed files with 24 additions and 2 deletions
|
|
@ -319,6 +319,13 @@ func moveBlock(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
currentBt := treenode.GetBlockTree(id)
|
||||
if nil == currentBt {
|
||||
ret.Code = -1
|
||||
ret.Msg = "block not found [id=" + id + "]"
|
||||
return
|
||||
}
|
||||
|
||||
var parentID, previousID string
|
||||
if nil != arg["parentID"] {
|
||||
parentID = arg["parentID"].(string)
|
||||
|
|
@ -340,6 +347,19 @@ func moveBlock(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
var targetBt *treenode.BlockTree
|
||||
if "" != previousID {
|
||||
targetBt = treenode.GetBlockTree(previousID)
|
||||
} else if "" != parentID {
|
||||
targetBt = treenode.GetBlockTree(parentID)
|
||||
}
|
||||
|
||||
if nil == targetBt {
|
||||
ret.Code = -1
|
||||
ret.Msg = "target block not found [id=" + parentID + "]"
|
||||
return
|
||||
}
|
||||
|
||||
transactions := []*model.Transaction{
|
||||
{
|
||||
DoOperations: []*model.Operation{
|
||||
|
|
@ -356,8 +376,10 @@ func moveBlock(c *gin.Context) {
|
|||
model.PerformTransactions(&transactions)
|
||||
model.FlushTxQueue()
|
||||
|
||||
ret.Data = transactions
|
||||
broadcastTransactions(transactions)
|
||||
model.ReloadProtyle(currentBt.RootID)
|
||||
if currentBt.RootID != targetBt.RootID {
|
||||
model.ReloadProtyle(targetBt.RootID)
|
||||
}
|
||||
}
|
||||
|
||||
func appendBlock(c *gin.Context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue