mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🧑💻 Add internal kernel API /api/av/getAttributeViewBoundBlockIDs and getAttributeViewItemIDs https://github.com/siyuan-note/siyuan/issues/15708
This commit is contained in:
parent
3c8c096d83
commit
ab66716178
3 changed files with 82 additions and 0 deletions
|
|
@ -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{}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue