mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-15 08:30:42 +08:00
🎨 Improve handling of copy block ref when including images https://github.com/siyuan-note/siyuan/issues/9317
This commit is contained in:
parent
82bed847e6
commit
121d33e74d
@ -279,6 +279,19 @@ func getTreeStat(c *gin.Context) {
|
|||||||
ret.Data = model.StatTree(id)
|
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) {
|
func getRefText(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
@ -159,6 +159,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||||||
ginServer.Handle("POST", "/api/block/getRefIDsByFileAnnotationID", model.CheckAuth, getRefIDsByFileAnnotationID)
|
ginServer.Handle("POST", "/api/block/getRefIDsByFileAnnotationID", model.CheckAuth, getRefIDsByFileAnnotationID)
|
||||||
ginServer.Handle("POST", "/api/block/getBlockDefIDsByRefText", model.CheckAuth, getBlockDefIDsByRefText)
|
ginServer.Handle("POST", "/api/block/getBlockDefIDsByRefText", model.CheckAuth, getBlockDefIDsByRefText)
|
||||||
ginServer.Handle("POST", "/api/block/getRefText", model.CheckAuth, getRefText)
|
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/getTreeStat", model.CheckAuth, getTreeStat)
|
||||||
ginServer.Handle("POST", "/api/block/getBlocksWordCount", model.CheckAuth, getBlocksWordCount)
|
ginServer.Handle("POST", "/api/block/getBlocksWordCount", model.CheckAuth, getBlocksWordCount)
|
||||||
ginServer.Handle("POST", "/api/block/getContentWordCount", model.CheckAuth, getContentWordCount)
|
ginServer.Handle("POST", "/api/block/getContentWordCount", model.CheckAuth, getContentWordCount)
|
||||||
|
@ -117,6 +117,13 @@ func GetBlockRefText(id string) string {
|
|||||||
return getNodeRefText(node)
|
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) {
|
func getBlockRefText(id string, tree *parse.Tree) (ret string) {
|
||||||
node := treenode.GetNodeInTree(tree, id)
|
node := treenode.GetNodeInTree(tree, id)
|
||||||
if nil == node {
|
if nil == node {
|
||||||
|
Loading…
Reference in New Issue
Block a user