diff --git a/www/common/onlyoffice/main.js b/www/common/onlyoffice/main.js index 8b79474ae..6a7d81a4b 100644 --- a/www/common/onlyoffice/main.js +++ b/www/common/onlyoffice/main.js @@ -145,16 +145,9 @@ define([ }); // X2T - var x2t; - var onConvert = function (obj, cb) { - x2t.convert(obj, cb); - }; sframeChan.on('Q_OO_CONVERT', function (obj, cb) { - if (x2t) { return void onConvert(obj, cb); } - require(['/common/outer/x2t.js'], function (X2T) { - x2t = X2T.start(); - onConvert(obj, cb); - }); + obj.modal = 'x2t'; + Utils.initUnsafeIframe(obj, cb); }); diff --git a/www/common/onlyoffice/ooiframe.js b/www/common/onlyoffice/ooiframe.js index 097d21e5e..23c6424e3 100644 --- a/www/common/onlyoffice/ooiframe.js +++ b/www/common/onlyoffice/ooiframe.js @@ -145,16 +145,9 @@ define([ }); // X2T - var x2t; - var onConvert = function (obj, cb) { - x2t.convert(obj, cb); - }; sframeChan.on('Q_OO_CONVERT', function (obj, cb) { - if (x2t) { return void onConvert(obj, cb); } - require(['/common/outer/x2t.js'], function (X2T) { - x2t = X2T.start(); - onConvert(obj, cb); - }); + obj.modal = 'x2t'; + Utils.initUnsafeIframe(obj, cb); }); sframeChan.onReady(function () { diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 3139aa4f0..95b6c52b9 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -72,6 +72,7 @@ define([ var SFrameChannel; var sframeChan; var SecureIframe; + var UnsafeIframe; var OOIframe; var Messaging; var Notifier; @@ -99,6 +100,7 @@ define([ '/common/cryptget.js', '/common/outer/worker-channel.js', '/secureiframe/main.js', + '/unsafeiframe/main.js', '/common/onlyoffice/ooiframe.js', '/common/common-messaging.js', '/common/common-notifier.js', @@ -114,7 +116,7 @@ define([ '/common/test.js', '/common/userObject.js', ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, - _SecureIframe, _OOIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, _Notify, + _SecureIframe, _UnsafeIframe, _OOIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, _Notify, _Constants, _Feedback, _LocalStore, _Cache, _AppConfig, _Test, _UserObject) { CpNfOuter = _CpNfOuter; Cryptpad = _Cryptpad; @@ -122,6 +124,7 @@ define([ Cryptget = _Cryptget; SFrameChannel = _SFrameChannel; SecureIframe = _SecureIframe; + UnsafeIframe = _UnsafeIframe; OOIframe = _OOIframe; Messaging = _Messaging; Notifier = _Notifier; @@ -1503,6 +1506,26 @@ define([ initSecureModal('share', data || {}); }); + // Unsafe iframe + var UnsafeObject = {}; + Utils.initUnsafeIframe = function (cfg, cb) { + if (!UnsafeObject.$iframe) { + var config = {}; + config.addCommonRpc = addCommonRpc; + config.modules = { + Cryptpad: Cryptpad, + SFrameChannel: SFrameChannel, + Utils: Utils + }; + UnsafeObject.$iframe = $('