From 6cf43b34a901fdad13a36ac3445cf353f9a95d9f Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 18 Sep 2022 10:56:13 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BD=BF=E7=94=A8=20API=20`/api/block/?= =?UTF-8?q?updateBlock`=20=E6=9B=B4=E6=96=B0=E5=88=97=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E6=97=B6=E6=97=A0=E6=B3=95=E6=B8=B2=E6=9F=93=E8=A1=8C=E5=86=85?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/5814?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/block_op.go | 3 +-- kernel/util/path.go | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go index 4090bcc37..568c60c73 100644 --- a/kernel/api/block_op.go +++ b/kernel/api/block_op.go @@ -215,9 +215,8 @@ func updateBlock(c *gin.Context) { DoOperations: ops, }) } else { - if "NodeListItem" == block.Type { + if "NodeListItem" == block.Type && ast.NodeList == tree.Root.FirstChild.Type { // 使用 API `api/block/updateBlock` 更新列表项时渲染错误 https://github.com/siyuan-note/siyuan/issues/4658 - tree.Root.AppendChild(tree.Root.FirstChild.FirstChild) // 将列表下的第一个列表项移到文档结尾,移动以后根下面直接挂列表项,渲染器可以正常工作 tree.Root.FirstChild.Unlink() // 删除列表 tree.Root.FirstChild.Unlink() // 继续删除列表 IAL diff --git a/kernel/util/path.go b/kernel/util/path.go index 4d501895e..9f3d6bd4a 100644 --- a/kernel/util/path.go +++ b/kernel/util/path.go @@ -22,6 +22,7 @@ import ( "os" "path" "strings" + "time" "github.com/88250/gulu" "github.com/siyuan-note/logging" @@ -131,6 +132,10 @@ func IsRelativePath(dest string) bool { } func TimeFromID(id string) (ret string) { + if 14 > len(id) { + logging.LogWarnf("invalid id [%s], stack [\n%s]", id, logging.ShortStack()) + return time.Now().Format("20060102150405") + } ret = id[:14] return }