From f161d167aeb8e74e654967e5f68c22393554f518 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 20 Dec 2021 21:35:47 -0500 Subject: [PATCH] Show "Add Note from Annotations" for all items with PDF attachments So that this works for PDFs with external annotations that haven't yet been processed. Going forward, if we add automatic/background scanning, we can avoid showing this option if the file hasn't changed and there are no Zotero annotations, which would probably be the majority of attachments. --- chrome/content/zotero/zoteroPane.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 51bdb624d9..261dfa4082 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -3090,7 +3090,10 @@ var ZoteroPane = new function() function isAttachmentWithExtractableAnnotations(item) { - return item.isPDFAttachment() && item.getAnnotations().some(x => x.annotationType != 'ink'); + // For now, consider all PDF attachments eligible, since we want to extract external + // annotations in unprocessed files if present + //return item.isPDFAttachment() && item.getAnnotations().some(x => x.annotationType != 'ink'); + return item.isPDFAttachment(); } @@ -4458,6 +4461,7 @@ var ZoteroPane = new function() this.displayCannotEditLibraryMessage(); return; } + await Zotero.PDFWorker.import(attachment.id, true); var note = await Zotero.EditorInstance.createNoteFromAnnotations( attachment.getAnnotations().filter(x => x.annotationType != 'ink'), attachment.parentID ); @@ -4478,13 +4482,10 @@ var ZoteroPane = new function() for (let item of items) { let attachments = []; if (item.isRegularItem()) { - // Find all child attachments with non-ink annotations + // Find all child attachments with extractable annotations attachments.push( ...Zotero.Items.get(item.getAttachments()) - .filter((x) => { - return x.isPDFAttachment() - && x.getAnnotations().some(x => x.annotationType != 'ink'); - }) + .filter(item => isAttachmentWithExtractableAnnotations(item)) ); } else if (item.isFileAttachment()) {