mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Database gallery view https://github.com/siyuan-note/siyuan/issues/10414
This commit is contained in:
parent
373f9f9f0f
commit
6658e16259
1 changed files with 22 additions and 1 deletions
|
|
@ -185,12 +185,33 @@ func GetAttributeViewKeysByAvID(avID string) (ret []*av.Key) {
|
|||
return ret
|
||||
}
|
||||
|
||||
func SetDatabaseBlockView(blockID, viewID string) (err error) {
|
||||
func SetDatabaseBlockView(blockID, avID, viewID string) (err error) {
|
||||
attrView, err := av.ParseAttributeView(avID)
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)
|
||||
return
|
||||
}
|
||||
if attrView.ViewID != viewID {
|
||||
attrView.ViewID = viewID
|
||||
if err = av.SaveAttributeView(attrView); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
view := attrView.GetView(viewID)
|
||||
if nil == view {
|
||||
err = av.ErrViewNotFound
|
||||
logging.LogErrorf("view [%s] not found in attribute view [%s]", viewID, avID)
|
||||
return
|
||||
}
|
||||
|
||||
node, tree, err := getNodeByBlockID(nil, blockID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
node.AttributeViewType = string(view.LayoutType)
|
||||
|
||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||
attrs[av.NodeAttrView] = viewID
|
||||
err = setNodeAttrs(node, tree, attrs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue