Skip to main content

Class: FieldMultilineInput

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:16

Class for an editable text area input field.

Extends​

  • FieldTextInput

Properties index​

PropertyDescription
ariaTypeNameThe ARIA-friendly label representation of this field's type.
borderRect_The rendered field's SVG border element.
clickTarget_The element the click handler is bound to.
constants_Constants associated with the source block's renderer.
DEFAULT_VALUETo overwrite the default value which is set in Field, directly update the prototype.
EDITABLEEditable fields usually show some sort of UI indicating they are editable. They will also be saved by the serializer.
enabled_Can the field value be changed using the editor on an editable block?
fieldGroup_The rendered field's SVG group element.
fullBlockClickTarget_Whether the field should consider the whole parent block to be its click target.
htmlInput_The HTML input element.
isBeingEdited_True if the field's value is currently being edited via the UI.
isDirty_Does this block need to be re-rendered?
isOverflowedY_Whether Y overflow is currently occurring.
isTextValid_True if the value currently displayed in the field's editory UI is valid.
maxDisplayLengthMaximum characters of text to display before adding an ellipsis.
maxLines_Defines the maximum number of lines of field. If exceeded, scrolling functionality is enabled.
nameName of field. Unique within each block. Static labels are usually unnamed.
SERIALIZABLESerializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.
sourceBlock_Block this field is attached to. Starts as null, then set in init.
spellcheck_Allow browser to spellcheck this field.
textContent_The rendered field's text content element.
textElement_The rendered field's SVG text element.
textGroupThe SVG group element that will contain a text element for each text row when initialized.
validator_Validation function called when user edits an editable field.
value_-
valueWhenEditorWasOpened_The intial value of the field when the user opened an editor to change its value. When the editor is disposed, an event will be fired that uses this as the event's oldValue.
visible_Is the field visible, or hidden due to the block being collapsed?
warningIconThe warning icon to display on invalid input
workspace_The workspace that this field belongs to.
BORDERRADIUSPixel size of input border radius. Should match blocklyText's border-radius in CSS.
EDITOR_MIN_WIDTHMinimum editor width (in SVG/workspace units) when the field is open. Prevents narrow editors when the initial text is very short.
enterCommitsWhether pressing Enter commits the value (default) or inserts a newline.
NBSPNon-breaking space.
showHintWhether to show the keyboard-shortcut hint bar in the editor.
SKIP_SETUPA value used to signal when a field's constructor should not set the field's value or run configure_, and should allow a subclass to do that instead.

Methods index​

