From 4cfa391a17cb6d0aa4ba55eda703043b025bd6bb Mon Sep 17 00:00:00 2001 From: Ludovic Dubost Date: Sat, 4 Jan 2020 02:02:20 +0100 Subject: [PATCH] Fixes in onlyoffice code for image upload realtime and ooslide --- .../onlyoffice/sdkjs/cell/sdk-all-min.js | 1 + www/common/onlyoffice/sdkjs/cell/sdk-all.js | 34 +++++++++++++------ .../onlyoffice/sdkjs/slide/sdk-all-min.js | 16 ++++++--- www/common/onlyoffice/sdkjs/slide/sdk-all.js | 19 +++++++---- .../onlyoffice/sdkjs/word/sdk-all-min.js | 16 ++++++--- www/common/onlyoffice/sdkjs/word/sdk-all.js | 19 +++++++---- 6 files changed, 75 insertions(+), 30 deletions(-) diff --git a/www/common/onlyoffice/sdkjs/cell/sdk-all-min.js b/www/common/onlyoffice/sdkjs/cell/sdk-all-min.js index 081b26ce4..eee77ef5a 100644 --- a/www/common/onlyoffice/sdkjs/cell/sdk-all-min.js +++ b/www/common/onlyoffice/sdkjs/cell/sdk-all-min.js @@ -25877,6 +25877,7 @@ function (window, undefined) // This method calls back to the cryptpad onlyoffice inner.js to load the cryptad file dialog window.parent.APP.AddImage(function(res) { // This method adds the loaded image to the list of loaded images + console.log("AddImageCallback"); t.asc_addImageCallback(res); // This method activats the image t._addImageUrl([res.url]); diff --git a/www/common/onlyoffice/sdkjs/cell/sdk-all.js b/www/common/onlyoffice/sdkjs/cell/sdk-all.js index 6636900ee..37c4f2caf 100644 --- a/www/common/onlyoffice/sdkjs/cell/sdk-all.js +++ b/www/common/onlyoffice/sdkjs/cell/sdk-all.js @@ -204531,6 +204531,11 @@ function DecodeBase64(imData, szSrc) this.LoadDocumentImages = function(_images, isUrl) { + // CryptPad added logging + console.log("Loading images"); + console.log(_images); + // CryptPad end logging + // сначала заполним массив if (this.ThemeLoader == null) this.Api.asyncImagesDocumentStartLoaded(); @@ -204694,16 +204699,18 @@ function DecodeBase64(imData, szSrc) oThat.Api.asyncImageEndLoadedBackground(oImage); }; //oImage.Image.crossOrigin = 'anonymous'; - + console.log("Loading image " + i); + console.log(oImage); // CRYPTPAD: if we find an image URL with #channel= in it // then we need to ask cryptpad to get the blob - if (oImage.src.indexOf("#src=")!=-1) - window.parent.APP.getImageURL(oImage.src, function(url) { + if (oImage.src.indexOf("#src=")!=-1) { + window.parent.APP.getImageURL(oImage.src, function(url) { oThis.loadImageByUrl(oImage.Image, url); oThis.map_image_index[url] = oImage; - }); - else - oThis.loadImageByUrl(oImage.Image, oImage.src); + }); + } else { + oThis.loadImageByUrl(oImage.Image, oImage.src); + } }; this.LoadImagesWithCallback = function(arr, loadImageCallBack, loadImageCallBackArgs) @@ -205226,6 +205233,11 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage if(false === oApi.isSaveFonts_Images){ oApi.isSaveFonts_Images = true; } + + // CryptPad - bypassing image loading which is breaking + AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); + + /* oApi.fCurCallback = function (oRes) { var aData, i, oUrls; if(oRes['status'] === 'ok') @@ -205241,6 +205253,7 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); }; AscCommon.sendCommand(oApi, null, rData); + */ }; CCollaborativeEditingBase.prototype.SendImagesCallback = function (aImages) { @@ -205454,15 +205467,16 @@ CCollaborativeEditingBase.prototype.Clear_NewImages = function() }; CCollaborativeEditingBase.prototype.Add_NewImage = function(Url) { + this.m_aNewImages.push( Url ); // CryptPad - Modify URL for local loading - var that = this; + /* + console.log("Add Image " + Url); if (Url.indexOf("#src=")!=-1) { window.parent.APP.getImageURL(Url, function(url) { - that.m_aNewImages.push( Url ); + console.log("CryptPad Image " + url); }); - } else { - this.m_aNewImages.push( Url ); } + */  // CryptPad - End modification }; //----------------------------------------------------------------------------------- diff --git a/www/common/onlyoffice/sdkjs/slide/sdk-all-min.js b/www/common/onlyoffice/sdkjs/slide/sdk-all-min.js index 319cff120..1546abfe4 100644 --- a/www/common/onlyoffice/sdkjs/slide/sdk-all-min.js +++ b/www/common/onlyoffice/sdkjs/slide/sdk-all-min.js @@ -21175,6 +21175,11 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage if(false === oApi.isSaveFonts_Images){ oApi.isSaveFonts_Images = true; } + + // CryptPad - bypassing image loading which is breaking + AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); + + /* oApi.fCurCallback = function (oRes) { var aData, i, oUrls; if(oRes['status'] === 'ok') @@ -21190,6 +21195,7 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); }; AscCommon.sendCommand(oApi, null, rData); + */ }; CCollaborativeEditingBase.prototype.SendImagesCallback = function (aImages) { @@ -21403,15 +21409,16 @@ CCollaborativeEditingBase.prototype.Clear_NewImages = function() }; CCollaborativeEditingBase.prototype.Add_NewImage = function(Url) { + this.m_aNewImages.push( Url ); // CryptPad - Modify URL for local loading - var that = this; + /* + console.log("Add Image " + Url); if (Url.indexOf("#src=")!=-1) { window.parent.APP.getImageURL(Url, function(url) { - that.m_aNewImages.push( Url ); + console.log("CryptPad Image " + url); }); - } else { - this.m_aNewImages.push( Url ); } + */  // CryptPad - End modification }; //----------------------------------------------------------------------------------- @@ -24334,6 +24341,7 @@ function (window, undefined) // This method calls back to the cryptpad onlyoffice inner.js to load the cryptad file dialog window.parent.APP.AddImage(function(res) { // This method adds the loaded image to the list of loaded images + console.log("AddImageCallback"); t.asc_addImageCallback(res); // This method activats the image t._addImageUrl([res.url]); diff --git a/www/common/onlyoffice/sdkjs/slide/sdk-all.js b/www/common/onlyoffice/sdkjs/slide/sdk-all.js index a3800b95e..7e5549a3a 100644 --- a/www/common/onlyoffice/sdkjs/slide/sdk-all.js +++ b/www/common/onlyoffice/sdkjs/slide/sdk-all.js @@ -205879,6 +205879,11 @@ function DecodeBase64(imData, szSrc) this.LoadDocumentImages = function(_images, isUrl) { + // CryptPad added logging + console.log("Loading images"); + console.log(_images); + // CryptPad end logging + // сначала заполним массив if (this.ThemeLoader == null) this.Api.asyncImagesDocumentStartLoaded(); @@ -206042,16 +206047,18 @@ function DecodeBase64(imData, szSrc) oThat.Api.asyncImageEndLoadedBackground(oImage); }; //oImage.Image.crossOrigin = 'anonymous'; - + console.log("Loading image " + i); + console.log(oImage); // CRYPTPAD: if we find an image URL with #channel= in it // then we need to ask cryptpad to get the blob - if (oImage.src.indexOf("#src=")!=-1) - window.parent.APP.getImageURL(oImage.src, function(url) { + if (oImage.src.indexOf("#src=")!=-1) { + window.parent.APP.getImageURL(oImage.src, function(url) { oThis.loadImageByUrl(oImage.Image, url); oThis.map_image_index[url] = oImage; - }); - else - oThis.loadImageByUrl(oImage.Image, oImage.src); + }); + } else { + oThis.loadImageByUrl(oImage.Image, oImage.src); + } }; this.LoadImagesWithCallback = function(arr, loadImageCallBack, loadImageCallBackArgs) diff --git a/www/common/onlyoffice/sdkjs/word/sdk-all-min.js b/www/common/onlyoffice/sdkjs/word/sdk-all-min.js index 83aba1209..24e5f8628 100644 --- a/www/common/onlyoffice/sdkjs/word/sdk-all-min.js +++ b/www/common/onlyoffice/sdkjs/word/sdk-all-min.js @@ -21308,6 +21308,11 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage if(false === oApi.isSaveFonts_Images){ oApi.isSaveFonts_Images = true; } + + // CryptPad - bypassing image loading which is breaking + AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); + + /* oApi.fCurCallback = function (oRes) { var aData, i, oUrls; if(oRes['status'] === 'ok') @@ -21323,6 +21328,7 @@ CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges = function (aImage AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad); }; AscCommon.sendCommand(oApi, null, rData); + */ }; CCollaborativeEditingBase.prototype.SendImagesCallback = function (aImages) { @@ -21536,15 +21542,16 @@ CCollaborativeEditingBase.prototype.Clear_NewImages = function() }; CCollaborativeEditingBase.prototype.Add_NewImage = function(Url) { + this.m_aNewImages.push( Url ); // CryptPad - Modify URL for local loading - var that = this; + /* + console.log("Add Image " + Url); if (Url.indexOf("#src=")!=-1) { window.parent.APP.getImageURL(Url, function(url) { - that.m_aNewImages.push( Url ); + console.log("CryptPad Image " + url); }); - } else { - this.m_aNewImages.push( Url ); } + */  // CryptPad - End modification }; //----------------------------------------------------------------------------------- @@ -24352,6 +24359,7 @@ function (window, undefined) // This method calls back to the cryptpad onlyoffice inner.js to load the cryptad file dialog window.parent.APP.AddImage(function(res) { // This method adds the loaded image to the list of loaded images + console.log("AddImageCallback"); t.asc_addImageCallback(res); // This method activats the image t._addImageUrl([res.url]); diff --git a/www/common/onlyoffice/sdkjs/word/sdk-all.js b/www/common/onlyoffice/sdkjs/word/sdk-all.js index 39f042f57..d2ef7baa3 100644 --- a/www/common/onlyoffice/sdkjs/word/sdk-all.js +++ b/www/common/onlyoffice/sdkjs/word/sdk-all.js @@ -205034,6 +205034,11 @@ function DecodeBase64(imData, szSrc) this.LoadDocumentImages = function(_images, isUrl) { + // CryptPad added logging + console.log("Loading images"); + console.log(_images); + // CryptPad end logging + // сначала заполним массив if (this.ThemeLoader == null) this.Api.asyncImagesDocumentStartLoaded(); @@ -205197,16 +205202,18 @@ function DecodeBase64(imData, szSrc) oThat.Api.asyncImageEndLoadedBackground(oImage); }; //oImage.Image.crossOrigin = 'anonymous'; - + console.log("Loading image " + i); + console.log(oImage); // CRYPTPAD: if we find an image URL with #channel= in it // then we need to ask cryptpad to get the blob - if (oImage.src.indexOf("#src=")!=-1) - window.parent.APP.getImageURL(oImage.src, function(url) { + if (oImage.src.indexOf("#src=")!=-1) { + window.parent.APP.getImageURL(oImage.src, function(url) { oThis.loadImageByUrl(oImage.Image, url); oThis.map_image_index[url] = oImage; - }); - else - oThis.loadImageByUrl(oImage.Image, oImage.src); + }); + } else { + oThis.loadImageByUrl(oImage.Image, oImage.src); + } }; this.LoadImagesWithCallback = function(arr, loadImageCallBack, loadImageCallBackArgs)