🎨 Add OCR-related operations to the picture menu https://github.com/siyuan-note/siyuan/issues/7203

This commit is contained in:
Liang Ding 2023-04-14 15:22:15 +08:00
parent c6b3083a24
commit 9461cc3f95
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 51 additions and 5 deletions

View file

@ -29,6 +29,40 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func getImageOCRText(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
path := arg["path"].(string)
force := false
if forceArg := arg["force"]; nil != forceArg {
force = forceArg.(bool)
}
ret.Data = map[string]interface{}{
"text": util.GetAssetText(path, force),
}
}
func setImageOCRText(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
path := arg["path"].(string)
text := arg["text"].(string)
util.SetAssetText(path, text)
}
func renameAsset(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)