From c20fa58d8aeb2a08f005f77f43e9550ff4fd68ae Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 13 Jan 2021 18:39:39 +0300 Subject: [PATCH] [DE] Caption dialog: consider current object --- apps/documenteditor/main/app/controller/Links.js | 15 ++++++++++----- .../documenteditor/main/app/view/CaptionDialog.js | 12 +++++++++--- .../main/app/view/DocumentHolder.js | 11 +---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 43cd15155..9c5e43e65 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -78,14 +78,15 @@ define([ }, 'DocumentHolder': { 'links:contents': this.onTableContents, - 'links:update': this.onTableContentsUpdate + 'links:update': this.onTableContentsUpdate, + 'links:caption': this.onCaptionClick } }); }, onLaunch: function () { this._state = { prcontrolsdisable:undefined, - in_object: false + in_object: undefined }; Common.Gateway.on('setactionlink', function (url) { console.log('url with actions: ' + url); @@ -137,7 +138,8 @@ define([ in_equation = false, in_image = false, in_table = false, - frame_pr = null; + frame_pr = null, + object_type; while (++i < selectedObjects.length) { type = selectedObjects[i].get_ObjectType(); @@ -151,14 +153,17 @@ define([ in_header = true; } else if (type === Asc.c_oAscTypeSelectElement.Image) { in_image = true; + object_type = type; } else if (type === Asc.c_oAscTypeSelectElement.Math) { in_equation = true; + object_type = type; } else if (type === Asc.c_oAscTypeSelectElement.Table) { in_table = true; + object_type = type; } } this._state.prcontrolsdisable = paragraph_locked || header_locked; - this._state.in_object = in_image || in_table || in_equation; + this._state.in_object = object_type; var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false, @@ -411,7 +416,7 @@ define([ onCaptionClick: function(btn) { var me = this; (new DE.Views.CaptionDialog({ - isObject: this._state.in_object, + objectType: this._state.in_object, handler: function (result, settings) { if (result == 'ok') { me.api.asc_AddObjectCaption(settings); diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index b7cbfee1b..2bbe2427c 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -126,7 +126,7 @@ define([ ].join('') }, options); - this.isObject = options.isObject; + this.objectType = options.objectType; this.handler = options.handler; this.props = options.props; @@ -151,7 +151,7 @@ define([ cls: 'input-group-nr', menuStyle: 'min-width: 75px;', editable: false, - disabled: !this.isObject, + disabled: (this.objectType===undefined), takeFocusOnClose: true, data: [ { displayValue: this.textBefore, value: 1 }, @@ -206,7 +206,13 @@ define([ if (curLabel && findIndLabel !== -1) { recLabel = this.cmbLabel.store.at(findIndLabel); } else { - recLabel = this.cmbLabel.store.at(this.arrLabel.length-1); + var index = this.arrLabel.length-1; + if (this.objectType === Asc.c_oAscTypeSelectElement.Math) { + index = this.arrLabel.length-3; + } else if (this.objectType === Asc.c_oAscTypeSelectElement.Image) { + index = this.arrLabel.length-2; + } + recLabel = this.cmbLabel.store.at(index); } this.cmbLabel.selectRecord(recLabel); diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index c718ffbe2..546f4b9bd 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -1887,16 +1887,7 @@ define([ }, onInsertCaption: function() { - var me = this; - (new DE.Views.CaptionDialog({ - isObject: true, - handler: function (result, settings) { - if (result == 'ok') { - me.api.asc_AddObjectCaption(settings); - } - me.fireEvent('editcomplete', me); - } - })).show(); + this.fireEvent('links:caption'); }, onContinueNumbering: function(item, e) {