Namespace: blocks

Class

Methods

append

static

append(state, workspace, param1) returns Blockly.Block

Loads the block represented by the given state into the given workspace.

Parameter

state

State

The state of a block to deserialize into the workspace.

Value must not be null.

workspace

Blockly.Workspace

The workspace to add the block to.

Value must not be null.

param1

Optional

{recordUndo: (boolean or undefined)}

recordUndo: If true, events triggered by this function will be undo-able by the user. False by default.

Returns

non-null Blockly.Block The block that was just loaded.

appendInternal

package   static

appendInternal(state, workspace, param1) returns Blockly.Block

Loads the block represented by the given state into the given workspace. This is defined internally so that the extra parameters don't clutter our external API. But it is exported so that other places within Blockly can call it directly with the extra parameters.

Parameter

state

State

The state of a block to deserialize into the workspace.

Value must not be null.

workspace

Blockly.Workspace

The workspace to add the block to.

Value must not be null.

param1

Optional

{parentConnection: (non-null Blockly.Connection or undefined), isShadow: (boolean or undefined), recordUndo: (boolean or undefined)}

parentConnection: If provided, the system will attempt to connect the block to this connection after it is created. Undefined by default. isShadow: If true, the block will be set to a shadow block after it is created. False by default. recordUndo: If true, events triggered by this function will be undo-able by the user. False by default.

Returns

non-null Blockly.Block The block that was just appended.

save

static

save(block, param1) returns State

Returns the state of the given block as a plain JavaScript object.

Parameter

block

Blockly.Block

The block to serialize.

Value must not be null.

param1

Optional

{addCoordinates: (boolean or undefined), addInputBlocks: (boolean or undefined), addNextBlocks: (boolean or undefined), doFullSerialization: (boolean or undefined)}

addCoordinates: If true, the coordinates of the block are added to the serialized state. False by default. addinputBlocks: If true, children of the block which are connected to inputs will be serialized. True by default. addNextBlocks: If true, children of the block which are connected to the block's next connection (if it exists) will be serialized. True by default. doFullSerialization: If true, fields that normally just save a reference to some external state (eg variables) will instead serialize all of the info about that state. This supports deserializing the block into a workspace where that state doesn't yet exist. True by default.

Returns

nullable State The serialized state of the block, or null if the block could not be serialied (eg it was an insertion marker).

Abstract types

ConnectionState

static

{shadow: (non-null State or undefined), block: (non-null State or undefined)}

Represents the state of a connection.

State

static

{type: string, id: (string or undefined), x: (number or undefined), y: (number or undefined), collapsed: (boolean or undefined), enabled: (boolean or undefined), inline: (boolean or undefined), data: (string or undefined), extra-state: (any type or undefined), icons: (non-null Object with any type properties or undefined), fields: (non-null Object with any type properties or undefined), inputs: (non-null Object with non-null ConnectionState properties or undefined), next: (non-null ConnectionState or undefined)}

Represents the state of a given block.