From d4339f20bdc06e107ad8201ef7b14d32ea2476f8 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Tue, 15 Mar 2022 11:04:02 +0200 Subject: [PATCH] Don't try to modify non-editable annotation item when saving image --- chrome/content/zotero/xpcom/reader.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js index 351475053a..f8754cfa75 100644 --- a/chrome/content/zotero/xpcom/reader.js +++ b/chrome/content/zotero/xpcom/reader.js @@ -649,6 +649,22 @@ class ReaderInstance { instanceID: this._instanceID } }; + + // Note: annotation.image is always saved separately from the rest + // of annotation properties + + let item = Zotero.Items.getByLibraryAndKey(attachment.libraryID, annotation.key); + // Save image for read-only annotation. + if (item + && !item.isEditable() + && annotation.image + && !await Zotero.Annotations.hasCacheImage(item) + ) { + let blob = this._dataURLtoBlob(annotation.image); + await Zotero.Annotations.saveCacheImage(item, blob); + continue; + } + let savedAnnotation = await Zotero.Annotations.saveFromJSON(attachment, annotation, saveOptions); if (annotation.image && !await Zotero.Annotations.hasCacheImage(savedAnnotation)) { let blob = this._dataURLtoBlob(annotation.image);