Skip to main content

TabNode

class
class TabNode

Import

import { TabNode } from '@modular/sdk/editor';

Members81

__text
string
importDOMoptional
() => DOMConversionMap<any> | null
$config()
() => import("../index.js").BaseStaticNodeConfig & { readonly text?: { readonly extends: typeof LexicalNode; readonly generated: import("../index.js").GeneratedJSONFactory; readonly importDOM: { readonly '#text': () => { conversion: (domNode: Node) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly b: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly code: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly em: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly i: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly mark: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly s: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly span: () => { conversion: (domNode: HTMLSpanElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly strong: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly sub: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly sup: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly u: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; }; readonly json: import("../index.js").NodeSerializationSchema<TextNode, { readonly detail?: string | number | undefined; readonly format?: string | number | undefined; readonly mode?: "normal" | "token" | "segmented" | undefined; readonly style?: string | undefined; readonly text?: string | undefined; }>; } | undefined; } & import("../index.js").StaticNodeTypeAccessor<"text"> & import("../index.js").StaticNodeConfigAccessor<{ readonly extends: typeof LexicalNode; readonly generated: import("../index.js").GeneratedJSONFactory; readonly importDOM: { readonly '#text': () => { conversion: (domNode: Node) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly b: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly code: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly em: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly i: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly mark: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly s: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly span: () => { conversion: (domNode: HTMLSpanElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly strong: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly sub: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly sup: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; readonly u: () => { conversion: (domNode: HTMLElement) => import("../index.js").DOMConversionOutput; priority: 0; }; }; readonly json: import("../index.js").NodeSerializationSchema<TextNode, { readonly detail?: string | number | undefined; readonly format?: string | number | undefined; readonly mode?: "normal" | "token" | "segmented" | undefined; readonly style?: string | undefined; readonly text?: string | undefined; }>; }> & { readonly tab?: { readonly extends: typeof TextNode; readonly generated: import("../index.js").GeneratedJSONFactory; readonly json: import("../index.js").NodeSerializationSchema<TabNode, { readonly detail?: string | number | undefined; readonly mode?: "normal" | undefined; readonly text?: string | undefined; }>; } | undefined; } & import("../index.js").StaticNodeTypeAccessor<"tab"> & import("../index.js").StaticNodeConfigAccessor<{ readonly extends: typeof TextNode; readonly generated: import("../index.js").GeneratedJSONFactory; readonly json: import("../index.js").NodeSerializationSchema<TabNode, { readonly detail?: string | number | undefined; readonly mode?: "normal" | undefined; readonly text?: string | undefined; }>; }>

Override this to implement the new static node configuration protocol, this method is called directly on the prototype and must not depend on anything initialized in the constructor. Generally it should be a trivial implementation.

afterCloneFrom()
(prevNode: this) => void

Perform any state updates on the clone of prevNode that are not already handled by the constructor call in the static clone method. If you have state to update in your clone that is not handled directly by the constructor, it is advisable to override this method but it is required to include a call to `super.afterCloneFrom(prevNode)` in your implementation. This is only intended to be called by $cloneWithProperties function or via a super call.

canHaveFormat()
() => boolean
canInsertTextAfter()
() => boolean

This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes when a user event would cause text to be inserted after them in the editor. If true, Lexical will attempt to insert text into this node. If false, it will insert the text in a new sibling node.

canInsertTextBefore()
() => boolean

This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes when a user event would cause text to be inserted before them in the editor. If true, Lexical will attempt to insert text into this node. If false, it will insert the text in a new sibling node.

clone()
(_data: unknown) => LexicalNode

Clones this node, creating a new node with a different key and adding it to the EditorState (but not attaching it anywhere!). All nodes must implement this method.

config()
<const Config extends StaticNodeConfigValue<this, string>>(type: symbol, config: Config) => AbstractStaticNodeConfigRecord<Config> | <Type extends string, const Config extends StaticNodeConfigValue<this, Type>>(type: Type, config: Config) => StaticNodeConfigRecord<Type, Config>

This is a convenience method for $config that aids in type inference. See LexicalNode.$config for example usage. An abstract base class that has no concrete node `type` may pass a well-known symbol (by convention `Symbol.for(<NodeClassName>)`) instead of a string `type` to declare configuration shared with its subclasses.

createDOM()
(config: EditorConfig) => HTMLElement

Called during the reconciliation process to determine which nodes to insert into the DOM for this Lexical Node. This method must return exactly one HTMLElement. Nested elements are not supported. Do not attempt to update the Lexical EditorState during this phase of the update lifecycle.

createParentElementNode()
() => ElementNode

The creation logic for any required parent. Should be implemented if isParentRequired returns true.

exportDOM()
(editor: LexicalEditor) => DOMExportOutput

Controls how the this node is serialized to HTML. This is important for copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces, in which case the primary transfer format is HTML. It's also important if you're serializing to HTML for any other reason via @lexical/html!$generateHtmlFromNodes. You could also use this method to build your own HTML renderer.

exportJSON()
(compact?: false) => SerializedTextNode | (compact: boolean) => SerializedPartial<SerializedTextNode>

Controls how the this node is serialized to JSON. This is important for copy and paste between Lexical editors sharing the same namespace. It's also important if you're serializing to JSON for persistent storage somewhere. See [Serialization & Deserialization](https://lexical.dev/docs/serialization/serialization#json). The base implementation writes every property the node's schema declares (its own and those it inherits), reading each through its getter — `get<Prop>` by default, or the name recorded with `withAccessors`. A getter that returns `undefined` omits its property. Override this only for output a schema can not describe, and call `super.exportJSON(compact)` when you do. **This may serialize the instance as-is, without resolving the latest version.** A property declared with withField is read straight off the node, which is the optimization the serialization walk is built on — every node the walk reaches comes from the EditorState's node map and is already current, so it resolves nothing per node. So on a reference that a `getWritable()` (any `set<Prop>`) has since superseded, this writes pre-mutation values. Which properties do is not something to rely on: a property whose accessor a subclass overrode still goes through that accessor and resolves the latest, so one node can write a current `text` beside a stale `style`. Call `node.getLatest().exportJSON()` whenever you hold such a reference rather than reasoning about which properties resolve. This is a breaking change. Every property previously went through an accessor, and every accessor resolves `getLatest()`, so a stale reference exported current values.

getDetail()
() => number

Returns a 32-bit integer that represents the TextDetailTypes currently applied to the TextNode. You probably don't want to use this method directly - consider using TextNode.isDirectionless or TextNode.isUnmergeable instead.

getDOMSlot()
(element: HTMLElement) => DOMSlot<HTMLElement>

Returns a DOMSlot pointing at the content-bearing element of this node's DOM. The default returns a slot wrapping the keyed DOM as-is. Override this when createDOM returns a wrapper around the content-bearing element (e.g. `<span><br/></span>` for a styled line break), so selection / reconciliation logic can target the inner element. ElementNode overrides this to return an ElementDOMSlot with children-management semantics (used by the reconciler to place managed children).

getFormat()
() => number

Returns a 32-bit integer that represents the TextFormatTypes currently applied to the TextNode. You probably don't want to use this method directly - consider using TextNode.hasFormat instead.

getFormatFlags()
(type: TextFormatType, alignWithFormat: null | number) => number

Returns the format flags applied to the node as a 32-bit integer.

getIndexWithinParent()
() => number

Returns the zero-based index of this node within the parent.

getKey()
() => NodeKey

Returns this nodes key.

getLatest()
() => this

Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.

getMode()
() => TextModeType

Returns the mode (TextModeType) of the TextNode, which may be "normal", "token", or "segmented"

getNextSibling()
() => LexicalNode | null | <T extends LexicalNode>() => T | null

Returns the node after this one in the same parent, or null if there is no such node.

getNextSiblings()
() => LexicalNode[] | <T extends LexicalNode>() => T[]

Returns all nodes after this one in the same parent, in document order.

getNodesBetween()
(targetNode: LexicalNode) => LexicalNode[]

Returns a list of nodes that are between this node and the target node in the EditorState.

getParent()
() => ElementNode | null | <T extends ElementNode>() => T | null

Returns the parent of this node, or null if none is found.

getParentKeys()
() => NodeKey[]

Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.

getParentOrThrow()
() => ElementNode | <T extends ElementNode>() => T

Returns the parent of this node, or throws if none is found.

getParents()
() => ElementNode[]

Returns a list of the every ancestor of this node, all the way up to the RootNode.

getPreviousSibling()
() => LexicalNode | null | <T extends LexicalNode>() => T | null

Returns the node before this one in the same parent, or null if there is no such node.

getPreviousSiblings()
() => LexicalNode[] | <T extends LexicalNode>() => T[]

Returns all nodes before this one in the same parent, in document order.

getStyle()
() => string

Returns the styles currently applied to the node. This is analogous to CSSText in the DOM.

getTextContent()
() => string

Returns the text content of the node as a string.

getTextContentSize()
() => number

Returns the length of the string produced by calling getTextContent on this node.

getTopLevelElement()
() => ElementNode | null

Returns the highest (in the EditorState tree) non-root ancestor of this node, or null if none is found. See lexical !$isRootOrShadowRoot for more information on which Elements comprise "roots".

getTopLevelElementOrThrow()
() => ElementNode

Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See lexical !$isRootOrShadowRoot for more information on which Elements comprise "roots".

getType()
() => string

Returns the string type of this node.

getType()
() => string

Returns the string type of this node. Every node must implement this and it MUST BE UNIQUE amongst nodes registered on the editor.

getWritable()
() => this

Returns a mutable version of the node using $cloneWithProperties if necessary. Will throw an error if called outside of a Lexical Editor LexicalEditor.update callback.

hasFormat()
(type: TextFormatType) => boolean

Returns whether or not the node has the provided format applied. Use this with the human-readable TextFormatType string values to get the format of a TextNode.

importJSON()
(_serializedNode: SerializedPartial<SerializedLexicalNode> & Record<string, unknown>) => LexicalNode

Controls how the this node is deserialized from JSON. This is usually boilerplate, but provides an abstraction between the node implementation and serialized interface that can be important if you ever make breaking changes to a node schema (by adding or removing properties). See [Serialization & Deserialization](https://lexical.dev/docs/serialization/serialization#json).

insertAfter()
(nodeToInsert: LexicalNode, restoreSelection?: boolean) => LexicalNode

Inserts a node after this LexicalNode (as the next sibling).

insertBefore()
(nodeToInsert: LexicalNode, restoreSelection?: boolean) => LexicalNode

Inserts a node before this LexicalNode (as the previous sibling).

is()
(object: LexicalNode | null | undefined) => boolean

Returns true if the provided node is the exact same one as this node, from Lexical's perspective. Always use this instead of referential equality.

isAttached()
() => boolean

Returns true if there is a path between this node and the RootNode, false otherwise. This is a way of determining if the node is "attached" EditorState. Unattached nodes won't be reconciled and will ultimately be cleaned up by the Lexical GC.

isBefore()
(targetNode: LexicalNode) => boolean

Returns true if this node logically precedes the target node in the editor state, false otherwise (including if there is no common ancestor). Note that this notion of isBefore is based on post-order; a descendant node is always before its ancestors. See also $getCommonAncestor and $comparePointCaretNext for more flexible ways to determine the relative positions of nodes.

isComposing()
() => boolean
isDirectionless()
() => boolean

Returns whether or not the node is "directionless". Directionless nodes don't respect changes between RTL and LTR modes.

isDirty()
() => boolean

Returns true if this node has been marked dirty during this update cycle.

isInline()
() => true
isParentOf()
(targetNode: LexicalNode) => boolean

Returns true if this node is an ancestor of and distinct from the target node, false otherwise.

isParentRequired()
() => boolean

Whether or not this node has a required parent. Used during copy + paste operations to normalize nodes that would otherwise be orphaned. For example, ListItemNodes without a ListNode parent or TextNodes with a ParagraphNode parent.

isSegmented()
() => boolean

Returns whether or not the node is in "segmented" mode. TextNodes in segmented mode can be navigated through character-by-character with a RangeSelection, but are deleted in space-delimited "segments".

isSelected()
(selection?: null | BaseSelection) => boolean

Returns true if this node is contained within the provided Selection., false otherwise. Relies on the algorithms implemented in BaseSelection.getNodes to determine what's included.

isSimpleText()
() => boolean

Returns whether or not the node is simple text. Simple text is defined as a TextNode that has the string type "text" (i.e., not a subclass) and has no mode applied to it (i.e., not segmented or token).

isTextEntity()
() => boolean

This method is meant to be overridden by TextNode subclasses to control the behavior of those nodes when used with the registerLexicalTextEntity function. If you're using registerLexicalTextEntity, the node class that you create and replace matched text with should return true from this method.

isToken()
() => boolean

Returns whether or not the node is in "token" mode. TextNodes in token mode can be navigated through character-by-character with a RangeSelection, but are deleted as a single entity (not individually by character).

isUnmergeable()
() => boolean

Returns whether or not the node is unmergeable. In some scenarios, Lexical tries to merge adjacent TextNodes into a single TextNode. If a TextNode is unmergeable, this won't happen.

markDirty()
() => void

Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.

mergeWithSibling()
(target: TextNode) => TextNode

Merges the target TextNode into this TextNode, removing the target node.

remove()
(preserveEmptyParent?: boolean) => void

Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.

replace()
<N extends LexicalNode>(replaceWith: N, includeChildren?: boolean) => N

Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node. Named slots are bound to their host node and are never transferred: this node keeps its slot map, so if it is reattached elsewhere (as `$wrapNodeInElement` does) its slots come with it, and if it stays detached the slot subtrees are garbage-collected along with it. To move a slot value onto another host, use `$setSlot` explicitly.

resetOnCopyNodeFrom()
(originalNode: this) => void

Reset state in this copy of originalNode, if necessary

select()
(_anchorOffset?: number, _focusOffset?: number) => RangeSelection

Sets the current Lexical selection to be a RangeSelection with anchor and focus on this TextNode at the provided offsets.

selectEnd()
() => RangeSelection
selectionTransform()
(prevSelection: null | BaseSelection, nextSelection: RangeSelection) => void
selectNext()
(anchorOffset?: number, focusOffset?: number) => RangeSelection

Moves selection to the next sibling of this node, at the specified offsets.

selectPrevious()
(anchorOffset?: number, focusOffset?: number) => RangeSelection

Moves selection to the previous sibling of this node, at the specified offsets.

selectStart()
() => RangeSelection
setDetail()
(detail: TextDetailType | number) => this

Sets the node detail to the provided TextDetailType or 32-bit integer. Note that the TextDetailType version of the argument can only specify one detail value and doing so will remove all other detail values that may be applied to the node. For toggling behavior, consider using TextNode.toggleDirectionless or TextNode.toggleUnmergeable

setFormat()
(format: TextFormatType | number) => this

Sets the node format to the provided TextFormatType or 32-bit integer. Note that the TextFormatType version of the argument can only specify one format and doing so will remove all other formats that may be applied to the node. For toggling behavior, consider using TextNode.toggleFormat

setMode()
(type: TextModeType) => this

Sets the mode of the node. Note: during IME composition, a segmented TextNode may be temporarily switched to normal mode to preserve the DOM element that the browser's composition tracker is bound to. Subclass transforms or method overrides that assume the node is always in segmented mode should account for this transient state.

setStyle()
(style: string) => this

Sets the node style to the provided CSSText-like string. Set this property as you would an HTMLElement style attribute to apply inline styles to the underlying DOM Element.

setTextContent()
(_text: string) => this

Always normalizes the stored content to `'\t'` regardless of input — see comment below for the rationale.

spliceText()
(offset: number, delCount: number, newText: string, moveSelection?: boolean) => TextNode

Inserts the provided text into this TextNode at the provided offset, deleting the number of characters specified. Can optionally calculate a new selection after the operation is complete.

splitText()
(...splitOffsets: number[]) => TextNode[]

Splits this TextNode at the provided character offsets, forming new TextNodes from the substrings formed by the split, and inserting those new TextNodes into the editor, replacing the one that was split.

toggleDirectionless()
() => this

Toggles the directionless detail value of the node. Prefer using this method over setDetail.

toggleFormat()
(type: TextFormatType) => this

Applies the provided format to this TextNode if it's not present. Removes it if it's present. The subscript and superscript formats are mutually exclusive. Prefer using this method to turn specific formats on and off.

toggleUnmergeable()
() => this

Toggles the unmergeable detail value of the node. Prefer using this method over setDetail.

transform()
() => ((node: LexicalNode) => void) | null
updateDOM()
(prevNode: this, dom: HTMLElement, config: EditorConfig) => boolean

Called when a node changes and should update the DOM in whatever way is necessary to make it align with any changes that might have happened during the update. Returning "true" here will cause lexical to unmount and recreate the DOM node (by calling createDOM). You would need to do this if the element tag changes, for instance.

updateFromJSON()
(serializedNode: LexicalParseJSON<SerializedTextNode>) => this

Update this LexicalNode instance from serialized JSON. It's recommended to implement as much logic as possible in this method instead of the static importJSON method, so that the functionality can be inherited in subclasses. The LexicalUpdateJSON utility type should be used to ignore any type, version, or children properties in the JSON so that the extended JSON from subclasses are acceptable parameters for the super call. If overridden, this method must call super.

Notes

noInheritDoc