🐛 Improve ChangeAttrViewLayout (#15157)

This commit is contained in:
Jeffrey Chen 2025-06-28 10:22:59 +08:00 committed by GitHub
parent 8656348ac8
commit bf0018e0c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -150,18 +150,20 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
view.LayoutType = newLayout
err = av.SaveAttributeView(attrView)
node, tree, err := getNodeByBlockID(nil, blockID)
if err != nil {
return
}
blockIDs := treenode.GetMirrorAttrViewBlockIDs(avID)
for _, blockID := range blockIDs {
node, tree, err := getNodeByBlockID(nil, blockID)
if err != nil {
continue
}
node.AttributeViewType = string(view.LayoutType)
attrs := parse.IAL2Map(node.KramdownIAL)
attrs[av.NodeAttrView] = view.ID
err = setNodeAttrs(node, tree, attrs)
if err != nil {
logging.LogWarnf("set node [%s] attrs failed: %s", blockID, err)
return
node.AttributeViewType = string(view.LayoutType)
attrs := parse.IAL2Map(node.KramdownIAL)
attrs[av.NodeAttrView] = view.ID
err = setNodeAttrs(node, tree, attrs)
if err != nil {
logging.LogWarnf("set node [%s] attrs failed: %s", blockID, err)
}
}
ReloadAttrView(avID)