Browse Source

:bug: 使用 API `/api/block/updateBlock` 更新列表块时无法渲染行内公式 https://github.com/siyuan-note/siyuan/issues/5814

Liang Ding 2 năm trước cách đây
mục cha
commit
6cf43b34a9
2 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 1 2
      kernel/api/block_op.go
  2. 5 0
      kernel/util/path.go

+ 1 - 2
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

+ 5 - 0
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
 }