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.
This commit is contained in:
Dan Stillman 2021-12-20 21:35:47 -05:00
parent ea18641a62
commit f161d167ae

View file

@ -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()) {