mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
🎨 Update av
This commit is contained in:
parent
3381f1f7d4
commit
073a8bcdd7
2 changed files with 97 additions and 52 deletions
|
|
@ -722,9 +722,44 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
|
|||
if err = tx.writeTree(tree); nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
syncDelete2AttributeView(node)
|
||||
return
|
||||
}
|
||||
|
||||
func syncDelete2AttributeView(node *ast.Node) {
|
||||
avs := node.IALAttr(NodeAttrNameAVs)
|
||||
if "" == avs {
|
||||
return
|
||||
}
|
||||
|
||||
avIDs := strings.Split(avs, ",")
|
||||
for _, avID := range avIDs {
|
||||
attrView, parseErr := av.ParseAttributeView(avID)
|
||||
if nil != parseErr {
|
||||
continue
|
||||
}
|
||||
|
||||
changedAv := false
|
||||
blockValues := attrView.GetBlockKeyValues()
|
||||
if nil == blockValues {
|
||||
continue
|
||||
}
|
||||
|
||||
for i, blockValue := range blockValues.Values {
|
||||
if blockValue.Block.ID == node.ID {
|
||||
blockValues.Values = append(blockValues.Values[:i], blockValues.Values[i+1:]...)
|
||||
changedAv = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if changedAv {
|
||||
av.SaveAttributeView(attrView)
|
||||
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
|
||||
var err error
|
||||
opParentID := operation.ParentID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue