mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Blockly Factory: Clean Up Workspace on Save Block, Import Lowercase Types (#584)
* save only factory base block upon save to library; import block library with lowercase blocktypes * nit comment
This commit is contained in:
@@ -197,7 +197,8 @@ AppController.prototype.formatBlockLibForImport_ = function(xmlText) {
|
||||
xmlDom.appendChild(blockNode);
|
||||
|
||||
var xmlText = Blockly.Xml.domToText(xmlDom);
|
||||
var blockType = this.getBlockTypeFromXml_(xmlText);
|
||||
// All block types should be lowercase.
|
||||
var blockType = this.getBlockTypeFromXml_(xmlText).toLowerCase();
|
||||
|
||||
blockXmlTextMap[blockType] = xmlText;
|
||||
}
|
||||
|
||||
@@ -139,11 +139,19 @@ BlockLibraryController.prototype.saveToBlockLibrary = function() {
|
||||
}
|
||||
}
|
||||
|
||||
// Create block xml.
|
||||
var xmlElement = goog.dom.createDom('xml');
|
||||
var block = FactoryUtils.getRootBlock(BlockFactory.mainWorkspace);
|
||||
xmlElement.appendChild(Blockly.Xml.blockToDomWithXY(block));
|
||||
|
||||
// Save block.
|
||||
var xmlElement = Blockly.Xml.workspaceToDom(BlockFactory.mainWorkspace);
|
||||
this.storage.addBlock(blockType, xmlElement);
|
||||
this.storage.saveToLocalStorage();
|
||||
|
||||
// Show saved block without other stray blocks sitting in Block Factory's
|
||||
// main workspace.
|
||||
this.openBlock(blockType);
|
||||
|
||||
// Do not add another option to dropdown if replacing.
|
||||
if (replace) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user