🎨 Add internal kernel API /api/block/getTailChildBlocks https://github.com/siyuan-note/siyuan/issues/9884

This commit is contained in:
Daniel 2023-12-14 22:54:27 +08:00
parent e6aeb5c5cd
commit a16fde8ae7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 81 additions and 0 deletions

View file

@ -533,3 +533,29 @@ func getChildBlocks(c *gin.Context) {
ret.Data = model.GetChildBlocks(id)
}
func getTailChildBlocks(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)
if util.InvalidIDPattern(id, ret) {
return
}
var n int
nArg := arg["n"]
if nil != nArg {
n = int(nArg.(float64))
}
if 1 > n {
n = 7
}
ret.Data = model.GetTailChildBlocks(id, n)
}

View file

@ -160,6 +160,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/block/getBlockDOM", model.CheckAuth, getBlockDOM)
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)
ginServer.Handle("POST", "/api/block/getBlockBreadcrumb", model.CheckAuth, getBlockBreadcrumb)
ginServer.Handle("POST", "/api/block/getBlockIndex", model.CheckAuth, getBlockIndex)
ginServer.Handle("POST", "/api/block/getRefIDs", model.CheckAuth, getRefIDs)