mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentBt := treenode.GetBlockTree(id)
|
||||||
|
if nil == currentBt {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "block not found [id=" + id + "]"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var parentID, previousID string
|
var parentID, previousID string
|
||||||
if nil != arg["parentID"] {
|
if nil != arg["parentID"] {
|
||||||
parentID = arg["parentID"].(string)
|
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{
|
transactions := []*model.Transaction{
|
||||||
{
|
{
|
||||||
DoOperations: []*model.Operation{
|
DoOperations: []*model.Operation{
|
||||||
|
|
@ -356,8 +376,10 @@ func moveBlock(c *gin.Context) {
|
||||||
model.PerformTransactions(&transactions)
|
model.PerformTransactions(&transactions)
|
||||||
model.FlushTxQueue()
|
model.FlushTxQueue()
|
||||||
|
|
||||||
ret.Data = transactions
|
model.ReloadProtyle(currentBt.RootID)
|
||||||
broadcastTransactions(transactions)
|
if currentBt.RootID != targetBt.RootID {
|
||||||
|
model.ReloadProtyle(targetBt.RootID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendBlock(c *gin.Context) {
|
func appendBlock(c *gin.Context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue