diff --git a/HISTORY.md b/HISTORY.md index 38feafac..90c3096f 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -58,6 +58,7 @@ ### 2022-07-04 * blocks, gui: directly import embedded blocks from a smart pic if the pic is dragged and dropped onto a scripting area or palette - otherwise import the pic as costume (with embedded blocks) +* gui: import smart pic as costume via "Import..." item in the project menu ### 2022-07-01 * extensions: added a slash-suffix to the EDC url allow-list entry diff --git a/src/gui.js b/src/gui.js index f2085bd4..f9371ad6 100644 --- a/src/gui.js +++ b/src/gui.js @@ -297,6 +297,7 @@ IDE_Morph.prototype.init = function (isAutoFill) { this.bulkDropInProgress = false; // for handling multiple file-drops this.cachedSceneFlag = null; // for importing multiple scenes at once + this.isImportingLocalFile = false; // for handling imports of smart pics // initialize inherited properties: IDE_Morph.uber.init.call(this); @@ -2465,6 +2466,7 @@ IDE_Morph.prototype.reactToWorldResize = function (rect) { if (this.filePicker) { document.body.removeChild(this.filePicker); this.filePicker = null; + this.isImportingLocalFile = false; } }; @@ -2502,15 +2504,18 @@ IDE_Morph.prototype.droppedImage = function (aCanvas, name, embeddedData, src) { // directly import embedded blocks if the image was dropped on // a scripting area or the palette, otherwise import as costume // (with embedded data) - if (isString(embeddedData) && + if (!this.isImportingLocalFile && + isString(embeddedData) && ['scripts', 'palette', 'categories'].includes(src) && embeddedData[0] === '<' && ['blocks', 'block', 'script'].some(tag => embeddedData.slice(1).startsWith(tag)) ) { + this.isImportingLocalFile = false; return this.droppedText(embeddedData, name, ''); } + this.isImportingLocalFile = false; costume.embeddedData = embeddedData || null; this.currentSprite.addCostume(costume); this.currentSprite.wearCostume(costume); @@ -4578,6 +4583,7 @@ IDE_Morph.prototype.importLocalFile = function () { if (addingScenes) { myself.isAddingNextScene = true; } + myself.isImportingLocalFile = true; world.hand.processDrop(inp.files); }, false