From 8317f7783783a672b2b30a9b041a611ded98aa61 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Tue, 3 Dec 2024 21:02:35 +0000 Subject: [PATCH] Trigger annotation import only for PDF attachments when creating a note Fixes https://forums.zotero.org/discussion/120181/batch-create-note-from-annotations-for-different-attachment-types --- chrome/content/zotero/zoteroPane.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 9e4390cda1..46b1b58bb6 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -5659,7 +5659,9 @@ var ZoteroPane = new function() this.displayCannotEditLibraryMessage(); return; } - await Zotero.PDFWorker.import(attachment.id, true); + if (attachment.isPDFAttachment()) { + await Zotero.PDFWorker.import(attachment.id, true); + } var annotations = attachment.getAnnotations().filter(x => x.annotationType != 'ink'); if (!annotations.length) { return; @@ -5727,11 +5729,13 @@ var ZoteroPane = new function() var annotations = []; for (let attachment of attachments) { - try { - await Zotero.PDFWorker.import(attachment.id, true); - } - catch (e) { - Zotero.logError(e); + if (attachment.isPDFAttachment()) { + try { + await Zotero.PDFWorker.import(attachment.id, true); + } + catch (e) { + Zotero.logError(e); + } } annotations.push(...attachment.getAnnotations().filter(x => x.annotationType != 'ink')); } @@ -5823,11 +5827,13 @@ var ZoteroPane = new function() continue; } for (let attachment of attachments) { - try { - await Zotero.PDFWorker.import(attachment.id, true); - } - catch (e) { - Zotero.logError(e); + if (attachment.isPDFAttachment()) { + try { + await Zotero.PDFWorker.import(attachment.id, true); + } + catch (e) { + Zotero.logError(e); + } } annotations.push(...attachment.getAnnotations().filter(x => x.annotationType != 'ink')); }