See the 2022 Blockly Developer Summit site here.

Namespace: fieldRegistry

Methods

fromJson

package   static

fromJson(options) returns Blockly.Field

Construct a Field from a JSON arg object. Finds the appropriate registered field by the type name as registered using fieldRegistry.register.

Parameter

options

Object

A JSON object with a type and options specific to the field type.

Value must not be null.

Returns

nullable Blockly.Field The new field instance or null if a field wasn't found with the given type name

register

static

register(type, fieldClass)

Registers a field type. fieldRegistry.fromJson uses this registry to find the appropriate field type.

Parameter

type

string

The field type name as used in the JSON definition.

fieldClass

Blockly.IRegistrableField

The field class containing a fromJson function that can construct an instance of the field.

Value must not be null.

Throws

Error if the type name is empty, the field is already registered, or the fieldClass is not an object containing a fromJson function.

unregister

static

unregister(type)

Unregisters the field registered with the given type.

Parameter

type

string

The field type name as used in the JSON definition.