diff --git a/www/common/common-util.js b/www/common/common-util.js index c48bf809f..aa939e5d1 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -867,6 +867,12 @@ const factory = (NaclUtil) => { }; /* End of code copied from saferphore */ + Util.requirePromise = function(modulePath){ + return new Promise((resolve) => { + require([modulePath], resolve); + }); + } + return Util; }; diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index e397e0a84..944b8919d 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1652,15 +1652,15 @@ define([ if (($(e.target).offset().top + $(e.target).height()) > ($(window).height()-$menu.height())) { if ( $(e.target).offset().top < $menu.height()) { menuPositionTop = 0; - + } else { - menuPositionTop = ($(e.target).offset().top - $menu.height()); - } + menuPositionTop = ($(e.target).offset().top - $menu.height()); + } } else { menuPositionTop = $(e.target).offset().top + $(e.target).outerHeight(); } if (($(e.target).offset().left + $(e.target).width()) < $menu.width()) { - menuPositionLeft = $(e.target).offset().left; + menuPositionLeft = $(e.target).offset().left; } else { menuPositionLeft = $(e.target).offset().left - ($menu.width() - $(e.target).width()) + 10; } @@ -4841,7 +4841,7 @@ define([ }); }; - var openInApp = function (paths, app) { + var openInApp = async function (paths, app) { var p = paths[0]; var el = manager.find(p.path); var path = currentPath; @@ -4854,6 +4854,13 @@ define([ password: _metadata.password, channel: _metadata.channel, }; + + const ext = _simpleData.title.split('.').pop(); + const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js'); + if (brokenFormats.brokenImportFormats.includes(ext)) { + await UI.alertPromise(Messages.oo_unstableMigrationWarning); + } + openIn(app, path, APP.team, _simpleData); }; @@ -5642,4 +5649,3 @@ define([ logError: logError }; }); - diff --git a/www/common/onlyoffice/broken-formats.js b/www/common/onlyoffice/broken-formats.js new file mode 100644 index 000000000..34c5a1024 --- /dev/null +++ b/www/common/onlyoffice/broken-formats.js @@ -0,0 +1,9 @@ + +// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team and contributors +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +define({ + brokenExportFormats: ['odt', 'odp'], + brokenImportFormats: ['odp'], +}); diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index d490358c4..cb1c1d2dc 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -63,8 +63,6 @@ define([ var PENDING_TIMEOUT = 30000; const HISTORY_KEEPER_INDEX_USER = 1; const READ_ONLY_INDEX_USER = 2; - const BROKEN_EXPORT_FORMATS = ['odt', 'odp']; - const BROKEN_IMPORT_FORMATS = ['odp']; //var READONLY_REFRESH_TO = 15000; var debug = function (x, type) { @@ -2241,7 +2239,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null return; } - if (BROKEN_EXPORT_FORMATS.includes(ext)) { + const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js'); + if (brokenFormats.brokenExportFormats.includes(ext)) { await UI.alertPromise(Messages.oo_unstableMigrationWarning); } @@ -2367,7 +2366,8 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null debug("Filename"); debug(filename); - if (BROKEN_IMPORT_FORMATS.includes(ext)) { + const brokenFormats = await Util.requirePromise('/common/onlyoffice/broken-formats.js'); + if (brokenFormats.brokenImportFormats.includes(ext)) { await UI.alertPromise(Messages.oo_unstableMigrationWarning); }