Class for one block. Not normally called directly, workspace.newBlock() is preferred.
A string representing the comment attached to this block.
A model of the comment attached to this block.
Optional text data that round-trips between blocks and XML. Has no effect. May be used by 3rd parties for meta information.
Has this block been disposed of?
An optional deserialization method for defining how to deserialize the
mutation state. This must be coupled with defining mutationToDom.
An optional property for declaring developer variables. Return a list of variable names for use by generators. Developer variables are never shown to the user, but are declared as global variables in the generated code.
Name of the type of hat.
An optional method called during initialization.
An optional serialization method for defining how to serialize the
mutation state. This must be coupled with defining domToMutation.
An optional callback method to use whenever the block's parent workspace changes. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
A count of statement inputs on the block.
An optional property for suppressing adding STATEMENT_PREFIX and STATEMENT_SUFFIX to generated code.
Recursively checks whether all statement and value inputs are filled with blocks. Also checks all following statement blocks in this stack.
Optionalopt_shadowBlocksAreFilled: booleanAn optional argument controlling whether shadow blocks are counted as filled. Defaults to true.
True if all inputs are filled, false otherwise.
Shortcut for appending a dummy input row.
Optionalopt_name: stringLanguage-neutral identifier which may used to find this input again. Should be unique to this block.
The input object created.
Shortcut for appending a statement input row.
Language-neutral identifier which may used to find this input again. Should be unique to this block.
The input object created.
Shortcut for appending a value input row.
Language-neutral identifier which may used to find this input again. Should be unique to this block.
The input object created.
Bump unconnected blocks out of alignment. Two blocks which aren't actually connected should not coincidentally line up on screen.
Find all the blocks that are directly nested inside this one. Includes value and statement inputs, as well as any following statement. Excludes any connection on an output tab or any preceding statement. Blocks are optionally sorted by position; top to bottom.
Sort the list if true.
Array of blocks.
Get the colour of a block.
#RRGGBB string.
Returns the comment on this block (or null if there is no comment).
Block's comment.
Returns all connections originating from this block.
If true, return all connections even hidden ones.
Array of connections.
Find all the blocks that are directly or indirectly nested inside this one. Includes this block in the list. Includes value and statement inputs, as well as any following statements. Excludes any connection on an output tab or any preceding statements. Blocks are optionally sorted by position; top to bottom.
Sort the list if true.
Flattened array of blocks.
Returns the language-neutral value of the given field.
The name of the field.
Value of the field or null if field does not exist.
Return the connection on the first statement input on this block, or null if there are none.
The first statement connection or null.
Get the HSV hue value of a block. Null if hue not set.
Hue value (0-360).
Get whether the block is disabled or not due to parents. The block's own disabled property is not considered.
True if disabled.
Fetches the named input object.
The name of the input.
The input object, or null if input does not exist.
Get whether value inputs are arranged horizontally or vertically.
True if inputs are horizontal.
Find the connection on this block that corresponds to the given connection on the other block. Used to match connections between a block and its insertion marker.
The other block to match against.
The other connection to match.
The matching connection on this block, or null.
Get the block's output shape.
Value representing output shape if one exists.
Return the parent block or null if this block is at the top level. The parent block is either the block connected to the previous connection (for a statement block) or the block connected to the output connection (for a value block).
The block (if any) that holds the current block.
Return the coordinates of the top-left corner of this block relative to the drawing surface's origin (0,0), in workspace units.
Object with .x and .y properties.
Get the name of the block style.
Name of the block style.
Returns the tooltip text for this block.
The tooltip text for this block.
Return all variables referenced by this block.
List of variable models.
Return all variables referenced by this block.
List of variable names.
Call initModel on all fields on the block. May be called more than once. Either initModel or initSvg must be called after creating a block and before the first interaction with it. Interactions include UI actions (e.g. clicking and dragging) and firing events (e.g. create, delete, and change).
Get whether the block is collapsed or not.
True if collapsed.
Get whether this block is deletable or not.
True if deletable.
Returns if this block has been disposed of / deleted.
True if this block has been disposed of / deleted.
Get whether is block is duplicatable or not. If duplicating this block and descendants will put this block over the workspace's capacity this block is not duplicatable. If duplicating this block and descendants will put any type over their maxInstances this block is not duplicatable.
True if duplicatable.
Get whether this block is editable or not.
True if editable.
Get whether this block is enabled or not.
True if enabled.
Get whether this block is an insertion marker block or not.
True if an insertion marker.
Get whether this block is movable or not.
True if movable.
Get whether this block is a shadow block or not.
True if a shadow.
Initialize this block using a cross-platform, internationalization-friendly JSON description.
Structured data describing the block.
Walks down a stack of blocks and finds the last next connection on the stack.
If true,the last connection on a non-shadow block will be returned. If false, this will follow shadows to find the last connection.
The last next connection on the stack, or null.
Add key/values from mixinObj to this block object. By default, this method will check that the keys in mixinObj will not overwrite existing values in the block, including prototype values. This provides some insurance against mixin / extension incompatibilities with future block features. This check can be disabled by passing true as the second argument.
The key/values pairs to add to this block object.
Optionalopt_disableCheck: booleanOption flag to disable overwrite checks.
Move a block by a relative offset.
Horizontal offset, in workspace units.
Vertical offset, in workspace units.
Move a named input to a different location on this block.
The name of the input to move.
Name of input that should be after the moved input, or null to be the input at the end.
Move a numbered input to a different location on this block.
Index of the input to move.
Index of input that should be after the moved input.
Remove an input from this block.
The name of the input.
Optionalopt_quiet: booleanTrue to prevent an error if input is not present.
True if operation succeeds, false if input is not present and opt_quiet is true
Notification that a variable is renaming. If the ID matches one of this block's variables, rename it.
ID of variable to rename.
ID of new variable. May be the same as oldId, but with an updated name.
Set whether the block is collapsed or not.
True if collapsed.
Change the colour of a block.
HSV hue value (0 to 360), #RRGGBB string, or a message reference string pointing to one of those two values.
Set this block's comment text.
The text, or null to delete.
Set whether this block is deletable or not.
True if deletable.
Set whether this block is editable or not.
True if editable.
Set whether the block is enabled or not.
True if enabled.
Sets the value of the given field for this block.
The value to set.
The name of the field to set the value of.
Set the URL of this block's help page.
URL string for block help, or function that returns a URL. Null for no help.
Set whether value inputs are arranged horizontally or vertically.
True if inputs are horizontal.
Set whether this block is movable or not.
True if movable.
Set whether another block can chain onto the bottom of this block.
True if there can be a next statement.
Optionalopt_check: anyStatement type or list of statement types. Null/undefined if any type could be connected.
Sets a callback function to use whenever the block's parent workspace changes, replacing any prior onchange handler. This is usually only called from the constructor, the block type initializer function, or an extension initializer function.
The callback to call when the block's workspace changes.
Set whether this block returns a value.
True if there is an output.
Optionalopt_check: anyReturned type or list of returned types. Null or undefined if any type could be returned (e.g. variable get).
Set the block's output shape.
Value representing an output shape.
Set whether this block can chain onto the bottom of another block.
True if there can be a previous statement.
Optionalopt_check: anyStatement type or list of statement types. Null/undefined if any type could be connected.
Set whether this block is a shadow block or not.
True if a shadow.
Set the style and colour values of a block.
Name of the block style.
Sets the tooltip for this block.
The text for the tooltip, a function that returns the text for the tooltip, or a parent object whose tooltip will be used. To not display a tooltip pass the empty string.
Set this block's warning text.
The text, or null to delete.
Optional_opt_id: stringAn optional ID for the warning text to be able to maintain multiple warnings.
This method returns a string describing this Block in developer terms (type name and ID; English only).
Intended to on be used in console logs and errors. If you need a string that uses the user's native language (including block text, field values, and child blocks), use [toString()]Blockly.Block#toString.
The description.
Create a human-readable text representation of this block and any children.
Optionalopt_maxLength: numberTruncate the string to this length.
Optionalopt_emptyToken: stringThe placeholder string used to denote an empty field. If not specified, '?' is used.
Text of block.
Unplug this block from its superior block. If this block is a statement, optionally reconnect the block underneath with the block on top.
Optionalopt_healStack: booleanDisconnect child statement and reconnect stack. Defaults to false.
Notification that a variable is renaming but keeping the same ID. If the variable is in use on this block, rerender to show the new name.
The variable being renamed.
Fake class which should be extended to avoid inheriting static properties