Compare commits
42 commits
main
...
insert-onl
Author | SHA1 | Date | |
---|---|---|---|
|
9f69feb244 | ||
|
0ccac55a49 | ||
|
6ee8ff5e57 | ||
|
2f8cb0dac6 | ||
|
86851f4f30 | ||
|
5cfbecc119 | ||
|
e3613ed97e | ||
|
0573b76bb1 | ||
|
9b2fc90476 | ||
|
0309a2462e | ||
|
944eaf2a53 | ||
|
d855d0b884 | ||
|
798fff51ba | ||
|
fbaf81090c | ||
|
4f1f7f6d6d | ||
|
716ce828ff | ||
|
d1f5a25cdd | ||
|
d172b420e7 | ||
|
6df12cd813 | ||
|
a90470c8d9 | ||
|
bf89d0a601 | ||
|
6d6c026e0d | ||
|
ecc3950387 | ||
|
b4a45f0351 | ||
|
7040ccd184 | ||
|
ff1173ac9e | ||
|
d66420496e | ||
|
90d27e68a9 | ||
|
792d27c896 | ||
|
5f269fcff8 | ||
|
e6ab5a90ac | ||
|
ef0c8cd39f | ||
|
97ccc16925 | ||
|
ec59395bca | ||
|
ceeebd679a | ||
|
46f8c04b3c | ||
|
5a4d78a56c | ||
|
83b52a221f | ||
|
c971cf1527 | ||
|
41fd888a39 | ||
|
4d748bd908 | ||
|
d58497ae8e |
4 changed files with 571 additions and 582 deletions
|
@ -33,7 +33,7 @@ main() {
|
||||||
install_version v4 6ebc6938
|
install_version v4 6ebc6938
|
||||||
install_version v5 88a356f0
|
install_version v5 88a356f0
|
||||||
install_version v6 abd8a309
|
install_version v6 abd8a309
|
||||||
install_version v7 ba82142f
|
install_version v7 2792e6e1
|
||||||
install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1
|
install_x2t v7.3+1 ab0c05b0e4c81071acea83f0c6a8e75f5870c360ec4abc4af09105dd9b52264af9711ec0b7020e87095193ac9b6e20305e446f2321a541f743626a598e5318c1
|
||||||
|
|
||||||
rm -rf "$BUILDS_DIR"
|
rm -rf "$BUILDS_DIR"
|
||||||
|
|
27
package-lock.json
generated
27
package-lock.json
generated
|
@ -44,6 +44,7 @@
|
||||||
"netflux-websocket": "^1.2.0",
|
"netflux-websocket": "^1.2.0",
|
||||||
"notp": "^2.0.3",
|
"notp": "^2.0.3",
|
||||||
"nthen": "0.1.8",
|
"nthen": "0.1.8",
|
||||||
|
"onlyoffice-editor": "file:../onlyoffice-editor",
|
||||||
"open-sans-fontface": "^1.4.0",
|
"open-sans-fontface": "^1.4.0",
|
||||||
"openid-client": "^5.4.2",
|
"openid-client": "^5.4.2",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
|
@ -74,6 +75,28 @@
|
||||||
"url": "https://opencollective.com/cryptpad"
|
"url": "https://opencollective.com/cryptpad"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"../onlyoffice-api": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"extraneous": true,
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"devDependencies": {
|
||||||
|
"parcel": "^2.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"../onlyoffice-editor": {
|
||||||
|
"version": "0.0.1",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.0.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"prettier": "3.2.5",
|
||||||
|
"ts-loader": "^9.5.1",
|
||||||
|
"typescript": "^5.4.5",
|
||||||
|
"typescript-eslint": "^7.7.0",
|
||||||
|
"webpack": "^5.91.0",
|
||||||
|
"webpack-cli": "^5.1.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@aashutoshrathi/word-wrap": {
|
"node_modules/@aashutoshrathi/word-wrap": {
|
||||||
"version": "1.2.6",
|
"version": "1.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz",
|
||||||
|
@ -3654,6 +3677,10 @@
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/onlyoffice-editor": {
|
||||||
|
"resolved": "../onlyoffice-editor",
|
||||||
|
"link": true
|
||||||
|
},
|
||||||
"node_modules/open-sans-fontface": {
|
"node_modules/open-sans-fontface": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/open-sans-fontface/-/open-sans-fontface-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/open-sans-fontface/-/open-sans-fontface-1.4.0.tgz",
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
define({
|
define(() => {
|
||||||
currentVersion: 'v7'
|
const version = 7;
|
||||||
|
return {
|
||||||
|
currentVersionNumber: version,
|
||||||
|
currentVersion: 'v' + version
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,16 +16,14 @@ define([
|
||||||
'/common/hyperscript.js',
|
'/common/hyperscript.js',
|
||||||
'/api/config',
|
'/api/config',
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
'/customize/application_config.js',
|
|
||||||
'/components/chainpad/chainpad.dist.js',
|
'/components/chainpad/chainpad.dist.js',
|
||||||
'/file/file-crypto.js',
|
'/file/file-crypto.js',
|
||||||
'/common/onlyoffice/history.js',
|
'/common/onlyoffice/history.js',
|
||||||
'/common/onlyoffice/oocell_base.js',
|
'/common/onlyoffice/oocell_base.js',
|
||||||
'/common/onlyoffice/oodoc_base.js',
|
'/common/onlyoffice/oodoc_base.js',
|
||||||
'/common/onlyoffice/ooslide_base.js',
|
'/common/onlyoffice/ooslide_base.js',
|
||||||
'/common/outer/worker-channel.js',
|
|
||||||
'/common/outer/x2t.js',
|
|
||||||
|
|
||||||
|
'/common/onlyoffice/current-version.js',
|
||||||
'/components/file-saver/FileSaver.min.js',
|
'/components/file-saver/FileSaver.min.js',
|
||||||
|
|
||||||
'css!/components/bootstrap/dist/css/bootstrap.min.css',
|
'css!/components/bootstrap/dist/css/bootstrap.min.css',
|
||||||
|
@ -45,15 +43,13 @@ define([
|
||||||
h,
|
h,
|
||||||
ApiConfig,
|
ApiConfig,
|
||||||
Messages,
|
Messages,
|
||||||
AppConfig,
|
|
||||||
ChainPad,
|
ChainPad,
|
||||||
FileCrypto,
|
FileCrypto,
|
||||||
History,
|
History,
|
||||||
EmptyCell,
|
EmptyCell,
|
||||||
EmptyDoc,
|
EmptyDoc,
|
||||||
EmptySlide,
|
EmptySlide,
|
||||||
Channel,
|
OOCurrentVersion)
|
||||||
X2T)
|
|
||||||
{
|
{
|
||||||
var saveAs = window.saveAs;
|
var saveAs = window.saveAs;
|
||||||
var Nacl = window.nacl;
|
var Nacl = window.nacl;
|
||||||
|
@ -65,9 +61,7 @@ define([
|
||||||
var CHECKPOINT_INTERVAL = 100;
|
var CHECKPOINT_INTERVAL = 100;
|
||||||
var FORCE_CHECKPOINT_INTERVAL = 10000;
|
var FORCE_CHECKPOINT_INTERVAL = 10000;
|
||||||
var DISPLAY_RESTORE_BUTTON = false;
|
var DISPLAY_RESTORE_BUTTON = false;
|
||||||
var NEW_VERSION = 7; // version of the .bin, patches and ChainPad formats
|
|
||||||
var PENDING_TIMEOUT = 30000;
|
var PENDING_TIMEOUT = 30000;
|
||||||
var CURRENT_VERSION = X2T.CURRENT_VERSION;
|
|
||||||
|
|
||||||
//var READONLY_REFRESH_TO = 15000;
|
//var READONLY_REFRESH_TO = 15000;
|
||||||
|
|
||||||
|
@ -98,7 +92,7 @@ define([
|
||||||
hashes: {},
|
hashes: {},
|
||||||
ids: {},
|
ids: {},
|
||||||
mediasSources: {},
|
mediasSources: {},
|
||||||
version: privateData.ooForceVersion ? Number(privateData.ooForceVersion) : NEW_VERSION
|
version: privateData.ooForceVersion ? Number(privateData.ooForceVersion) : OOCurrentVersion.currentVersionNumber
|
||||||
};
|
};
|
||||||
var oldHashes = {};
|
var oldHashes = {};
|
||||||
var oldIds = {};
|
var oldIds = {};
|
||||||
|
@ -111,7 +105,7 @@ define([
|
||||||
|
|
||||||
var evOnPatch = Util.mkEvent();
|
var evOnPatch = Util.mkEvent();
|
||||||
var evOnSync = Util.mkEvent();
|
var evOnSync = Util.mkEvent();
|
||||||
var evIntegrationSave = Util.mkEvent();
|
const evIntegrationSave = Util.mkEvent();
|
||||||
|
|
||||||
// This structure is used for caching media data and blob urls for each media cryptpad url
|
// This structure is used for caching media data and blob urls for each media cryptpad url
|
||||||
var mediasData = {};
|
var mediasData = {};
|
||||||
|
@ -398,9 +392,9 @@ define([
|
||||||
_content.hashes[1] = {
|
_content.hashes[1] = {
|
||||||
file: data.url,
|
file: data.url,
|
||||||
index: 0,
|
index: 0,
|
||||||
version: NEW_VERSION
|
version: OOCurrentVersion.currentVersionNumber
|
||||||
};
|
};
|
||||||
_content.version = NEW_VERSION;
|
_content.version = OOCurrentVersion.currentVersionNumber;
|
||||||
_content.channel = Hash.createChannelId();
|
_content.channel = Hash.createChannelId();
|
||||||
_content.ids = {};
|
_content.ids = {};
|
||||||
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
||||||
|
@ -454,7 +448,7 @@ define([
|
||||||
file: data.url,
|
file: data.url,
|
||||||
hash: ev.hash,
|
hash: ev.hash,
|
||||||
index: ev.index,
|
index: ev.index,
|
||||||
version: NEW_VERSION
|
version: OOCurrentVersion.currentVersionNumber
|
||||||
};
|
};
|
||||||
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
||||||
content.locks = {};
|
content.locks = {};
|
||||||
|
@ -462,7 +456,7 @@ define([
|
||||||
// If this is a migration, set the new version
|
// If this is a migration, set the new version
|
||||||
if (APP.migrate) {
|
if (APP.migrate) {
|
||||||
delete content.migration;
|
delete content.migration;
|
||||||
content.version = NEW_VERSION;
|
content.version = OOCurrentVersion.currentVersionNumber;
|
||||||
}
|
}
|
||||||
APP.onLocal();
|
APP.onLocal();
|
||||||
APP.realtime.onSettle(function () {
|
APP.realtime.onSettle(function () {
|
||||||
|
@ -1068,10 +1062,8 @@ define([
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleAuth = function (obj, send) {
|
const getInitialChanges = function() {
|
||||||
//setEditable(false);
|
const changes = [];
|
||||||
|
|
||||||
var changes = [];
|
|
||||||
if (content.version > 2) {
|
if (content.version > 2) {
|
||||||
ooChannel.queue.forEach(function (data) {
|
ooChannel.queue.forEach(function (data) {
|
||||||
Array.prototype.push.apply(changes, data.msg.changes);
|
Array.prototype.push.apply(changes, data.msg.changes);
|
||||||
|
@ -1081,55 +1073,14 @@ define([
|
||||||
ooChannel.cpIndex += ooChannel.queue.length;
|
ooChannel.cpIndex += ooChannel.queue.length;
|
||||||
var last = ooChannel.queue.pop();
|
var last = ooChannel.queue.pop();
|
||||||
if (last) { ooChannel.lastHash = last.hash; }
|
if (last) { ooChannel.lastHash = last.hash; }
|
||||||
} else {
|
}
|
||||||
|
return changes;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAuth = function () {
|
||||||
|
if (content.version <= 2) {
|
||||||
setEditable(false, true);
|
setEditable(false, true);
|
||||||
}
|
}
|
||||||
send({
|
|
||||||
type: "authChanges",
|
|
||||||
changes: changes
|
|
||||||
});
|
|
||||||
|
|
||||||
// Answer to the auth command
|
|
||||||
var p = getParticipants();
|
|
||||||
send({
|
|
||||||
type: "auth",
|
|
||||||
result: 1,
|
|
||||||
sessionId: sessionId,
|
|
||||||
participants: p.list,
|
|
||||||
locks: [],
|
|
||||||
changes: [],
|
|
||||||
changesIndex: 0,
|
|
||||||
indexUser: p.index,
|
|
||||||
buildVersion: "5.2.6",
|
|
||||||
buildNumber: 2,
|
|
||||||
licenseType: 3,
|
|
||||||
//"g_cAscSpellCheckUrl": "/spellchecker",
|
|
||||||
//"settings":{"spellcheckerUrl":"/spellchecker","reconnection":{"attempts":50,"delay":2000}}
|
|
||||||
});
|
|
||||||
// Open the document
|
|
||||||
send({
|
|
||||||
type: "documentOpen",
|
|
||||||
data: {"type":"open","status":"ok","data":{"Editor.bin":obj.openCmd.url}}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
// TODO: make sure we don't have new popups that can break our integration
|
|
||||||
var observer = new MutationObserver(function(mutations) {
|
|
||||||
mutations.forEach(function(mutation) {
|
|
||||||
if (mutation.type === "childList") {
|
|
||||||
for (var i = 0; i < mutation.addedNodes.length; i++) {
|
|
||||||
if (mutation.addedNodes[i].classList.contains('asc-window') &&
|
|
||||||
mutation.addedNodes[i].classList.contains('alert')) {
|
|
||||||
$(mutation.addedNodes[i]).find('button').not('.custom').click();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
observer.observe(window.frames[0].document.body, {
|
|
||||||
childList: true,
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var handleLock = function (obj, send) {
|
var handleLock = function (obj, send) {
|
||||||
|
@ -1401,43 +1352,29 @@ define([
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const send = ooChannel.send = function (obj, force) {
|
||||||
var makeChannel = function () {
|
|
||||||
var msgEv = Util.mkEvent();
|
|
||||||
var iframe = $('#cp-app-oo-editor > iframe')[0].contentWindow;
|
|
||||||
var type = common.getMetadataMgr().getPrivateData().ooType;
|
|
||||||
window.addEventListener('message', function (msg) {
|
|
||||||
if (msg.source !== iframe) { return; }
|
|
||||||
msgEv.fire(msg);
|
|
||||||
});
|
|
||||||
var postMsg = function (data) {
|
|
||||||
iframe.postMessage(data, ApiConfig.httpSafeOrigin);
|
|
||||||
};
|
|
||||||
Channel.create(msgEv, postMsg, function (chan) {
|
|
||||||
APP.chan = chan;
|
|
||||||
|
|
||||||
var send = ooChannel.send = function (obj, force) {
|
|
||||||
// can't push to OO before reloading cp
|
// can't push to OO before reloading cp
|
||||||
if (APP.onStrictSaveChanges && !force) { return; }
|
if (APP.onStrictSaveChanges && !force) { return; }
|
||||||
// We only need to release locks for sheets
|
// We only need to release locks for sheets
|
||||||
|
const type = common.getMetadataMgr().getPrivateData().ooType;
|
||||||
if (type !== "sheet" && obj.type === "releaseLock") { return; }
|
if (type !== "sheet" && obj.type === "releaseLock") { return; }
|
||||||
if (type === "presentation" && obj.type === "cp_theme") {
|
if (type === "presentation" && obj.type === "cp_theme") {
|
||||||
console.error(obj);
|
console.error(obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(obj, 'toOO');
|
debug(obj, 'toOOClient');
|
||||||
chan.event('CMD', obj);
|
APP.docEditor.sendMessageToOO(obj);
|
||||||
if (obj && obj.type === "saveChanges") {
|
if (obj && obj.type === "saveChanges") {
|
||||||
evIntegrationSave.fire();
|
evIntegrationSave.fire();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
chan.on('CMD', function (obj) {
|
const fromOOHandler = function (obj) {
|
||||||
debug(obj, 'fromOO');
|
debug(obj, 'fromOOClient');
|
||||||
switch (obj.type) {
|
switch (obj.type) {
|
||||||
case "auth":
|
case "auth":
|
||||||
handleAuth(obj, send);
|
// Handled by onlyoffice-editor now
|
||||||
break;
|
break;
|
||||||
case "isSaveLock":
|
case "isSaveLock":
|
||||||
// TODO ping the server to check if we're online first?
|
// TODO ping the server to check if we're online first?
|
||||||
|
@ -1480,6 +1417,7 @@ define([
|
||||||
case "saveChanges":
|
case "saveChanges":
|
||||||
// If we have unsaved data before reloading for a checkpoint...
|
// If we have unsaved data before reloading for a checkpoint...
|
||||||
if (APP.onStrictSaveChanges) {
|
if (APP.onStrictSaveChanges) {
|
||||||
|
const type = common.getMetadataMgr().getPrivateData().ooType;
|
||||||
delete APP.unsavedLocks;
|
delete APP.unsavedLocks;
|
||||||
APP.unsavedChanges = {
|
APP.unsavedChanges = {
|
||||||
type: "saveChanges",
|
type: "saveChanges",
|
||||||
|
@ -1599,8 +1537,6 @@ define([
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var x2tConvertData = function (data, fileName, format, cb) {
|
var x2tConvertData = function (data, fileName, format, cb) {
|
||||||
|
@ -1658,56 +1594,8 @@ define([
|
||||||
// to be downloaded and decrypted before converting to xlsx
|
// to be downloaded and decrypted before converting to xlsx
|
||||||
var downloadImages = {};
|
var downloadImages = {};
|
||||||
|
|
||||||
var firstOO = true;
|
const onAppReady = function() {
|
||||||
startOO = function (blob, file, force) {
|
APP.docEditor.getIframe().setAttribute('tabindex', '-1');
|
||||||
if (APP.ooconfig && !force) { return void console.error('already started'); }
|
|
||||||
var url = URL.createObjectURL(blob);
|
|
||||||
var lock = !APP.history && (APP.migrate);
|
|
||||||
|
|
||||||
var fromContent = metadataMgr.getPrivateData().fromContent;
|
|
||||||
if (!firstOO) { fromContent = undefined; }
|
|
||||||
firstOO = false;
|
|
||||||
|
|
||||||
// Starting from version 3, we can use the view mode again
|
|
||||||
// defined but never used
|
|
||||||
//var mode = (content && content.version > 2 && lock) ? "view" : "edit";
|
|
||||||
|
|
||||||
var lang = (window.cryptpadLanguage || navigator.language || navigator.userLanguage || '').slice(0,2);
|
|
||||||
|
|
||||||
// Config
|
|
||||||
APP.ooconfig = {
|
|
||||||
"document": {
|
|
||||||
"fileType": file.type,
|
|
||||||
"key": "fresh",
|
|
||||||
"title": file.title,
|
|
||||||
"url": url,
|
|
||||||
"permissions": {
|
|
||||||
"download": false,
|
|
||||||
"print": true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"documentType": file.doc,
|
|
||||||
"editorConfig": {
|
|
||||||
customization: {
|
|
||||||
chat: false,
|
|
||||||
logo: {
|
|
||||||
url: "/bounce/#" + encodeURIComponent('https://www.onlyoffice.com')
|
|
||||||
},
|
|
||||||
comments: !lock && !readOnly
|
|
||||||
},
|
|
||||||
"user": {
|
|
||||||
"id": String(myOOId), //"c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
|
|
||||||
"firstname": metadataMgr.getUserData().name || Messages.anonymous,
|
|
||||||
"name": metadataMgr.getUserData().name || Messages.anonymous,
|
|
||||||
},
|
|
||||||
"mode": "edit",
|
|
||||||
"lang": lang
|
|
||||||
},
|
|
||||||
"events": {
|
|
||||||
"onAppReady": function(/*evt*/) {
|
|
||||||
var $iframe = $('iframe[name="frameEditor"]').contents();
|
|
||||||
$iframe.prop('tabindex', '-1');
|
|
||||||
var $tb = $iframe.find('head');
|
|
||||||
var css = // Old OO
|
var css = // Old OO
|
||||||
//'#id-toolbar-full .toolbar-group:nth-child(2), #id-toolbar-full .separator:nth-child(3) { display: none; }' +
|
//'#id-toolbar-full .toolbar-group:nth-child(2), #id-toolbar-full .separator:nth-child(3) { display: none; }' +
|
||||||
//'#fm-btn-save { display: none !important; }' +
|
//'#fm-btn-save { display: none !important; }' +
|
||||||
|
@ -1736,7 +1624,7 @@ define([
|
||||||
//css += '#app-title { display: none !important; }'; // OnlyOffice logo + doc title
|
//css += '#app-title { display: none !important; }'; // OnlyOffice logo + doc title
|
||||||
//css += '#file-menu-panel { top: 28px !important; }'; // Position of the "File" menu
|
//css += '#file-menu-panel { top: 28px !important; }'; // Position of the "File" menu
|
||||||
}
|
}
|
||||||
$('<style>').text(css).appendTo($tb);
|
APP.docEditor.injectCSS(css);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$(window).trigger('resize');
|
$(window).trigger('resize');
|
||||||
});
|
});
|
||||||
|
@ -1745,15 +1633,17 @@ define([
|
||||||
window.setTimeout(function () { UI.findOKButton().focus(); });
|
window.setTimeout(function () { UI.findOKButton().focus(); });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
"onError": function () {
|
|
||||||
|
const onError = function() {
|
||||||
console.error(arguments);
|
console.error(arguments);
|
||||||
if (APP.isDownload) {
|
if (APP.isDownload) {
|
||||||
var sframeChan = common.getSframeChannel();
|
var sframeChan = common.getSframeChannel();
|
||||||
sframeChan.event('EV_OOIFRAME_DONE', '');
|
sframeChan.event('EV_OOIFRAME_DONE', '');
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
"onDocumentReady": function () {
|
|
||||||
|
const onDocumentReady = function(lock, lang, fromContent, file, force) {
|
||||||
evOnSync.fire();
|
evOnSync.fire();
|
||||||
var onMigrateRdy = Util.mkEvent();
|
var onMigrateRdy = Util.mkEvent();
|
||||||
onMigrateRdy.reg(function () {
|
onMigrateRdy.reg(function () {
|
||||||
|
@ -1926,9 +1816,63 @@ define([
|
||||||
}];
|
}];
|
||||||
common.checkTrimHistory(channels);
|
common.checkTrimHistory(channels);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const createOOConfig = function(blob, file, lock, fromContent, lang, force) {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
return {
|
||||||
|
"document": {
|
||||||
|
"fileType": file.type,
|
||||||
|
"key": "fresh",
|
||||||
|
"title": file.title,
|
||||||
|
"url": url,
|
||||||
|
"permissions": {
|
||||||
|
"download": false,
|
||||||
|
"print": true,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"documentType": file.doc,
|
||||||
|
"editorConfig": {
|
||||||
|
customization: {
|
||||||
|
chat: false,
|
||||||
|
logo: {
|
||||||
|
url: "/bounce/#" + encodeURIComponent('https://www.onlyoffice.com')
|
||||||
|
},
|
||||||
|
comments: !lock && !readOnly
|
||||||
|
},
|
||||||
|
"user": {
|
||||||
|
"id": String(myOOId), //"c0c3bf82-20d7-4663-bf6d-7fa39c598b1d",
|
||||||
|
"firstname": metadataMgr.getUserData().name || Messages.anonymous,
|
||||||
|
"name": metadataMgr.getUserData().name || Messages.anonymous,
|
||||||
|
},
|
||||||
|
"mode": "edit",
|
||||||
|
"lang": lang
|
||||||
|
},
|
||||||
|
"events": {
|
||||||
|
"onAppReady": onAppReady,
|
||||||
|
"onError": onError,
|
||||||
|
"onDocumentReady": () => onDocumentReady(lock, lang, fromContent, file, force),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var firstOO = true;
|
||||||
|
startOO = function (blob, file, force) {
|
||||||
|
if (APP.ooconfig && !force) { return void console.error('already started'); }
|
||||||
|
const lock = !APP.history && (APP.migrate);
|
||||||
|
|
||||||
|
let fromContent = metadataMgr.getPrivateData().fromContent;
|
||||||
|
if (!firstOO) { fromContent = undefined; }
|
||||||
|
firstOO = false;
|
||||||
|
|
||||||
|
// Starting from version 3, we can use the view mode again
|
||||||
|
// defined but never used
|
||||||
|
//var mode = (content && content.version > 2 && lock) ? "view" : "edit";
|
||||||
|
|
||||||
|
const lang = (window.cryptpadLanguage || navigator.language || navigator.userLanguage || '').slice(0,2);
|
||||||
|
|
||||||
|
// Config
|
||||||
|
APP.ooconfig = createOOConfig(blob, file, lock, fromContent, lang, force);
|
||||||
/*
|
/*
|
||||||
// NOTE: Make sure it won't break anaything new (Firefox setTimeout bug)
|
// NOTE: Make sure it won't break anaything new (Firefox setTimeout bug)
|
||||||
window.onbeforeunload = function () {
|
window.onbeforeunload = function () {
|
||||||
|
@ -2004,7 +1948,7 @@ define([
|
||||||
APP.onLocal();
|
APP.onLocal();
|
||||||
|
|
||||||
APP.realtime.onSettle(function () {
|
APP.realtime.onSettle(function () {
|
||||||
APP.getImageURL(name, function(url) {
|
getImageURL(name).then(function(url) {
|
||||||
debug("CRYPTPAD success add " + name);
|
debug("CRYPTPAD success add " + name);
|
||||||
common.setPadAttribute('atime', +new Date(), null, data.href);
|
common.setPadAttribute('atime', +new Date(), null, data.href);
|
||||||
APP.AddImageSuccessCallback({
|
APP.AddImageSuccessCallback({
|
||||||
|
@ -2039,9 +1983,10 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
};
|
};
|
||||||
|
|
||||||
APP.loadingImage = 0;
|
APP.loadingImage = 0;
|
||||||
APP.getImageURL = function(name, callback) {
|
const getImageURL = function(name) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
if (name && /^data:image/.test(name)) {
|
if (name && /^data:image/.test(name)) {
|
||||||
return void callback('');
|
return void resolve('');
|
||||||
}
|
}
|
||||||
|
|
||||||
var mediasSources = getMediasSources();
|
var mediasSources = getMediasSources();
|
||||||
|
@ -2059,12 +2004,12 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
};
|
};
|
||||||
var b = new Blob([u8], {type: "image/jpeg"});
|
var b = new Blob([u8], {type: "image/jpeg"});
|
||||||
var blobUrl = URL.createObjectURL(b);
|
var blobUrl = URL.createObjectURL(b);
|
||||||
return void callback(blobUrl);
|
return void resolve(blobUrl);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
debug("CryptPad - could not find matching media for " + name);
|
debug("CryptPad - could not find matching media for " + name);
|
||||||
return void callback("");
|
return void resolve("");
|
||||||
}
|
}
|
||||||
|
|
||||||
var blobUrl = (typeof mediasData[data.src] === 'undefined') ? "" : mediasData[data.src].blobUrl;
|
var blobUrl = (typeof mediasData[data.src] === 'undefined') ? "" : mediasData[data.src].blobUrl;
|
||||||
|
@ -2080,7 +2025,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
documentUrls.addImageUrl(data.name, blobUrl);
|
documentUrls.addImageUrl(data.name, blobUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return void callback(blobUrl);
|
return void resolve(blobUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
APP.loadingImage++;
|
APP.loadingImage++;
|
||||||
|
@ -2088,7 +2033,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
if (err) {
|
if (err) {
|
||||||
APP.loadingImage--;
|
APP.loadingImage--;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return void callback("");
|
return void resolve("");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
debug("Decrypt with key " + data.key);
|
debug("Decrypt with key " + data.key);
|
||||||
|
@ -2096,7 +2041,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
APP.loadingImage--;
|
APP.loadingImage--;
|
||||||
if (err || !res.content) {
|
if (err || !res.content) {
|
||||||
debug("Decrypting failed");
|
debug("Decrypting failed");
|
||||||
return void callback("");
|
return void resolve("");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -2117,21 +2062,33 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
reader.readAsArrayBuffer(res.content);
|
reader.readAsArrayBuffer(res.content);
|
||||||
debug("Adding CryptPad Image " + data.name + ": " + blobUrl);
|
debug("Adding CryptPad Image " + data.name + ": " + blobUrl);
|
||||||
window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name, blobUrl);
|
window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name, blobUrl);
|
||||||
callback(blobUrl);
|
resolve(blobUrl);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
APP.loadingImage--;
|
APP.loadingImage--;
|
||||||
debug("Exception decrypting image " + data.name);
|
debug("Exception decrypting image " + data.name);
|
||||||
console.error(e);
|
console.error(e);
|
||||||
callback("");
|
resolve("");
|
||||||
}
|
}
|
||||||
}, void 0, common.getCache());
|
}, void 0, common.getCache());
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder-a", APP.ooconfig);
|
APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder-a", APP.ooconfig);
|
||||||
|
|
||||||
ooLoaded = true;
|
ooLoaded = true;
|
||||||
makeChannel();
|
// TODO move this back to CryptPad
|
||||||
|
// if (content.version < 7) {
|
||||||
|
// APP.docEditor.installLegacyChannel();
|
||||||
|
// }
|
||||||
|
APP.docEditor.connectMockServer({
|
||||||
|
onMessage: fromOOHandler,
|
||||||
|
getParticipants: getParticipants,
|
||||||
|
onAuth: onAuth,
|
||||||
|
getImageURL: getImageURL,
|
||||||
|
getInitialChanges: getInitialChanges,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
APP.printPdf = function (obj, cb) {
|
APP.printPdf = function (obj, cb) {
|
||||||
|
@ -2609,6 +2566,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
UI.warn(Messages.error);
|
UI.warn(Messages.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
sframeChan.on('EV_OOIFRAME_REFRESH', function (data) {
|
sframeChan.on('EV_OOIFRAME_REFRESH', function (data) {
|
||||||
// We want to get the "bin" content of a sheet from its json in order to download
|
// We want to get the "bin" content of a sheet from its json in order to download
|
||||||
// something useful from a non-onlyoffice app (download from drive or settings).
|
// something useful from a non-onlyoffice app (download from drive or settings).
|
||||||
|
@ -2624,7 +2582,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
content = json.content;
|
content = json.content;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
var version = (!content.version || content.version === 1) ? 'v1/' :
|
var version = (!content.version || content.version === 1) ? 'v1/' :
|
||||||
(content.version <= 3 ? 'v2b/' : CURRENT_VERSION+'/');
|
(content.version <= 3 ? 'v2b/' : OOCurrentVersion.currentVersion + '/');
|
||||||
var s = h('script', {
|
var s = h('script', {
|
||||||
type:'text/javascript',
|
type:'text/javascript',
|
||||||
src: '/common/onlyoffice/dist/'+version+'web-apps/apps/api/documents/api.js'
|
src: '/common/onlyoffice/dist/'+version+'web-apps/apps/api/documents/api.js'
|
||||||
|
@ -2983,7 +2941,7 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||||
|
|
||||||
APP.startNew = isNew;
|
APP.startNew = isNew;
|
||||||
|
|
||||||
var version = CURRENT_VERSION + '/';
|
var version = OOCurrentVersion.currentVersion + '/';
|
||||||
var msg;
|
var msg;
|
||||||
// Old version detected: use the old OO and start the migration if we can
|
// Old version detected: use the old OO and start the migration if we can
|
||||||
if (privateData.ooForceVersion) {
|
if (privateData.ooForceVersion) {
|
||||||
|
|
Loading…
Reference in a new issue