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:306
Properties
__text
• __text: string
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:288
constructor
• constructor: KlassConstructor
<typeof TextNode
>
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:287
Methods
canHaveFormat
▸ canHaveFormat(): boolean
Returns
boolean
true if the text node supports font styling, false otherwise.
Defined in
packages/lexical/src/nodes/LexicalTextNode.ts:456
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:899
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:888
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:462
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:1037
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:613
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:641
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:497
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:333
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:321
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:446
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:325
getKey
▸ getKey(): string
Returns this nodes key.
Returns
string
Inherited from
Defined in
packages/lexical/src/LexicalNode.ts:317
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:683
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:343
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:470
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:481
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:602
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:345
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:422
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:356
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:407
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:437