More customization

This commit is contained in:
yflory 2025-02-11 15:47:04 +01:00
parent 8246195dc7
commit e730be0a36
3 changed files with 59 additions and 11 deletions

View File

@ -1685,16 +1685,20 @@ define([
|| metadataMgr.getUserData().name
|| Messages.anonymous;
let integrationConfig = privateData?.integrationConfig?._;
let ec = integrationConfig?.editorConfig;
let dc = integrationConfig?.document;
// Config
APP.ooconfig = {
"document": {
"fileType": file.type,
"key": "fresh",
"title": file.title,
"url": url,
"permissions": {
"download": false,
"print": true,
document: {
fileType: file.type,
key: "fresh",
title: dc?.title || file.title,
url: url,
permissions: {
download: dc?.permissions?.download || false,
print: dc?.permissions?.print || true,
}
},
"documentType": file.doc,
@ -2140,6 +2144,31 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
}, void 0, common.getCache());
};
let copy = (a, b) => {
Object.keys(b).forEach(k => {
if (a[k]) {
if (typeof(a[k]) === "object" && typeof(b[k]) === "object") {
copy(a[k], b[k]);
}
return;
}
a[k] = b[k];
});
};
let integrationConfig = privateData?.integrationConfig?._;
if (integrationConfig) {
let ec = integrationConfig.editorConfig;
copy(APP.ooconfig.editorConfig, ec);
// Open "goback" in new tabs because of csp and
// iframes
if (ec.editorConfig?.customization?.goback) {
let c = APP.ooconfig.editorConfig.customization;
c.goback.blank = true;
}
}
console.error('updated config', APP.ooconfig);
APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder-a", APP.ooconfig);
ooLoaded = true;
makeChannel();

View File

@ -112,6 +112,18 @@
xhr.send();
};
let serializedConfig = () => {
let _config = {};
_config.editorConfig = config.editorConfig;
_config.document = {
permissions: config.document?.permissions,
title: config.document?.title,
info: config.document?.info,
referenceData: config.document?.referenceData
};
return _config;
};
var start = function () {
//config.document.key = key;
chan.send('START', {
@ -123,7 +135,8 @@
document: blob,
ext: config.document.fileType,
autosave: config.events.onSave && (config.autosave || 10),
editorConfig: config.editorConfig || {}
editorConfig: config.editorConfig || {},
_config: serializeConfig()
}, function (obj) {
if (obj && obj.error) { reject(obj.error); return console.error(obj.error); }
resolve({});
@ -137,7 +150,12 @@
blob = config.document.blob;
return start();
}
// XXX Nextcloud will log us out if we try from the client
// NOTE: Nextcloud will log us out if we try from the client
// TODO: make sure the server plugin is installed if we don't
// call getBlob()
if (!config.events?.onSave) {
return void start();
}
getBlob(function (err, _blob) {
if (err) { // Can't get blob from client, try from server
console.warn(err);

View File

@ -243,7 +243,8 @@ define([
fileName: data.name,
fileType: data.ext,
autosave: data.autosave,
user: data.editorConfig.user
user: data.editorConfig.user,
_: data._config
},
utils: {
onReady: onReady,