[DE] Use sdk events to display equation bar

This commit is contained in:
Julia Radzhabova 2022-11-01 21:00:32 +03:00
parent be04262bf4
commit c3d27b5711
2 changed files with 55 additions and 22 deletions

View file

@ -212,6 +212,8 @@ define([
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this));
this.api.asc_registerCallback('asc_onLockDocumentProps', _.bind(this.onApiLockDocumentProps, this));
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_registerCallback('asc_onCoAuthoringDisconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
@ -614,9 +616,9 @@ define([
onFocusObject: function(selectedElements) {
var me = this,
currentMenu = me.documentHolder.currentMenu,
docProtection = me.documentHolder._docProtection;
currentMenu = me.documentHolder.currentMenu;
if (currentMenu && currentMenu.isVisible() && currentMenu !== me.documentHolder.hdrMenu){
var docProtection = me.documentHolder._docProtection;
var obj = (me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) ?
me.fillMenuProps(selectedElements) : me.fillViewMenuProps(selectedElements);
if (obj) {
@ -626,19 +628,25 @@ define([
}
}
}
var i = -1,
in_equation = false,
locked = false;
while (++i < selectedElements.length) {
var type = selectedElements[i].get_ObjectType();
if (type === Asc.c_oAscTypeSelectElement.Math) {
in_equation = true;
} else if (type === Asc.c_oAscTypeSelectElement.Paragraph || type === Asc.c_oAscTypeSelectElement.Table || type === Asc.c_oAscTypeSelectElement.Header) {
var value = selectedElements[i].get_ObjectValue();
value && (locked = locked || value.get_Locked());
if (this.mode && this.mode.isEdit) {
var i = -1,
in_equation = false,
locked = false;
while (++i < selectedElements.length) {
var type = selectedElements[i].get_ObjectType();
if (type === Asc.c_oAscTypeSelectElement.Math) {
in_equation = true;
} else if (type === Asc.c_oAscTypeSelectElement.Paragraph || type === Asc.c_oAscTypeSelectElement.Table || type === Asc.c_oAscTypeSelectElement.Header) {
var value = selectedElements[i].get_ObjectValue();
value && (locked = locked || value.get_Locked());
}
}
if (in_equation) {
this._state.equationLocked = locked;
this.disableEquationBar();
}
}
in_equation && me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly) ? this.onEquationPanelShow(locked) : this.onEquationPanelHide();
},
handleDocumentWheel: function(event) {
@ -1513,6 +1521,7 @@ define([
SetDisabled: function(state, canProtect, fillFormMode) {
this._isDisabled = state;
this.documentHolder.SetDisabled(state, canProtect, fillFormMode);
this.disableEquationBar();
},
onTextLanguage: function(langid) {
@ -2323,7 +2332,11 @@ define([
return false;
},
onEquationPanelShow: function(disabled) {
onShowMathTrack: function(bounds) {
if (bounds[3] < 0) {
this.onHideMathTrack();
return;
}
var me = this,
documentHolder = me.documentHolder,
eqContainer = documentHolder.cmpEl.find('#equation-container');
@ -2378,7 +2391,7 @@ define([
menu : new Common.UI.Menu({
cls: 'menu-shapes',
value: i,
// restoreHeight: equationGroup.get('groupHeight') ? parseInt(equationGroup.get('groupHeight')) : true,
restoreHeight: equationGroup.get('groupHeight') ? parseInt(equationGroup.get('groupHeight')) : true,
items: [
{ template: _.template('<div id="id-document-holder-btn-equation-menu-' + i +
'" class="menu-shape" style="width:' + (equationGroup.get('groupWidth') + 8) + 'px; ' +
@ -2410,8 +2423,16 @@ define([
});
}
var showPoint = [(me._Width - eqContainer.outerWidth())/2, 0];
eqContainer.css({left: showPoint[0], top : showPoint[1]});
var showPoint = [(bounds[0] + bounds[2])/2 - eqContainer.outerWidth()/2, bounds[1] - eqContainer.outerHeight() - 10];
if (!Common.Utils.InternalSettings.get("de-hidden-rulers")) {
showPoint = [showPoint[0] - 19, showPoint[1] - 26];
}
if (showPoint[1]<0) {
showPoint[1] = bounds[3] + 10;
!Common.Utils.InternalSettings.get("de-hidden-rulers") && (showPoint[1] -= 26);
}
eqContainer.css({left: showPoint[0], top : Math.min(this._Height - eqContainer.outerHeight(), Math.max(0, showPoint[1]))});
// menu.menuAlign = validation ? 'tr-br' : 'tl-bl';
if (eqContainer.is(':visible')) {
if (me.equationSettingsBtn.menu.isVisible()) {
me.equationSettingsBtn.menu.options.initMenu();
@ -2420,19 +2441,29 @@ define([
} else {
eqContainer.show();
}
me.equationBtns.forEach(function(item){
item && item.setDisabled(!!disabled);
});
me.equationSettingsBtn.setDisabled(!!disabled);
me.disableEquationBar();
},
onEquationPanelHide: function() {
onHideMathTrack: function() {
var eqContainer = this.documentHolder.cmpEl.find('#equation-container');
if (eqContainer.is(':visible')) {
eqContainer.hide();
}
},
disableEquationBar: function() {
var eqContainer = this.documentHolder.cmpEl.find('#equation-container'),
docProtection = this.documentHolder._docProtection,
disabled = this._isDisabled || this._state.equationLocked || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly;
if (eqContainer.length>0 && eqContainer.is(':visible')) {
this.equationBtns.forEach(function(item){
item && item.setDisabled(!!disabled);
});
this.equationSettingsBtn.setDisabled(!!disabled);
}
},
convertEquation: function(menu, item, e) {
if (this.api) {
if (item.options.type=='input')
@ -2451,6 +2482,7 @@ define([
}
if (props && this.documentHolder) {
this.documentHolder._docProtection = props;
this.disableEquationBar();
}
},

View file

@ -179,6 +179,7 @@
.separator {
height: 20px;
}
z-index: @zindex-dropdown - 19;
}
.dropdown-menu.list-settings-level {