From 44fa7b6462ea2108c686a4b0811faa6e8a0ddcf9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 22 Sep 2020 00:01:04 +0300 Subject: [PATCH] [DE] Fix Bug 46598 --- .../main/app/controller/Toolbar.js | 17 +++--- .../main/app/view/DocumentHolder.js | 57 ++++++------------- apps/documenteditor/main/locale/en.json | 1 + 3 files changed, 28 insertions(+), 47 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 0a0c5095d..b2b2974bf 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -310,7 +310,7 @@ define([ toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnDropCap.menu.on('item:click', _.bind(this.onDropCapSelect, this)); toolbar.btnContentControls.menu.on('item:click', _.bind(this.onControlsSelect, this)); - toolbar.mnuDropCapAdvanced.on('click', _.bind(this.onDropCapAdvancedClick, this)); + toolbar.mnuDropCapAdvanced.on('click', _.bind(this.onDropCapAdvancedClick, this, false)); toolbar.btnColumns.menu.on('item:click', _.bind(this.onColumnsSelect, this)); toolbar.btnPageOrient.menu.on('item:click', _.bind(this.onPageOrientSelect, this)); toolbar.btnPageMargins.menu.on('item:click', _.bind(this.onPageMarginsSelect, this)); @@ -394,6 +394,7 @@ define([ this.api.asc_registerCallback('asc_onTableEraseModeChanged', _.bind(this.onTableErase, this)); Common.NotificationCenter.on('storage:image-load', _.bind(this.openImageFromStorage, this)); Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this)); + Common.NotificationCenter.on('dropcap:settings', _.bind(this.onDropCapAdvancedClick, this)); } else if (this.mode.isRestrictedEdit) { this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObjectRestrictedEdit, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); @@ -1742,11 +1743,11 @@ define([ this._state.dropcap = v; }, - onDropCapAdvancedClick: function() { + onDropCapAdvancedClick: function(isFrame) { var win, props, text, me = this; - if (_.isUndefined(me.fontstore)) { + if (!isFrame && _.isUndefined(me.fontstore)) { me.fontstore = new Common.Collections.Fonts(); var fonts = me.toolbar.cmbFontName.store.toJSON(); var arr = []; @@ -1776,16 +1777,18 @@ define([ (new DE.Views.DropcapSettingsAdvanced({ tableStylerRows: 2, tableStylerColumns: 1, - fontStore: me.fontstore, + fontStore: !isFrame ? me.fontstore : null, paragraphProps: props, borderProps: me.borderAdvancedProps, api: me.api, - isFrame: false, + isFrame: !!isFrame, handler: function(result, value) { if (result == 'ok') { me.borderAdvancedProps = value.borderProps; - if (value.paragraphProps && value.paragraphProps.get_DropCap() === Asc.c_oAscDropCap.None) { - me.api.removeDropcap(true); + if (value.paragraphProps && + ( !isFrame && value.paragraphProps.get_DropCap() === Asc.c_oAscDropCap.None || + isFrame && value.paragraphProps.get_Wrap() === c_oAscFrameWrap.None)) { + me.api.removeDropcap(!isFrame); } else me.api.put_FramePr(value.paragraphProps); } diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index c6e99822e..c986e8257 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -1657,43 +1657,8 @@ define([ } }, - advancedFrameClick: function(item, e, eOpt){ - var win, me = this; - if (me.api){ - var selectedElements = me.api.getSelectedElements(); - if (selectedElements && _.isArray(selectedElements)){ - for (var i = selectedElements.length - 1; i >= 0; i--) { - var elType, elValue; - elType = selectedElements[i].get_ObjectType(); - elValue = selectedElements[i].get_ObjectValue(); // заменить на свойства рамки - if (Asc.c_oAscTypeSelectElement.Paragraph == elType) { - win = new DE.Views.DropcapSettingsAdvanced({ - tableStylerRows : 2, - tableStylerColumns : 1, - paragraphProps : elValue, - borderProps : me.borderAdvancedProps, - api : me.api, - isFrame : true, - handler: function(result, value) { - if (result == 'ok') { - me.borderAdvancedProps = value.borderProps; - if (value.paragraphProps && value.paragraphProps.get_Wrap() === c_oAscFrameWrap.None) { - me.api.removeDropcap(false); - } else - me.api.put_FramePr(value.paragraphProps); - } - me.fireEvent('editcomplete', me); - } - }); - break; - } - } - } - } - - if (win) { - win.show(); - } + advancedFrameClick: function(isFrame, item, e, eOpt){ + Common.NotificationCenter.trigger('dropcap:settings', isFrame); }, advancedTableClick: function(item, e, eOpt){ @@ -3551,7 +3516,12 @@ define([ var menuFrameAdvanced = new Common.UI.MenuItem({ caption : me.advancedFrameText - }).on('click', _.bind(me.advancedFrameClick, me)); + }).on('click', _.bind(me.advancedFrameClick, me, true)); + + var menuDropCapAdvanced = new Common.UI.MenuItem({ + iconCls: 'menu__icon dropcap-intext', + caption : me.advancedDropCapText + }).on('click', _.bind(me.advancedFrameClick, me, false)); /** coauthoring begin **/ var menuCommentSeparatorPara = new Common.UI.MenuItem({ @@ -3871,6 +3841,7 @@ define([ menuParagraphKeepLines.setDisabled(disabled); menuParagraphAdvanced.setDisabled(disabled); menuFrameAdvanced.setDisabled(disabled); + menuDropCapAdvanced.setDisabled(disabled); menuParagraphVAlign.setDisabled(disabled); menuParagraphDirection.setDisabled(disabled); @@ -3914,7 +3885,11 @@ define([ menuEquationInsertCaption.setVisible(isEquation); menuEquationInsertCaptionSeparator.setVisible(isEquation); - menuFrameAdvanced.setVisible(value.paraProps.value.get_FramePr() !== undefined); + var frame_pr = value.paraProps.value.get_FramePr(); + menuFrameAdvanced.setVisible(frame_pr !== undefined); + menuDropCapAdvanced.setVisible(frame_pr !== undefined); + if (frame_pr) + menuDropCapAdvanced.setIconCls(frame_pr.get_DropCap()===Asc.c_oAscDropCap.Drop ? 'menu__icon dropcap-intext' : 'menu__icon dropcap-inmargin'); menuStyleSeparator.setVisible(me.mode.canEditStyles && !isInChart); menuStyle.setVisible(me.mode.canEditStyles && !isInChart); @@ -4009,6 +3984,7 @@ define([ menuParagraphDirection, menuParagraphAdvanced, menuFrameAdvanced, + menuDropCapAdvanced, /** coauthoring begin **/ menuCommentSeparatorPara, menuAddCommentPara, @@ -4569,7 +4545,8 @@ define([ textSeveral: 'Several Rows/Columns', txtInsertCaption: 'Insert Caption', txtEmpty: '(Empty)', - textFromStorage: 'From Storage' + textFromStorage: 'From Storage', + advancedDropCapText: 'Drop Cap Settings' }, DE.Views.DocumentHolder || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 082a2efba..d693c7ce7 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1234,6 +1234,7 @@ "DE.Views.DateTimeDialog.txtTitle": "Date & Time", "DE.Views.DocumentHolder.aboveText": "Above", "DE.Views.DocumentHolder.addCommentText": "Add Comment", + "DE.Views.DocumentHolder.advancedDropCapText": "Drop Cap Settings", "DE.Views.DocumentHolder.advancedFrameText": "Frame Advanced Settings", "DE.Views.DocumentHolder.advancedParagraphText": "Paragraph Advanced Settings", "DE.Views.DocumentHolder.advancedTableText": "Table Advanced Settings",