diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go index 31b5567a8..1d58fb9af 100644 --- a/kernel/api/block_op.go +++ b/kernel/api/block_op.go @@ -25,6 +25,7 @@ import ( "github.com/88250/lute/ast" "github.com/88250/lute/parse" "github.com/gin-gonic/gin" + "github.com/siyuan-note/logging" "github.com/siyuan-note/siyuan/kernel/filesys" "github.com/siyuan-note/siyuan/kernel/model" "github.com/siyuan-note/siyuan/kernel/treenode" @@ -701,7 +702,13 @@ func updateBlock(c *gin.Context) { tree.Root.FirstChild.Unlink() // 删除列表 tree.Root.FirstChild.Unlink() // 继续删除列表 IAL } - tree.Root.FirstChild.SetIALAttr("id", id) + + if nil != tree.Root.FirstChild { + tree.Root.FirstChild.SetIALAttr("id", id) + } else { + logging.LogWarnf("tree root has no child node when updating block [id=%s]", id) + return + } data = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions) transactions = []*model.Transaction{