Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: Broadcast ws-main setBlockAttrs event after API call https://github.com/siyuan-note/siyuan/issues/17179 (#17196)

konti1334f0f2bdd2c19b
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index 2e9a009920..fa35e7503c 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -133,6 +133,7 @@ func BatchSetBlockAttrs(blockAttrs []map[string]interface{}) (err error) {
cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))
pushBroadcastAttrTransactions(oldAttrs, node)
+ util.PushSetBlockAttrs(node.ID, tree.Root.ID)
nodes = append(nodes, node)
}
@@ -182,6 +183,7 @@ func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string
cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))
pushBroadcastAttrTransactions(oldAttrs, node)
+ util.PushSetBlockAttrs(node.ID, tree.Root.ID)
go func() {
sql.FlushQueue()
diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go
index a94cbe730a..4a64d41656 100644
--- a/kernel/util/websocket.go
+++ b/kernel/util/websocket.go
@@ -285,6 +285,10 @@ func PushReloadDoc(rootID string) {
BroadcastByType("main", "reloaddoc", 0, "", rootID)
}
+func PushSetBlockAttrs(id, rootID string) {
+ BroadcastByType("main", "setBlockAttrs", 0, "", map[string]interface{}{"id": id, "rootID": rootID})
+}
+
func PushSaveDoc(rootID, typ string, sources interface{}) {
evt := NewCmdResult("savedoc", 0, PushModeBroadcast)
evt.Data = map[string]interface{}{