Block factory fix (#4327)

This commit is contained in:
alschmiedt
2020-09-28 10:42:45 -07:00
committed by GitHub
parent a47c619078
commit 3d698f4bcc
4 changed files with 21 additions and 5 deletions

View File

@@ -363,3 +363,19 @@ Blockly.Options.parseThemeOptions_ = function(options) {
return Blockly.Theme.defineTheme(theme.name ||
('builtin' + Blockly.utils.IdGenerator.getNextUniqueId()), theme);
};
/**
* Parse the provided toolbox tree into a consistent DOM format.
* @param {?Node|?string} toolboxDef DOM tree of blocks, or text representation
* of same.
* @return {?Node} DOM tree of blocks, or null.
* @deprecated Use Blockly.utils.toolbox.parseToolboxTree. (2020 September 28)
*/
Blockly.Options.parseToolboxTree = function(toolboxDef) {
Blockly.utils.deprecation.warn(
'Blockly.Options.parseToolboxTree',
'September 2020',
'September 2021',
'Blockly.utils.toolbox.parseToolboxTree');
return Blockly.utils.toolbox.parseToolboxTree(toolboxDef);
};

View File

@@ -34,7 +34,7 @@ Blockly.ToolboxItem = function(toolboxItemDef, toolbox, opt_parent) {
* @type {string}
* @protected
*/
this.id_ = toolboxItemDef['id'] || Blockly.utils.IdGenerator.getNextUniqueId();
this.id_ = toolboxItemDef['toolboxitemid'] || Blockly.utils.IdGenerator.getNextUniqueId();
/**
* The parent of the category.

View File

@@ -398,7 +398,7 @@ WorkspaceFactoryController.prototype.updatePreview = function() {
// Only update the toolbox if not in read only mode.
if (!this.model.options['readOnly']) {
// Get toolbox XML.
var tree = Blockly.Options.parseToolboxTree(
var tree = Blockly.utils.toolbox.parseToolboxTree(
this.generator.generateToolboxXml());
// No categories, creates a simple flyout.
@@ -1084,7 +1084,7 @@ WorkspaceFactoryController.prototype.setStandardOptionsAndUpdate = function() {
WorkspaceFactoryController.prototype.generateNewOptions = function() {
this.model.setOptions(this.readOptions_());
this.reinjectPreview(Blockly.Options.parseToolboxTree(
this.reinjectPreview(Blockly.utils.toolbox.parseToolboxTree(
this.generator.generateToolboxXml()));
};

View File

@@ -146,10 +146,10 @@
<category name="Second">
<block type="stack_block"></block>
</category>
<sep id="separator" gap="-1"></sep>
<sep toolboxitemid="separator" gap="-1"></sep>
<category name="Variables" custom="VARIABLE"></category>
<category name="NestedCategory" >
<category id="nestedCategory" name="NestedItemOne"></category>
<category toolboxitemid="nestedCategory" name="NestedItemOne"></category>
</category>
<category name="lastItem"></category>
</xml>