mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-11 17:54:20 +01:00
🎨 状态栏显示选中内容的字数 https://github.com/siyuan-note/siyuan/issues/4932
This commit is contained in:
parent
1b173ae421
commit
46c4d842f9
3 changed files with 62 additions and 0 deletions
|
|
@ -104,6 +104,44 @@ func getRecentUpdatedBlocks(c *gin.Context) {
|
|||
ret.Data = blocks
|
||||
}
|
||||
|
||||
func getContentWordCount(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
content := arg["content"].(string)
|
||||
runeCount, wordCount := model.ContentWordCount(content)
|
||||
ret.Data = map[string]interface{}{
|
||||
"runeCount": runeCount,
|
||||
"wordCount": wordCount,
|
||||
}
|
||||
}
|
||||
|
||||
func getBlocksWordCount(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))
|
||||
}
|
||||
runeCount, wordCount := model.BlocksWordCount(ids)
|
||||
ret.Data = map[string]interface{}{
|
||||
"runeCount": runeCount,
|
||||
"wordCount": wordCount,
|
||||
}
|
||||
}
|
||||
|
||||
func getBlockWordCount(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/block/getBlockDefIDsByRefText", model.CheckAuth, getBlockDefIDsByRefText)
|
||||
ginServer.Handle("POST", "/api/block/getRefText", model.CheckAuth, getRefText)
|
||||
ginServer.Handle("POST", "/api/block/getBlockWordCount", model.CheckAuth, getBlockWordCount)
|
||||
ginServer.Handle("POST", "/api/block/getBlocksWordCount", model.CheckAuth, getBlocksWordCount)
|
||||
ginServer.Handle("POST", "/api/block/getContentWordCount", model.CheckAuth, getContentWordCount)
|
||||
ginServer.Handle("POST", "/api/block/getRecentUpdatedBlocks", model.CheckAuth, getRecentUpdatedBlocks)
|
||||
ginServer.Handle("POST", "/api/block/getDocInfo", model.CheckAuth, getDocInfo)
|
||||
ginServer.Handle("POST", "/api/block/checkBlockExist", model.CheckAuth, checkBlockExist)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue