🧑‍💻 Add internal kernel API /api/av/getAttributeViewBoundBlockIDs and getAttributeViewItemIDs https://github.com/siyuan-note/siyuan/issues/15708

This commit is contained in:
Daniel 2025-08-30 19:05:01 +08:00
parent 3c8c096d83
commit ab66716178
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 82 additions and 0 deletions

View file

@ -44,6 +44,48 @@ import (
"github.com/xrash/smetrics"
)
func GetAttributeViewItemIDs(avID string, blockIDs []string) (ret map[string]string) {
ret = map[string]string{}
for _, blockID := range blockIDs {
ret[blockID] = ""
}
attrView, err := av.ParseAttributeView(avID)
if err != nil {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
return
}
blockKv := attrView.GetBlockKeyValues()
for _, b := range blockKv.Values {
if _, ok := ret[b.Block.ID]; ok {
ret[b.Block.ID] = b.BlockID
}
}
return
}
func GetAttributeViewBoundBlockIDs(avID string, itemIDs []string) (ret map[string]string) {
ret = map[string]string{}
for _, itemID := range itemIDs {
ret[itemID] = ""
}
attrView, err := av.ParseAttributeView(avID)
if err != nil {
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
return
}
blockKv := attrView.GetBlockKeyValues()
for _, b := range blockKv.Values {
if _, ok := ret[b.BlockID]; ok {
ret[b.BlockID] = b.Block.ID
}
}
return
}
func GetAttrViewAddingBlockDefaultValues(avID, viewID, groupID, previousBlockID, addingBlockID string) (ret map[string]*av.Value) {
ret = map[string]*av.Value{}