mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
🧑💻 Add internal kernel API /api/block/getBlockDOMWithEmbed and /api/block/getBlockDOMsWithEmbed (#16237)
* 🎨 Add internal kernel API `/api/block/getBlockDOMWithEmbed` and `/api/block/getBlockDOMsWithEmbed` fix https://github.com/siyuan-note/siyuan/issues/16021 * 🎨 Add internal kernel API `/api/block/getBlockDOMWithEmbed` and `/api/block/getBlockDOMsWithEmbed` fix https://github.com/siyuan-note/siyuan/issues/16021
This commit is contained in:
parent
65c8344add
commit
4c2684d11d
3 changed files with 190 additions and 0 deletions
|
|
@ -738,6 +738,42 @@ func getBlockDOMs(c *gin.Context) {
|
|||
ret.Data = doms
|
||||
}
|
||||
|
||||
func getBlockDOMWithEmbed(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
dom := model.GetBlockDOMWithEmbed(id)
|
||||
ret.Data = map[string]string{
|
||||
"id": id,
|
||||
"dom": dom,
|
||||
}
|
||||
}
|
||||
|
||||
func getBlockDOMsWithEmbed(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
idsArg := arg["ids"].([]interface{})
|
||||
var ids []string
|
||||
for _, id := range idsArg {
|
||||
ids = append(ids, id.(string))
|
||||
}
|
||||
|
||||
doms := model.GetBlockDOMsWithEmbed(ids)
|
||||
ret.Data = doms
|
||||
}
|
||||
|
||||
func getBlockKramdown(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -185,6 +185,8 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/block/getBlockInfo", model.CheckAuth, getBlockInfo)
|
||||
ginServer.Handle("POST", "/api/block/getBlockDOM", model.CheckAuth, getBlockDOM)
|
||||
ginServer.Handle("POST", "/api/block/getBlockDOMs", model.CheckAuth, getBlockDOMs)
|
||||
ginServer.Handle("POST", "/api/block/getBlockDOMWithEmbed", model.CheckAuth, getBlockDOMWithEmbed)
|
||||
ginServer.Handle("POST", "/api/block/getBlockDOMsWithEmbed", model.CheckAuth, getBlockDOMsWithEmbed)
|
||||
ginServer.Handle("POST", "/api/block/getBlockKramdown", model.CheckAuth, getBlockKramdown)
|
||||
ginServer.Handle("POST", "/api/block/getChildBlocks", model.CheckAuth, getChildBlocks)
|
||||
ginServer.Handle("POST", "/api/block/getTailChildBlocks", model.CheckAuth, getTailChildBlocks)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue