mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🎨 Database values no longer correspond to block attributes Fix https://github.com/siyuan-note/siyuan/issues/9293
This commit is contained in:
parent
ad53100fd1
commit
c1bc0c2b0e
3 changed files with 12 additions and 16 deletions
|
|
@ -171,6 +171,14 @@ func fixLegacyData(tip, node *ast.Node, idMap *map[string]bool, needFix, needMig
|
|||
node.Children = node.Children[:len(node.Children)-1]
|
||||
*needFix = true
|
||||
}
|
||||
|
||||
for _, kv := range node.KramdownIAL {
|
||||
if strings.Contains(kv[0], "custom-av-key-") {
|
||||
// 删除数据库属性键值对 https://github.com/siyuan-note/siyuan/issues/9293
|
||||
node.RemoveIALAttr(kv[0])
|
||||
*needFix = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if "" != node.ID {
|
||||
if _, ok := (*idMap)[node.ID]; ok {
|
||||
|
|
|
|||
|
|
@ -519,8 +519,6 @@ func (tx *Transaction) removeAttributeViewBlock(operation *Operation) (err error
|
|||
delete(attrs, "custom-hidden")
|
||||
node.RemoveIALAttr("custom-hidden")
|
||||
}
|
||||
delete(attrs, NodeAttrNamePrefixAvKey+operation.AvID+"-"+values.KeyID)
|
||||
node.RemoveIALAttr(NodeAttrNamePrefixAvKey + operation.AvID + "-" + values.KeyID)
|
||||
|
||||
if avs := attrs[NodeAttrNameAvs]; "" != avs {
|
||||
avIDs := strings.Split(avs, ",")
|
||||
|
|
@ -937,13 +935,6 @@ func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, valueData interf
|
|||
return
|
||||
}
|
||||
|
||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||
attrs[NodeAttrNamePrefixAvKey+avID+"-"+val.KeyID] = val.ToJSONString()
|
||||
|
||||
if err = setNodeAttrs(node, tree, attrs); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
if err = av.SaveAttributeView(attrView); nil != err {
|
||||
return
|
||||
}
|
||||
|
|
@ -1095,6 +1086,5 @@ func updateAttributeViewColumnOption(operation *Operation) (err error) {
|
|||
}
|
||||
|
||||
const (
|
||||
NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id
|
||||
NodeAttrNamePrefixAvKey = "custom-av-key-" // 用于标记列
|
||||
NodeAttrNameAvs = "custom-avs" // 用于标记块所属的属性视图,逗号分隔 av id
|
||||
)
|
||||
|
|
|
|||
|
|
@ -153,10 +153,8 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
|
||||
// 重新指向数据库属性值
|
||||
ial := parse.IAL2Map(n.KramdownIAL)
|
||||
for k, v := range ial {
|
||||
if strings.HasPrefix(k, NodeAttrNamePrefixAvKey) {
|
||||
v = strings.ReplaceAll(v, oldNodeID, newNodeID)
|
||||
n.SetIALAttr(k, v)
|
||||
for k, _ := range ial {
|
||||
if strings.HasPrefix(k, NodeAttrNameAvs) {
|
||||
avBlockIDs[oldNodeID] = newNodeID
|
||||
}
|
||||
}
|
||||
|
|
@ -259,7 +257,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
|
||||
ial := parse.IAL2Map(n.KramdownIAL)
|
||||
for k, v := range ial {
|
||||
if strings.HasPrefix(k, NodeAttrNamePrefixAvKey) || strings.HasPrefix(k, NodeAttrNameAvs) {
|
||||
if strings.HasPrefix(k, NodeAttrNameAvs) {
|
||||
newKey, newVal := k, v
|
||||
for oldAvID, newAvID := range avIDs {
|
||||
newKey = strings.ReplaceAll(newKey, oldAvID, newAvID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue