Merge pull request #1690 from ONLYOFFICE/feature/tof-add-text

Feature/tof add text
This commit is contained in:
Julia Radzhabova 2022-04-07 15:35:18 +03:00 committed by GitHub
commit d51be57861
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 86 additions and 5 deletions

View file

@ -75,7 +75,9 @@ define([
'links:caption': this.onCaptionClick,
'links:crossref': this.onCrossRefClick,
'links:tof': this.onTableFigures,
'links:tof-update': this.onTableFiguresUpdate
'links:tof-update': this.onTableFiguresUpdate,
'links:addtext': this.onAddText,
'links:addtext-open': this.onAddTextOpen
},
'DocumentHolder': {
'links:contents': this.onTableContents,
@ -138,7 +140,9 @@ define([
in_header = false,
in_equation = false,
in_image = false,
in_image_inline = false,
in_table = false,
in_para = false,
frame_pr = null,
object_type;
@ -149,11 +153,13 @@ define([
if (type === Asc.c_oAscTypeSelectElement.Paragraph) {
paragraph_locked = pr.get_Locked();
frame_pr = pr;
in_para = true;
} else if (type === Asc.c_oAscTypeSelectElement.Header) {
header_locked = pr.get_Locked();
in_header = true;
} else if (type === Asc.c_oAscTypeSelectElement.Image) {
in_image = true;
in_image_inline = (pr.get_WrappingStyle() === Asc.c_oAscWrapStyle2.Inline);
object_type = type;
} else if (type === Asc.c_oAscTypeSelectElement.Math) {
in_equation = true;
@ -189,6 +195,9 @@ define([
this.lockToolbar(Common.enumLock.plainDelLock, plain_del_lock, {array: this.view.btnsContents.concat([this.view.btnTableFigures, this.view.btnTableFiguresUpdate])});
this.lockToolbar(Common.enumLock.contentLock, content_locked, {array: [this.view.btnCrossRef]});
this.lockToolbar(Common.enumLock.cantUpdateTOF, !this.api.asc_CanUpdateTablesOfFigures(), {array: [this.view.btnTableFiguresUpdate]});
this.lockToolbar(Common.enumLock.inFootnote, this.api.asc_IsCursorInFootnote() || this.api.asc_IsCursorInEndnote(), {array: [this.view.btnAddText]});
this.lockToolbar(Common.enumLock.inHeader, in_header, {array: [this.view.btnAddText]});
this.lockToolbar(Common.enumLock.cantAddTextTOF, in_image && !in_image_inline && !in_para, {array: [this.view.btnAddText]});
this.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(this.view.btnCrossRef.isDisabled());
},
@ -314,6 +323,17 @@ define([
this.api.asc_getButtonsTOC(menu.items[0].options.previewId, menu.items[1].options.previewId);
},
onAddTextOpen: function(menu) {
var props = this.api.asc_GetTableOfContentsPr(),
end = props ? props.get_OutlineEnd() : 3;
(end<0) && (end = 9);
this.view.fillAddTextMenu(menu, end, this.api.asc_GetCurrentLevelTOC());
},
onAddText: function(value) {
this.api.asc_AddParagraphToTOC(value);
},
onNotesClick: function(type) {
var me = this;
switch (type) {

View file

@ -149,7 +149,14 @@
<section class="panel" data-tab="links">
<div class="group">
<span class="btn-slot text x-huge btn-contents"></span>
<span class="btn-slot text x-huge" id="slot-btn-contents-update"></span>
</div>
<div class="group small">
<div class="elset">
<span class="btn-slot text" id="slot-btn-add-text"></span>
</div>
<div class="elset">
<span class="btn-slot text" id="slot-btn-contents-update"></span>
</div>
</div>
<div class="separator long"></div>
<div class="group">

View file

@ -81,6 +81,13 @@ define([
}, 10);
});
this.btnAddText.menu.on('item:click', function (menu, item, e) {
me.fireEvent('links:addtext', [item.value]);
});
this.btnAddText.menu.on('show:after', function (menu, e) {
me.fireEvent('links:addtext-open', [menu]);
});
this.btnsNotes.forEach(function(button) {
button.menu.on('item:click', function (menu, item, e) {
me.fireEvent('links:notes', [item.value]);
@ -174,7 +181,7 @@ define([
this.btnContentsUpdate = new Common.UI.Button({
parentEl: $host.find('#slot-btn-contents-update'),
cls: 'btn-toolbar x-huge icon-top',
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-update',
lock: [ _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart],
caption: this.capBtnContentsUpdate,
@ -182,10 +189,25 @@ define([
menu: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
dataHintOffset: '0, -8'
});
this.paragraphControls.push(this.btnContentsUpdate);
this.btnAddText = new Common.UI.Button({
parentEl: $host.find('#slot-btn-add-text'),
cls: 'btn-toolbar',
iconCls: 'toolbar__icon add-text',
lock: [ _set.cantAddTextTOF, _set.inHeader, _set.inFootnote, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart],
caption: this.capBtnAddText,
menu: new Common.UI.Menu({
items: []
}),
dataHint: '1',
dataHintDirection: 'left',
dataHintOffset: 'medium'
});
this.paragraphControls.push(this.btnAddText);
this.btnBookmarks = new Common.UI.Button({
parentEl: $host.find('#slot-btn-bookmarks'),
cls: 'btn-toolbar x-huge icon-top',
@ -294,6 +316,8 @@ define([
]
}));
me.btnAddText.updateHint(me.tipAddText);
me.contentsUpdateMenu = new Common.UI.Menu({
items: [
{caption: me.textUpdateAll, value: 'all'},
@ -386,6 +410,27 @@ define([
});
},
fillAddTextMenu: function(menu, endlevel, current) {
endlevel = Math.max(endlevel || 3, current+1);
menu.removeAll();
menu.addItem(new Common.UI.MenuItem({
caption: this.txtDontShowTof,
value: -1,
checkable: true,
checked: current<0,
toggleGroup : 'addTextGroup'
}));
for (var i=0; i<endlevel; i++) {
menu.addItem(new Common.UI.MenuItem({
caption: this.txtLevel + ' ' + (i+1),
value: i,
checkable: true,
checked: current===i,
toggleGroup : 'addTextGroup'
}));
}
},
show: function () {
Common.UI.BaseView.prototype.show.call(this);
this.fireEvent('show', this);
@ -437,7 +482,11 @@ define([
tipTableFiguresUpdate: 'Refresh table of figures',
tipTableFigures: 'Insert table of figures',
confirmReplaceTOF: 'Do you want to replace the selected table of figures?',
titleUpdateTOF: 'Refresh Table of Figures'
titleUpdateTOF: 'Refresh Table of Figures',
capBtnAddText: 'Add Text',
tipAddText: 'Include heading in the Table of Contents',
txtDontShowTof: 'Do Not Show in Table of Contents',
txtLevel: 'Level'
}
}()), DE.Views.Links || {}));
});

View file

@ -109,6 +109,7 @@ define([
cantAddPageNum: 'cant-add-page-num',
cantPageBreak: 'cant-page-break',
cantUpdateTOF: 'cant-update-tof',
cantAddTextTOF: 'cant-addtext-tof',
cantGroup: 'cant-group',
cantWrap: 'cant-wrap',
cantArrange: 'cant-arrange',

View file

@ -2072,6 +2072,10 @@
"DE.Views.Links.tipTableFigures": "Insert table of figures",
"DE.Views.Links.tipTableFiguresUpdate": "Update table of figures",
"DE.Views.Links.titleUpdateTOF": "Update Table of Figures",
"DE.Views.Links.capBtnAddText": "Add Text",
"DE.Views.Links.tipAddText": "Include heading in the Table of Contents",
"DE.Views.Links.txtDontShowTof": "Do Not Show in Table of Contents",
"DE.Views.Links.txtLevel": "Level",
"DE.Views.ListSettingsDialog.textAuto": "Automatic",
"DE.Views.ListSettingsDialog.textCenter": "Center",
"DE.Views.ListSettingsDialog.textLeft": "Left",