diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 529dfd92c..b60b1b7b0 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -2136,6 +2136,19 @@ define([ } }; + const copy = (a, b) => { + Object.keys(b).forEach(k => { + if (k === "user") { return; } // Don't change user values + if (a[k]) { + if (typeof(a[k]) === "object" && typeof(b[k]) === "object") { + copy(a[k], b[k]); + } + return; + } + a[k] = b[k]; + }); + }; + const createOOConfig = function(blob, file, lock, fromContent, lang, force) { const url = URL.createObjectURL(blob); let username = Util.find(privateData, ['integrationConfig', 'user', 'name']) @@ -2185,18 +2198,6 @@ define([ } }; - let copy = (a, b) => { - Object.keys(b).forEach(k => { - if (k === "user") { return; } // Don't change user values - if (a[k]) { - if (typeof(a[k]) === "object" && typeof(b[k]) === "object") { - copy(a[k], b[k]); - } - return; - } - a[k] = b[k]; - }); - }; if (integrationConfig) { let ec = integrationConfig.editorConfig; let c = ooconfig.editorConfig.customization; diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 75a934a7f..ea7733d4e 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -776,8 +776,13 @@ define([ }; var setFileImporter = function (options, fi, async) { - if (readOnly) { return; } + const priv = cpNfInner.metadataMgr.getPrivateData(); + const isReadOnlyIntegration = priv.isNewFile && + Boolean(priv.integrationConfig) && + priv.initialState; + if (readOnly && !isReadOnlyIntegration) { return; } fileImporter = function (c, f) { + console.error(state, STATE.READY, unsyncMode); if (state !== STATE.READY || unsyncMode) { return void UI.warn(Messages.disconnected); } diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 4cb708ef3..a1a6a4eea 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -799,7 +799,7 @@ define([ origin: window.location.origin, pathname: window.location.pathname, fileHost: ApiConfig.fileHost, - readOnly: readOnly, + readOnly: cfg?.integrationConfig?.readOnly || readOnly, isTemplate: isTemplate, newTemplate: Array.isArray(Cryptpad.initialPath) && Cryptpad.initialPath[0] === "template", diff --git a/www/cryptpad-api.js b/www/cryptpad-api.js index 9efd6c569..ac185e945 100644 --- a/www/cryptpad-api.js +++ b/www/cryptpad-api.js @@ -135,6 +135,7 @@ document: blob, ext: config.document.fileType, autosave: config.events.onSave && (config.autosave || 10), + readOnly: config.mode === 'view', editorConfig: config.editorConfig || {}, _config: serializedConfig() }, function (obj) { diff --git a/www/integration/main.js b/www/integration/main.js index 0e8ca50be..4046d068c 100644 --- a/www/integration/main.js +++ b/www/integration/main.js @@ -240,6 +240,7 @@ define([ href: href, initialState: blob, config: { + readOnly: data.readOnly, fileName: data.name, fileType: data.ext, autosave: data.autosave,