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: Support modifying the primary key value of the binding block https://github.com/siyuan-note/siyuan/issues/9892
Daniel55272543737c
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex dc8f114720..7b24faaa8f 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1776,6 +1776,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,}oldIsDetached := val.IsDetached+ oldBoundBlockID := val.BlockIDdata, err := gulu.JSON.MarshalJSON(valueData)if nil != err {@@ -1785,9 +1786,25 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,return}- if oldIsDetached && !val.IsDetached {- // 将游离行绑定到新建的块上- bindBlockAv(tx, avID, rowID)+ if oldIsDetached { // 之前是游离行+ if !val.IsDetached { // 现在绑定了块+ // 将游离行绑定到新建的块上+ bindBlockAv(tx, avID, rowID)+ }+ } else { // 之前绑定了块+ if val.IsDetached { // 现在是游离行+ // 将绑定的块从属性视图中移除+ unbindBlockAv(tx, avID, rowID)+ } else { // 现在绑定了块+ if oldBoundBlockID != val.BlockID { // 之前绑定的块和现在绑定的块不一样+ // 换绑块+ unbindBlockAv(tx, avID, oldBoundBlockID)+ bindBlockAv(tx, avID, val.BlockID)+ } else { // 之前绑定的块和现在绑定的块一样+ // 直接返回,因为锚文本不允许更改+ return+ }+ }}for _, kv := range attrView.KeyValues {@@ -1809,6 +1826,39 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,return}+func unbindBlockAv(tx *Transaction, avID, blockID string) {+ node, tree, err := getNodeByBlockID(tx, blockID)+ if nil != err {+ return+ }++ attrs := parse.IAL2Map(node.KramdownIAL)+ if "" == attrs[av.NodeAttrNameAvs] {+ return+ }++ avIDs := strings.Split(attrs[av.NodeAttrNameAvs], ",")+ avIDs = gulu.Str.RemoveElem(avIDs, avID)+ if 0 == len(avIDs) {+ delete(attrs, av.NodeAttrNameAvs)+ node.RemoveIALAttr(av.NodeAttrNameAvs)+ } else {+ attrs[av.NodeAttrNameAvs] = strings.Join(avIDs, ",")+ node.SetIALAttr(av.NodeAttrNameAvs, strings.Join(avIDs, ","))+ }++ if nil != tx {+ err = setNodeAttrsWithTx(tx, node, tree, attrs)+ } else {+ err = setNodeAttrs(node, tree, attrs)+ }+ if nil != err {+ logging.LogWarnf("set node [%s] attrs failed: %s", blockID, err)+ return+ }+ return+}+func bindBlockAv(tx *Transaction, avID, blockID string) {node, tree, err := getNodeByBlockID(tx, blockID)if nil != err {