From 33381b79eea8b9c0cd964c1cc2cd741bbd02b95c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 1 Nov 2022 22:23:28 +0300 Subject: [PATCH] [PE] Add equation settings --- .../main/app/controller/DocumentHolder.js | 28 ++++-- .../main/app/view/DocumentHolder.js | 91 ++++++++++++++++++- 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/DocumentHolder.js b/apps/presentationeditor/main/app/controller/DocumentHolder.js index d37849eb2..cb923c966 100644 --- a/apps/presentationeditor/main/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/main/app/controller/DocumentHolder.js @@ -428,6 +428,8 @@ define([ view.mnuGuides.menu.on('item:click', _.bind(me.onGuidesClick, me)); view.mnuGridlines.menu.on('item:click', _.bind(me.onGridlinesClick, me)); view.mnuRulers.on('click', _.bind(me.onRulersClick, me)); + view.menuTableEquation.menu.on('item:click', _.bind(me.convertEquation, me)); + view.menuParagraphEquation.menu.on('item:click', _.bind(me.convertEquation, me)); }, getView: function (name) { @@ -2254,8 +2256,8 @@ define([ var style = 'margin-right: 8px;' + (i==0 ? 'margin-left: 5px;' : ''); eqStr += ''; } - // eqStr += '
'; - // eqStr += ''; + eqStr += '
'; + eqStr += ''; eqStr += ''; eqContainer = $(eqStr); documentHolder.cmpEl.append(eqContainer); @@ -2304,7 +2306,6 @@ define([ me.equationBtns.push(btn); } - /* me.equationSettingsBtn = new Common.UI.Button({ parentEl: $('#id-document-holder-btn-equation-settings', documentHolder.cmpEl), cls : 'btn-toolbar no-caret', @@ -2317,29 +2318,27 @@ define([ var menu = me.equationSettingsBtn.menu; menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode); menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX); - menu.items[8].setChecked(me.api.asc_IsInlineMath()); }; me.equationSettingsBtn.menu.on('item:click', _.bind(me.convertEquation, me)); me.equationSettingsBtn.menu.on('show:before', function(menu) { menu.options.initMenu(); }); - */ } var showPoint = [(me._Width - eqContainer.outerWidth())/2, 0]; eqContainer.css({left: showPoint[0], top : showPoint[1]}); if (eqContainer.is(':visible')) { - // if (me.equationSettingsBtn.menu.isVisible()) { - // me.equationSettingsBtn.menu.options.initMenu(); - // me.equationSettingsBtn.menu.alignPosition(); - // } + if (me.equationSettingsBtn.menu.isVisible()) { + me.equationSettingsBtn.menu.options.initMenu(); + me.equationSettingsBtn.menu.alignPosition(); + } } else { eqContainer.show(); } me.equationBtns.forEach(function(item){ item && item.setDisabled(!!disabled); }); - // me.equationSettingsBtn.setDisabled(!!disabled); + me.equationSettingsBtn.setDisabled(!!disabled); }, onEquationPanelHide: function() { @@ -2349,6 +2348,15 @@ define([ } }, + convertEquation: function(menu, item, e) { + if (this.api) { + if (item.options.type=='input') + this.api.asc_SetMathInputType(item.value); + else if (item.options.type=='view') + this.api.asc_ConvertMathView(item.value.linear, item.value.all); + } + }, + SetDisabled: function(state) { this._isDisabled = state; this.documentHolder.SetDisabled(state); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 5c718eb4e..2e2ddc638 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1894,6 +1894,16 @@ define([ caption : '--' }); + me.menuParagraphEquation = new Common.UI.MenuItem({ + caption : me.advancedEquationText, + menu : me.createEquationMenu('popupparaeqinput', 'tl-tr') + }); + + me.menuTableEquation = new Common.UI.MenuItem({ + caption : me.advancedEquationText, + menu : me.createEquationMenu('popuptableeqinput', 'tl-tr') + }); + me.menuAddToLayoutTable = new Common.UI.MenuItem({ caption : me.addToLayoutText }); @@ -2028,6 +2038,14 @@ define([ } else me.clearEquationMenu(true, 12); menuEquationSeparator.setVisible(isEquation && eqlen>0); + + me.menuParagraphEquation.setVisible(isEquation); + me.menuParagraphEquation.setDisabled(disabled); + if (isEquation) { + var eq = me.api.asc_GetMathInputType(); + me.menuParagraphEquation.menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode); + me.menuParagraphEquation.menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX); + } }, items: [ me.menuSpellPara, @@ -2046,6 +2064,7 @@ define([ me.menuParagraphVAlign, me.menuParagraphDirection, me.menuParagraphAdvanced, + me.menuParagraphEquation, menuCommentParaSeparator, /** coauthoring begin **/ me.menuAddCommentPara, @@ -2168,6 +2187,14 @@ define([ menuHyperlinkSeparator.setVisible(menuHyperlinkSeparator.isVisible() && eqlen>0); } else me.clearEquationMenu(false, 6); + + me.menuTableEquation.setVisible(isEquation); + me.menuTableEquation.setDisabled(disabled); + if (isEquation) { + var eq = me.api.asc_GetMathInputType(); + me.menuTableEquation.menu.items[0].setChecked(eq===Asc.c_oAscMathInputType.Unicode); + me.menuTableEquation.menu.items[1].setChecked(eq===Asc.c_oAscMathInputType.LaTeX); + } }, items: [ me.menuSpellCheckTable, @@ -2192,6 +2219,7 @@ define([ menuHyperlinkSeparator, /** coauthoring begin **/ me.menuAddCommentTable, + me.menuTableEquation, /** coauthoring end **/ me.menuAddHyperlinkTable, menuHyperlinkTable, @@ -2362,6 +2390,60 @@ define([ } }, + createEquationMenu: function(toggleGroup, menuAlign) { + return new Common.UI.Menu({ + cls: 'ppm-toolbar shifted-right', + menuAlign: menuAlign, + items : [ + new Common.UI.MenuItem({ + caption : this.unicodeText, + iconCls : 'menu__icon unicode', + checkable : true, + checkmark : false, + checked : false, + toggleGroup : toggleGroup, + type : 'input', + value : Asc.c_oAscMathInputType.Unicode + }), + new Common.UI.MenuItem({ + caption : this.latexText, + iconCls : 'menu__icon latex', + checkable : true, + checkmark : false, + checked : false, + toggleGroup : toggleGroup, + type : 'input', + value : Asc.c_oAscMathInputType.LaTeX + }), + { caption : '--' }, + new Common.UI.MenuItem({ + caption : this.currProfText, + iconCls : 'menu__icon professional-equation', + type : 'view', + value : {all: false, linear: false} + }), + new Common.UI.MenuItem({ + caption : this.currLinearText, + iconCls : 'menu__icon linear-equation', + type : 'view', + value : {all: false, linear: true} + }), + new Common.UI.MenuItem({ + caption : this.allProfText, + iconCls : 'menu__icon professional-equation', + type : 'view', + value : {all: true, linear: false} + }), + new Common.UI.MenuItem({ + caption : this.allLinearText, + iconCls : 'menu__icon linear-equation', + type : 'view', + value : {all: true, linear: true} + }) + ] + }); + }, + unitsChanged: function(m) { this._state.unitsChanged = true; }, @@ -2567,7 +2649,14 @@ define([ textCm: 'cm', textCustom: 'Custom', textRulers: 'Rulers', - textDeleteGuide: 'Delete Guide' + textDeleteGuide: 'Delete Guide', + advancedEquationText: 'Equation Settings', + unicodeText: 'Unicode', + latexText: 'LaTeX', + currProfText: 'Current - Professional', + currLinearText: 'Current - Linear', + allProfText: 'All - Professional', + allLinearText: 'All - Linear' }, PE.Views.DocumentHolder || {})); }); \ No newline at end of file