Class: TextNode
lexical.TextNode
Hierarchy
-
↳
TextNode
↳↳
TabNode
↳↳
HashtagNode
Constructors
constructor
• new TextNode(text
, key?
): TextNode
Parameters
Name | Type |
---|---|
text | string |
key? | string |
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:317
Properties
__text
• __text: string
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:291
constructor
• constructor: KlassConstructor
<typeof TextNode
>
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:290
Methods
afterCloneFrom
▸ afterCloneFrom(prevNode
): 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.
Parameters
Name | Type |
---|---|
prevNode | this |
Returns
void
Example
class ClassesTextNode extends TextNode {
// Not shown: static getType, static importJSON, exportJSON, createDOM, updateDOM
__classes = new Set<string>();
static clone(node: ClassesTextNode): ClassesTextNode {
// The inherited TextNode constructor is used here, so
// classes is not set by this method.
return new ClassesTextNode(node.__text, node.__key);
}
afterCloneFrom(node: this): void {
// This calls TextNode.afterCloneFrom and LexicalNode.afterCloneFrom
// for necessary state updates
super.afterCloneFrom(node);
this.__addClasses(node.__classes);
}
// This method is a private implementation detail, it is not
// suitable for the public API because it does not call getWritable
__addClasses(classNames: Iterable<string>): this {
for (const className of classNames) {
this.__classes.add(className);
}
return this;
}
addClass(...classNames: string[]): this {
return this.getWritable().__addClasses(classNames);
}
removeClass(...classNames: string[]): this {
const node = this.getWritable();
for (const className of classNames) {
this.__classes.delete(className);
}
return this;
}
getClasses(): Set<string> {
return this.getLatest().__classes;
}
}
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:309
canHaveFormat
▸ canHaveFormat(): boolean
Returns
boolean
true if the text node supports font styling, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:467
canInsertTextAfter
▸ canInsertTextAfter(): boolean
This method is meant to be overriden 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.
Returns
boolean
true if text can be inserted after the node, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:906
canInsertTextBefore
▸ canInsertTextBefore(): boolean
This method is meant to be overriden 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.
Returns
boolean
true if text can be inserted before the node, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:895
createDOM
▸ createDOM(config
, editor?
): 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 lifecyle.
Parameters
Name | Type | Description |
---|---|---|
config | EditorConfig | allows access to things like the EditorTheme (to apply classes) during reconciliation. |
editor? | LexicalEditor | allows access to the editor for context during reconciliation. |
Returns
HTMLElement
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:473
createParentElementNode
▸ createParentElementNode(): ElementNode
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Inherited from
LexicalNode.createParentElementNode
Defined in
packages/lexical/src/LexicalNode.ts:1108
exportDOM
▸ exportDOM(editor
): 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 $generateHtmlFromNodes. You could also use this method to build your own HTML renderer.
Parameters
Name | Type |
---|---|
editor | LexicalEditor |
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:620
exportJSON
▸ exportJSON(): 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.
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:648
getCommonAncestor
▸ getCommonAncestor<T
>(node
): null
| T
Returns the closest common ancestor of this node and the provided one or null if one cannot be found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode = ElementNode |
Parameters
Name | Type | Description |
---|---|---|
node | LexicalNode | the other node to find the common ancestor of. |
Returns
null
| T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:567
getDetail
▸ 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.
Returns
number
a number representing the detail of the text node.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:344
getFormat
▸ 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.
Returns
number
a number representing the format of the text node.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:332
getFormatFlags
▸ getFormatFlags(type
, alignWithFormat
): number
Returns the format flags applied to the node as a 32-bit integer.
Parameters
Name | Type |
---|---|
type | TextFormatType |
alignWithFormat | null | number |
Returns
number
a number representing the TextFormatTypes applied to the node.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:457
getIndexWithinParent
▸ getIndexWithinParent(): number
Returns the zero-based index of this node within the parent.
Returns
number
Inherited from
LexicalNode.getIndexWithinParent
Defined in
packages/lexical/src/LexicalNode.ts:395
getKey
▸ getKey(): string
Returns this nodes key.
Returns
string
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:387
getLatest
▸ getLatest(): this
Returns the latest version of the node from the active EditorState. This is used to avoid getting values from stale node references.
Returns
this
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:753
getMode
▸ getMode(): TextModeType
Returns the mode (TextModeType) of the TextNode, which may be "normal", "token", or "segmented"
Returns
TextModeType.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:354
getNextSibling
▸ getNextSibling<T
>(): null
| T
Returns the "next" siblings - that is, the node that comes after this one in the same parent
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
null
| T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:540
getNextSiblings
▸ getNextSiblings<T
>(): T
[]
Returns all "next" siblings - that is, the nodes that come between this one and the last child of it's parent, inclusive.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
T
[]
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:551
getNodesBetween
▸ getNodesBetween(targetNode
): LexicalNode
[]
Returns a list of nodes that are between this node and the target node in the EditorState.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the node that marks the other end of the range of nodes to be returned. |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:672
getParent
▸ getParent<T
>(): null
| T
Returns the parent of this node, or null if none is found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode |
Returns
null
| T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:415
getParentKeys
▸ getParentKeys(): string
[]
Returns a list of the keys of every ancestor of this node, all the way up to the RootNode.
Returns
string
[]
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:492
getParentOrThrow
▸ getParentOrThrow<T
>(): T
Returns the parent of this node, or throws if none is found.
Type parameters
Name | Type |
---|---|
T | extends ElementNode |
Returns
T
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:426
getParents
▸ getParents(): ElementNode
[]
Returns a list of the every ancestor of this node, all the way up to the RootNode.
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:477
getPreviousSibling
▸ getPreviousSibling<T
>(): null
| T
Returns the "previous" siblings - that is, the node that comes before this one in the same parent.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
null
| T
Inherited from
LexicalNode.getPreviousSibling
Defined in
packages/lexical/src/LexicalNode.ts:507
getPreviousSiblings
▸ getPreviousSiblings<T
>(): T
[]
Returns the "previous" siblings - that is, the nodes that come between this one and the first child of it's parent, inclusive.
Type parameters
Name | Type |
---|---|
T | extends LexicalNode |
Returns
T
[]
Inherited from
LexicalNode.getPreviousSiblings
Defined in
packages/lexical/src/LexicalNode.ts:518
getStyle
▸ getStyle(): string
Returns the styles currently applied to the node. This is analogous to CSSText in the DOM.
Returns
string
CSSText-like string of styles applied to the underlying DOM node.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:364
getTextContent
▸ getTextContent(): string
Returns the text content of the node as a string.
Returns
string
a string representing the text content of the node.
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:447
getTextContentSize
▸ getTextContentSize(): number
Returns the length of the string produced by calling getTextContent on this node.
Returns
number
Inherited from
LexicalNode.getTextContentSize
Defined in
packages/lexical/src/LexicalNode.ts:811
getTopLevelElement
▸ getTopLevelElement(): null
| ElementNode
Returns the highest (in the EditorState tree) non-root ancestor of this node, or null if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
null
| ElementNode
Inherited from
LexicalNode.getTopLevelElement
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:283
getTopLevelElementOrThrow
▸ getTopLevelElementOrThrow(): ElementNode
Returns the highest (in the EditorState tree) non-root ancestor of this node, or throws if none is found. See $isRootOrShadowRoot for more information on which Elements comprise "roots".
Returns
Inherited from
LexicalNode.getTopLevelElementOrThrow
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:284
getType
▸ getType(): string
Returns the string type of this node.
Returns
string
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:300
getWritable
▸ 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.
Returns
this
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:770
hasFormat
▸ hasFormat(type
): 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.
Parameters
Name | Type | Description |
---|---|---|
type | TextFormatType | the TextFormatType to check for. |
Returns
boolean
true if the node has the provided format, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:427
insertAfter
▸ insertAfter(nodeToInsert
, restoreSelection?
): LexicalNode
Inserts a node after this LexicalNode (as the next sibling).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
nodeToInsert | LexicalNode | undefined | The node to insert after this one. |
restoreSelection | boolean | true | Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete. |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:993
insertBefore
▸ insertBefore(nodeToInsert
, restoreSelection?
): LexicalNode
Inserts a node before this LexicalNode (as the previous sibling).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
nodeToInsert | LexicalNode | undefined | The node to insert before this one. |
restoreSelection | boolean | true | Whether or not to attempt to resolve the selection to the appropriate place after the operation is complete. |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:1060
is
▸ is(object
): 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.
Parameters
Name | Type | Description |
---|---|---|
object | undefined | null | LexicalNode | the node to perform the equality comparison on. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:599
isAttached
▸ 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 ultimatelt be cleaned up by the Lexical GC.
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:317
isBefore
▸ isBefore(targetNode
): boolean
Returns true if this node logical precedes the target node in the editor state.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the node we're testing to see if it's after this one. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:611
isComposing
▸ isComposing(): boolean
Returns
boolean
true if Lexical detects that an IME or other 3rd-party script is attempting to mutate the TextNode, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:385
isDirectionless
▸ isDirectionless(): boolean
Returns whether or not the node is "directionless". Directionless nodes don't respect changes between RTL and LTR modes.
Returns
boolean
true if the node is directionless, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:404
isDirty
▸ isDirty(): boolean
Returns true if this node has been marked dirty during this update cycle.
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:742
isInline
▸ isInline(): boolean
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:304
isParentOf
▸ isParentOf(targetNode
): boolean
Returns true if this node is the parent of the target node, false otherwise.
Parameters
Name | Type | Description |
---|---|---|
targetNode | LexicalNode | the would-be child node. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:650
isParentRequired
▸ 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.
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:1100
isSegmented
▸ isSegmented(): boolean
Returns whether or not the node is in "segemented" mode. TextNodes in segemented mode can be navigated through character-by-character with a RangeSelection, but are deleted in space-delimited "segments".
Returns
boolean
true if the node is in segmented mode, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:395
isSelected
▸ isSelected(selection?
): 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.
Parameters
Name | Type | Description |
---|---|---|
selection? | null | BaseSelection | The selection that we want to determine if the node is in. |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:341
isSimpleText
▸ 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).
Returns
boolean
true if the node is simple text, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:438
isTextEntity
▸ isTextEntity(): boolean
This method is meant to be overriden 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.
Returns
boolean
true if the node is to be treated as a "text entity", false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:1103
isToken
▸ 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 invdividually by character).
Returns
boolean
true if the node is in token mode, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:375
isUnmergeable
▸ 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.
Returns
boolean
true if the node is unmergeable, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:414
markDirty
▸ markDirty(): void
Marks a node dirty, triggering transforms and forcing it to be reconciled during the update cycle.
Returns
void
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:1169
mergeWithSibling
▸ mergeWithSibling(target
): TextNode
Merges the target TextNode into this TextNode, removing the target node.
Parameters
Name | Type | Description |
---|---|---|
target | TextNode | the TextNode to merge into this one. |
Returns
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:1046
remove
▸ remove(preserveEmptyParent?
): void
Removes this LexicalNode from the EditorState. If the node isn't re-inserted somewhere, the Lexical garbage collector will eventually clean it up.
Parameters
Name | Type | Description |
---|---|---|
preserveEmptyParent? | boolean | If falsy, the node's parent will be removed if it's empty after the removal operation. This is the default behavior, subject to other node heuristics such as ElementNode#canBeEmpty |
Returns
void
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:912
replace
▸ replace<N
>(replaceWith
, includeChildren?
): N
Replaces this LexicalNode with the provided node, optionally transferring the children of the replaced node to the replacing node.
Type parameters
Name | Type |
---|---|
N | extends LexicalNode |
Parameters
Name | Type | Description |
---|---|---|
replaceWith | N | The node to replace this one with. |
includeChildren? | boolean | Whether or not to transfer the children of this node to the replacing node. |
Returns
N
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:923
select
▸ select(_anchorOffset?
, _focusOffset?
): RangeSelection
Sets the current Lexical selection to be a RangeSelection with anchor and focus on this TextNode at the provided offsets.
Parameters
Name | Type | Description |
---|---|---|
_anchorOffset? | number | the offset at which the Selection anchor will be placed. |
_focusOffset? | number | the offset at which the Selection focus will be placed. |
Returns
the new RangeSelection.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:793
selectEnd
▸ selectEnd(): RangeSelection
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:838
selectNext
▸ selectNext(anchorOffset?
, focusOffset?
): RangeSelection
Moves selection to the next sibling of this node, at the specified offsets.
Parameters
Name | Type | Description |
---|---|---|
anchorOffset? | number | The anchor offset for selection. |
focusOffset? | number | The focus offset for selection |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:1148
selectPrevious
▸ selectPrevious(anchorOffset?
, focusOffset?
): RangeSelection
Moves selection to the previous sibling of this node, at the specified offsets.
Parameters
Name | Type | Description |
---|---|---|
anchorOffset? | number | The anchor offset for selection. |
focusOffset? | number | The focus offset for selection |
Returns
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:1126
selectStart
▸ selectStart(): RangeSelection
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:834
selectionTransform
▸ selectionTransform(prevSelection
, nextSelection
): void
Parameters
Name | Type |
---|---|
prevSelection | null | BaseSelection |
nextSelection | RangeSelection |
Returns
void
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:661
setDetail
▸ setDetail(detail
): 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
Parameters
Name | Type | Description |
---|---|---|
detail | number | TextDetailType | TextDetailType or 32-bit integer representing the node detail. |
Returns
this
this TextNode.
// TODO 0.12 This should just be a string
.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:696
setFormat
▸ setFormat(format
): 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
Parameters
Name | Type | Description |
---|---|---|
format | number | TextFormatType | TextFormatType or 32-bit integer representing the node format. |
Returns
this
this TextNode.
// TODO 0.12 This should just be a string
.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:678
setMode
▸ setMode(type
): this
Sets the mode of the node.
Parameters
Name | Type |
---|---|
type | TextModeType |
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:759
setStyle
▸ setStyle(style
): 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.
Parameters
Name | Type | Description |
---|---|---|
style | string | CSSText to be applied to the underlying HTMLElement. |
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:711
setTextContent
▸ setTextContent(text
): this
Sets the text content of the node.
Parameters
Name | Type | Description |
---|---|---|
text | string | the string to set as the text value of the node. |
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:776
spliceText
▸ spliceText(offset
, delCount
, newText
, moveSelection?
): 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.
Parameters
Name | Type | Description |
---|---|---|
offset | number | the offset at which the splice operation should begin. |
delCount | number | the number of characters to delete, starting from the offset. |
newText | string | the text to insert into the TextNode at the offset. |
moveSelection? | boolean | optional, whether or not to move selection to the end of the inserted substring. |
Returns
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:854
splitText
▸ splitText(...splitOffsets
): 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.
Parameters
Name | Type | Description |
---|---|---|
...splitOffsets | number [] | rest param of the text content character offsets at which this node should be split. |
Returns
TextNode
[]
an Array containing the newly-created TextNodes.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:918
toggleDirectionless
▸ toggleDirectionless(): this
Toggles the directionless detail value of the node. Prefer using this method over setDetail.
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:737
toggleFormat
▸ toggleFormat(type
): 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.
Parameters
Name | Type | Description |
---|---|---|
type | TextFormatType | TextFormatType to toggle. |
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:726
toggleUnmergeable
▸ toggleUnmergeable(): this
Toggles the unmergeable detail value of the node. Prefer using this method over setDetail.
Returns
this
this TextNode.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:748
updateDOM
▸ updateDOM(prevNode
, dom
, config
): 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.
Parameters
Name | Type |
---|---|
prevNode | this |
dom | HTMLElement |
config | EditorConfig |
Returns
boolean
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:496
clone
▸ clone(node
): TextNode
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.
Parameters
Name | Type |
---|---|
node | TextNode |
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:305
getType
▸ 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.
Returns
string
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:301
importDOM
▸ importDOM(): null
| DOMConversionMap
Returns
null
| DOMConversionMap
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:559
importJSON
▸ importJSON(serializedNode
): TextNode
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.
Parameters
Name | Type |
---|---|
serializedNode | SerializedTextNode |
Returns
Inherited from
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:608
transform
▸ transform(): null
| (node
: LexicalNode
) => void
Registers the returned function as a transform on the node during Editor initialization. Most such use cases should be addressed via the LexicalEditor.registerNodeTransform API.
Experimental - use at your own risk.
Returns
null
| (node
: LexicalNode
) => void