🎨 List item disconnection no longer affects database binding blocks https://github.com/siyuan-note/siyuan/issues/12235

This commit is contained in:
Daniel 2024-08-12 10:51:19 +08:00
parent e4ab00df37
commit 6777ace282
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -772,8 +772,36 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
return
}
syncDelete2AttributeView(node)
syncDelete2Block(node)
// 如果是断开列表时的删除列表项事务,则不需要删除数据库绑定块,因为断开列表事务后面会再次插入相同 ID 的列表项
// List item disconnection no longer affects database binding blocks https://github.com/siyuan-note/siyuan/issues/12235
needSyncDel2AvBlock := true
if ast.NodeListItem == node.Type {
for _, op := range tx.DoOperations {
// 不可能出现相同 ID 先插入再删除的情况,只可能出现先删除再插入的情况,所以这里只需要查找插入操作
if "insert" == op.Action {
data := strings.ReplaceAll(op.Data.(string), editor.FrontEndCaret, "")
subTree := tx.luteEngine.BlockDOM2Tree(data)
ast.Walk(subTree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || ast.NodeListItem != n.Type {
return ast.WalkContinue
}
if n.ID == operation.ID {
needSyncDel2AvBlock = false
return ast.WalkStop
}
return ast.WalkContinue
})
break
}
}
}
if needSyncDel2AvBlock {
syncDelete2AttributeView(node)
syncDelete2Block(node)
}
return
}