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 handling of copy block ref when including images https://github.com/siyuan-note/siyuan/issues/9317
Daniel121d33e74d77
diff --git a/kernel/api/block.go b/kernel/api/block.goindex 46986a10c6..90e79b50ae 100644--- a/kernel/api/block.go+++ b/kernel/api/block.go@@ -279,6 +279,19 @@ func getTreeStat(c *gin.Context) {ret.Data = model.StatTree(id)}+func getDOMText(c *gin.Context) {+ ret := gulu.Ret.NewResult()+ defer c.JSON(http.StatusOK, ret)++ arg, ok := util.JsonArg(c, ret)+ if !ok {+ return+ }++ dom := arg["dom"].(string)+ ret.Data = model.GetDOMText(dom)+}+func getRefText(c *gin.Context) {ret := gulu.Ret.NewResult()defer c.JSON(http.StatusOK, ret)diff --git a/kernel/api/router.go b/kernel/api/router.goindex 4a27bdd717..fcd7fffb24 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -159,6 +159,7 @@ func ServeAPI(ginServer *gin.Engine) {ginServer.Handle("POST", "/api/block/getRefIDsByFileAnnotationID", model.CheckAuth, getRefIDsByFileAnnotationID)ginServer.Handle("POST", "/api/block/getBlockDefIDsByRefText", model.CheckAuth, getBlockDefIDsByRefText)ginServer.Handle("POST", "/api/block/getRefText", model.CheckAuth, getRefText)+ ginServer.Handle("POST", "/api/block/getDOMText", model.CheckAuth, getDOMText)ginServer.Handle("POST", "/api/block/getTreeStat", model.CheckAuth, getTreeStat)ginServer.Handle("POST", "/api/block/getBlocksWordCount", model.CheckAuth, getBlocksWordCount)ginServer.Handle("POST", "/api/block/getContentWordCount", model.CheckAuth, getContentWordCount)diff --git a/kernel/model/blockinfo.go b/kernel/model/blockinfo.goindex acebebdb9f..e2aa800b0e 100644--- a/kernel/model/blockinfo.go+++ b/kernel/model/blockinfo.go@@ -117,6 +117,13 @@ func GetBlockRefText(id string) string {return getNodeRefText(node)}+func GetDOMText(dom string) (ret string) {+ luteEngine := NewLute()+ tree := luteEngine.BlockDOM2Tree(dom)+ ret = renderBlockText(tree.Root, nil)+ return+}+func getBlockRefText(id string, tree *parse.Tree) (ret string) {node := treenode.GetNodeInTree(tree, id)if nil == node {