Don't allow to rotate or delete pages for read-only PDF

This commit is contained in:
Martynas Bagdonas 2022-10-06 18:00:32 +03:00
parent 28329aa785
commit 29dd0cf5dc

View file

@ -893,6 +893,7 @@ class ReaderInstance {
// Rotate Left
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', Zotero.getString('pdfReader.rotateLeft'));
menuitem.setAttribute('disabled', this._isReadOnly());
menuitem.addEventListener('command', async () => {
this._postMessage({ action: 'reloading' });
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 270, true);
@ -902,6 +903,7 @@ class ReaderInstance {
// Rotate Right
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', Zotero.getString('pdfReader.rotateRight'));
menuitem.setAttribute('disabled', this._isReadOnly());
menuitem.addEventListener('command', async () => {
this._postMessage({ action: 'reloading' });
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 90, true);
@ -911,6 +913,7 @@ class ReaderInstance {
// Rotate 180
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', Zotero.getString('pdfReader.rotate180'));
menuitem.setAttribute('disabled', this._isReadOnly());
menuitem.addEventListener('command', async () => {
this._postMessage({ action: 'reloading' });
await Zotero.PDFWorker.rotatePages(this._itemID, data.pageIndexes, 180, true);
@ -922,6 +925,7 @@ class ReaderInstance {
// Delete
menuitem = this._window.document.createElement('menuitem');
menuitem.setAttribute('label', Zotero.getString('general.delete'));
menuitem.setAttribute('disabled', this._isReadOnly());
menuitem.addEventListener('command', async () => {
if (this.promptToDeletePages(data.pageIndexes.length)) {
this._postMessage({ action: 'reloading' });