diff --git a/HISTORY.md b/HISTORY.md index f575970c..69dee39a 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,8 @@ # Snap! (BYOB) History ## in development: +* **New Features:** + * you can now also "peel off" custom block instances from their prototype templates in the block editor * **Notable Changes:** * speed-up talk bubble positioning by 5x * **Notable Fixes:** @@ -9,7 +11,8 @@ ### 2021-04-17 * objects: fixed an occasional rendering glitch when changing the display style of a variable watcher -* objects: tweaked CellMorph shadow rendering +* objects: tweaked CellMorph shadow rendering +* byob: enable "peeling off" custom block instances from their prototype templates ### 2021-04-17 * new dev version diff --git a/snap.html b/snap.html index 8f7157c2..d1998ca9 100755 --- a/snap.html +++ b/snap.html @@ -14,7 +14,7 @@ - + diff --git a/src/byob.js b/src/byob.js index 9dc8d4de..f9cffb7c 100644 --- a/src/byob.js +++ b/src/byob.js @@ -106,7 +106,7 @@ WatcherMorph, XML_Serializer, SnapTranslator*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2021-March-05'; +modules.byob = '2021-April-20'; // Declarations @@ -645,6 +645,9 @@ CustomCommandBlockMorph.prototype.init = function (definition, isProto) { this.isGlobal = definition ? definition.isGlobal : false; this.isPrototype = isProto || false; // optional CustomCommandBlockMorph.uber.init.call(this); + if (isProto) { + this.isTemplate = true; + } this.category = definition.category; this.selector = 'evaluateCustomBlock'; this.variables = null; @@ -655,6 +658,17 @@ CustomCommandBlockMorph.prototype.init = function (definition, isProto) { } }; +CustomCommandBlockMorph.prototype.reactToTemplateCopy = function () { + var def; + if (this.isPrototype) { + def = this.definition; + this.isPrototype = false; + this.refresh(); + this.refreshDefaults(def); + } + CustomCommandBlockMorph.uber.reactToTemplateCopy.call(this); +}; + CustomCommandBlockMorph.prototype.initializeVariables = function (oldVars) { this.variables = new VariableFrame(); if (!this.isGlobal) { @@ -1413,6 +1427,9 @@ CustomReporterBlockMorph.prototype.init = function ( this.isGlobal = definition ? definition.isGlobal : false; this.isPrototype = isProto || false; // optional CustomReporterBlockMorph.uber.init.call(this, isPredicate, true); // sil. + if (isProto) { + this.isTemplate = true; + } this.category = definition.category; this.storedTranslations = null; // transient - only for "wishes" this.variables = new VariableFrame(); @@ -1426,6 +1443,9 @@ CustomReporterBlockMorph.prototype.init = function ( CustomReporterBlockMorph.prototype.initializeVariables = CustomCommandBlockMorph.prototype.initializeVariables; +CustomReporterBlockMorph.prototype.reactToTemplateCopy = + CustomCommandBlockMorph.prototype.reactToTemplateCopy; + CustomReporterBlockMorph.prototype.refresh = function (aDefinition) { var def = aDefinition || this.definition; CustomCommandBlockMorph.prototype.refresh.call(this, aDefinition, true);