diff --git a/js/io/io.js b/js/io/io.js index 052c8941..be42b551 100644 --- a/js/io/io.js +++ b/js/io/io.js @@ -7,6 +7,19 @@ function setupDragHandlers() { loadImages(files, event) } ) + Blockbench.addDragHandler( + 'reference_image', + {extensions: ['jpg', 'jpeg', 'bmp', 'tiff', 'tif', 'gif'], propagate: true, readtype: 'image', condition: () => !Dialog.open}, + function(files, event) { + files.map(file => { + return new ReferenceImage({ + source: file.content, + name: file.name || 'Reference' + }).addAsReference(true); + }).last().select(); + ReferenceImageMode.activate(); + } + ) Blockbench.addDragHandler( 'model', {extensions: Codec.getAllExtensions}, @@ -125,7 +138,7 @@ async function loadImages(files, event) { } else if (method == 'reference_image') { files.map(file => { - new ReferenceImage({ + return new ReferenceImage({ source: file.content, name: file.name || 'Reference' }).addAsReference(true); diff --git a/js/preview/reference_images.js b/js/preview/reference_images.js index a33670ea..b933704f 100644 --- a/js/preview/reference_images.js +++ b/js/preview/reference_images.js @@ -520,9 +520,12 @@ class ReferenceImage { } async delete(force) { if (!force) { + let img = new Image(); + img.src = this.source; let result = await new Promise(resolve => Blockbench.showMessageBox({ title: 'data.reference_image', message: 'message.delete_reference_image', + icon: img, buttons: ['dialog.confirm', 'dialog.cancel'] }, resolve)); if (result == 1) return;