Class: FieldDate
Defined in: plugins/field-date/src/field_date.ts:16
Class for a date input field.
Extends
FieldTextInput
Properties index
| Property | Description |
|---|---|
| ariaTypeName | The 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_VALUE | To overwrite the default value which is set in Field, directly update the prototype. |
| EDITABLE | Editable 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? |
| isTextValid_ | True if the value currently displayed in the field's editory UI is valid. |
| maxDisplayLength | Maximum characters of text to display before adding an ellipsis. |
| name | Name of field. Unique within each block. Static labels are usually unnamed. |
| SERIALIZABLE | Serializable fields are saved by the XML renderer, 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. |
| 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? |
| warningIcon | The warning icon to display on invalid input |
| workspace_ | The workspace that this field belongs to. |
| BORDERRADIUS | Pixel size of input border radius. Should match blocklyText's border-radius in CSS. |
| NBSP | Non-breaking space. |
| 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. |
Methods index
| Method | Description |
|---|---|
| applyColour | Updates 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. |
| canBeFocused | See IFocusableNode.canBeFocused. |
| computeAriaLabel | Computes a descriptive ARIA label to represent this field with configurable verbosity. |
| configure_ | Process the configuration map passed to the field. |
| 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. |
| createWarningIcon | Creates the DOM elements for the invalid input warning icon. |
| dispose | Dispose of all DOM objects and events belonging to this editable field. |
| doClassValidation_ | Ensures that the input value is a valid date. Additionally, if the date string provided includes a time, the time will be removed and the date for relative to the user's timezone will be used. |
| 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_). |
| forceRerender | 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. |
| fromXml | Sets 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. |
| getAriaTypeName | Returns a description of the type of this field for screenreaders. |
| getAriaValue | Returns a description of the current date for use by screenreaders. |
| getBorderRect | Gets 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. |
| getConstants | Get the renderer constant provider. |
| getDisplayText_ | Get the text from this field to display on the block. 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_. |
| getFlipRtl | Returns whether or not we should flip the field in RTL. |
| getFocusableElement | See IFocusableNode.getFocusableElement. |
| getFocusableTree | See IFocusableNode.getFocusableTree. |
| getSize | Returns the height and width of the field. |
| getSourceBlock | Get the block this field is attached to. |
| getSvgRoot | Gets the group element for this editable field. Used for measuring the size and for positioning. |
| getText | Get the text from this field. Override getText_ to provide a different behavior than simply casting the value to a string. |
| getText_ | Get the text to display on the block when the input hasn't spawned in. |
| getTextContent | Gets the text content. |
| getTextElement | Gets the text element. |
| getTooltip | Returns the tooltip text for this field. |
| getValidator | Gets the validation function for editable fields, or null if not set. |
| getValue | Get 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_. |
| initModel | Initializes the model of the field after it has been installed on a block. No-op by default. |
| initView | - |
| isClickable | Check whether this field defines the showEditor_ function. |
| isClickableInFlyout | 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. |
| isCurrentlyEditable | 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. |
| isEnabled | Check whether this field's value can be changed using the editor when the source block is editable. |
| isFullBlockField | Defines whether this field should take up the full block or not. |
| isSerializable | Check whether this field should be serialized by the XML renderer. Handles the logic for backwards compatibility and incongruous states. |
| isVisible | Gets whether this editable field is visible or not. |
| loadLegacyState | 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. |
| loadState | Sets the field's state based on the given state value. Should only be called by the serialization system. |
| onFinishEditing_ | A callback triggered when the user is done editing the field via the UI. |
| onHtmlInputKeyDown_ | Handle key down to the editor. |
| onLocationChange | Notifies 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. |
| onNodeBlur | See IFocusableNode.onNodeBlur. |
| onNodeFocus | See IFocusableNode.onNodeFocus. |
| onShortcut | Handles the given keyboard shortcut. |
| performAction | Handles 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. |
| recomputeAriaContext | Customizes the label for this field to include "editable" if it applies. |
| referencesVariables | 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. |
| refreshVariableName | Refresh the variable name referenced by this field if this field references variables. |
| render_ | Renders the field. If the picker is shown make sure it has the current date selected. |
| renderWarningIcon | - |
| repositionForWindowResize | 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. |
| resizeEditor_ | Resize the editor to fit the text. |
| saveLegacyState | 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. |
| saveState | Saves this fields value as something which can be serialized to JSON. Should only be called by the serialization system. |
| setAriaTypeName | Sets 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. |
| setEnabled | Set whether this field's value can be changed using the editor when the source block is editable. |
| setSourceBlock | Attach this field to a block. |
| setSpellcheck | Set whether this field is spellchecked by the browser. |
| setTooltip | Sets the tooltip for this field. |
| setValidator | Sets a new validation function for editable fields, or clears a previously set validator. |
| setValue | Used to change the value of the field. Handles validation and events. Subclasses should override doClassValidation_ and doValueUpdate_ rather than this method. |
| showEditor_ | Shows the inline free-text editor on top of the text along with the date editor. |
| toXml | Serializes this field's value to XML. Should only be called by Blockly.Xml. |
| unbindInputEvents_ | Unbind handlers for user input and workspace size changes. |
| updateEditable | Add 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 html input and set it to type date. |
| widgetDispose_ | Closes the editor, saves the results, and disposes of any events or DOM-references belonging to the editor. |
| fromJson | Constructs a FieldDate from a JSON arg object. |
Constructors
Constructor
new FieldDate(
value?,
validator?,
config?
): FieldDate;
Defined in: plugins/field-date/src/field_date.ts:35
Class for a date input field. Derived from the Closure library date picker.
Parameters
| Parameter | Type | Description |
|---|---|---|
value? | string | The initial value of the field. Should be in 'YYYY-MM-DD' format. Defaults to the current date. |
validator? | FieldTextInputValidator | A function that is called to validate changes to the field's value. Takes in a date string & returns a validated date string ('YYYY-MM-DD' format), or null to abort the change. |
config? | FieldDateConfig | A map of options used to configure the field. |
Returns
FieldDate
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_
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
name?
name?: string;
Name of field. Unique within each block. Static labels are usually unnamed.
Inherited from
Blockly.FieldTextInput.name
SERIALIZABLE
SERIALIZABLE: boolean = true;
Defined in: plugins/field-date/src/field_date.ts:21
Serializable fields are saved by the XML renderer, non-serializable fields are not. Editable fields should also be serializable.
Overrides
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_
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
NBSP
readonly static NBSP: " " = "\u00A0";
Non-breaking space.
Inherited from
Blockly.FieldTextInput.NBSP
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
| Parameter | Type |
|---|---|
newValue | Size |
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
| Parameter | Type | Description |
|---|---|---|
htmlInput | HTMLElement | The 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
| Parameter | Type | Description |
|---|---|---|
includeTypeInfo? | boolean | Whether 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;
Process the configuration map passed to the field.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | FieldInputConfig | A map of options used to configure the field. See the individual field's documentation for a list of properties this parameter supports. |
Returns
void
Inherited from
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;
Defined in: plugins/field-date/src/field_date.ts:68
Ensures that the input value is a valid date. Additionally, if the date string provided includes a time, the time will be removed and the date for relative to the user's timezone will be used.
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue? | string | The input value. Ex: '2023-04-28' |
Returns
string | null
A valid date string, or null if invalid.
Overrides
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
| Parameter | Type | Description |
|---|---|---|
_invalidValue | any | The 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? | boolean | Whether to fire a change event if the value changes. |
Returns
void
Inherited from
Blockly.FieldTextInput.doValueInvalid_
doValueUpdate_()
protected doValueUpdate_(newValue): void;
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_).
Parameters
| Parameter | Type | Description |
|---|---|---|
newValue | string | The value to be saved. The default validator guarantees that this is a string. |
Returns
void
Inherited from
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;
Sets the field's value based on the given XML element. Should only be called by Blockly.Xml.
Parameters
| Parameter | Type | Description |
|---|---|---|
fieldElement | Element | The element containing info about the field's state. |
Returns
void
Inherited from
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;
Defined in: plugins/field-date/src/field_date.ts:99
Returns a description of the type of this field for screenreaders.
Returns
string
Overrides
Blockly.FieldTextInput.getAriaTypeName
getAriaValue()
getAriaValue(): string | null;
Defined in: plugins/field-date/src/field_date.ts:106
Returns a description of the current date for use by screenreaders.
Returns
string | null
Overrides
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;
Get the text from this field to display on the block. May differ from
getText due to ellipsis, and other formatting.
Returns
string
Text to display.
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
value | any | The 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(): HTMLElement | SVGElement;
See IFocusableNode.getFocusableElement.
Returns
HTMLElement | SVGElement
Inherited from
Blockly.FieldTextInput.getFocusableElement
getFocusableTree()
getFocusableTree(): IFocusableTree;
See IFocusableNode.getFocusableTree.
Returns
IFocusableTree
Inherited from
Blockly.FieldTextInput.getFocusableTree
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;
Defined in: plugins/field-date/src/field_date.ts:87
Get the text to display on the block when the input hasn't spawned in.
Returns
string | null
The text to display on the block.
Overrides
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
| Parameter | Type | Description |
|---|---|---|
text | string | Text 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;
Returns
void
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
autoClosingFlyout | boolean | true 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
| Parameter | Type | Description |
|---|---|---|
callingClass | FieldProto | The class calling this method. Used to see if this has overridden any relevant hooks. |
state | any | The state to apply to the field. |
Returns
boolean
Whether the state was applied or not.
Inherited from
Blockly.FieldTextInput.loadLegacyState
loadState()
loadState(state): void;
Sets the field's state based on the given state value. Should only be called by the serialization system.
Parameters
| Parameter | Type | Description |
|---|---|---|
state | any | The state we want to apply to the field. |
Returns
void
Inherited from
Blockly.FieldTextInput.loadState
onFinishEditing_()
onFinishEditing_(_value): void;
A callback triggered when the user is done editing the field via the UI.
Parameters
| Parameter | Type | Description |
|---|---|---|
_value | any | The new value of the field. |
Returns
void
Inherited from
Blockly.FieldTextInput.onFinishEditing_
onHtmlInputKeyDown_()
protected onHtmlInputKeyDown_(e): void;
Handle key down to the editor.
Parameters
| Parameter | Type | Description |
|---|---|---|
e | KeyboardEvent | Keyboard event. |
Returns
void
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
e | PointerEvent | Pointer 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
| Parameter | Type | Description |
|---|---|---|
_shortcut | KeyboardShortcut | The 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
| Parameter | Type | Description |
|---|---|---|
xMargin | number | x offset to use when positioning the text element. |
contentWidth | number | The 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-date/src/field_date.ts:126
Renders the field. If the picker is shown make sure it has the current date selected.
Returns
void
Overrides
Blockly.FieldTextInput.render_
renderWarningIcon()
protected renderWarningIcon(rtl, isValid): void;
Parameters
| Parameter | Type |
|---|---|
rtl | boolean |
isValid | boolean |
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
| Parameter | Type | Description |
|---|---|---|
callingClass | FieldProto | The 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(_doFullSerialization?): any;
Saves this fields value as something which can be serialized to JSON. Should only be called by the serialization system.
Parameters
| Parameter | Type | Description |
|---|---|---|
_doFullSerialization? | boolean | If true, this signals to the field that if it normally just saves a reference to some state (eg variable fields) it should instead serialize the full state of the thing being referenced. See the field serialization docs for more information. |
Returns
any
JSON serializable state.
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
ariaTypeName | string | An 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
| Parameter | Type | Description |
|---|---|---|
newValue | any | New value. |
fireChangeEvent? | boolean | Whether 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
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | True if enabled. |
Returns
void
Inherited from
Blockly.FieldTextInput.setEnabled
setSourceBlock()
setSourceBlock(block): void;
Attach this field to a block.
Parameters
| Parameter | Type | Description |
|---|---|---|
block | Block | The 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
| Parameter | Type | Description |
|---|---|---|
check | boolean | True if checked. |
Returns
void
Inherited from
Blockly.FieldTextInput.setSpellcheck
setTooltip()
setTooltip(newTip): void;
Sets the tooltip for this field.
Parameters
| Parameter | Type | Description |
|---|---|---|
newTip | TipInfo | null | The 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
| Parameter | Type | Description |
|---|---|---|
handler | FieldValidator<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
| Parameter | Type | Description |
|---|---|---|
newValue | any | New value. |
fireChangeEvent? | boolean | Whether 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_()
protected showEditor_(e?): void;
Defined in: plugins/field-date/src/field_date.ts:138
Shows the inline free-text editor on top of the text along with the date editor.
Parameters
| Parameter | Type | Description |
|---|---|---|
e? | Event | Optional mouse event that triggered the field to open, or undefined if triggered programmatically. |
Returns
void
Overrides
Blockly.FieldTextInput.showEditor_
toXml()
toXml(fieldElement): Element;
Serializes this field's value to XML. Should only be called by Blockly.Xml.
Parameters
| Parameter | Type | Description |
|---|---|---|
fieldElement | Element | The element to populate with info about the field's state. |
Returns
Element
The element containing info about the field's state.
Inherited from
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_(margin?): void;
Defined in: plugins/field-date/src/field_date.ts:158
Updates the size of the field based on the text.
Parameters
| Parameter | Type | Description |
|---|---|---|
margin? | number | margin to use when positioning the text element. |
Returns
void
Overrides
Blockly.FieldTextInput.updateSize_
widgetCreate_()
protected widgetCreate_(): HTMLInputElement;
Defined in: plugins/field-date/src/field_date.ts:189
Create the html input and set it to type date.
Returns
HTMLInputElement
The newly created date 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): FieldDate;
Defined in: plugins/field-date/src/field_date.ts:51
Constructs a FieldDate from a JSON arg object.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | FieldDateFromJsonConfig | A JSON object with options (date). |
Returns
FieldDate
The new field instance.
Package
Nocollapse
Overrides
Blockly.FieldTextInput.fromJson