Throw on missing parentItemID in Attachments.importEmbeddedImage()
This commit is contained in:
parent
a94323fc15
commit
3c6ae0e656
1 changed files with 6 additions and 2 deletions
|
@ -358,13 +358,17 @@ Zotero.Attachments = new function(){
|
||||||
*
|
*
|
||||||
* @param {Object} params
|
* @param {Object} params
|
||||||
* @param {Blob} params.blob - Image to save
|
* @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()
|
* @param {Object} [params.saveOptions] - Options to pass to Zotero.Item::save()
|
||||||
* @return {Promise<Zotero.Item>}
|
* @return {Promise<Zotero.Item>}
|
||||||
*/
|
*/
|
||||||
this.importEmbeddedImage = async function ({ blob, parentItemID, saveOptions }) {
|
this.importEmbeddedImage = async function ({ blob, parentItemID, saveOptions }) {
|
||||||
Zotero.debug('Importing note or annotation image');
|
Zotero.debug('Importing note or annotation image');
|
||||||
|
|
||||||
|
if (!parentItemID) {
|
||||||
|
throw new Error("parentItemID must be provided");
|
||||||
|
}
|
||||||
|
|
||||||
var contentType = blob.type;
|
var contentType = blob.type;
|
||||||
var fileExt;
|
var fileExt;
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
|
@ -379,7 +383,7 @@ Zotero.Attachments = new function(){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unsupported embedded image content type '${contentType}`);
|
throw new Error(`Unsupported embedded image content type '${contentType}'`);
|
||||||
}
|
}
|
||||||
var filename = 'image.' + fileExt;
|
var filename = 'image.' + fileExt;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue