mirror of
https://github.com/google/blockly.git
synced 2026-01-09 01:50:11 +01:00
Move block database to workspace.
This commit is contained in:
@@ -51,6 +51,8 @@ Blockly.Workspace = function(opt_options) {
|
||||
this.undoStack_ = [];
|
||||
/** @type {!Array.<!Blockly.Events.Abstract>} */
|
||||
this.redoStack_ = [];
|
||||
/** @type {!Object} */
|
||||
this.blockDB_ = Object.create(null);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -289,6 +291,15 @@ Blockly.Workspace.prototype.fireChangeListener = function(event) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Find the block on this workspace with the specified ID.
|
||||
* @param {string} id ID of block to find.
|
||||
* @return {Blockly.Block} The sought after block or null if not found.
|
||||
*/
|
||||
Blockly.Workspace.prototype.getBlockById = function(id) {
|
||||
return this.blockDB_[id] || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Database of all workspaces.
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user