🎨 Add kernel API /api/filetree/getIDsByHPath https://github.com/siyuan-note/siyuan/issues/9654

This commit is contained in:
Daniel 2023-11-15 09:08:41 +08:00
parent 8eb5e53f81
commit 38099e4892
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 115 additions and 2 deletions

View file

@ -143,6 +143,22 @@ func GetBlockTreeRootByHPath(boxID, hPath string) (ret *BlockTree) {
return
}
func GetBlockTreeRootsByHPath(boxID, hPath string) (ret []*BlockTree) {
hPath = gulu.Str.RemoveInvisible(hPath)
blockTrees.Range(func(key, value interface{}) bool {
slice := value.(*btSlice)
slice.m.Lock()
for _, b := range slice.data {
if b.BoxID == boxID && b.HPath == hPath && b.RootID == b.ID {
ret = append(ret, b)
}
}
slice.m.Unlock()
return true
})
return
}
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
hPath = gulu.Str.RemoveInvisible(hPath)
var roots []*BlockTree