An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:technologist: Improve internal kernel API `/api/attr/batchSetBlockAttrs` Fix https://github.com/siyuan-note/siyuan/issues/10401
Danielfbbf83b52d46
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.goindex 49f98b6090..c0fa6c5ecb 100644--- a/kernel/model/blockial.go+++ b/kernel/model/blockial.go@@ -104,25 +104,34 @@ func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {trees := map[string]*parse.Tree{}for _, blockAttr := range blockAttrs {id := blockAttr["id"].(string)- if nil == trees[id] {+ bt := treenode.GetBlockTree(id)+ if nil == bt {+ return errors.New(fmt.Sprintf(Conf.Language(15), id))+ }++ if nil == trees[bt.RootID] {tree, e := loadTreeByBlockID(id)if nil != e {return e}- trees[id] = tree+ trees[bt.RootID] = tree}}var nodes []*ast.Nodefor _, blockAttr := range blockAttrs {id := blockAttr["id"].(string)- attrs := blockAttr["attrs"].(map[string]string)- tree := trees[id]+ bt := treenode.GetBlockTree(id)+ if nil == bt {+ return errors.New(fmt.Sprintf(Conf.Language(15), id))+ }+ tree := trees[bt.RootID]node := treenode.GetNodeInTree(tree, id)if nil == node {return errors.New(fmt.Sprintf(Conf.Language(15), id))}+ attrs := blockAttr["attrs"].(map[string]string)oldAttrs, e := setNodeAttrs0(node, attrs)if nil != e {return e@@ -133,6 +142,12 @@ func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {nodes = append(nodes, node)}+ for _, tree := range trees {+ if err = indexWriteJSONQueue(tree); nil != err {+ return+ }+ }+IncSync()// 不做锚文本刷新return