From d9b5110ea5122c3a2d45c02a3d944c89b3059c4b Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 22 Dec 2023 20:53:59 +0800 Subject: [PATCH 1/3] :art: Improve kernel API `/api/block/appendBlock` https://github.com/siyuan-note/siyuan/issues/9955 --- kernel/model/transaction.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index 73608c33d..352d1b03e 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -577,7 +577,24 @@ func (tx *Transaction) doAppendInsert(operation *Operation) (ret *TxErr) { for i := 0; i < len(toInserts); i++ { toInsert := toInserts[i] if isContainer { - if ast.NodeSuperBlock == node.Type { + if ast.NodeList == node.Type { + // 列表下只能挂列表项,所以这里需要分情况处理 https://github.com/siyuan-note/siyuan/issues/9955 + if ast.NodeList == toInsert.Type { + var childLis []*ast.Node + for childLi := toInsert.FirstChild; nil != childLi; childLi = childLi.Next { + childLis = append(childLis, childLi) + } + for _, childLi := range childLis { + node.AppendChild(childLi) + } + } else { + newLiID := ast.NewNodeID() + newLi := &ast.Node{ID: newLiID, Type: ast.NodeListItem, ListData: &ast.ListData{Typ: node.ListData.Typ}} + newLi.SetIALAttr("id", newLiID) + node.AppendChild(newLi) + newLi.AppendChild(toInsert) + } + } else if ast.NodeSuperBlock == node.Type { node.LastChild.InsertBefore(toInsert) } else { node.AppendChild(toInsert) From 2742fc369b82ef16426fb383071dd53838c75450 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 22 Dec 2023 23:37:54 +0800 Subject: [PATCH 2/3] :art: Improve remove workspace dir path https://ld246.com/article/1703151906396 --- kernel/api/workspace.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/api/workspace.go b/kernel/api/workspace.go index aada5d169..bf489e25b 100644 --- a/kernel/api/workspace.go +++ b/kernel/api/workspace.go @@ -138,8 +138,11 @@ func removeWorkspaceDir(c *gin.Context) { path := arg["path"].(string) - if util.IsWorkspaceLocked(path) { - logging.LogWarnf("skip remove workspace [%s] because it is locked", path) + if util.IsWorkspaceLocked(path) || util.WorkspaceDir == path { + msg := "Cannot remove current workspace" + ret.Code = -1 + ret.Msg = msg + ret.Data = map[string]interface{}{"closeTimeout": 3000} return } From b1f0e325b9a0402222b2f3c50b7230a498e9bb76 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 22 Dec 2023 23:38:31 +0800 Subject: [PATCH 3/3] :art: Improve remove workspace dir path https://ld246.com/article/1703151906396 --- kernel/api/workspace.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/api/workspace.go b/kernel/api/workspace.go index bf489e25b..bdda877c3 100644 --- a/kernel/api/workspace.go +++ b/kernel/api/workspace.go @@ -160,10 +160,6 @@ func removeWorkspaceDir(c *gin.Context) { ret.Msg = err.Error() return } - - if util.WorkspaceDir == path && (util.ContainerIOS == util.Container || util.ContainerAndroid == util.Container) { - os.Exit(logging.ExitCodeOk) - } } func removeWorkspaceDirPhysically(c *gin.Context) {