diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 9e970a1990..f463e23710 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -389,6 +389,7 @@ class MainController extends Component { Common.Gateway.on('downloadas', this.onDownloadAs.bind(this)); Common.Gateway.on('requestclose', this.onRequestClose.bind(this)); Common.Gateway.on('setfavorite', this.onSetFavorite.bind(this)); + Common.Gateway.on('insertimage', this.insertImage.bind(this)); Common.Gateway.sendInfo({ mode: appOptions.isEdit ? 'edit' : 'view' @@ -499,6 +500,30 @@ class MainController extends Component { } } + insertImage (data) { + if (data && (data.url || data.images)) { + if (data.url) { + console.log("Obsolete: The 'url' parameter of the 'insertImage' method is deprecated. Please use 'images' parameter instead."); + } + + let arr = []; + + if (data.images && data.images.length > 0) { + for (let i = 0; i < data.images.length; i++) { + if (data.images[i] && data.images[i].url) { + arr.push(data.images[i].url); + } + } + } else if (data.url) { + arr.push(data.url); + } + + data._urls = arr; + } + + Common.Notifications.trigger('storage:image-insert', data); + } + loadDefaultMetricSettings() { const appOptions = this.props.storeAppOptions; let region = ''; @@ -932,6 +957,13 @@ class MainController extends Component { }); Common.Notifications.on('markfavorite', this.markFavorite.bind(this)); + Common.Notifications.on('storage:image-insert', this.insertImageFromStorage.bind(this)); + } + + insertImageFromStorage(data) { + if (data && data._urls && (!data.c || data.c === 'add') && data._urls.length > 0) { + this.api.AddImageUrl(data._urls, undefined, data.token); + } } markFavorite(favorite) { diff --git a/apps/presentationeditor/mobile/src/controller/Main.jsx b/apps/presentationeditor/mobile/src/controller/Main.jsx index 3c190aa293..b7030225c4 100644 --- a/apps/presentationeditor/mobile/src/controller/Main.jsx +++ b/apps/presentationeditor/mobile/src/controller/Main.jsx @@ -519,6 +519,14 @@ class MainController extends Component { storePresentationInfo.changeTitle(meta.title); } }); + + Common.Notifications.on('storage:image-insert', this.insertImageFromStorage.bind(this)); + } + + insertImageFromStorage(data) { + if (data && data._urls && (!data.c || data.c === 'add') && data._urls.length > 0) { + this.api.AddImageUrl(data._urls, undefined, data.token); + } } onApiTextReplaced(found, replaced) { @@ -563,6 +571,7 @@ class MainController extends Component { Common.Gateway.on('processrightschange', this.onProcessRightsChange.bind(this)); Common.Gateway.on('downloadas', this.onDownloadAs.bind(this)); Common.Gateway.on('requestclose', this.onRequestClose.bind(this)); + Common.Gateway.on('insertimage', this.insertImage.bind(this)); Common.Gateway.sendInfo({ mode: appOptions.isEdit ? 'edit' : 'view' @@ -582,6 +591,30 @@ class MainController extends Component { appOptions.changeDocReady(true); } + insertImage (data) { + if (data && (data.url || data.images)) { + if (data.url) { + console.log("Obsolete: The 'url' parameter of the 'insertImage' method is deprecated. Please use 'images' parameter instead."); + } + + let arr = []; + + if (data.images && data.images.length > 0) { + for (let i = 0; i < data.images.length; i++) { + if (data.images[i] && data.images[i].url) { + arr.push(data.images[i].url); + } + } + } else if (data.url) { + arr.push(data.url); + } + + data._urls = arr; + } + + Common.Notifications.trigger('storage:image-insert', data); + } + onLicenseChanged (params) { const appOptions = this.props.storeAppOptions; const licType = params.asc_getLicenseType(); diff --git a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx index 47b46ed26e..182e4bc484 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Main.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Main.jsx @@ -440,6 +440,7 @@ class MainController extends Component { this.api.asc_registerCallback('asc_onEndAction', this._onLongActionEnd.bind(this)); Common.Notifications.on('download:cancel', this.onDownloadCancel.bind(this)); + Common.Notifications.on('storage:image-insert', this.insertImageFromStorage.bind(this)); EditorUIController.initCellInfo && EditorUIController.initCellInfo(this.props); @@ -585,6 +586,12 @@ class MainController extends Component { this.api.asc_setFilteringMode && this.api.asc_setFilteringMode(storeAppOptions.canModifyFilter); } + insertImageFromStorage (data) { + if (data && data._urls && (!data.c || data.c === 'add') && data._urls.length > 0) { + this.api.asc_addImageDrawingObject(data._urls, undefined, data.token); + } + } + onNeedUpdateExternalReference() { const { t } = this.props; @@ -732,6 +739,7 @@ class MainController extends Component { Common.Gateway.on('processrightschange', this.onProcessRightsChange.bind(this)); Common.Gateway.on('downloadas', this.onDownloadAs.bind(this)); Common.Gateway.on('requestclose', this.onRequestClose.bind(this)); + Common.Gateway.on('insertimage', this.insertImage.bind(this)); Common.Gateway.sendInfo({ mode: appOptions.isEdit ? 'edit' : 'view' @@ -750,6 +758,30 @@ class MainController extends Component { appOptions.changeDocReady(true); } + insertImage (data) { + if (data && (data.url || data.images)) { + if (data.url) { + console.log("Obsolete: The 'url' parameter of the 'insertImage' method is deprecated. Please use 'images' parameter instead."); + } + + let arr = []; + + if (data.images && data.images.length > 0) { + for (let i = 0; i < data.images.length; i++) { + if (data.images[i] && data.images[i].url) { + arr.push(data.images[i].url); + } + } + } else if (data.url) { + arr.push(data.url); + } + + data._urls = arr; + } + + Common.Notifications.trigger('storage:image-insert', data); + } + applyMode (appOptions) { this.api.asc_enableKeyEvents(appOptions.isEdit);