An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Add internal kernel API `/api/setting/setEditorReadOnly` https://github.com/siyuan-note/siyuan/issues/10268
Daniel0dd90ecef656
diff --git a/kernel/api/router.go b/kernel/api/router.goindex 0be3f8526b..271f30306c 100644--- a/kernel/api/router.go+++ b/kernel/api/router.go@@ -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)diff --git a/kernel/api/setting.go b/kernel/api/setting.goindex e9c9c9d338..126966952c 100644--- a/kernel/api/setting.go+++ b/kernel/api/setting.go@@ -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)