Namespace: Blockly

Classes

Interfaces

Namespaces

Enumerations

ConnectionType

constant   static

number

Enum for the type of a connection or input.

Value

INPUT_VALUE

OUTPUT_VALUE

NEXT_STATEMENT

PREVIOUS_STATEMENT

inputTypes

constant   static

number

Enum for the type of a connection or input.

Value

VALUE

STATEMENT

DUMMY

Properties

alert

static

non-null function(string, optional function())

Wrapper to window.alert() that app developers may override to provide alternatives to the modal browser window.

Deprecated
Use Blockly.dialog.alert / .setAlert() instead. (December 2021)

ALIGN_CENTRE

static

See also
Blockly.Input.Align.CENTRE

ALIGN_LEFT

static

See also
Blockly.Input.Align.LEFT

ALIGN_RIGHT

static

See also
Blockly.Input.Align.RIGHT

confirm

static

non-null function(string, optional function())

Wrapper to window.confirm() that app developers may override to provide alternatives to the modal browser window.

Deprecated
Use Blockly.dialog.confirm / .setConfirm() instead. (December 2021)

ConnectionType

constant   static

number

Enum for the type of a connection or input.

Value

INPUT_VALUE

OUTPUT_VALUE

NEXT_STATEMENT

PREVIOUS_STATEMENT

defineBlocksWithJsonArray

static

Define blocks from an array of JSON block definitions, as might be generated by the Blockly Developer Tools.

Parameter

jsonArray

Array of non-null Object

An array of JSON block definitions.

Value must not be null.

See also
Blockly.common.defineBlocksWithJsonArray

DUMMY_INPUT

static

See also
inputTypes.DUMMY_INPUT

getMainWorkspace

static

Returns the main workspace. Returns the last used main workspace (based on focus). Try not to use this function, particularly if there are multiple Blockly instances on a page.

See also
Blockly.common.getMainWorkspace
Returns

non-null Blockly.Workspace The main workspace.

HSV_SATURATION

static

number

The richness of block colours, regardless of the hue. Must be in the range of 0 (inclusive) to 1 (exclusive).

HSV_VALUE

static

number

The intensity of block colours, regardless of the hue. Must be in the range of 0 (inclusive) to 1 (exclusive).

INPUT_VALUE

static

See also
ConnectionType.INPUT_VALUE

inputTypes

constant   static

number

Enum for the type of a connection or input.

Value

VALUE

STATEMENT

DUMMY

mainWorkspace

static

Blockly.Workspace

The main workspace most recently used. Set by Blockly.WorkspaceSvg.prototype.markFocused

NEXT_STATEMENT

static

See also
ConnectionType.NEXT_STATEMENT

OUTPUT_VALUE

static

See also
ConnectionType.OUTPUT_VALUE

PREVIOUS_STATEMENT

static

See also
ConnectionType.PREVIOUS_STATEMENT

PROCEDURE_CATEGORY_NAME

constant   static

string

String for use in the "custom" attribute of a category in toolbox XML. This string indicates that the category should be dynamically populated with procedure blocks.

prompt

static

non-null function(string, string, optional function())

Wrapper to window.prompt() that app developers may override to provide alternatives to the modal browser window. Built-in browser prompts are often used for better text input experience on mobile device. We strongly recommend testing mobile when overriding this.

Deprecated
Use Blockly.dialog.prompt / .setPrompt() instead. (December 2021)

selected

static

nullable Blockly.ICopyable

Currently selected block.

setParentContainer

static

Set the parent container. This is the container element that the WidgetDiv, dropDownDiv, and Tooltip are rendered into the first time Blockly.inject is called. This method is a NOP if called after the first Blockly.inject.

Parameter

container

Element

The container element.

Value must not be null.

See also
Blockly.common.setParentContainer

svgResize

static

Size the SVG image to completely fill its container. Call this when the view actually changes sizes (e.g. on a window resize/device orientation change). See workspace.resizeContents to resize the workspace when the contents change (e.g. when a block is added or removed). Record the height/width of the SVG image.

Parameter

workspace

Blockly.WorkspaceSvg

Any workspace in the SVG.

Value must not be null.

See also
Blockly.common.svgResize

svgSize

static

Returns the dimensions of the specified SVG image.

Parameter

svg

SVGElement

SVG image.

Value must not be null.

Deprecated
Use workspace.setCachedParentSvgSize. (2021 March 5)
See also
Blockly.WorkspaceSvg.setCachedParentSvgSize
Returns

non-null Size Contains width and height properties.

TOOLBOX_AT_BOTTOM

static

See also
toolbox.Position.BOTTOM

TOOLBOX_AT_LEFT

static

See also
toolbox.Position.LEFT

TOOLBOX_AT_RIGHT

static

See also
toolbox.Position.RIGHT

TOOLBOX_AT_TOP

static

See also
toolbox.Position.TOP

VARIABLE_CATEGORY_NAME

constant   static

string

String for use in the "custom" attribute of a category in toolbox XML. This string indicates that the category should be dynamically populated with variable blocks.

VARIABLE_DYNAMIC_CATEGORY_NAME

constant   static

string

String for use in the "custom" attribute of a category in toolbox XML. This string indicates that the category should be dynamically populated with variable blocks.

VERSION

constant   static

string

