diff --git a/server/common/plugin.go b/server/common/plugin.go index 87b304926..9912eee4e 100644 --- a/server/common/plugin.go +++ b/server/common/plugin.go @@ -194,13 +194,24 @@ func (this Get) FrontendOverrides() []string { return overrides } -var xdg_open []string +var xdg_open []func() string func (this Register) XDGOpen(jsString string) { - xdg_open = append(xdg_open, jsString) + xdg_open = append(xdg_open, func() string { + return jsString + }) +} + +func (this Register) XDGOpenFunc(fn func() string) { + xdg_open = append(xdg_open, fn) } + func (this Get) XDGOpen() []string { - return xdg_open + var s []string + for i := 0; i < len(xdg_open); i++ { + s = append(s, xdg_open[i]()) + } + return s } var cssOverride []func() string diff --git a/server/plugin/plg_editor_onlyoffice/index.go b/server/plugin/plg_editor_onlyoffice/index.go index 34a7bca50..23c09924d 100644 --- a/server/plugin/plg_editor_onlyoffice/index.go +++ b/server/plugin/plg_editor_onlyoffice/index.go @@ -108,14 +108,19 @@ func init() { ).Methods("GET") return nil }) - Hooks.Register.XDGOpen(` + Hooks.Register.XDGOpenFunc(func() string { + if plugin_enable() == false { + return "" + } + return ` if(mime === "application/word" || mime === "application/msword" || mime === "application/vnd.oasis.opendocument.text" || mime === "application/vnd.oasis.opendocument.spreadsheet" || mime === "application/excel" || mime === "application/vnd.ms-excel" || mime === "application/powerpoint" || mime === "application/vnd.ms-powerpoint" || mime === "application/vnd.oasis.opendocument.presentation" ) { return ["appframe", {"endpoint": "/api/onlyoffice/iframe"}]; } - `) + ` + }) } func StaticHandler(res http.ResponseWriter, req *http.Request) {