Throw on missing parentItemID in Attachments.importEmbeddedImage()

This commit is contained in:
Dan Stillman 2020-09-08 04:08:44 -04:00
parent a94323fc15
commit 3c6ae0e656

View file

@ -358,13 +358,17 @@ Zotero.Attachments = new function(){
*
* @param {Object} params
* @param {Blob} params.blob - Image to save
* @param {Integer} params.parentItemID - Annotation item to add item to
* @param {Integer} params.parentItemID - Note or annotation item to add item to
* @param {Object} [params.saveOptions] - Options to pass to Zotero.Item::save()
* @return {Promise<Zotero.Item>}
*/
this.importEmbeddedImage = async function ({ blob, parentItemID, saveOptions }) {
Zotero.debug('Importing note or annotation image');
if (!parentItemID) {
throw new Error("parentItemID must be provided");
}
var contentType = blob.type;
var fileExt;
switch (contentType) {
@ -379,7 +383,7 @@ Zotero.Attachments = new function(){
break;
default:
throw new Error(`Unsupported embedded image content type '${contentType}`);
throw new Error(`Unsupported embedded image content type '${contentType}'`);
}
var filename = 'image.' + fileExt;