MethodDescription
applyColourUpdates text field to match the colour/style of the block.
bindEvents_Bind events to the field. Can be overridden by subclasses if they need to do custom input handling.
bindInputEvents_Bind handlers for user input on the text input field's editor.
canBeFocusedSee IFocusableNode.canBeFocused.
computeAriaLabelComputes a descriptive ARIA label to represent this field with configurable verbosity.
configure_Configure the field based on the given map of options.
createBorderRect_Create a field border rect element. Not to be overridden by subclasses. Instead modify the result of the function inside initView, or create a separate function to call.
createTextElement_Create a field text element. Not to be overridden by subclasses. Instead, modify the result of the function inside initView, or create a separate function to call. Aria state is hidden; use the aria label for the field and/or containing block to expose content to screen readers. Text content for custom blocks can be set after creation.
createWarningIconCreates the DOM elements for the invalid input warning icon.
disposeDispose of all DOM objects and events belonging to this editable field.
doClassValidation_Ensure that the input value casts to a valid string.
doValueInvalid_Called by setValue if the text input is not valid. If the field is currently being edited it reverts value of the field to the previous value while allowing the display text to be handled by the htmlInput_.
doValueUpdate_Called by setValue if the text input is valid. Updates the value of the field, and updates the text of the field if it is not currently being edited (i.e. handled by the htmlInput_). Is being redefined here to update overflow state of the field.
forceRerenderForce a rerender of the block that this field is installed on, which will rerender this field and adjust for any sizing changes. Other fields on the same block will not rerender, because their sizes have already been recorded.
fromXmlSets the field's value based on the given XML element. Should only be called by Blockly.Xml.
getAbsoluteXY_Return the absolute coordinates of the top-left corner of this field. The origin (0,0) is the top-left corner of the page body.
getAriaTypeNameGets an ARIA-friendly label representation of this field's type.
getAriaValueGets an ARIA-friendly label representation of this field's value.
getBorderRectGets the border rectangle element.
getClickTarget_The element to bind the click handler to. If not set explicitly, defaults to the SVG root of the field. When this element is clicked on an editable field, the editor will open.
getConstantsGet the renderer constant provider.
getDisplayText_Get the text from this field as displayed on screen. May differ from getText due to ellipsis, and other formatting.
getEditorText_Transform the provided value into a text to show in the HTML input. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getValueFromEditorText_.
getFlipRtlReturns whether or not we should flip the field in RTL.
getFocusableElementSee IFocusableNode.getFocusableElement.
getFocusableTreeSee IFocusableNode.getFocusableTree.
getMaxLinesReturns the maxLines config of this field.
getSizeReturns the height and width of the field.
getSourceBlockGet the block this field is attached to.
getSvgRootGets the group element for this editable field. Used for measuring the size and for positioning.
getTextGet the text from this field. Override getText_ to provide a different behavior than simply casting the value to a string.
getText_Use the getText_ developer hook to override the field's text representation. When we're currently editing, return the current HTML value instead. Otherwise, return null which tells the field to use the default behaviour (which is a string cast of the field's value).
getTextContentGets the text content.
getTextElementGets the text element.
getTooltipReturns the tooltip text for this field.
getValidatorGets the validation function for editable fields, or null if not set.
getValueGet the current value of the field.
getValueFromEditorText_Transform the text received from the HTML input into a value to store in this field. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getEditorText_.
initModelInitializes the model of the field after it has been installed on a block. No-op by default.
initViewCreate the block UI for this field.
isClickableCheck whether this field defines the showEditor_ function.
isClickableInFlyoutCheck whether the field should be clickable while the block is in a flyout. The default is that fields are clickable in always-open flyouts such as the simple toolbox, but not in autoclosing flyouts such as the category toolbox. Subclasses may override this function to change this behavior. Note that isClickable must also return true for this to have any effect.
isCurrentlyEditableCheck whether this field is currently editable. Some fields are never EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on non-editable blocks or be currently disabled.
isEnabledCheck whether this field's value can be changed using the editor when the source block is editable.
isFullBlockFieldDefines whether this field should take up the full block or not.
isSerializableCheck whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states.
isVisibleGets whether this editable field is visible or not.
loadLegacyStateLoads the given state using either the old XML hooks, if they should be used. Returns true to indicate loading has been handled, false otherwise.
loadStateSets the field's value based on the given state. This function only exists for subclasses of FieldMultilineInput which predate the load/saveState API and only define to/fromXml.
onFinishEditing_A callback triggered when the user is done editing the field via the UI.
onHtmlInputKeyDown_Handle key down to the editor.
onLocationChangeNotifies the field that it has changed locations. Moves the widget div to be in the correct place if it is open.
onMouseDown_Handle a pointerdown event on a field.
onNodeBlurSee IFocusableNode.onNodeBlur.
onNodeFocusSee IFocusableNode.onNodeFocus.
onShortcutHandles the given keyboard shortcut.
performActionHandles the user acting on this field via keyboard navigation. Shows and focuses the field editor.
positionBorderRect_Position a field's border rect after a size change.
positionTextElement_Position a field's text element after a size change. This handles both LTR and RTL positioning.
recomputeAriaContextCustomizes the label for this field to include "editable" if it applies.
referencesVariablesWhether this field references any Blockly variables. If true it may need to be handled differently during serialization and deserialization, and this field's value must correspond to the ID of an existing variable. Subclasses may override this.
refreshVariableNameRefresh the variable name referenced by this field if this field references variables.
render_Updates the text of the textElement.
renderWarningIcon-
repositionForWindowResizeHandles repositioning the WidgetDiv used for input fields when the workspace is resized. Scrolls this field into view, then updates the position of the text input.
resizeEditor_Resize the editor to fit the text.
saveLegacyStateReturns a stringified version of the XML state, if it should be used. Otherwise this returns null, to signal the field should use its own serialization.
saveStateSaves this field's value. This function only exists for subclasses of FieldMultilineInput which predate the load/saveState API and only define to/fromXml.
setAriaTypeNameSets the ARIA-friendly label representation of this field's type.
setEditorValue_Set the HTML input value and the field's internal value. The difference between this and setValue is that this also updates the HTML input value whilst editing.
setEnabledSet whether this field's value can be changed using the editor when the source block is editable.
setMaxLinesSets the maxLines config for this field.
setSourceBlockAttach this field to a block.
setSpellcheckSet whether this field is spellchecked by the browser.
setTooltipSets the tooltip for this field.
setValidatorSets a new validation function for editable fields, or clears a previously set validator.
setValueUsed to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method.
showEditor_Show the inline free-text editor on top of the text. Overrides the default behaviour to force rerender in order to correct block size, based on editor text.
toXmlSerializes this field's value to XML. Should only be called by Blockly.Xml.
unbindInputEvents_Unbind handlers for user input and workspace size changes.
updateEditableAdd or remove the UI indicating if this field is editable or not.
updateSize_Updates the size of the field based on the text.
widgetCreate_Create the text input editor widget.
widgetDispose_Closes the editor, saves the results, and disposes of any events or DOM-references belonging to the editor.
fromJsonConstruct a FieldMultilineInput from a JSON arg object, dereferencing any string table references.

Constructors​

Constructor​

new FieldMultilineInput(
value?,
validator?,
config?
): FieldMultilineInput;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:71

Parameters​

ParameterTypeDescription
value?string | typeof SKIP_SETUPThe initial content of the field. Should cast to a string. Defaults to an empty string if null or undefined. Also accepts Field.SKIP_SETUP if you wish to skip setup (only used by subclasses that want to handle configuration and setting the field value after their own constructors have run).
validator?FieldTextInputValidatorAn optional function that is called to validate any constraints on what the user entered. Takes the new text as an argument and returns either the accepted text, a replacement text, or null to abort the change.
config?FieldMultilineInputConfigA map of options used to configure the field. See the [field creation documentation]https://www.npmjs.com/package/@blockly/field-multilineinput for a list of properties this parameter supports.

Returns​

FieldMultilineInput

Overrides​

Blockly.FieldTextInput.constructor

Properties​

ariaTypeName​

protected ariaTypeName: string | null;

The ARIA-friendly label representation of this field's type.

Inherited from​

Blockly.FieldTextInput.ariaTypeName


borderRect_​

protected borderRect_: SVGRectElement | null;

The rendered field's SVG border element.

Inherited from​

Blockly.FieldTextInput.borderRect_


clickTarget_​

protected clickTarget_: Element | null;

The element the click handler is bound to.

Inherited from​

Blockly.FieldTextInput.clickTarget_


constants_​

protected constants_: ConstantProvider | null;

Constants associated with the source block's renderer.

Inherited from​

Blockly.FieldTextInput.constants_


DEFAULT_VALUE​

DEFAULT_VALUE: string | null;

To overwrite the default value which is set in Field, directly update the prototype.

Example: FieldImage.prototype.DEFAULT_VALUE = null;

Inherited from​

Blockly.FieldTextInput.DEFAULT_VALUE


EDITABLE​

EDITABLE: boolean;

Editable fields usually show some sort of UI indicating they are editable. They will also be saved by the serializer.

Inherited from​

Blockly.FieldTextInput.EDITABLE


enabled_​

protected enabled_: boolean;

Can the field value be changed using the editor on an editable block?

Inherited from​

Blockly.FieldTextInput.enabled_


fieldGroup_​

protected fieldGroup_: SVGGElement | null;

The rendered field's SVG group element.

Inherited from​

Blockly.FieldTextInput.fieldGroup_


fullBlockClickTarget_​

fullBlockClickTarget_: boolean;

Whether the field should consider the whole parent block to be its click target.

Inherited from​

Blockly.FieldTextInput.fullBlockClickTarget_


htmlInput_​

protected htmlInput_: HTMLInputElement | null;

The HTML input element.

Inherited from​

Blockly.FieldTextInput.htmlInput_


isBeingEdited_​

protected isBeingEdited_: boolean;

True if the field's value is currently being edited via the UI.

Inherited from​

Blockly.FieldTextInput.isBeingEdited_


isDirty_​

protected isDirty_: boolean;

Does this block need to be re-rendered?

Inherited from​

Blockly.FieldTextInput.isDirty_


isOverflowedY_​

protected isOverflowedY_: boolean = false;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:39

Whether Y overflow is currently occurring.


isTextValid_​

protected isTextValid_: boolean;

True if the value currently displayed in the field's editory UI is valid.

Inherited from​

Blockly.FieldTextInput.isTextValid_


maxDisplayLength​

maxDisplayLength: number;

Maximum characters of text to display before adding an ellipsis.

Inherited from​

Blockly.FieldTextInput.maxDisplayLength


maxLines_​

protected maxLines_: number = Infinity;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:35

Defines the maximum number of lines of field. If exceeded, scrolling functionality is enabled.


name?​

name?: string;

Name of field. Unique within each block. Static labels are usually unnamed.

Inherited from​

Blockly.FieldTextInput.name


SERIALIZABLE​

SERIALIZABLE: boolean;

Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.

Inherited from​

Blockly.FieldTextInput.SERIALIZABLE


sourceBlock_​

protected sourceBlock_: Block | null;

Block this field is attached to. Starts as null, then set in init.

Inherited from​

Blockly.FieldTextInput.sourceBlock_


spellcheck_​

protected spellcheck_: boolean;

Allow browser to spellcheck this field.

Inherited from​

Blockly.FieldTextInput.spellcheck_


textContent_​

protected textContent_: Text | null;

The rendered field's text content element.

Inherited from​

Blockly.FieldTextInput.textContent_


textElement_​

protected textElement_: SVGTextElement | null;

The rendered field's SVG text element.

Inherited from​

Blockly.FieldTextInput.textElement_


textGroup​

textGroup: SVGGElement | null = null;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:28

The SVG group element that will contain a text element for each text row when initialized.


validator_​

protected validator_: FieldValidator<string> | null;

Validation function called when user edits an editable field.

Inherited from​

Blockly.FieldTextInput.validator_


value_​

protected value_: string | null;

Inherited from​

Blockly.FieldTextInput.value_


valueWhenEditorWasOpened_​

protected valueWhenEditorWasOpened_: string | null;

The intial value of the field when the user opened an editor to change its value. When the editor is disposed, an event will be fired that uses this as the event's oldValue.

Inherited from​

Blockly.FieldTextInput.valueWhenEditorWasOpened_


visible_​

protected visible_: boolean;

Is the field visible, or hidden due to the block being collapsed?

Inherited from​

Blockly.FieldTextInput.visible_


warningIcon​

protected warningIcon: SVGElement | null;

The warning icon to display on invalid input

Inherited from​

Blockly.FieldTextInput.warningIcon


workspace_​

protected workspace_: WorkspaceSvg | null;

The workspace that this field belongs to.

Inherited from​

Blockly.FieldTextInput.workspace_


BORDERRADIUS​

static BORDERRADIUS: number;

Pixel size of input border radius. Should match blocklyText's border-radius in CSS.

Inherited from​

Blockly.FieldTextInput.BORDERRADIUS


EDITOR_MIN_WIDTH​

readonly static EDITOR_MIN_WIDTH: 150 = 150;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:22

Minimum editor width (in SVG/workspace units) when the field is open. Prevents narrow editors when the initial text is very short.


enterCommits​

static enterCommits: boolean = true;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:42

Whether pressing Enter commits the value (default) or inserts a newline.


NBSP​

readonly static NBSP: " " = "\u00A0";

Non-breaking space.

Inherited from​

Blockly.FieldTextInput.NBSP


showHint​

static showHint: boolean = true;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:45

Whether to show the keyboard-shortcut hint bar in the editor.


SKIP_SETUP​

readonly static SKIP_SETUP: typeof SKIP_SETUP;

A value used to signal when a field's constructor should not set the field's value or run configure_, and should allow a subclass to do that instead.

Inherited from​

Blockly.FieldTextInput.SKIP_SETUP

Accessors​

size_​

Get Signature​

get protected size_(): Size;

Returns the size of this field, with a minimum width of 14.

Returns​

Size

Set Signature​

set protected size_(newValue): void;

Gets the size of this field. Because getSize() and updateSize() have side effects, this acts as a shim for subclasses which wish to adjust field bounds when setting/getting the size without triggering unwanted rendering or other side effects. Note that subclasses must override both get and set if either is overridden; the implementation may just call directly through to super, but it must exist per the JS spec.

Parameters​
ParameterType
newValueSize
Returns​

void

Inherited from​

Blockly.FieldTextInput.size_

Methods​

applyColour()​

applyColour(): void;

Updates text field to match the colour/style of the block.

Returns​

void

Inherited from​

Blockly.FieldTextInput.applyColour


bindEvents_()​

protected bindEvents_(): void;

Bind events to the field. Can be overridden by subclasses if they need to do custom input handling.

Returns​

void

Inherited from​

Blockly.FieldTextInput.bindEvents_


bindInputEvents_()​

protected bindInputEvents_(htmlInput): void;

Bind handlers for user input on the text input field's editor.

Parameters​

ParameterTypeDescription
htmlInputHTMLElementThe htmlInput to which event handlers will be bound.

Returns​

void

Inherited from​

Blockly.FieldTextInput.bindInputEvents_


canBeFocused()​

canBeFocused(): boolean;

See IFocusableNode.canBeFocused.

Returns​

boolean

Inherited from​

Blockly.FieldTextInput.canBeFocused


computeAriaLabel()​

computeAriaLabel(includeTypeInfo?): string;

Computes a descriptive ARIA label to represent this field with configurable verbosity.

A 'verbose' label includes type information, if available, whereas a non-verbose label only contains the field's value.

Note that this will always return the latest representation of the field's label which may differ from any previously set ARIA label for the field itself. Implementations are largely responsible for ensuring that the field's ARIA label is set correctly at relevant moments in the field's lifecycle (such as when its value changes).

Finally, it is never guaranteed that implementations use the label returned by this method for their actual ARIA label. Some implementations may rely on other contexts to convey information like the field's value. Example: checkboxes represent their checked/non-checked status (i.e. value) through a separate ARIA property.

If the field's value is empty then it will return a localized placeholder indicating that its value is empty. If this method returns an empty string, the output will be ignored when composing the block-level ARIA label. Make sure you want your label hidden from screenreaders before returning an empty string.

Parameters​

ParameterTypeDescription
includeTypeInfo?booleanWhether to include the field's type information in the returned label, if available.

Returns​

string

Inherited from​

Blockly.FieldTextInput.computeAriaLabel


configure_()​

protected configure_(config): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:94

Configure the field based on the given map of options.

Parameters​

ParameterTypeDescription
configFieldMultilineInputConfigA map of options to configure the field based on.

Returns​

void

Overrides​

Blockly.FieldTextInput.configure_


createBorderRect_()​

protected createBorderRect_(): void;

Create a field border rect element. Not to be overridden by subclasses. Instead modify the result of the function inside initView, or create a separate function to call.

Returns​

void

Inherited from​

Blockly.FieldTextInput.createBorderRect_


createTextElement_()​

protected createTextElement_(): void;

Create a field text element. Not to be overridden by subclasses. Instead, modify the result of the function inside initView, or create a separate function to call. Aria state is hidden; use the aria label for the field and/or containing block to expose content to screen readers. Text content for custom blocks can be set after creation.

Returns​

void

Inherited from​

Blockly.FieldTextInput.createTextElement_


createWarningIcon()​

protected createWarningIcon(): SVGElement | null;

Creates the DOM elements for the invalid input warning icon.

Returns​

SVGElement | null

Inherited from​

Blockly.FieldTextInput.createWarningIcon


dispose()​

dispose(): void;

Dispose of all DOM objects and events belonging to this editable field.

Returns​

void

Inherited from​

Blockly.FieldTextInput.dispose


doClassValidation_()​

protected doClassValidation_(newValue?): string | null;

Ensure that the input value casts to a valid string.

Parameters​

ParameterTypeDescription
newValue?anyThe input value.

Returns​

string | null

A valid string, or null if invalid.

Inherited from​

Blockly.FieldTextInput.doClassValidation_


doValueInvalid_()​

protected doValueInvalid_(_invalidValue, fireChangeEvent?): void;

Called by setValue if the text input is not valid. If the field is currently being edited it reverts value of the field to the previous value while allowing the display text to be handled by the htmlInput_.

Parameters​

ParameterTypeDescription
_invalidValueanyThe input value that was determined to be invalid. This is not used by the text input because its display value is stored on the htmlInput_.
fireChangeEvent?booleanWhether to fire a change event if the value changes.

Returns​

void

Inherited from​

Blockly.FieldTextInput.doValueInvalid_


doValueUpdate_()​

protected doValueUpdate_(newValue): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:234

Called by setValue if the text input is valid. Updates the value of the field, and updates the text of the field if it is not currently being edited (i.e. handled by the htmlInput_). Is being redefined here to update overflow state of the field.

Parameters​

ParameterTypeDescription
newValuestringThe value to be saved. The default validator guarantees that this is a string.

Returns​

void

Overrides​

Blockly.FieldTextInput.doValueUpdate_


forceRerender()​

forceRerender(): void;

Force a rerender of the block that this field is installed on, which will rerender this field and adjust for any sizing changes. Other fields on the same block will not rerender, because their sizes have already been recorded.

Returns​

void

Inherited from​

Blockly.FieldTextInput.forceRerender


fromXml()​

fromXml(fieldElement): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:125

Sets the field's value based on the given XML element. Should only be called by Blockly.Xml.

Parameters​

ParameterTypeDescription
fieldElementElementThe element containing info about the field's state.

Returns​

void

Overrides​

Blockly.FieldTextInput.fromXml


getAbsoluteXY_()​

protected getAbsoluteXY_(): Coordinate;

Return the absolute coordinates of the top-left corner of this field. The origin (0,0) is the top-left corner of the page body.

Returns​

Coordinate

Object with .x and .y properties.

Inherited from​

Blockly.FieldTextInput.getAbsoluteXY_


getAriaTypeName()​

getAriaTypeName(): string | null;

Gets an ARIA-friendly label representation of this field's type.

Implementations are responsible for, and encouraged to, return a localized version of the ARIA representation of the field's type.

Returns​

string | null

An ARIA representation of the field's type or a default if it is unspecified.

Inherited from​

Blockly.FieldTextInput.getAriaTypeName


getAriaValue()​

getAriaValue(): string | null;

Gets an ARIA-friendly label representation of this field's value.

Implementations are responsible for, and encouraged to, return a localized version of the ARIA representation of the field's value.

Returns​

string | null

An ARIA representation of the field's text.

Inherited from​

Blockly.FieldTextInput.getAriaValue


getBorderRect()​

protected getBorderRect(): SVGRectElement;

Gets the border rectangle element.

Returns​

SVGRectElement

The border rectangle element.

Throws​

An error if the border rectangle element is not defined.

Inherited from​

Blockly.FieldTextInput.getBorderRect


getClickTarget_()​

protected getClickTarget_(): Element | null;

The element to bind the click handler to. If not set explicitly, defaults to the SVG root of the field. When this element is clicked on an editable field, the editor will open.

Returns​

Element | null

Element to bind click handler to.

Inherited from​

Blockly.FieldTextInput.getClickTarget_


getConstants()​

getConstants(): ConstantProvider | null;

Get the renderer constant provider.

Returns​

ConstantProvider | null

The renderer constant provider.

Inherited from​

Blockly.FieldTextInput.getConstants


getDisplayText_()​

protected getDisplayText_(): string;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:182

Get the text from this field as displayed on screen. May differ from getText due to ellipsis, and other formatting.

Returns​

string

Currently displayed text.

Overrides​

Blockly.FieldTextInput.getDisplayText_


getEditorText_()​

protected getEditorText_(value): string;

Transform the provided value into a text to show in the HTML input. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getValueFromEditorText_.

Parameters​

ParameterTypeDescription
valueanyThe value stored in this field.

Returns​

string

The text to show on the HTML input.

Inherited from​

Blockly.FieldTextInput.getEditorText_


getFlipRtl()​

getFlipRtl(): boolean;

Returns whether or not we should flip the field in RTL.

Returns​

boolean

True if we should flip in RTL.

Inherited from​

Blockly.FieldTextInput.getFlipRtl


getFocusableElement()​

getFocusableElement(): SVGElement | HTMLElement;

See IFocusableNode.getFocusableElement.

Returns​

SVGElement | HTMLElement

Inherited from​

Blockly.FieldTextInput.getFocusableElement


getFocusableTree()​

getFocusableTree(): IFocusableTree;

See IFocusableNode.getFocusableTree.

Returns​

IFocusableTree

Inherited from​

Blockly.FieldTextInput.getFocusableTree


getMaxLines()​

getMaxLines(): number;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:603

Returns the maxLines config of this field.

Returns​

number

The maxLines config value.


getSize()​

getSize(): Size;

Returns the height and width of the field.

This should in general be the only place render_ gets called from.

Returns​

Size

Height and width.

Inherited from​

Blockly.FieldTextInput.getSize


getSourceBlock()​

getSourceBlock(): Block | null;

Get the block this field is attached to.

Returns​

Block | null

The block containing this field.

Throws​

An error if the source block is not defined.

Inherited from​

Blockly.FieldTextInput.getSourceBlock


getSvgRoot()​

getSvgRoot(): SVGGElement | null;

Gets the group element for this editable field. Used for measuring the size and for positioning.

Returns​

SVGGElement | null

The group element.

Inherited from​

Blockly.FieldTextInput.getSvgRoot


getText()​

getText(): string;

Sealed

Get the text from this field. Override getText_ to provide a different behavior than simply casting the value to a string.

Returns​

string

Current text.

Inherited from​

Blockly.FieldTextInput.getText


getText_()​

protected getText_(): string | null;

Use the getText_ developer hook to override the field's text representation. When we're currently editing, return the current HTML value instead. Otherwise, return null which tells the field to use the default behaviour (which is a string cast of the field's value).

Returns​

string | null

The HTML value if we're editing, otherwise null.

Inherited from​

Blockly.FieldTextInput.getText_


getTextContent()​

protected getTextContent(): Text;

Gets the text content.

Returns​

Text

The text content.

Throws​

An error if the text content is not defined.

Inherited from​

Blockly.FieldTextInput.getTextContent


getTextElement()​

protected getTextElement(): SVGTextElement;

Gets the text element.

Returns​

SVGTextElement

The text element.

Throws​

An error if the text element is not defined.

Inherited from​

Blockly.FieldTextInput.getTextElement


getTooltip()​

getTooltip(): string;

Returns the tooltip text for this field.

Returns​

string

The tooltip text for this field.

Inherited from​

Blockly.FieldTextInput.getTooltip


getValidator()​

getValidator(): FieldValidator<string> | null;

Gets the validation function for editable fields, or null if not set.

Returns​

FieldValidator<string> | null

Validation function, or null.

Inherited from​

Blockly.FieldTextInput.getValidator


getValue()​

getValue(): string | null;

Get the current value of the field.

Returns​

string | null

Current value.

Inherited from​

Blockly.FieldTextInput.getValue


getValueFromEditorText_()​

protected getValueFromEditorText_(text): any;

Transform the text received from the HTML input into a value to store in this field. Override this method if the field's HTML input representation is different than the field's value. This should be coupled with an override of getEditorText_.

Parameters​

ParameterTypeDescription
textstringText received from the HTML input.

Returns​

any

The value to store.

Inherited from​

Blockly.FieldTextInput.getValueFromEditorText_


initModel()​

initModel(): void;

Initializes the model of the field after it has been installed on a block. No-op by default.

Returns​

void

Inherited from​

Blockly.FieldTextInput.initModel


initView()​

initView(): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:161

Create the block UI for this field.

Returns​

void

Overrides​

Blockly.FieldTextInput.initView


isClickable()​

isClickable(): boolean;

Check whether this field defines the showEditor_ function.

Returns​

boolean

Whether this field is clickable.

Inherited from​

Blockly.FieldTextInput.isClickable


isClickableInFlyout()​

isClickableInFlyout(autoClosingFlyout): boolean;

Check whether the field should be clickable while the block is in a flyout. The default is that fields are clickable in always-open flyouts such as the simple toolbox, but not in autoclosing flyouts such as the category toolbox. Subclasses may override this function to change this behavior. Note that isClickable must also return true for this to have any effect.

Parameters​

ParameterTypeDescription
autoClosingFlyoutbooleantrue if the containing flyout is an auto-closing one.

Returns​

boolean

Whether the field should be clickable while the block is in a flyout.

Inherited from​

Blockly.FieldTextInput.isClickableInFlyout


isCurrentlyEditable()​

isCurrentlyEditable(): boolean;

Check whether this field is currently editable. Some fields are never EDITABLE (e.g. text labels). Other fields may be EDITABLE but may exist on non-editable blocks or be currently disabled.

Returns​

boolean

Whether this field is currently enabled, editable and on an editable block.

Inherited from​

Blockly.FieldTextInput.isCurrentlyEditable


isEnabled()​

isEnabled(): boolean;

Check whether this field's value can be changed using the editor when the source block is editable.

Returns​

boolean

Whether this field is enabled.

Inherited from​

Blockly.FieldTextInput.isEnabled


isFullBlockField()​

isFullBlockField(): boolean;

Defines whether this field should take up the full block or not.

This is typically only done for certain kinds of fields and in certain renderers. You should only override this if you're sure your field will render correctly in zelos and other renderers that support full-block fields.

Blocks that contain only a single field that is a full-block-field have a special appearance in some renderers and their behavior is unique, because we pretend that the field is a whole block in some cases. This is hacky and you should use caution when attempting to do anything with this method.

Returns​

boolean

Inherited from​

Blockly.FieldTextInput.isFullBlockField


isSerializable()​

isSerializable(): boolean;

Check whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states.

Returns​

boolean

Whether this field should be serialized or not.

Inherited from​

Blockly.FieldTextInput.isSerializable


isVisible()​

isVisible(): boolean;

Gets whether this editable field is visible or not.

Returns​

boolean

True if visible.

Inherited from​

Blockly.FieldTextInput.isVisible


loadLegacyState()​

loadLegacyState(callingClass, state): boolean;

Loads the given state using either the old XML hooks, if they should be used. Returns true to indicate loading has been handled, false otherwise.

Parameters​

ParameterTypeDescription
callingClassFieldProtoThe class calling this method. Used to see if this has overridden any relevant hooks.
stateanyThe state to apply to the field.

Returns​

boolean

Whether the state was applied or not.

Inherited from​

Blockly.FieldTextInput.loadLegacyState


loadState()​

loadState(state): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:151

Sets the field's value based on the given state. This function only exists for subclasses of FieldMultilineInput which predate the load/saveState API and only define to/fromXml.

Parameters​

ParameterTypeDescription
stateunknownThe state of the variable to assign to this variable field.

Returns​

void

Overrides​

Blockly.FieldTextInput.loadState


onFinishEditing_()​

onFinishEditing_(_value): void;

A callback triggered when the user is done editing the field via the UI.

Parameters​

ParameterTypeDescription
_valueanyThe new value of the field.

Returns​

void

Inherited from​

Blockly.FieldTextInput.onFinishEditing_


onHtmlInputKeyDown_()​

protected onHtmlInputKeyDown_(e): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:617

Handle key down to the editor.

Enter commits the value and closes the editor (matching FieldTextInput). Shift+Enter inserts a newline at the cursor. All other keys are handled by the parent class (Escape reverts, Tab navigates).

Parameters​

ParameterTypeDescription
eKeyboardEventKeyboard event.

Returns​

void

Overrides​

Blockly.FieldTextInput.onHtmlInputKeyDown_


onLocationChange()​

onLocationChange(): void;

Notifies the field that it has changed locations. Moves the widget div to be in the correct place if it is open.

Returns​

void

Inherited from​

Blockly.FieldTextInput.onLocationChange


onMouseDown_()​

protected onMouseDown_(e): void;

Handle a pointerdown event on a field.

Parameters​

ParameterTypeDescription
ePointerEventPointer down event.

Returns​

void

Inherited from​

Blockly.FieldTextInput.onMouseDown_


onNodeBlur()​

onNodeBlur(): void;

See IFocusableNode.onNodeBlur.

Returns​

void

Inherited from​

Blockly.FieldTextInput.onNodeBlur


onNodeFocus()​

onNodeFocus(): void;

See IFocusableNode.onNodeFocus.

Returns​

void

Inherited from​

Blockly.FieldTextInput.onNodeFocus


onShortcut()​

onShortcut(_shortcut): boolean;

Handles the given keyboard shortcut.

Parameters​

ParameterTypeDescription
_shortcutKeyboardShortcutThe shortcut to be handled.

Returns​

boolean

True if the shortcut has been handled, false otherwise.

Inherited from​

Blockly.FieldTextInput.onShortcut


performAction()​

performAction(): void;

Handles the user acting on this field via keyboard navigation. Shows and focuses the field editor.

Returns​

void

Inherited from​

Blockly.FieldTextInput.performAction


positionBorderRect_()​

protected positionBorderRect_(): void;

Position a field's border rect after a size change.

Returns​

void

Inherited from​

Blockly.FieldTextInput.positionBorderRect_


positionTextElement_()​

protected positionTextElement_(xMargin, contentWidth): void;

Position a field's text element after a size change. This handles both LTR and RTL positioning.

Parameters​

ParameterTypeDescription
xMarginnumberx offset to use when positioning the text element.
contentWidthnumberThe content width.

Returns​

void

Inherited from​

Blockly.FieldTextInput.positionTextElement_


recomputeAriaContext()​

recomputeAriaContext(): boolean;

Customizes the label for this field to include "editable" if it applies.

Returns​

boolean

Inherited from​

Blockly.FieldTextInput.recomputeAriaContext


referencesVariables()​

referencesVariables(): boolean;

Whether this field references any Blockly variables. If true it may need to be handled differently during serialization and deserialization, and this field's value must correspond to the ID of an existing variable. Subclasses may override this.

Returns​

boolean

True if this field has any variable references.

Inherited from​

Blockly.FieldTextInput.referencesVariables


refreshVariableName()​

refreshVariableName(): void;

Refresh the variable name referenced by this field if this field references variables.

Returns​

void

Inherited from​

Blockly.FieldTextInput.refreshVariableName


render_()​

protected render_(): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:243

Updates the text of the textElement.

Returns​

void

Overrides​

Blockly.FieldTextInput.render_


renderWarningIcon()​

protected renderWarningIcon(rtl, isValid): void;

Parameters​

ParameterType
rtlboolean
isValidboolean

Returns​

void

Inherited from​

Blockly.FieldTextInput.renderWarningIcon


repositionForWindowResize()​

repositionForWindowResize(): boolean;

Handles repositioning the WidgetDiv used for input fields when the workspace is resized. Scrolls this field into view, then updates the position of the text input.

Returns​

boolean

True for rendered workspaces, as we never want to hide the widget div.

Inherited from​

Blockly.FieldTextInput.repositionForWindowResize


resizeEditor_()​

protected resizeEditor_(): void;

Resize the editor to fit the text.

Returns​

void

Inherited from​

Blockly.FieldTextInput.resizeEditor_


saveLegacyState()​

protected saveLegacyState(callingClass): string | null;

Returns a stringified version of the XML state, if it should be used. Otherwise this returns null, to signal the field should use its own serialization.

Parameters​

ParameterTypeDescription
callingClassFieldProtoThe class calling this method. Used to see if this has overridden any relevant hooks.

Returns​

string | null

The stringified version of the XML state, or null.

Inherited from​

Blockly.FieldTextInput.saveLegacyState


saveState()​

saveState(): string | null;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:136

Saves this field's value. This function only exists for subclasses of FieldMultilineInput which predate the load/saveState API and only define to/fromXml.

Returns​

string | null

The state of this field.

Overrides​

Blockly.FieldTextInput.saveState


setAriaTypeName()​

setAriaTypeName(ariaTypeName): void;

Sets the ARIA-friendly label representation of this field's type.

Implementations are responsible for, and encouraged to, set a localized version of the ARIA representation of the field's type. To that end, the provided value may contain message references of the form %{BKY_...} (e.g. %{BKY_MY_FIELD_ARIA_TYPE}), which are replaced with the corresponding Blockly.Msg value.

Parameters​

ParameterTypeDescription
ariaTypeNamestringAn ARIA representation of the field's type.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setAriaTypeName


setEditorValue_()​

protected setEditorValue_(newValue, fireChangeEvent?): void;

Set the HTML input value and the field's internal value. The difference between this and setValue is that this also updates the HTML input value whilst editing.

Parameters​

ParameterTypeDescription
newValueanyNew value.
fireChangeEvent?booleanWhether to fire a change event. Defaults to true. Should usually be true unless the change will be reported some other way, e.g. an intermediate field change event.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setEditorValue_


setEnabled()​

setEnabled(enabled): void;

Set whether this field's value can be changed using the editor when the source block is editable.

Parameters​

ParameterTypeDescription
enabledbooleanTrue if enabled.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setEnabled


setMaxLines()​

setMaxLines(maxLines): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:587

Sets the maxLines config for this field.

Parameters​

ParameterTypeDescription
maxLinesnumberDefines the maximum number of lines allowed, before scrolling functionality is enabled.

Returns​

void


setSourceBlock()​

setSourceBlock(block): void;

Attach this field to a block.

Parameters​

ParameterTypeDescription
blockBlockThe block containing this field.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setSourceBlock


setSpellcheck()​

setSpellcheck(check): void;

Set whether this field is spellchecked by the browser.

Parameters​

ParameterTypeDescription
checkbooleanTrue if checked.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setSpellcheck


setTooltip()​

setTooltip(newTip): void;

Sets the tooltip for this field.

Parameters​

ParameterTypeDescription
newTipTipInfo | nullThe text for the tooltip, a function that returns the text for the tooltip, a parent object whose tooltip will be used, or null to display the tooltip of the parent block. To not display a tooltip pass the empty string.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setTooltip


setValidator()​

setValidator(handler): void;

Sets a new validation function for editable fields, or clears a previously set validator.

The validator function takes in the new field value, and returns validated value. The validated value could be the input value, a modified version of the input value, or null to abort the change.

If the function does not return anything (or returns undefined) the new value is accepted as valid. This is to allow for fields using the validated function as a field-level change event notification.

Parameters​

ParameterTypeDescription
handlerFieldValidator<string>The validator function or null to clear a previous validator.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setValidator


setValue()​

setValue(newValue, fireChangeEvent?): void;

Sealed

Used to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method.

Parameters​

ParameterTypeDescription
newValueanyNew value.
fireChangeEvent?booleanWhether to fire a change event. Defaults to true. Should usually be true unless the change will be reported some other way, e.g. an intermediate field change event.

Returns​

void

Inherited from​

Blockly.FieldTextInput.setValue


showEditor_()​

showEditor_(e?, quietInput?): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:433

Show the inline free-text editor on top of the text. Overrides the default behaviour to force rerender in order to correct block size, based on editor text.

Parameters​

ParameterTypeDescription
e?EventOptional mouse event that triggered the field to open, or undefined if triggered programmatically.
quietInput?booleanTrue if editor should be created without focus. Defaults to false.

Returns​

void

Overrides​

Blockly.FieldTextInput.showEditor_


toXml()​

toXml(fieldElement): Element;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:107

Serializes this field's value to XML. Should only be called by Blockly.Xml.

Parameters​

ParameterTypeDescription
fieldElementElementThe element to populate with info about the field's state.

Returns​

Element

The element containing info about the field's state.

Overrides​

Blockly.FieldTextInput.toXml


unbindInputEvents_()​

protected unbindInputEvents_(): void;

Unbind handlers for user input and workspace size changes.

Returns​

void

Inherited from​

Blockly.FieldTextInput.unbindInputEvents_


updateEditable()​

updateEditable(): void;

Add or remove the UI indicating if this field is editable or not.

Returns​

void

Inherited from​

Blockly.FieldTextInput.updateEditable


updateSize_()​

protected updateSize_(): void;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:328

Updates the size of the field based on the text.

Returns​

void

Overrides​

Blockly.FieldTextInput.updateSize_


widgetCreate_()​

protected widgetCreate_(): HTMLTextAreaElement;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:444

Create the text input editor widget.

Returns​

HTMLTextAreaElement

The newly created text input editor.

Overrides​

Blockly.FieldTextInput.widgetCreate_


widgetDispose_()​

protected widgetDispose_(): void;

Closes the editor, saves the results, and disposes of any events or DOM-references belonging to the editor.

Returns​

void

Inherited from​

Blockly.FieldTextInput.widgetDispose_


fromJson()​

static fromJson(options): FieldMultilineInput;

Defined in: plugins/field-multilineinput/src/field_multilineinput.ts:670

Construct a FieldMultilineInput from a JSON arg object, dereferencing any string table references.

Parameters​

ParameterTypeDescription
optionsFieldMultilineInputFromJsonConfigA JSON object with options (text, and spellcheck).

Returns​

FieldMultilineInput

The new field instance.

Nocollapse​

Overrides​

Blockly.FieldTextInput.fromJson