mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 02:59:50 +08:00
🎨 Add internal kernel API /api/setting/setEditorReadOnly
https://github.com/siyuan-note/siyuan/issues/10268
This commit is contained in:
parent
bb4e8c9a8e
commit
0dd90ecef6
@ -317,6 +317,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||
ginServer.Handle("POST", "/api/setting/addVirtualBlockRefInclude", model.CheckAuth, model.CheckReadonly, addVirtualBlockRefInclude)
|
||||
ginServer.Handle("POST", "/api/setting/addVirtualBlockRefExclude", model.CheckAuth, model.CheckReadonly, addVirtualBlockRefExclude)
|
||||
ginServer.Handle("POST", "/api/setting/setSnippet", model.CheckAuth, model.CheckReadonly, setConfSnippet)
|
||||
ginServer.Handle("POST", "/api/setting/setEditorReadOnly", model.CheckAuth, model.CheckReadonly, setEditorReadOnly)
|
||||
|
||||
ginServer.Handle("POST", "/api/graph/resetGraph", model.CheckAuth, model.CheckReadonly, resetGraph)
|
||||
ginServer.Handle("POST", "/api/graph/resetLocalGraph", model.CheckAuth, model.CheckReadonly, resetLocalGraph)
|
||||
|
@ -29,6 +29,27 @@ import (
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func setEditorReadOnly(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
readOnly := arg["readonly"].(bool)
|
||||
|
||||
oldReadOnly := model.Conf.Editor.ReadOnly
|
||||
model.Conf.Editor.ReadOnly = readOnly
|
||||
model.Conf.Save()
|
||||
|
||||
if oldReadOnly != model.Conf.Editor.ReadOnly {
|
||||
util.BroadcastByType("protyle", "readonly", 0, "", model.Conf.Editor.ReadOnly)
|
||||
util.BroadcastByType("main", "readonly", 0, "", model.Conf.Editor.ReadOnly)
|
||||
}
|
||||
}
|
||||
|
||||
func setConfSnippet(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
Loading…
Reference in New Issue
Block a user