Blockly core version. This constant is overridden by the build script (npm run build) to the value of the version in package.json. This is done by the Closure Compiler in the buildCompressed gulp task. For local builds, you can pass --define='Blockly.VERSION=X.Y.Z' to the compiler to override this constant.

Methods

bindEvent_

static

bindEvent_(node, name, thisObject, func) returns browserEvents.Data

Bind an event handler that should be called regardless of whether it is part of the active touch stream. Use this for events that are not part of a multi-part gesture (e.g. mouseover for tooltips).

Parameter

node

EventTarget

Node upon which to listen.

Value must not be null.

name

string

Event name to listen to (e.g. 'mousedown').

thisObject

Object

The value of 'this' in the function.

Value may be null.

func

function()

Function to call when event is triggered.

Value must not be null.

Deprecated
Use Blockly.browserEvents.bind(). (December 2021)
See also
Blockly.browserEvents.bind
Returns

non-null browserEvents.Data Opaque data that can be passed to unbindEvent_.

bindEventWithChecks_

static

bindEventWithChecks_(node, name, thisObject, func, opt_noCaptureIdentifier, opt_noPreventDefault) returns browserEvents.Data

Bind an event handler that can be ignored if it is not part of the active touch stream. Use this for events that either start or continue a multi-part gesture (e.g. mousedown or mousemove, which may be part of a drag or click).

Parameter

node

EventTarget

Node upon which to listen.

Value must not be null.

name

string

Event name to listen to (e.g. 'mousedown').

thisObject

Object

The value of 'this' in the function.

Value may be null.

func

function()

Function to call when event is triggered.

Value must not be null.

opt_noCaptureIdentifier

Optional

boolean

True if triggering on this event should not block execution of other event handlers on this touch or other simultaneous touches. False by default.

opt_noPreventDefault

Optional

boolean

True if triggering on this event should prevent the default handler. False by default. If opt_noPreventDefault is provided, opt_noCaptureIdentifier must also be provided.

Deprecated
Use Blockly.browserEvents.conditionalBind(). (December 2021)
See also
browserEvents.conditionalBind
Returns

non-null browserEvents.Data Opaque data that can be passed to unbindEvent_.

copy

static

copy(toCopy)

Copy a block or workspace comment onto the local clipboard.

Parameter

toCopy

Blockly.ICopyable

Block or Workspace Comment to be copied.

Value must not be null.

Deprecated
Use Blockly.clipboard.copy(). (2021 December)
See also
Blockly.clipboard.copy

duplicate

static

duplicate(toDuplicate)

Duplicate this block and its children, or a workspace comment.

Parameter

toDuplicate

Blockly.ICopyable

Block or Workspace Comment to be copied.

Value must not be null.

Deprecated
Use Blockly.clipboard.duplicate(). (2021 December)
See also
Blockly.clipboard.duplicate

hideChaff

static

hideChaff(opt_onlyClosePopups)

Close tooltips, context menus, dropdown selections, etc.

Parameter

opt_onlyClosePopups

Optional

boolean

Whether only popups should be closed.

See also
Blockly.WorkspaceSvg.hideChaff

hueToHex

static

hueToHex(hue) returns string

Convert a hue (HSV model) into an RGB hex triplet.

Parameter

hue

number

Hue on a colour wheel (0-360).

Deprecated
Use Blockly.utils.colour.hueToHex(). (2021 December)
See also
Blockly.utils.colour.hueToHex
Returns

string RGB code, e.g. '#5ba65b'.

inject

static

inject(container, opt_options) returns Blockly.WorkspaceSvg

Inject a Blockly editor into the specified container element (usually a div).

Parameter

container

(Element or string)

Containing element, or its ID, or a CSS selector.

opt_options

Optional

BlocklyBlockly.Options

Optional dictionary of options.

Returns

non-null Blockly.WorkspaceSvg Newly created main workspace.

isNumber

static

isNumber(str) returns boolean

Is the given string a number (includes negative and decimals).

Parameter

str

string

Input string.

Deprecated
Use Blockly.utils.string.isNumber(str). (2021 December)
See also
Blockly.utils.string.isNumber
Returns

boolean True if number, false otherwise.

paste

static

paste() returns boolean

Paste a block or workspace comment on to the main workspace.

Deprecated
Use Blockly.clipboard.paste(). (2021 December)
See also
Blockly.clipboard.paste
Returns

boolean True if the paste was successful, false otherwise.

resizeSvgContents

static

resizeSvgContents(workspace)

Size the workspace when the contents change. This also updates scrollbars accordingly.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace to resize.

Value must not be null.

Deprecated
Use workspace.resizeContents. (2021 December)
See also
Blockly.WorkspaceSvg.resizeContents

unbindEvent_

static

unbindEvent_(bindData) returns function()

Unbind one or more events event from a function call.

Parameter

bindData

browserEvents.Data

Opaque data from bindEvent_. This list is emptied during the course of calling this function.

Value must not be null.

Deprecated
Use Blockly.browserEvents.unbind(). (December 2021)
See also
browserEvents.unbind
Returns

non-null function() The function call.

Abstract type

IRegistrableField

static

{fromJson:IRegistrableField.fromJson}

A registrable field. Note: We are not using an interface here as we are interested in defining the static methods of a field rather than the instance methods.