diff --git a/apps/documenteditor/main/app/controller/DocumentHolder.js b/apps/documenteditor/main/app/controller/DocumentHolder.js index a5f42263c..84bcb1c79 100644 --- a/apps/documenteditor/main/app/controller/DocumentHolder.js +++ b/apps/documenteditor/main/app/controller/DocumentHolder.js @@ -214,6 +214,9 @@ define([ this.api.asc_registerCallback('asc_onUnLockDocumentProps', _.bind(this.onApiUnLockDocumentProps, this)); this.api.asc_registerCallback('asc_onShowMathTrack', _.bind(this.onShowMathTrack, this)); this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, this)); + this.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Image, _.bind(this.onInsertImage, this)); + this.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.ImageUrl, _.bind(this.onInsertImageUrl, this)); + } this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); @@ -2495,6 +2498,29 @@ define([ } }, + onInsertImage: function(obj, x, y) { + if (this.api) + this.api.asc_addImage(obj); + this.editComplete(); + }, + + onInsertImageUrl: function(obj, x, y) { + var me = this; + (new Common.Views.ImageFromUrlDialog({ + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + me.api.AddImageUrl([checkUrl], undefined, undefined, obj); + } + } + } + me.editComplete(); + } + })).show(); + }, + editComplete: function() { this.documentHolder && this.documentHolder.fireEvent('editcomplete', this.documentHolder); } diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 9103767a8..4e4575def 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -374,8 +374,12 @@ define([ this.api.asc_registerCallback('asc_onInputMessage', _.bind(this.onInputMessage, this)); this.api.asc_registerCallback('asc_onTableTotalMenu', _.bind(this.onTableTotalMenu, this)); this.api.asc_registerCallback('asc_onShowPivotGroupDialog', _.bind(this.onShowPivotGroupDialog, this)); - if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle) + if (!this.permissions.isEditMailMerge && !this.permissions.isEditDiagram && !this.permissions.isEditOle) { this.api.asc_registerCallback('asc_doubleClickOnTableOleObject', _.bind(this.onDoubleClickOnTableOleObject, this)); + this.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Image, _.bind(this.onInsertImage, this)); + this.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.ImageUrl, _.bind(this.onInsertImageUrl, this)); + + } this.api.asc_registerCallback('asc_onShowMathTrack', _.bind(this.onShowMathTrack, this)); this.api.asc_registerCallback('asc_onHideMathTrack', _.bind(this.onHideMathTrack, this)); } @@ -4411,6 +4415,29 @@ define([ } }, + onInsertImage: function(obj, x, y) { + if (this.api) + this.api.asc_addImage(obj); + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + }, + + onInsertImageUrl: function(obj, x, y) { + var me = this; + (new Common.Views.ImageFromUrlDialog({ + handler: function(result, value) { + if (result == 'ok') { + if (me.api) { + var checkUrl = value.replace(/ /g, ''); + if (!_.isEmpty(checkUrl)) { + me.api.AddImageUrl([checkUrl], undefined, undefined, obj); + } + } + } + Common.NotificationCenter.trigger('edit:complete', me.documentHolder); + } + })).show(); + }, + getUserName: function(id){ var usersStore = SSE.getCollection('Common.Collections.Users'); if (usersStore){