diff --git a/HISTORY.md b/HISTORY.md
index 14780091..81944382 100755
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -13,6 +13,9 @@
* **Documentation Updates:**
* **Translation Updates:**
+### 2022-03-14
+* gui, byob: refactored library serialization
+
### 2022-03-11
* blocks: fixed an edge case for slot type inferral
* objects: added "combinations" primitive to the palette
diff --git a/snap.html b/snap.html
index b652db47..ed4a85d9 100755
--- a/snap.html
+++ b/snap.html
@@ -20,10 +20,10 @@
-
+
-
+
diff --git a/src/byob.js b/src/byob.js
index 95b0cccf..c78bb84f 100644
--- a/src/byob.js
+++ b/src/byob.js
@@ -111,7 +111,7 @@ ArgLabelMorph*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2022-March-09';
+modules.byob = '2022-March-14';
// Declarations
@@ -4311,25 +4311,11 @@ BlockExportDialogMorph.prototype.selectNone = function () {
// BlockExportDialogMorph ops
BlockExportDialogMorph.prototype.exportBlocks = function () {
- var globals = this.blocks.filter(def => def.isGlobal),
- glbStr = globals.length ? this.serializer.serialize(globals, true) : '',
- locals = this.blocks.filter(def => !def.isGlobal),
- locStr = locals.length ? this.serializer.serialize(locals, true) : '',
- ide = this.world().children[0],
- str;
+ var ide = this.world().children[0];
if (this.blocks.length) {
- str = ''
- + this.paletteXML()
- + (globals.length ? glbStr : '')
- + (locals.length ? ('' + locStr + '') : '')
- + '';
ide.saveXMLAs(
- str,
+ ide.blocksLibraryXML(this.blocks),
(ide.getProjectName() || localize('untitled')) +
' ' +
localize('blocks'
@@ -4344,19 +4330,6 @@ BlockExportDialogMorph.prototype.exportBlocks = function () {
}
};
-BlockExportDialogMorph.prototype.paletteXML = function () {
- var palette = new Map();
- this.blocks.forEach(def => {
- if (SpriteMorph.prototype.customCategories.has(def.category)) {
- palette.set(
- def.category,
- SpriteMorph.prototype.customCategories.get(def.category)
- );
- }
- });
- return this.serializer.paletteToXML(palette);
-};
-
// BlockExportDialogMorph layout
BlockExportDialogMorph.prototype.fixLayout
diff --git a/src/gui.js b/src/gui.js
index 07357337..8ba6d0ac 100644
--- a/src/gui.js
+++ b/src/gui.js
@@ -86,7 +86,7 @@ BlockVisibilityDialogMorph, ThreadManager*/
// Global stuff ////////////////////////////////////////////////////////
-modules.gui = '2022-March-11';
+modules.gui = '2022-March-14';
// Declarations
@@ -7389,6 +7389,41 @@ IDE_Morph.prototype.getURL = function (url, callback, responseType) {
}
};
+// IDE_Morph serialization helper ops
+
+IDE_Morph.prototype.blocksLibraryXML = function (definitions) {
+ // answer an XML string encoding of an array of CustomBlockDefinitions
+ var globals = definitions.filter(def => def.isGlobal),
+ locals = definitions.filter(def => !def.isGlobal),
+ glbStr = globals.length ? this.serializer.serialize(globals, true) : '',
+ locStr = locals.length ? this.serializer.serialize(locals, true) : '';
+
+ return '' +
+ this.paletteXML(definitions) +
+ (globals.length ? glbStr : '') +
+ (locals.length ? ('' + locStr + '') : '') +
+ '';
+};
+
+IDE_Morph.prototype.paletteXML = function (definitions) {
+ // private - answer an XML string containing the palette information
+ // found in an array of CustomBlockDefinitions
+ var palette = new Map();
+ definitions.forEach(def => {
+ if (SpriteMorph.prototype.customCategories.has(def.category)) {
+ palette.set(
+ def.category,
+ SpriteMorph.prototype.customCategories.get(def.category)
+ );
+ }
+ });
+ return this.serializer.paletteToXML(palette);
+};
+
// IDE_Morph user dialog shortcuts
IDE_Morph.prototype.showMessage = function (message, secs) {