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 error tip when renaming tags/bookmarks containing Markdown markers Fix https://github.com/siyuan-note/siyuan/issues/9248
Daniel8a7c64cdb49b
diff --git a/kernel/api/av.go b/kernel/api/av.goindex d732076590..f945c9fe5a 100644--- a/kernel/api/av.go+++ b/kernel/api/av.go@@ -91,7 +91,7 @@ func setAttributeViewBlockAttr(c *gin.Context) {rowID := arg["rowID"].(string)cellID := arg["cellID"].(string)value := arg["value"].(interface{})- blockAttributeViewKeys := model.UpdateAttributeViewCell(avID, keyID, rowID, cellID, value)+ blockAttributeViewKeys := model.UpdateAttributeViewCell(nil, avID, keyID, rowID, cellID, value)util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})ret.Data = blockAttributeViewKeys}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex 252b805f01..7201dc3c29 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -886,19 +886,24 @@ func removeAttributeViewColumn(operation *Operation) (err error) {}func (tx *Transaction) doReplaceAttrViewBlock(operation *Operation) (ret *TxErr) {- err := replaceAttributeViewBlock(operation)+ err := replaceAttributeViewBlock(operation, tx)if nil != err {return &TxErr{code: TxErrWriteAttributeView, id: operation.AvID}}return}-func replaceAttributeViewBlock(operation *Operation) (err error) {+func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error) {attrView, err := av.ParseAttributeView(operation.AvID)if nil != err {return}+ var node *ast.Node+ if !operation.IsDetached {+ node, _, _ = getNodeByBlockID(tx, operation.NextID)+ }+for _, keyValues := range attrView.KeyValues {for _, value := range keyValues.Values {if value.BlockID == operation.PreviousID {@@ -906,10 +911,13 @@ func replaceAttributeViewBlock(operation *Operation) (err error) {if nil != value.Block {value.Block.ID = operation.NextIDvalue.IsDetached = operation.IsDetached+ if !operation.IsDetached {+ value.Block.Content = getNodeRefText(node)+ }}if !operation.IsDetached {- bindBlockAv(operation.AvID, operation.NextID)+ bindBlockAv(tx, operation.AvID, operation.NextID)}}}@@ -939,11 +947,11 @@ func (tx *Transaction) doUpdateAttrViewCell(operation *Operation) (ret *TxErr) {}func updateAttributeViewCell(operation *Operation, tx *Transaction) (err error) {- err = UpdateAttributeViewCell(operation.AvID, operation.KeyID, operation.RowID, operation.ID, operation.Data)+ err = UpdateAttributeViewCell(tx, operation.AvID, operation.KeyID, operation.RowID, operation.ID, operation.Data)return}-func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, valueData interface{}) (err error) {+func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string, valueData interface{}) (err error) {attrView, err := av.ParseAttributeView(avID)if nil != err {return@@ -982,7 +990,7 @@ func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, valueData interfif oldIsDetached && !val.IsDetached {// 将游离行绑定到新建的块上- bindBlockAv(avID, rowID)+ bindBlockAv(tx, avID, rowID)}if err = av.SaveAttributeView(attrView); nil != err {@@ -991,16 +999,9 @@ func UpdateAttributeViewCell(avID, keyID, rowID, cellID string, valueData interfreturn}-func bindBlockAv(avID, blockID string) {- tree, loadErr := loadTreeByBlockID(blockID)- if nil != loadErr {- logging.LogWarnf("load tree by block id [%s] failed: %s", blockID, loadErr)- return- }-- node := treenode.GetNodeInTree(tree, blockID)- if nil == node {- logging.LogWarnf("node [%s] not found in tree [%s]", blockID, tree.ID)+func bindBlockAv(tx *Transaction, avID, blockID string) {+ node, tree, err := getNodeByBlockID(tx, blockID)+ if nil != err {return}@@ -1018,8 +1019,32 @@ func bindBlockAv(avID, blockID string) {attrs[NodeAttrNameAvs] = strings.Join(avIDs, ",")}- if err := setNodeAttrs(node, tree, attrs); nil != err {+ 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 getNodeByBlockID(tx *Transaction, blockID string) (node *ast.Node, tree *parse.Tree, err error) {+ if nil != tx {+ tree, err = tx.loadTree(blockID)+ } else {+ tree, err = loadTreeByBlockID(blockID)+ }+ if nil != err {+ logging.LogWarnf("load tree by block id [%s] failed: %s", blockID, err)+ return+ }+ node = treenode.GetNodeInTree(tree, blockID)+ if nil == node {+ logging.LogWarnf("node [%s] not found in tree [%s]", blockID, tree.ID)+ return}return}diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.goindex 8fe542b56b..acebebdb9f 100644--- a/kernel/model/blockinfo.go+++ b/kernel/model/blockinfo.go@@ -129,6 +129,10 @@ func getBlockRefText(id string, tree *parse.Tree) (ret string) {}func getNodeRefText(node *ast.Node) string {+ if nil == node {+ return ""+ }+if ret := node.IALAttr("name"); "" != ret {ret = strings.TrimSpace(ret)ret = util.EscapeHTML(ret)