An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve av https://github.com/siyuan-note/siyuan/issues/15665
Daniela5ca8efcae9c
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 6dbce775d3..af04790686 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -4265,18 +4265,18 @@ func replaceAttributeViewBlock(avID, oldBlockID, newBlockID string, isDetached breturn}-func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlockID string, isDetached bool, tx *Transaction) (err error) {+func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newNodeID string, isDetached bool, tx *Transaction) (err error) {avID := attrView.IDvar tree *parse.Treevar node *ast.Nodeif !isDetached {- node, tree, _ = getNodeByBlockID(tx, newBlockID)+ node, tree, _ = getNodeByBlockID(tx, newNodeID)}now := util.CurrentTimeMillis()// 检查是否已经存在绑定块,如果存在的话则重新绑定for _, blockVal := range attrView.GetBlockKeyValues().Values {- if !isDetached && blockVal.Block.ID == newBlockID && nil != node && nil != tree {+ if !isDetached && blockVal.Block.ID == newNodeID && nil != node && nil != tree {bindBlockAv0(tx, avID, node, tree)blockVal.IsDetached = falseicon, content := getNodeAvBlockText(node, "")@@ -4288,7 +4288,6 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlock}}- var changedAvIDs []stringfor _, blockVal := range attrView.GetBlockKeyValues().Values {if blockVal.BlockID != oldBlockID {continue@@ -4297,17 +4296,17 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlockif av.KeyTypeBlock == blockVal.Type {blockVal.IsDetached = isDetachedif !isDetached {- if "" != blockVal.Block.ID && blockVal.Block.ID != newBlockID {+ if "" != blockVal.Block.ID && blockVal.Block.ID != newNodeID {unbindBlockAv(tx, avID, blockVal.Block.ID)}- bindBlockAv(tx, avID, newBlockID)+ bindBlockAv(tx, avID, newNodeID)+ blockVal.Block.ID = newNodeIDicon, content := getNodeAvBlockText(node, "")content = util.UnescapeHTML(content)blockVal.Block.Icon, blockVal.Block.Content = icon, content- avIDs := replaceRelationAvValues(avID, blockVal.Block.ID, newBlockID)- blockVal.Block.ID = newBlockID- changedAvIDs = append(changedAvIDs, avIDs...)++ refreshRelatedSrcAvs(avID)} else {blockVal.Block.ID = ""}@@ -4315,11 +4314,6 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newBlock}regenAttrViewGroups(attrView, "force")-- changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)- for _, id := range changedAvIDs {- ReloadAttrView(id)- }return}@@ -5126,48 +5120,6 @@ func getAttrViewName(attrView *av.AttributeView) string {return ret}-func replaceRelationAvValues(avID, previousID, nextID string) (changedSrcAvID []string) {- // The database relation fields follow the change after the primary key field is changed https://github.com/siyuan-note/siyuan/issues/11117-- srcAvIDs := av.GetSrcAvIDs(avID)- for _, srcAvID := range srcAvIDs {- srcAv, parseErr := av.ParseAttributeView(srcAvID)- changed := false- if nil != parseErr {- continue- }-- for _, srcKeyValues := range srcAv.KeyValues {- if av.KeyTypeRelation != srcKeyValues.Key.Type {- continue- }-- if nil == srcKeyValues.Key.Relation || avID != srcKeyValues.Key.Relation.AvID {- continue- }-- for _, srcValue := range srcKeyValues.Values {- if nil == srcValue.Relation {- continue- }-- srcAvChanged := false- srcValue.Relation.BlockIDs, srcAvChanged = util.ReplaceStr(srcValue.Relation.BlockIDs, previousID, nextID)- if srcAvChanged {- changed = true- }- }- }-- if changed {- regenAttrViewGroups(srcAv, "force")- av.SaveAttributeView(srcAv)- changedSrcAvID = append(changedSrcAvID, srcAvID)- }- }- return-}-func updateBoundBlockAvsAttribute(avIDs []string) {// 更新指定 avIDs 中绑定块的 avs 属性