From 3fd0abf6b0637debcf11a46fba5592193f4d89ef Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 16 May 2022 13:33:52 +0300 Subject: [PATCH] Avoid error interrupting annotation extraction from multiple items --- chrome/content/zotero/contextPane.js | 8 +++++--- chrome/content/zotero/zoteroPane.js | 12 ++++++++---- note-editor | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/chrome/content/zotero/contextPane.js b/chrome/content/zotero/contextPane.js index 903f32ba7c..24d6b5493d 100644 --- a/chrome/content/zotero/contextPane.js +++ b/chrome/content/zotero/contextPane.js @@ -440,9 +440,11 @@ var ZoteroContextPane = new function () { if (!attachment) { return; } - var note = await Zotero.EditorInstance.createNoteFromAnnotations( - attachment.getAnnotations().filter(x => x.annotationType != 'ink'), child && attachment.parentID - ); + var annotations = attachment.getAnnotations().filter(x => x.annotationType != 'ink'); + if (!annotations.length) { + return; + } + var note = await Zotero.EditorInstance.createNoteFromAnnotations(annotations, child && attachment.parentID); _updateAddToNote(); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index c667d940ef..023106c6d0 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -4835,9 +4835,11 @@ var ZoteroPane = new function() return; } await Zotero.PDFWorker.import(attachment.id, true); - var note = await Zotero.EditorInstance.createNoteFromAnnotations( - attachment.getAnnotations().filter(x => x.annotationType != 'ink'), attachment.parentID - ); + var annotations = attachment.getAnnotations().filter(x => x.annotationType != 'ink'); + if (!annotations.length) { + return; + } + var note = await Zotero.EditorInstance.createNoteFromAnnotations(annotations, attachment.parentID); if (!skipSelect) { await this.selectItem(note.id); } @@ -4875,7 +4877,9 @@ var ZoteroPane = new function() attachment, { skipSelect: true } ); - itemIDsToSelect.push(note.id); + if (note) { + itemIDsToSelect.push(note.id); + } } } await this.selectItems(itemIDsToSelect); diff --git a/note-editor b/note-editor index 1a3fa7b30d..fb3daf6c7e 160000 --- a/note-editor +++ b/note-editor @@ -1 +1 @@ -Subproject commit 1a3fa7b30df0a1530d49042a308e0840ac907f1a +Subproject commit fb3daf6c7e1d7a91992deeea52889cb9c95972f7