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 db block editing https://github.com/siyuan-note/siyuan/issues/13031
Danieldc70276dae51
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 6cd1c9aa63..8e8d2a0fa8 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1715,16 +1715,16 @@ func getAvNames(avIDs string) (ret string) {return}-func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (trees []*parse.Tree, nodes []*ast.Node) {+func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (trees map[string]*parse.Tree, nodes []*ast.Node) {blockKeyValues := attrView.GetBlockKeyValues()- treeCache := map[string]*parse.Tree{}+ trees = map[string]*parse.Tree{}for _, blockKeyValue := range blockKeyValues.Values {if blockKeyValue.IsDetached {continue}var tree *parse.Tree- tree = treeCache[blockKeyValue.BlockID]+ tree = trees[blockKeyValue.BlockID]if nil == tree {if nil == tx {tree, _ = LoadTreeByBlockID(blockKeyValue.BlockID)@@ -1735,7 +1735,7 @@ func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (treesif nil == tree {continue}- treeCache[blockKeyValue.BlockID] = tree+ trees[blockKeyValue.BlockID] = treenode := treenode.GetNodeInTree(tree, blockKeyValue.BlockID)if nil == node {@@ -1744,9 +1744,6 @@ func (tx *Transaction) getAttrViewBoundNodes(attrView *av.AttributeView) (treesnodes = append(nodes, node)}- for _, tree := range treeCache {- trees = append(trees, tree)- }return}diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex aa8b0af3e0..fd47851cd3 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -1100,6 +1100,19 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {ReloadAttrView(avID)}+ // 插入数据库块时需要重新绑定其中已经存在的块+ // 比如剪切操作时,会先进行 delete 数据库解绑块,这里需要重新绑定 https://github.com/siyuan-note/siyuan/issues/13031+ if ast.NodeAttributeView == insertedNode.Type {+ attrView, parseErr := av.ParseAttributeView(insertedNode.AttributeViewID)+ if nil == parseErr {+ trees, toBindNodes := tx.getAttrViewBoundNodes(attrView)+ for _, toBindNode := range toBindNodes {+ t := trees[toBindNode.ID]+ bindBlockAv0(tx, insertedNode.AttributeViewID, toBindNode, t)+ }+ }+ }+operation.ID = insertedNode.IDoperation.ParentID = insertedNode.Parent.ID