🎨 文档树支持 Ctrl+Click
和 Shift+↑/↓
进行多选 https://github.com/siyuan-note/siyuan/issues/1359
This commit is contained in:
parent
47a8b0c050
commit
e3a6bb2251
4 changed files with 55 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue