Skip to content

Commit

Permalink
Merge pull request #2952 from ONLYOFFICE/fix/bug-67442
Browse files Browse the repository at this point in the history
Fix/bug 67442
  • Loading branch information
JuliaRadzhabova authored Apr 19, 2024
2 parents ce56dfd + 89d9ad3 commit f2d757d
Show file tree
Hide file tree
Showing 28 changed files with 454 additions and 44 deletions.
8 changes: 4 additions & 4 deletions apps/common/main/lib/component/ColorButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,22 @@ define([
id: id,
cls: 'color-menu ' + (options.eyeDropper ? 'shifted-right' : 'shifted-left'),
additionalAlign: options.additionalAlign,
items: (options.additionalItems ? options.additionalItems : []).concat(auto).concat([
items: (options.additionalItemsBefore ? options.additionalItemsBefore : []).concat(auto).concat([
{ template: _.template('<div id="' + id + '-color-menu" style="width: ' + width + '; height:' + height + '; display: inline-block;"></div>') },
{caption: '--'}
]).concat(eyedropper).concat([
{
id: id + '-color-new',
template: _.template('<a tabindex="-1" type="menuitem" style="">' + this.textNewColor + '</a>')
}
])
]).concat(options.additionalItemsAfter ? options.additionalItemsAfter : [])
});
this.initInnerMenu();
var me = this;
menu.on('show:after', function(menu) {
me.colorPicker && _.delay(function() {
me.colorPicker.showLastSelected();
!(options.additionalItems || options.auto) && me.colorPicker.focus();
!(options.additionalItemsBefore || options.auto) && me.colorPicker.focus();
}, 10);
});
return menu;
Expand All @@ -147,7 +147,7 @@ define([
initInnerMenu: function() {
if (!this.colorPicker || typeof this.menu !== 'object') return;

var index = (this.options.additionalItems || []).length + (this.options.auto ? 2 : 0);
var index = (this.options.additionalItemsBefore || []).length + (this.options.auto ? 2 : 0);
this.colorPicker.outerMenu = {menu: this.menu, index: index};
this.menu.setInnerMenu([{menu: this.colorPicker, index: index}]);
},
Expand Down
131 changes: 114 additions & 17 deletions apps/documenteditor/main/app/controller/PageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,39 +56,52 @@ define([
onLaunch: function (view) {
this.toolbar = view;
this.editMode = true;
this._state = {};
this._state = {
LeftIndent: null,
RightIndent: null,
LineSpacingBefore: null,
LineSpacingAfter: null
};
return this;
},

onAppReady: function (config) {
var me = this;
var me = this,
toolbar = me.toolbar;

me.toolbar.btnImgAlign.menu.on('item:click', me.onClickMenuAlign.bind(me));
me.toolbar.btnImgAlign.menu.on('show:before', me.onBeforeShapeAlign.bind(me));
me.toolbar.btnImgWrapping.menu.on('item:click', me.onClickMenuWrapping.bind(me));
me.toolbar.btnImgGroup.menu.on('item:click', me.onClickMenuGroup.bind(me));
me.toolbar.btnImgForward.menu.on('item:click', me.onClickMenuForward.bind(me));
me.toolbar.btnImgBackward.menu.on('item:click', me.onClickMenuForward.bind(me));
toolbar.btnImgAlign.menu.on('item:click', me.onClickMenuAlign.bind(me));
toolbar.btnImgAlign.menu.on('show:before', me.onBeforeShapeAlign.bind(me));
toolbar.btnImgWrapping.menu.on('item:click', me.onClickMenuWrapping.bind(me));
toolbar.btnImgGroup.menu.on('item:click', me.onClickMenuGroup.bind(me));
toolbar.btnImgForward.menu.on('item:click', me.onClickMenuForward.bind(me));
toolbar.btnImgBackward.menu.on('item:click', me.onClickMenuForward.bind(me));

me.toolbar.btnImgForward.on('click', me.onClickMenuForward.bind(me, 'forward'));
me.toolbar.btnImgBackward.on('click', me.onClickMenuForward.bind(me, 'backward'));
toolbar.btnImgForward.on('click', me.onClickMenuForward.bind(me, 'forward'));
toolbar.btnImgBackward.on('click', me.onClickMenuForward.bind(me, 'backward'));

me.toolbar.btnsPageBreak.forEach( function(btn) {
toolbar.btnsPageBreak.forEach( function(btn) {
var _menu_section_break = btn.menu.items[2].menu;
_menu_section_break.on('item:click', function (menu, item, e) {
me.toolbar.fireEvent('insert:break', [item.value]);
toolbar.fireEvent('insert:break', [item.value]);
});

btn.menu.on('item:click', function (menu, item, e) {
if ( !(item.value == 'section') )
me.toolbar.fireEvent('insert:break', [item.value]);
toolbar.fireEvent('insert:break', [item.value]);
});

btn.on('click', function(e) {
me.toolbar.fireEvent('insert:break', ['page']);
toolbar.fireEvent('insert:break', ['page']);
});
});

toolbar.numSpacingBefore.on('change', me.onNumSpacingBeforeChange.bind(me));
toolbar.numSpacingAfter.on('change', me.onNumSpacingAfterChange.bind(me));
toolbar.numSpacingBefore.on('inputleave', function(){ toolbar.fireEvent('editcomplete', toolbar);});
toolbar.numSpacingAfter.on('inputleave', function(){ toolbar.fireEvent('editcomplete', toolbar);});
toolbar.numIndentsLeft.on('change', me.onNumIndentsLeftChange.bind(me));
toolbar.numIndentsRight.on('change', me.onNumIndentsRightChange.bind(me));
toolbar.numIndentsLeft.on('inputleave', function(){ toolbar.fireEvent('editcomplete', toolbar);});
toolbar.numIndentsRight.on('inputleave', function(){ toolbar.fireEvent('editcomplete', toolbar);});
},

setApi: function (api) {
Expand Down Expand Up @@ -128,7 +141,9 @@ define([
canGroupUngroup = false,
wrapping,
content_locked = false,
no_object = true;
no_object = true,
in_para = false,
paraProps;

for (var i in objects) {
type = objects[i].get_ObjectType();
Expand Down Expand Up @@ -161,7 +176,9 @@ define([
}

_imgOriginalProps = props;
break;
} else if (type === Asc.c_oAscTypeSelectElement.Paragraph) {
in_para = true;
paraProps = objects[i].get_ObjectValue()
}
}
me.toolbar.lockToolbar(Common.enumLock.noObjectSelected, no_object, {array: [me.toolbar.btnImgAlign, me.toolbar.btnImgGroup, me.toolbar.btnImgWrapping, me.toolbar.btnImgForward, me.toolbar.btnImgBackward]});
Expand All @@ -172,6 +189,8 @@ define([
me.toolbar.lockToolbar(Common.enumLock.cantGroup, !canGroupUngroup, {array: [me.toolbar.btnImgGroup]});
me.toolbar.lockToolbar(Common.enumLock.cantWrap, disable.wrapping, {array: [me.toolbar.btnImgWrapping]});
me.toolbar.lockToolbar(Common.enumLock.cantArrange, disable.arrange, {array: [me.toolbar.btnImgForward, me.toolbar.btnImgBackward]});
me.toolbar.lockToolbar(Common.enumLock.noParagraphSelected, !in_para, {array: [me.toolbar.numIndentsLeft, me.toolbar.numIndentsRight, me.toolbar.lblIndentsLeft, me.toolbar.lblIndentsRight]});
me.ChangeSettingsPara(paraProps);
},

onApiCoAuthoringDisconnect: function() {
Expand Down Expand Up @@ -253,6 +272,84 @@ define([

this.api.ImgApply(props);
this.toolbar.fireEvent('editcomplete', this.toolbar);
},

onNumSpacingBeforeChange: function(field, newValue, oldValue, eOpts){
if (this.api) {
var num = field.getNumberValue();
this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num);
this.api.put_LineSpacingBeforeAfter(0, this._state.LineSpacingBefore);
}
},

onNumSpacingAfterChange: function(field, newValue, oldValue, eOpts){
if (this.api){
var num = field.getNumberValue();
this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num);
this.api.put_LineSpacingBeforeAfter(1, this._state.LineSpacingAfter);
}
},

onNumIndentsLeftChange: function(field, newValue, oldValue, eOpts){
var left = Common.Utils.Metric.fnRecalcToMM(field.getNumberValue());
if (this._state.FirstLine<0) {
left = left-this._state.FirstLine;
}
var props = new Asc.asc_CParagraphProperty();
props.put_Ind(new Asc.asc_CParagraphInd());
props.get_Ind().put_Left(left);
if (this.api)
this.api.paraApply(props);
},

onNumIndentsRightChange: function(field, newValue, oldValue, eOpts){
var props = new Asc.asc_CParagraphProperty();
props.put_Ind(new Asc.asc_CParagraphInd());
props.get_Ind().put_Right(Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
if (this.api)
this.api.paraApply(props);
},

ChangeSettingsPara: function(prop) {
var left = 0,
right = 0,
before = 0,
after = 0;
if (prop) {
var indents = prop.get_Ind(),
first = (indents !== null) ? indents.get_FirstLine() : null;
left = (indents !== null) ? indents.get_Left() : null;
if (first<0 && left !== null)
left = left + first;

right = (indents !== null) ? indents.get_Right() : null;

before = prop.get_Spacing().get_Before();
after = prop.get_Spacing().get_After();
}
if ( Math.abs(this._state.LeftIndent-left)>0.001 ||
(this._state.LeftIndent===null || left===null)&&(this._state.LeftIndent!==left)) {
this.toolbar.numIndentsLeft.setValue(left!==null ? Common.Utils.Metric.fnRecalcFromMM(left) : '', true);
this._state.LeftIndent=left;
}
if ( Math.abs(this._state.RightIndent-right)>0.001 ||
(this._state.RightIndent===null || right===null)&&(this._state.RightIndent!==right)) {
this.toolbar.numIndentsRight.setValue(right!==null ? Common.Utils.Metric.fnRecalcFromMM(right) : '', true);
this._state.RightIndent=right;
}
if ( Math.abs(this._state.LineSpacingBefore-before)>0.001 ||
(this._state.LineSpacingBefore===null || before===null)&&(this._state.LineSpacingBefore!==before)) {

this.toolbar.numSpacingBefore.setValue((before !== null) ? ((before<0) ? before : Common.Utils.Metric.fnRecalcFromMM(before) ) : '', true);
this._state.LineSpacingBefore=before;
}

if ( Math.abs(this._state.LineSpacingAfter-after)>0.001 ||
(this._state.LineSpacingAfter===null || after===null)&&(this._state.LineSpacingAfter!==after)) {

this.toolbar.numSpacingAfter.setValue((after !== null) ? ((after<0) ? after : Common.Utils.Metric.fnRecalcFromMM(after) ) : '', true);
this._state.LineSpacingAfter=after;
}
}
}
})());
Expand Down
16 changes: 16 additions & 0 deletions apps/documenteditor/main/app/controller/RightMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,27 @@ define([
!status && Common.NotificationCenter.trigger('forms:close-help', 'key');
!status && Common.NotificationCenter.trigger('forms:close-help', 'group-key');
!status && Common.NotificationCenter.trigger('forms:close-help', 'settings');

!view && this.rightmenu.fireEvent('view:hide', [this, !status]);
}
Common.NotificationCenter.trigger('layout:changed', 'main');
Common.NotificationCenter.trigger('edit:complete', this.rightmenu);
},

onRightMenuOpen: function(type) {
if (this._settings[type]===undefined || this._settings[type].hidden || this._settings[type].btn.isDisabled() || this._settings[type].panelId===this.rightmenu.GetActivePane()) return;

this.tryToShowRightMenu();
this.rightmenu.SetActivePane(type, true);
this._settings[type].panel.ChangeSettings.call(this._settings[type].panel, this._settings[type].props);
this.rightmenu.updateScroller();
},

tryToShowRightMenu: function() {
if (this.rightmenu && this.rightmenu.mode && (!this.rightmenu.mode.canBrandingExt || !this.rightmenu.mode.customization || this.rightmenu.mode.customization.rightMenu !== false) && Common.UI.LayoutManager.isElementVisible('rightMenu'))
this.onRightMenuHide(null, true);
},

addNewPlugin: function (button, $button, $panel) {
this.rightmenu.insertButton(button, $button);
this.rightmenu.insertPanel($panel);
Expand Down
30 changes: 28 additions & 2 deletions apps/documenteditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,13 @@ define([
toolbar.mnuHighlightColorPicker.on('select', _.bind(this.onSelectHighlightColor, this));
toolbar.mnuHighlightTransparent.on('click', _.bind(this.onHighlightTransparentClick, this));
toolbar.mnuLineSpace.on('item:toggle', _.bind(this.onLineSpaceToggle, this));
toolbar.mnuLineSpace.on('item:click', _.bind(this.onLineSpaceClick, this));
toolbar.mnuLineSpace.on('show:after', _.bind(this.onLineSpaceShow, this));
toolbar.mnuNonPrinting.on('item:toggle', _.bind(this.onMenuNonPrintingToggle, this));
toolbar.btnShowHidenChars.on('toggle', _.bind(this.onNonPrintingToggle, this));
toolbar.mnuTablePicker.on('select', _.bind(this.onTablePickerSelect, this));
toolbar.mnuInsertTable.on('item:click', _.bind(this.onInsertTableClick, this));
toolbar.mnuInsertTable.on('show:after', _.bind(this.onInsertTableShow, this));
toolbar.mnuInsertTable.on('show:after', _.bind(this.onInsertTableShow, this));
toolbar.mnuInsertImage.on('item:click', _.bind(this.onInsertImageClick, this));
toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this));
toolbar.btnInsertText.menu.on('item:click', _.bind(this.onMenuInsertTextClick, this));
Expand Down Expand Up @@ -897,7 +899,7 @@ define([
this.toolbar.lockToolbar(Common.enumLock.chartLock, in_chart && image_locked, {array: [toolbar.btnInsertChart]});

this.toolbar.lockToolbar(Common.enumLock.cantAddEquation, !can_add_image&&!in_equation, {array: [toolbar.btnInsertEquation]});
this.toolbar.lockToolbar(Common.enumLock.noParagraphSelected, !in_para, {array: [toolbar.btnInsertSymbol, toolbar.btnInsDateTime]});
this.toolbar.lockToolbar(Common.enumLock.noParagraphSelected, !in_para, {array: [toolbar.btnInsertSymbol, toolbar.btnInsDateTime, toolbar.btnLineSpace]});
this.toolbar.lockToolbar(Common.enumLock.inImage, in_image, {array: [toolbar.btnColumns]});
this.toolbar.lockToolbar(Common.enumLock.inImagePara, in_image && in_para, {array: [toolbar.btnLineNumbers]});

Expand Down Expand Up @@ -1645,6 +1647,30 @@ define([
}
},

onLineSpaceClick: function(menu, item) {
if (item.value==='options') {
this.getApplication().getController('RightMenu').onRightMenuOpen(Common.Utils.documentSettingsType.Paragraph);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
} else if (item.value==='before') {
item.options.action === 'add' ? this.api.asc_addSpaceBeforeParagraph() : this.api.asc_removeSpaceBeforeParagraph();
} else if (item.value==='after') {
item.options.action === 'add' ? this.api.asc_addSpaceAfterParagraph() : this.api.asc_removeSpaceAfterParagraph();
}
},

onLineSpaceShow: function(menu) {
if (this.api) {
var toolbar = this.toolbar,
before = this.api.asc_haveSpaceBeforeParagraph(),
after = this.api.asc_haveSpaceAfterParagraph();
toolbar.mnuLineSpaceBefore.setCaption(before ? toolbar.textRemSpaceBefore : toolbar.textAddSpaceBefore);
toolbar.mnuLineSpaceBefore.options.action = before ? 'remove' : 'add';
toolbar.mnuLineSpaceAfter.setCaption(after ? toolbar.textRemSpaceAfter : toolbar.textAddSpaceAfter);
toolbar.mnuLineSpaceAfter.options.action = after ? 'remove' : 'add';

}
},

onMenuNonPrintingToggle: function(menu, item, state, e) {
var me = this;
if (item.value === 'characters') {
Expand Down
5 changes: 5 additions & 0 deletions apps/documenteditor/main/app/controller/ViewTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ define([
'view:hide': _.bind(function (leftmenu, state) {
this.view.chLeftMenu.setValue(!state, true);
}, this)
},
'RightMenu': {
'view:hide': _.bind(function (leftmenu, state) {
this.view.chRightMenu.setValue(!state, true);
}, this)
}
});
},
Expand Down
21 changes: 21 additions & 0 deletions apps/documenteditor/main/app/template/Toolbar.template
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,27 @@
<span class="btn-slot text x-huge" id="slot-btn-hyphenation"></span>
</div>
<div class="separator long"></div>
<div class="group small">
<div class="elset" style="display: flex; align-items: baseline;">
<span class="btn-slot text font-size-normal margin-right-6" id="slot-lbl-ind-left" style="flex-grow:1;"></span>
<span id="slot-spin-ind-left" class="btn-slot text spinner"></span>
</div>
<div class="elset" style="display: flex; align-items: baseline;">
<span class="btn-slot text font-size-normal margin-right-6" id="slot-lbl-ind-right" style="flex-grow:1;"></span>
<span id="slot-spin-ind-right" class="btn-slot text spinner"></span>
</div>
</div>
<div class="group small">
<div class="elset margin-left-6" style="display: flex; align-items: baseline;">
<span class="btn-slot text font-size-normal margin-right-6" id="slot-lbl-space-before" style="flex-grow:1;"></span>
<span id="slot-spin-space-before" class="btn-slot text spinner"></span>
</div>
<div class="elset margin-left-6" style="display: flex; align-items: baseline;">
<span class="btn-slot text font-size-normal margin-right-6" id="slot-lbl-space-after" style="flex-grow:1;"></span>
<span id="slot-spin-space-after" class="btn-slot text spinner"></span>
</div>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-img-wrapping"></span>
<span class="btn-slot text x-huge" id="slot-img-movefrwd"></span>
Expand Down
Loading

0 comments on commit f2d757d

Please sign in to comment.