diff --git a/HISTORY.md b/HISTORY.md
index 56d080eb..38feafac 100755
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -56,6 +56,9 @@
* **Translation Updates:**
* German
+### 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)
+
### 2022-07-01
* extensions: added a slash-suffix to the EDC url allow-list entry
diff --git a/snap.html b/snap.html
index 62fa6413..754b715e 100755
--- a/snap.html
+++ b/snap.html
@@ -16,11 +16,11 @@
-
+
-
+
diff --git a/src/blocks.js b/src/blocks.js
index ce31e043..fa68343d 100644
--- a/src/blocks.js
+++ b/src/blocks.js
@@ -161,7 +161,7 @@ CostumeIconMorph, SoundIconMorph, SVG_Costume, embedMetadataPNG*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2022-June-28';
+modules.blocks = '2022-July-04';
var SyntaxElementMorph;
var BlockMorph;
@@ -8537,6 +8537,16 @@ ScriptsMorph.prototype.selectForEdit = function () {
return this;
};
+ScriptsMorph.prototype.droppedImage = function (aCanvas, name, embeddedData) {
+ var ide = this.parentThatIsA(IDE_Morph),
+ blockEditor = this.parentThatIsA(BlockEditorMorph);
+ if (!ide && blockEditor) {
+ ide = blockEditor.target.parentThatIsA(IDE_Morph);
+ }
+ if (!ide) {return; }
+ ide.droppedImage(aCanvas, name, embeddedData, 'scripts');
+};
+
// ScriptsMorph keyboard support
ScriptsMorph.prototype.edit = function (pos) {
diff --git a/src/gui.js b/src/gui.js
index 8fa8d319..f2085bd4 100644
--- a/src/gui.js
+++ b/src/gui.js
@@ -80,13 +80,13 @@ BlockLabelPlaceHolderMorph, SpeechBubbleMorph, XML_Element, WatcherMorph, WHITE,
BlockRemovalDialogMorph,TableMorph, isSnapObject, isRetinaEnabled, SliderMorph,
disableRetinaSupport, enableRetinaSupport, isRetinaSupported, MediaRecorder,
Animation, BoxMorph, BlockDialogMorph, RingMorph, Project, ZERO, BLACK,
-BlockVisibilityDialogMorph, ThreadManager*/
+BlockVisibilityDialogMorph, ThreadManager, isString*/
/*jshint esversion: 6*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2022-May-19';
+modules.gui = '2022-July-04';
// Declarations
@@ -1309,6 +1309,10 @@ IDE_Morph.prototype.createCategories = function () {
this.categories.buttons = [];
this.categories.isVisible = flag;
+ this.categories.droppedImage = (aCanvas, name, embeddedData) => {
+ this.droppedImage(aCanvas, name, embeddedData, 'categories');
+ };
+
this.categories.refresh = function () {
this.buttons.forEach(cat => {
cat.refresh();
@@ -1594,6 +1598,10 @@ IDE_Morph.prototype.createPalette = function (forSearching) {
}
};
+ this.palette.droppedImage = (aCanvas, name, embeddedData) => {
+ this.droppedImage(aCanvas, name, embeddedData, 'palette');
+ };
+
this.palette.setWidth(this.logo.width());
this.add(this.palette);
return this.palette;
@@ -2471,7 +2479,7 @@ IDE_Morph.prototype.endBulkDrop = function () {
this.bulkDropInProgress = false;
};
-IDE_Morph.prototype.droppedImage = function (aCanvas, name, embeddedData) {
+IDE_Morph.prototype.droppedImage = function (aCanvas, name, embeddedData, src) {
var costume = new Costume(
aCanvas,
this.currentSprite.newCostumeName(
@@ -2491,6 +2499,18 @@ IDE_Morph.prototype.droppedImage = function (aCanvas, name, embeddedData) {
return;
}
+ // 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) &&
+ ['scripts', 'palette', 'categories'].includes(src) &&
+ embeddedData[0] === '<' &&
+ ['blocks', 'block', 'script'].some(tag =>
+ embeddedData.slice(1).startsWith(tag))
+ ) {
+ return this.droppedText(embeddedData, name, '');
+ }
+
costume.embeddedData = embeddedData || null;
this.currentSprite.addCostume(costume);
this.currentSprite.wearCostume(costume);