Class: TextNode
lexical.TextNode
Hierarchy
↳
TextNode
↳↳
TabNode
↳↳
HashtagNode
Constructors
constructor
• new TextNode(text
, key?
)
Parameters
Name | Type |
---|---|
text | string |
key? | string |
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:295
Properties
__text
• __text: string
Defined in
lexical/src/nodes/LexicalTextNode.ts:277
Methods
canInsertTextAfter
▸ canInsertTextAfter(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:701
canInsertTextBefore
▸ canInsertTextBefore(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:697
createDOM
▸ createDOM(config
): 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. |
Returns
HTMLElement
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:370
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
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:518
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
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:544
getDetail
▸ getDetail(): number
Returns
number
Defined in
lexical/src/nodes/LexicalTextNode.ts:309
getFormat
▸ getFormat(): number
Returns
number
Defined in
lexical/src/nodes/LexicalTextNode.ts:304
getFormatFlags
▸ getFormatFlags(type
, alignWithFormat
): number
Parameters
Name | Type |
---|---|
type | TextFormatType |
alignWithFormat | null | number |
Returns
number
Defined in
lexical/src/nodes/LexicalTextNode.ts:362
getMode
▸ getMode(): TextModeType
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:314
getStyle
▸ getStyle(): string
Returns
string
Defined in
lexical/src/nodes/LexicalTextNode.ts:319
getTextContent
▸ getTextContent(): string
Returns the text content of the node. Override this for custom nodes that should have a representation in plain text format (for copy + paste, for example)
Returns
string
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:357
hasFormat
▸ hasFormat(type
): boolean
Parameters
Name | Type |
---|---|
type | TextFormatType |
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:348
isComposing
▸ isComposing(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:329
isDirectionless
▸ isDirectionless(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:338
isSegmented
▸ isSegmented(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:333
isSimpleText
▸ isSimpleText(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:353
isTextEntity
▸ isTextEntity(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:874
isToken
▸ isToken(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:324
isUnmergeable
▸ isUnmergeable(): boolean
Returns
boolean
Defined in
lexical/src/nodes/LexicalTextNode.ts:343
mergeWithSibling
▸ mergeWithSibling(target
): TextNode
Parameters
Name | Type |
---|---|
target | TextNode |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:824
select
▸ select(_anchorOffset?
, _focusOffset?
): RangeSelection
Parameters
Name | Type |
---|---|
_anchorOffset? | number |
_focusOffset? | number |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:622
selectionTransform
▸ selectionTransform(prevSelection
, nextSelection
): void
Parameters
Name | Type |
---|---|
prevSelection | null | RangeSelection | NodeSelection | GridSelection |
nextSelection | RangeSelection |
Returns
void
Defined in
lexical/src/nodes/LexicalTextNode.ts:557
setDetail
▸ setDetail(detail
): TextNode
Parameters
Name | Type |
---|---|
detail | number | TextDetailType |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:573
setFormat
▸ setFormat(format
): TextNode
Parameters
Name | Type |
---|---|
format | number | TextFormatType |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:565
setMode
▸ setMode(type
): TextNode
Parameters
Name | Type |
---|---|
type | TextModeType |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:603
setStyle
▸ setStyle(style
): TextNode
Parameters
Name | Type |
---|---|
style | string |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:580
setTextContent
▸ setTextContent(text
): TextNode
Parameters
Name | Type |
---|---|
text | string |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:613
spliceText
▸ spliceText(offset
, delCount
, newText
, moveSelection?
): TextNode
Parameters
Name | Type |
---|---|
offset | number |
delCount | number |
newText | string |
moveSelection? | boolean |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:663
splitText
▸ splitText(...splitOffsets
): TextNode
[]
Parameters
Name | Type |
---|---|
...splitOffsets | number [] |
Returns
TextNode
[]
Defined in
lexical/src/nodes/LexicalTextNode.ts:705
toggleDirectionless
▸ toggleDirectionless(): TextNode
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:591
toggleFormat
▸ toggleFormat(type
): TextNode
Parameters
Name | Type |
---|---|
type | TextFormatType |
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:586
toggleUnmergeable
▸ toggleUnmergeable(): TextNode
Returns
Defined in
lexical/src/nodes/LexicalTextNode.ts:597
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 | TextNode |
dom | HTMLElement |
config | EditorConfig |
Returns
boolean
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:390
clone
▸ Static
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
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:291
getType
▸ Static
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
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:287
importDOM
▸ Static
importDOM(): null
| DOMConversionMap
<HTMLElement
>
Returns
null
| DOMConversionMap
<HTMLElement
>
Defined in
lexical/src/nodes/LexicalTextNode.ts:457
importJSON
▸ Static
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
Overrides
Defined in
lexical/src/nodes/LexicalTextNode.ts:506