🧑‍💻 Add internal kernel API /api/block/getBlockKramdowns (#16751)

This commit is contained in:
Vip 2026-01-02 11:12:37 +08:00 committed by GitHub
parent 276282815b
commit 89a6dd6fa9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 74 additions and 0 deletions

View file

@ -813,6 +813,42 @@ func getBlockKramdown(c *gin.Context) {
}
}
func getBlockKramdowns(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 {
idStr := id.(string)
// 验证 ID 格式,跳过无效的 ID
if !util.InvalidIDPattern(idStr, nil) {
ids = append(ids, idStr)
}
}
// mdMarkdown 标记符模式,使用标记符导出
// textmark文本标记模式使用 span 标签导出
// https://github.com/siyuan-note/siyuan/issues/13183
mode := "md"
if modeArg := arg["mode"]; nil != modeArg {
mode = modeArg.(string)
if "md" != mode && "textmark" != mode {
ret.Code = -1
ret.Msg = "Invalid mode"
return
}
}
kramdowns := model.GetBlockKramdowns(ids, mode)
ret.Data = kramdowns
}
func getChildBlocks(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)