An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: 文档树支持 `Ctrl+Click` 和 `Shift+↑/↓` 进行多选 https://github.com/siyuan-note/siyuan/issues/1359
Liang Dinge3a6bb22519b
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.goindex 522969ee4d..6607a43a2d 100644--- a/kernel/api/filetree.go+++ b/kernel/api/filetree.go@@ -193,6 +193,29 @@ func getHPathByPath(c *gin.Context) {ret.Data = hPath}+func getHPathsByPaths(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ pathsArg := arg["paths"].([]interface{})+ var paths []string+ for _, p := range pathsArg {+ paths = append(paths, p.(string))+ }+ hPath, err := model.GetHPathsByPaths(paths)+ if nil != err {+ ret.Code = -1+ ret.Msg = err.Error()+ return+ }+ ret.Data = hPath+}+func getHPathByID(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex 436ee25f99..db19690a85 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -92,6 +92,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/filetree/moveDocs", model.CheckAuth, model.CheckReadonly, moveDocs)ginServer.Handle("POST", "/api/filetree/duplicateDoc", model.CheckAuth, model.CheckReadonly, duplicateDoc)ginServer.Handle("POST", "/api/filetree/getHPathByPath", model.CheckAuth, getHPathByPath)+ ginServer.Handle("POST", "/api/filetree/getHPathsByPaths", model.CheckAuth, getHPathsByPaths)ginServer.Handle("POST", "/api/filetree/getHPathByID", model.CheckAuth, getHPathByID)ginServer.Handle("POST", "/api/filetree/getFullHPathByID", model.CheckAuth, getFullHPathByID)ginServer.Handle("POST", "/api/filetree/doc2Heading", model.CheckAuth, model.CheckReadonly, doc2Heading)diff --git a/kernel/model/file.go b/kernel/model/file.goindex 679bcc284b..0e2aeefe7e 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -962,6 +962,25 @@ func GetHPathByPath(boxID, p string) (hPath string, err error) {return}+func GetHPathsByPaths(paths []string) (hPaths []string, err error) {+ pathsBoxes := getBoxesByPaths(paths)+ for p, box := range pathsBoxes {+ if nil == box {+ logging.LogWarnf("box not found by path [%s]", p)+ continue+ }++ bt := treenode.GetBlockTreeByPath(p)+ if nil == bt {+ logging.LogWarnf("block tree not found by path [%s]", p)+ continue+ }++ hPaths = append(hPaths, box.Name+bt.HPath)+ }+ return+}+func GetHPathByID(id string) (hPath string, err error) {tree, err := loadTreeByBlockID(id)if nil != err {diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.goindex 2ed87ba9ca..173823dd9f 100644--- a/kernel/treenode/blocktree.go+++ b/kernel/treenode/blocktree.go@@ -46,6 +46,18 @@ type BlockTree struct {HPath string // 文档逻辑路径}+func GetBlockTreeByPath(path string) *BlockTree {+ blockTreesLock.Lock()+ defer blockTreesLock.Unlock()++ for _, b := range blockTrees {+ if b.Path == path {+ return b+ }+ }+ return nil+}+func CountTrees() (ret int) {roots := map[string]bool{}for _, b := range blockTrees {