From 57f91cc6dda088cde3d63a7e88a3a9f380ab6647 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 18 Nov 2019 15:14:14 +0300 Subject: [PATCH] [PE] Support picture placeholders --- .../main/app/view/DocumentHolder.js | 54 ++++++++++++------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 48cac30b7..077826844 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1586,7 +1586,9 @@ define([ me.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_ChangeCropState', _.bind(onChangeCropState, me)); - + me.api.asc_registerCallback('asc_onHidePlaceholderActions', _.bind(onChangeCropState, me)); + me.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.Image, _.bind(me.onInsertImage, me, true)); + me.api.asc_registerPlaceholderCallback(AscCommon.PlaceholderButtonType.ImageUrl, _.bind(me.onInsertImageUrl, me, true)); } me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(onCoAuthoringDisconnect, me)); Common.NotificationCenter.on('api:disconnect', _.bind(onCoAuthoringDisconnect, me)); @@ -2781,29 +2783,12 @@ define([ caption : this.textFromFile }).on('click', function(item) { setTimeout(function(){ - if (me.api) me.api.ChangeImageFromFile(); - me.fireEvent('editcomplete', me); + me.onInsertImage(); }, 10); }), new Common.UI.MenuItem({ caption : this.textFromUrl - }).on('click', function(item) { - (new Common.Views.ImageFromUrlDialog({ - handler: function(result, value) { - if (result == 'ok') { - if (me.api) { - var checkUrl = value.replace(/ /g, ''); - if (!_.isEmpty(checkUrl)) { - var props = new Asc.asc_CImgProperty(); - props.put_ImageUrl(checkUrl); - me.api.ImgApply(props); - } - } - } - me.fireEvent('editcomplete', me); - } - })).show(); - }) + }).on('click', _.bind(me.onInsertImageUrl, me, false)) ] }) }); @@ -3432,6 +3417,35 @@ define([ this._isDisabled = state; }, + onInsertImage: function(placeholder, obj, x, y) { + if (this.api) + (placeholder) ? this.api.asc_addImage() : this.api.ChangeImageFromFile(); + this.fireEvent('editcomplete', this); + }, + + onInsertImageUrl: function(placeholder, 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)) { + if (placeholder) + me.api.AddImageUrl(checkUrl); + else { + var props = new Asc.asc_CImgProperty(); + props.put_ImageUrl(checkUrl); + me.api.ImgApply(props); + } + } + } + } + me.fireEvent('editcomplete', me); + } + })).show(); + }, + insertRowAboveText : 'Row Above', insertRowBelowText : 'Row Below', insertColumnLeftText : 'Column Left',