Skip to content

Commit

Permalink
Merge pull request #3015 from ONLYOFFICE/fix/pdf
Browse files Browse the repository at this point in the history
Fix/pdf
  • Loading branch information
JuliaRadzhabova authored May 30, 2024
2 parents b0d7746 + 1301176 commit 167d307
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 55 deletions.
7 changes: 4 additions & 3 deletions apps/pdfeditor/main/app/controller/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ define([
view.menuTableDeleteText.menu.on('item:click', _.bind(me.tableDeleteText, me));
view.menuTableEquationSettings.menu.on('item:click', _.bind(me.convertEquation, me));
view.menuParagraphEquation.menu.on('item:click', _.bind(me.convertEquation, me));
view.mnuNewPage.on('click', _.bind(me.onNewPage, me));
view.mnuNewPageBefore.on('click', _.bind(me.onNewPage, me));
view.mnuNewPageAfter.on('click', _.bind(me.onNewPage, me));
view.mnuDeletePage.on('click', _.bind(me.onDeletePage, me));
view.mnuRotatePageRight.on('click', _.bind(me.onRotatePage, me, 90));
view.mnuRotatePageLeft.on('click', _.bind(me.onRotatePage, me, -90));
Expand Down Expand Up @@ -2774,8 +2775,8 @@ define([
this.documentHolder && (this.documentHolder._pagesCount = count);
},

onNewPage: function() {
this.api && this.api.asc_AddPage();
onNewPage: function(item) {
this.api && this.api.asc_AddPage(item.value);

Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
},
Expand Down
4 changes: 2 additions & 2 deletions apps/pdfeditor/main/app/controller/InsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,8 @@ define([
}
},

onAddPage: function() {
this.api && this.api.asc_AddPage();
onAddPage: function(before) {
this.api && this.api.asc_AddPage(!!before);
},
/*
mouseenterSmartArt: function (groupName, menu) {
Expand Down
23 changes: 22 additions & 1 deletion apps/pdfeditor/main/app/controller/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ define([
clrunderline: undefined,
clrhighlight: undefined,
pageCount: 1,
currentPage: 0,
bullets: {type:undefined, subtype:undefined},
linespace: undefined,
pralign: undefined,
Expand Down Expand Up @@ -317,6 +318,9 @@ define([
toolbar.btnShapeAlign.menu.on('item:click', _.bind(this.onShapeAlign, this));
toolbar.btnShapeAlign.menu.on('show:before', _.bind(this.onBeforeShapeAlign, this));
toolbar.btnShapeArrange.menu.on('item:click', _.bind(this.onShapeArrange, this));
toolbar.btnRotatePage.menu.on('item:click', _.bind(this.onRotatePageMenu, this));
toolbar.btnRotatePage.on('click', _.bind(this.onRotatePage, this));
toolbar.btnDelPage.on('click', _.bind(this.onDelPage, this));

},

Expand Down Expand Up @@ -436,9 +440,11 @@ define([
onCountPages: function(count) {
this._state.pageCount = count;
this.toolbar && this.toolbar.fieldPages && this.toolbar.fieldPages.setFixedValue('/ ' + count);
this.toolbar.lockToolbar(Common.enumLock.singlePage, count<2, {array: [this.toolbar.btnDelPage]});
},

onCurrentPage: function(value) {
this._state.currentPage = value;
if (this.toolbar) {
this.toolbar.fieldPages && this.toolbar.fieldPages.setValue(value + 1);
this.toolbar.lockToolbar(Common.enumLock.firstPage, value<1, {array: [this.toolbar.btnFirstPage, this.toolbar.btnPrevPage]});
Expand Down Expand Up @@ -1255,6 +1261,7 @@ define([
me.attachPDFEditUIEvents(toolbar);
me.fillFontsStore(toolbar.cmbFontName, me._state.fontname);
toolbar.lockToolbar(Common.enumLock.disableOnStart, false);
me.onCountPages(me._state.pageCount);
me.onApiFocusObject([]);
me.api.UpdateInterfaceState();
}, 50);
Expand All @@ -1275,7 +1282,6 @@ define([
toolbar.setVisible('ins', this.mode.isPDFEdit);
$host.find('.annotate').toggleClass('hidden', this.mode.isPDFEdit);
$host.find('.pdfedit').toggleClass('hidden', !this.mode.isPDFEdit);
this.mode.isPDFEdit && me.turnOnSelectTool();
},

onAppReady: function (config) {
Expand Down Expand Up @@ -2137,6 +2143,21 @@ define([
}
},

onDelPage: function() {
this.api && this.api.asc_RemovePage();
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},

onRotatePage: function() {
this.api && this.api.asc_RotatePage(this.api.asc_GetPageRotate(this._state.currentPage) + 90);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},

onRotatePageMenu: function(menu, item) {
this.api && this.api.asc_RotatePage(this.api.asc_GetPageRotate(this._state.currentPage) + item.value);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},

_clearBullets: function() {
this.toolbar.btnMarkers.toggle(false, true);
this.toolbar.btnNumbers.toggle(false, true);
Expand Down
10 changes: 8 additions & 2 deletions apps/pdfeditor/main/app/template/Toolbar.template
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
<span class="btn-slot text x-huge" id="slot-btn-tb-edit-mode"></span>
</div>
<div class="separator long"></div>
<div class="group annotate">
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-hand-tool"></span>
<span class="btn-slot text x-huge" id="slot-btn-select-tool"></span>
</div>
<div class="separator long annotate"></div>
<div class="separator long"></div>
</section>
<section class="box-panels">
<section class="panel" data-tab="home">
Expand Down Expand Up @@ -131,6 +131,12 @@
<span class="btn-slot text x-huge" id="slot-btn-edittext"></span>
</div>
<div class="separator long pdfedit"></div>
<div class="group pdfedit">
<span class="btn-slot text x-huge slot-inspage"></span>
<span class="btn-slot text x-huge" id="slot-btn-rotate"></span>
<span class="btn-slot text x-huge" id="slot-btn-deletepage"></span>
</div>
<div class="separator long pdfedit"></div>
<div class="group pdfedit">
<span class="btn-slot text x-huge slot-instext"></span>
<span class="btn-slot text x-huge slot-insertimg"></span>
Expand Down
18 changes: 12 additions & 6 deletions apps/pdfeditor/main/app/view/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1163,9 +1163,13 @@ define([
iconCls: 'menu__icon btn-cc-remove',
caption : me.txtDeletePage
});
me.mnuNewPage = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-add-text',
caption : me.txtNewPage
me.mnuNewPageBefore = new Common.UI.MenuItem({
caption : me.txtNewPageBefore,
value: true
});
me.mnuNewPageAfter = new Common.UI.MenuItem({
caption : me.txtNewPageAfter,
value: false
});
me.mnuRotatePageRight = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-rotate-90',
Expand Down Expand Up @@ -1199,7 +1203,8 @@ define([
me.mnuDeletePage.setDisabled(me._pagesCount<2);
},
items: [
me.mnuNewPage,
me.mnuNewPageBefore,
me.mnuNewPageAfter,
menuPageNewSeparator,
me.mnuRotatePageRight,
me.mnuRotatePageLeft,
Expand Down Expand Up @@ -2494,12 +2499,13 @@ define([
textEditPoints: 'Edit Points',
confirmAddFontName: 'The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the device fonts, the saved font will be used when it is available.<br>Do you want to continue?',
txtDeletePage: 'Delete page',
txtNewPage: 'Insert blank page',
txtRotateRight: 'Rotate page right',
txtRotateLeft: 'Rotate page left',
removeCommentText: 'Remove',
textRecognize: 'Recognize text',
tipRecognize: 'Recognize text'
tipRecognize: 'Recognize text',
txtNewPageBefore: 'Insert blank page before',
txtNewPageAfter: 'Insert blank page after',

}, PDFE.Views.DocumentHolder || {}));
});
52 changes: 30 additions & 22 deletions apps/pdfeditor/main/app/view/InsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
var template =
'<section class="panel" data-tab="ins">' +
'<div class="group">' +
'<span class="btn-slot text x-huge" id="slot-btn-addpage"></span>' +
'<span class="btn-slot text x-huge slot-inspage"></span>' +
'</div>' +
'<div class="group" style="display:none;"></div>' +
'<div class="separator long"></div>' +
Expand Down Expand Up @@ -89,9 +89,6 @@ define([
setEvents: function () {
var me = this;

me.btnAddPage.on('click', _.bind(function () {
me.fireEvent('insert:page');
}, me));
// me.btnEditHeader.on('click', _.bind(function () {
// me.fireEvent('insert:header', ['header']);
// }, me));
Expand Down Expand Up @@ -293,18 +290,6 @@ define([
});
me.lockedControls.push(me.btnInsertShape);

me.btnAddPage = new Common.UI.Button({
id: 'tlbtn-addpage',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-blankpage',
caption: me.capAddPage,
lock: [_set.lostConnect, _set.disableOnStart],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
me.lockedControls.push(me.btnAddPage);

me.cmbInsertShape = new Common.UI.ComboDataViewShape({
cls: 'combo-styles shapes',
itemWidth: 20,
Expand Down Expand Up @@ -336,7 +321,6 @@ define([
Common.Utils.injectComponent($host.find(id), cmp);
};
// _injectComponent('#slot-btn-inssmartart', this.btnInsertSmartArt);
_injectComponent('#slot-btn-addpage', this.btnAddPage);
_injectComponent('#slot-btn-insertequation', this.btnInsertEquation);
_injectComponent('#slot-btn-inssymbol', this.btnInsertSymbol);
_injectComponent('#slot-btn-insertlink', this.btnInsertHyperlink);
Expand All @@ -355,9 +339,11 @@ define([
[Common.enumLock.lostConnect, Common.enumLock.disableOnStart], true, false, true, '1', 'bottom', 'small');
this.btnsInsertShape = Common.Utils.injectButtons($host.find('.slot-insertshape').add(this.toolbar.$el.find('.slot-insertshape')), 'tlbtn-insertshape-', 'toolbar__icon btn-insertshape', this.capInsertShape,
[Common.enumLock.lostConnect, Common.enumLock.disableOnStart], false, true, true, '1', 'bottom', 'small');
this.btnsAddPage = Common.Utils.injectButtons($host.find('.slot-inspage').add(this.toolbar.$el.find('.slot-inspage')), 'tlbtn-insertpage-', 'toolbar__icon btn-blankpage', this.capInsPage,
[Common.enumLock.lostConnect, Common.enumLock.disableOnStart], true, true, false, '1', 'bottom', 'small');
}

var created = this.btnsInsertImage.concat(this.btnsInsertText, this.btnsInsertShape);
var created = this.btnsInsertImage.concat(this.btnsInsertText, this.btnsInsertShape, this.btnsAddPage);
Common.Utils.lockControls(Common.enumLock.disableOnStart, true, {array: created});
Array.prototype.push.apply(this.lockedControls, created);

Expand Down Expand Up @@ -427,6 +413,25 @@ define([
);
});

me.btnsAddPage.forEach(function (btn) {
btn.updateHint([me.tipInsertPageAfter, me.tipInsertPage]);
btn.setMenu(
new Common.UI.Menu({
items: [
{caption: me.txtNewPageBefore, value: true},
{caption: me.txtNewPageAfter, value: false}
]
}).on('item:click', function (menu, item, e) {
me.fireEvent('insert:page', [item.value]);
})
);
btn.on('click', function (btn, e) {
me.fireEvent('insert:page');
});
if (btn.cmpEl.closest('[data-tab=ins]').length>0)
btn.setCaption(me.capBlankPage);
});

this.btnInsertTable.updateHint(this.tipInsertTable);
// this.btnInsertChart.updateHint(this.tipInsertChart);
// this.btnInsertSmartArt.updateHint(this.tipInsertSmartArt);
Expand All @@ -437,7 +442,6 @@ define([
// this.btnEditHeader.updateHint(this.tipEditHeaderFooter);
// this.btnInsDateTime.updateHint(this.tipDateTime);
// this.btnInsSlideNum.updateHint(this.tipPageNum);
this.btnAddPage.updateHint(this.tipAddPage);
/*
this.btnInsertChart.setMenu( new Common.UI.Menu({
style: 'width: 364px;padding-top: 12px;',
Expand Down Expand Up @@ -758,8 +762,6 @@ define([
capInsertChart: 'Chart',
capInsertHyperlink: 'Hyperlink',
capInsertEquation: 'Equation',
capAddPage: 'Add Page',
tipAddPage: 'Add page',
tipInsertChart: 'Insert Chart',
tipPageNum: 'Insert page number',
tipDateTime: 'Insert current date and time',
Expand Down Expand Up @@ -797,7 +799,13 @@ define([
textYen: 'Yen Sign',
capBtnInsHeaderFooter: 'Header & Footer',
tipEditHeaderFooter: 'Edit header or footer',
textRecentlyUsed: 'Recently Used'
textRecentlyUsed: 'Recently Used',
tipInsertPageAfter: 'Insert blank page after',
tipInsertPage: 'Insert blank page',
txtNewPageBefore: 'Insert blank page before',
txtNewPageAfter: 'Insert blank page after',
capBlankPage: 'Blank Page',
capInsPage: 'Insert Page'
}
}()), PDFE.Views.InsTab || {}));
});
Loading

0 comments on commit 167d307

Please sign in to comment.