An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Outdent of list items causes database bind blocks to be deleted https://github.com/siyuan-note/siyuan/issues/17108
Daniel8c8aaa6a6988
diff --git a/kernel/model/file.go b/kernel/model/file.goindex 9bdfd1ad58..adcd019d92 100644--- a/kernel/model/file.go+++ b/kernel/model/file.go@@ -1603,7 +1603,7 @@ func removeDoc(box *Box, p string, luteEngine *lute.Lute) (ret *parse.Tree) {continue}- syncDelete2AvBlock(removeTree.Root, removeTree, nil)+ syncDelete2AvBlock(removeTree.Root, removeTree, true, nil)}if existChildren {diff --git a/kernel/model/transaction.go b/kernel/model/transaction.goindex 3162924f9a..a94c37be41 100644--- a/kernel/model/transaction.go+++ b/kernel/model/transaction.go@@ -1011,12 +1011,12 @@ func (tx *Transaction) doDelete0(operation *Operation, tree *parse.Tree) {}if needSyncDel2AvBlock {- syncDelete2AvBlock(node, tree, tx)+ syncDelete2AvBlock(node, tree, true, tx)}}-func syncDelete2AvBlock(node *ast.Node, nodeTree *parse.Tree, tx *Transaction) {- changedAvIDs := syncDelete2AttributeView(node)+func syncDelete2AvBlock(node *ast.Node, nodeTree *parse.Tree, delChildrenWhenDelParent bool, tx *Transaction) {+ changedAvIDs := syncDelete2AttributeView(node, delChildrenWhenDelParent)avIDs := tx.syncDelete2Block(node, nodeTree)changedAvIDs = append(changedAvIDs, avIDs...)changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)@@ -1078,53 +1078,63 @@ func (tx *Transaction) syncDelete2Block(node *ast.Node, nodeTree *parse.Tree) (creturn}-func syncDelete2AttributeView(node *ast.Node) (changedAvIDs []string) {+func syncDelete2AttributeView(node *ast.Node, delChildrenWhenDelParent bool) (changedAvIDs []string) {+ if !delChildrenWhenDelParent {+ changedAvIDs = deleteAttrView(node, changedAvIDs)+ return+ }+ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {if !entering || !n.IsBlock() {return ast.WalkContinue}- avs := n.IALAttr(av.NodeAttrNameAvs)- if "" == avs {- return ast.WalkContinue- }+ changedAvIDs = append(changedAvIDs, deleteAttrView(n, changedAvIDs)...)+ return ast.WalkContinue+ })- avIDs := strings.Split(avs, ",")- for _, avID := range avIDs {- attrView, parseErr := av.ParseAttributeView(avID)- if nil != parseErr {- continue- }+ changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)+ return+}- changedAv := false- blockValues := attrView.GetBlockKeyValues()- if nil == blockValues {- continue- }+func deleteAttrView(n *ast.Node, changedAvIDs []string) []string {+ avs := n.IALAttr(av.NodeAttrNameAvs)+ if "" == avs {+ return nil+ }- for i, blockValue := range blockValues.Values {- if nil == blockValue.Block {- continue- }+ avIDs := strings.Split(avs, ",")+ for _, avID := range avIDs {+ attrView, parseErr := av.ParseAttributeView(avID)+ if nil != parseErr {+ continue+ }- if blockValue.Block.ID == n.ID {- blockValues.Values = append(blockValues.Values[:i], blockValues.Values[i+1:]...)- changedAv = true- break- }+ changedAv := false+ blockValues := attrView.GetBlockKeyValues()+ if nil == blockValues {+ continue+ }++ for i, blockValue := range blockValues.Values {+ if nil == blockValue.Block {+ continue}- if changedAv {- regenAttrViewGroups(attrView)- av.SaveAttributeView(attrView)- changedAvIDs = append(changedAvIDs, avID)+ if blockValue.Block.ID == n.ID {+ blockValues.Values = append(blockValues.Values[:i], blockValues.Values[i+1:]...)+ changedAv = true+ break}}- return ast.WalkContinue- })- changedAvIDs = gulu.Str.RemoveDuplicatedElem(changedAvIDs)- return+ if changedAv {+ regenAttrViewGroups(attrView)+ av.SaveAttributeView(attrView)+ changedAvIDs = append(changedAvIDs, avID)+ }+ }+ return changedAvIDs}func (tx *Transaction) doLargeInsert(operations []*Operation) {@@ -1482,7 +1492,7 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {removedNodes := getRemovedNodes(oldNode, updatedNode)for _, n := range removedNodes {- syncDelete2AvBlock(n, tree, tx)+ syncDelete2AvBlock(n, tree, false, tx)}// 将不属于折叠标题的块移动到折叠标题下方,需要展开折叠标题