mirror of
https://github.com/google/blockly.git
synced 2026-01-04 23:50:12 +01:00
Block factory fix (#4327)
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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()));
|
||||
};
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user