From 49906c3fa0d51e7eb5697a34d2a3cdc7bfd15450 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 3 Mar 2021 15:30:29 -0500 Subject: [PATCH] Add "Export PDF" options to File menu Quick implementation, but works on parent items or PDF attachments Currently always includes annotations, but we'll want that to be an option --- .../content/zotero/standalone/standalone.js | 40 +++++++++++++++ .../content/zotero/standalone/standalone.xul | 9 +++- chrome/content/zotero/zoteroPane.js | 51 +++++++++++++++++-- 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index 9819910149..4c0df56ecf 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -143,6 +143,46 @@ const ZoteroStandalone = new function() { } catch (e) {} this.updateMenuItemEnabled('manage-attachments-menu', active); + + // TEMP: Quick implementation + try { + let menuitem = document.getElementById('menu_export_files'); + let sep = menuitem.nextSibling; + + let zp = Zotero.getActiveZoteroPane(); + if (zp) { + let numFiles = zp.getSelectedItems().reduce((num, item) => { + if (item.isPDFAttachment()) { + return num + 1; + } + if (item.isRegularItem()) { + return num + item.numPDFAttachments(); + } + return num; + }, 0); + if (numFiles) { + menuitem.hidden = false; + sep.hidden = false; + if (numFiles == 1) { + menuitem.label = 'Export PDF…'; + } + else { + menuitem.label = 'Export PDFs…'; + } + } + else { + menuitem.hidden = true; + sep.hidden = true; + } + } + else { + menuitem.hidden = true; + sep.hidden = true; + } + } + catch (e) { + Zotero.logError(e); + } }; diff --git a/chrome/content/zotero/standalone/standalone.xul b/chrome/content/zotero/standalone/standalone.xul index 42434bb6aa..335fcbc378 100644 --- a/chrome/content/zotero/standalone/standalone.xul +++ b/chrome/content/zotero/standalone/standalone.xul @@ -147,7 +147,10 @@ command="cmd_zotero_newStandaloneNote"/> - + + +