From c2575d2a1455f0586c876295fc5a78e8fc4e602a Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 22 Jul 2024 14:41:13 +0300 Subject: [PATCH] =?UTF-8?q?Gray=20out=20"Import=20Annotations=E2=80=A6"=20?= =?UTF-8?q?in=20reader=20window=20when=20no=20annotations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4416 --- chrome/content/zotero/reader.xhtml | 2 +- chrome/content/zotero/xpcom/reader.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/reader.xhtml b/chrome/content/zotero/reader.xhtml index 6301c630d0..a25b90ffe1 100644 --- a/chrome/content/zotero/reader.xhtml +++ b/chrome/content/zotero/reader.xhtml @@ -94,7 +94,7 @@ - + { if (event.target === this._window.document) { this._popupset = this._window.document.getElementById('zotero-reader-popupset'); + this._window.onFileMenuOpen = this._onFileMenuOpen.bind(this); this._window.onGoMenuOpen = this._onGoMenuOpen.bind(this); this._window.onViewMenuOpen = this._onViewMenuOpen.bind(this); this._window.reader = this; @@ -1251,6 +1252,22 @@ class ReaderWindow extends ReaderInstance { this._window.document.title = title; } + _onFileMenuOpen() { + let item = Zotero.Items.get(this._item.id); + let library = Zotero.Libraries.get(item.libraryID); + if (item + && library.filesEditable + && library.editable + && !(item.deleted || item.parentItem && item.parentItem.deleted)) { + let annotations = item.getAnnotations(); + let canTransferFromPDF = annotations.find(x => x.annotationIsExternal); + this._window.document.getElementById('menu_transferFromPDF').setAttribute('disabled', !canTransferFromPDF); + } + else { + this._window.document.getElementById('menu_transferFromPDF').setAttribute('disabled', true); + } + } + _onViewMenuOpen() { if (this._type === 'pdf' || this._type === 'epub') { this._window.document.getElementById('view-menuitem-no-spreads').setAttribute('checked', this._internalReader.spreadMode === 0);