Fixes refresh on simple toolbox withno categories

This commit is contained in:
alschmiedt
2019-01-03 12:56:19 -08:00
parent d3a603ffd9
commit bfc55ada27
2 changed files with 22 additions and 7 deletions

View File

@@ -688,9 +688,27 @@ Blockly.checkBlockColourConstant_ = function(
Blockly.setStyle = function(style) {
this.style_ = style;
var workspace = Blockly.getMainWorkspace();
var blocks = workspace.getAllBlocks();
workspace.refreshToolboxSelection();
this.updateBlockStyles_(workspace.getAllBlocks());
if (!workspace.toolbox_) {
this.updateBlockStyles_(workspace.flyout_.workspace_.getAllBlocks());
}
else {
workspace.refreshToolboxSelection();
}
var event = new Blockly.Events.Ui(null, 'styleChanged');
event.workspaceId = workspace.id;
Blockly.Events.fire(event);
};
/**
* Updates all the blocks with new style.
* @param {!Array.<Blockly.Block>} blocks List of blocks to update the style on.
* @private
*/
Blockly.updateBlockStyles_ = function(blocks) {
for (var i = 0; i < blocks.length; i++) {
var block = blocks[i];
var blockStyleName = block.getStyleName();
@@ -700,10 +718,6 @@ Blockly.setStyle = function(style) {
block.mutator.updateBlockStyle(blockStyleName);
}
}
var event = new Blockly.Events.Ui(null, 'styleChanged');
event.workspaceId = workspace.id;
Blockly.Events.fire(event);
};
/**

View File

@@ -69,12 +69,13 @@ Blockly.inject = function(container, opt_options) {
var workspace = Blockly.createMainWorkspace_(svg, options, blockDragSurface,
workspaceDragSurface);
Blockly.setStyle(options.style);
Blockly.init_(workspace);
Blockly.mainWorkspace = workspace;
Blockly.svgResize(workspace);
Blockly.setStyle(options.style);
return workspace;
};