fix: add compose and decompose to block (#6102)

This commit is contained in:
Rachel Fenichel
2022-04-22 09:43:07 -07:00
committed by GitHub
parent 7eed6a6302
commit 619ee66b23
2 changed files with 17 additions and 3 deletions

View File

@@ -179,6 +179,20 @@ class Block {
*/
this.getDeveloperVariables = undefined;
/**
* An optional function that reconfigures the block based on the contents of
* the mutator dialog.
* @type {undefined|?function(!Block):void}
*/
this.compose = undefined;
/**
* An optional function that populates the mutator's dialog with
* this block's components.
* @type {undefined|?function(!Workspace):!Block}
*/
this.decompose = undefined;
/** @type {string} */
this.id = (opt_id && !workspace.getBlockById(opt_id)) ?
opt_id :

View File

@@ -372,8 +372,8 @@ const filter = function(queueIn, forward) {
if (!event.isNull()) {
// Treat all UI events as the same type in hash table.
const eventType = event.isUiEvent ? UI : event.type;
// TODO(#5927): Ceck whether `blockId` exists before accessing it.
const blockId = /** @type {*} */ (event).blockId;
// TODO(#5927): Check whether `blockId` exists before accessing it.
const blockId = /** @type {?} */ (event).blockId;
const key = [eventType, blockId, event.workspaceId].join(' ');
const lastEntry = hash[key];
@@ -525,7 +525,7 @@ exports.getDescendantIds = getDescendantIds;
* @alias Blockly.Events.utils.fromJson
*/
const fromJson = function(json, workspace) {
const eventClass = get(json.type);
const eventClass = get(json['type']);
if (!eventClass) {
throw Error('Unknown event type.');
}