Class for a block's SVG representation. Not normally called directly, workspace.newBlock() is preferred.
The block's workspace.
Name of the language object containing type-specific functions for this block.
Optionalopt_id: stringOptional ID. Use this ID if provided, otherwise create a new ID.
Block's comment icon (if any).
A model of the comment attached to this block.
An optional method called when a mutator dialog saves its content.
This function is called to modify the original block according to new
settings. This method must also be coupled with defining a decompose
method for the default mutation dialog button and UI to appear.
An optional method for defining custom block context menu items.
Optional text data that round-trips between blocks and XML. Has no effect. May be used by 3rd parties for meta information.
An optional method called when a mutator dialog is first opened.
This function must create and initialize a top-level block for the mutator
dialog, and return it. This function should also populate this top-level
block with any sub-blocks which are appropriate. This method must also be
coupled with defining a compose method for the default mutation dialog
button and UI to appear.
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.
Height of this block, not including any statement blocks above or below. Height is in workspace units.
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.
Block's mutator icon (if any).
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.
The renderer's path object.
An property used internally to reference the block's rendering debugger.
A count of statement inputs on the block.
A block style object.
An optional property for suppressing adding STATEMENT_PREFIX and STATEMENT_SUFFIX to generated code.
Block's warning icon (if any).
Width of this block, including any connected value blocks. Width is in workspace units.
Select this block. Highlight it visually.
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.
Get the border colour(s) of a block.
An object containing colour values for the border(s) of the block. If the block is using a style the colourBorder will be defined and equal to the tertiary colour of the style (#RRGGBB string). Otherwise the colourDark and colourLight attributes will be defined (#RRGGBB strings).
Get the secondary colour of a block.
#RRGGBB string.
Get the tertiary colour of a block.
#RRGGBB string.
Returns the comment on this block (or null if there is no comment).
Block's comment.
Returns connections originating from this block.
If true, return all connections even hidden ones. Otherwise, for a non-rendered block return an empty list, and for a collapsed block don't return inputs connections.
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. If the block is on the workspace, (0, 0) is the origin of the workspace coordinate system. This does not change with workspace scale.
Object with .x and .y properties in workspace coordinates.
Get the name of the block style.
Name of the block style.
Return the root node of the SVG or null if none exists.
The root SVG node (probably a group).
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.
Visual effect to show that if the dragging block is dropped it will connect to this input.
The connection on the input to highlight.
True if highlighting should be added.
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).
Create and initialize the SVG representation of the block. May be called more than once.
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.
Notify every input on this block to mark its fields as dirty. A dirty field is a field that needs to be re-rendered.
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 this block during a drag, taking into account whether we are using a drag surface to translate blocks. This block must be a top-level block.
The location to translate to, in workspace coordinates.
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.
Move this block back to the workspace block canvas. Generally should be called at the same time as setDragging_(false). Does nothing if useDragSurface_ is false.
The position the block should take on on the workspace canvas, in workspace coordinates.
Move a block to a position.
The position to move to in workspace units.
Position a block so that it doesn't move the target block when connected. The block to position is usually either the first block in a dragged stack or an insertion marker.
The connection on the moving block's stack.
The connection that should stay stationary as this block is positioned.
Remove an input from this block.
The name of the input.
Optionalopt_quiet: booleanTrue to prevent error if input is not present.
True if operation succeeds, false if input is not present and opt_quiet is true
Unselect this block. Remove its highlighting.
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.
Lays out and reflows a block based on its contents and settings.
Optionalopt_bubble: booleanIf false, just render this block. If true, also render block's parent, grandparent, etc. Defaults to true.
Select this block. Highlight it visually.
Set whether the block is collapsed or not.
True if collapsed.
Change the colour of a block.
HSV hue value, or #RRGGBB string.
Set this block's comment text.
The text, or null to delete.
Sets whether this block's connections are tracked in the database or not.
Used by the deserializer to be more efficient. Setting a connection's tracked_ value to false keeps it from adding itself to the db when it gets its first moveTo call, saving expensive ops for later.
If true, start tracking. If false, stop tracking.
Add the cursor SVG to this block's SVG group.
The SVG root of the cursor to be added to the block SVG group.
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 the block is highlighted or not. Block highlighting is often used to visually mark blocks currently being executed.
True if highlighted.
Set whether value inputs are arranged horizontally or vertically.
True if inputs are horizontal.
Add the marker SVG to this block's SVG group.
The SVG root of the marker to be added to the block SVG group.
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.
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.
Optionalopt_id: stringAn optional ID for the warning text to be able to maintain multiple warnings.
Snap this block to the nearest grid point.
Encode a block for copying.
Copy metadata, or null if the block is an insertion marker.
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.
Transforms a block by setting the translation on the transform attribute of the block's SVG.
The x coordinate of the translation in workspace units.
The y coordinate of the translation in workspace units.
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.
Unselect this block. Remove its highlighting.
Enable or disable a block.
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