🐛 The updateBlock API encountered a null pointer error https://github.com/siyuan-note/siyuan/issues/16705

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2025-12-26 21:58:49 +08:00
parent da1656b083
commit 89dc302694
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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{