mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-12 19:49:59 +05:00
Add support for readOnly mode in API
This commit is contained in:
parent
a3552a9250
commit
03a84fe127
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -240,6 +240,7 @@ define([
|
||||
href: href,
|
||||
initialState: blob,
|
||||
config: {
|
||||
readOnly: data.readOnly,
|
||||
fileName: data.name,
|
||||
fileType: data.ext,
|
||||
autosave: data.autosave,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user