From 9b2fc9047674a01f4635bda45c98da8e87200f00 Mon Sep 17 00:00:00 2001 From: Wolfgang Ginolas Date: Mon, 24 Jun 2024 13:29:20 +0200 Subject: [PATCH] Load OO from window again --- package.json | 1 - scripts/copy-components.js | 3 +-- www/common/common-util.js | 29 ----------------------------- www/common/onlyoffice/inner.js | 22 ++++++++++++---------- 4 files changed, 13 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index 96b091612..5446303f7 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "netflux-websocket": "^1.0.0", "notp": "^2.0.3", "nthen": "0.1.8", - "onlyoffice-editor": "file:../onlyoffice-editor", "open-sans-fontface": "^1.4.0", "openid-client": "^5.4.2", "pako": "^2.1.0", diff --git a/scripts/copy-components.js b/scripts/copy-components.js index 025674050..bba138518 100644 --- a/scripts/copy-components.js +++ b/scripts/copy-components.js @@ -46,8 +46,7 @@ Fse.rmSync(oldComponentsPath, { recursive: true, force: true }); "netflux-websocket", "drawio", "pako", - "x2js", - "onlyoffice-editor" + "x2js" ].forEach(l => { const source = Path.join("node_modules", l); const destination = Path.join(componentsPath, l); diff --git a/www/common/common-util.js b/www/common/common-util.js index 95b346a67..fd96f12c4 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -758,35 +758,6 @@ return ver || undefined; }; - Util.get = function(obj, key, defaultValue = undefined) { - if (typeof key === "string") { - key = key.split("."); - } - - for (const k of key) { - if (obj == null) { - return defaultValue; - } - obj = obj[k]; - } - - if (obj == null) { - return defaultValue; - } - return obj; - }; - - Util.deepAssign = function(target, source) { - if (typeof target != "object") { - return source; - } - - const result = Object.assign({}, target); - for (const key of Object.keys(source)) { - result[key] = Util.deepAssign(target[key], source[key]); - } - return result; - }; if (typeof(module) !== 'undefined' && module.exports) { module.exports = Util; diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 018fd9069..b517890b8 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -23,7 +23,6 @@ define([ '/common/onlyoffice/oodoc_base.js', '/common/onlyoffice/ooslide_base.js', - '/components/onlyoffice-editor/dist/bundle.js', '/common/onlyoffice/current-version.js', '/components/file-saver/FileSaver.min.js', @@ -50,7 +49,6 @@ define([ EmptyCell, EmptyDoc, EmptySlide, - OOEditor, OOCurrentVersion) { var saveAs = window.saveAs; @@ -2105,14 +2103,14 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null }, void 0, common.getCache()); }; + APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder-a", APP.ooconfig); - APP.docEditor.init(APP.ooconfig).then(() => { - ooLoaded = true; - if (content.version < 7) { - APP.docEditor.installLegacyChannel(); - } - APP.docEditor.setOnMessageFromOOHandler(fromOOHandler); - }); + ooLoaded = true; + // TODO movie this back to CryptPad + // if (content.version < 7) { + // APP.docEditor.installLegacyChannel(); + // } + APP.docEditor.setOnMessageFromOOHandler(fromOOHandler); }; APP.printPdf = function (obj, cb) { @@ -3032,7 +3030,11 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null checkCheckpoint(); } - APP.docEditor = new OOEditor.OnlyOfficeEditor("cp-app-oo-placeholder-a", '/common/onlyoffice/dist/'+version+'web-apps/apps/api/documents/api.js'); + var s = h('script', { + type:'text/javascript', + src: '/common/onlyoffice/dist/'+version+'web-apps/apps/api/documents/api.js' + }); + $('#cp-app-oo-editor').append(s); if (metadataMgr.getPrivateData().burnAfterReading && content && content.channel) { sframeChan.event('EV_BURN_PAD', content.channel);