mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Fixes refresh on simple toolbox withno categories
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user