[DE] Add text to table of contents

This commit is contained in:
Julia Radzhabova 2022-03-14 20:19:17 +03:00
parent b0e59d6df8
commit 2fe8fb6cfa
4 changed files with 80 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,
@ -189,6 +191,8 @@ 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.dlgCrossRefDialog && this.dlgCrossRefDialog.isVisible() && this.dlgCrossRefDialog.setLocked(this.view.btnCrossRef.isDisabled());
},
@ -314,6 +318,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 btn-update',
lock: [ _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

@ -2082,6 +2082,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",