Class: ListItemNode
@lexical/list.ListItemNode
Hierarchy
-
↳
ListItemNode
Constructors
constructor
• new ListItemNode(value?
, checked?
, key?
): ListItemNode
Parameters
Name | Type |
---|---|
value? | number |
checked? | boolean |
key? | string |
Returns
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:68
Methods
append
▸ append(...nodes
): this
Parameters
Name | Type |
---|---|
...nodes | LexicalNode [] |
Returns
this
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:148
canMergeWhenEmpty
▸ canMergeWhenEmpty(): true
Determines whether this node, when empty, can merge with a first block of nodes being inserted.
This method is specifically called in RangeSelection.insertNodes to determine merging behavior during nodes insertion.
Returns
true
Example
// In a ListItemNode or QuoteNode implementation:
canMergeWhenEmpty(): true {
return true;
}
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:410
canMergeWith
▸ canMergeWith(node
): boolean
Parameters
Name | Type |
---|---|
node | LexicalNode |
Returns
boolean
Overrides
ElementNode.canMergeWith
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:383
collapseAtStart
▸ collapseAtStart(selection
): true
Parameters
Name | Type |
---|---|
selection | RangeSelection |
Returns
true
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:266
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
packages/lexical-list/src/LexicalListItemNode.ts:74
createParentElementNode
▸ createParentElementNode(): ElementNode
The creation logic for any required parent. Should be implemented if isParentRequired returns true.
Returns
Overrides
ElementNode.createParentElementNode
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:406
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
packages/lexical-list/src/LexicalListItemNode.ts:130
exportJSON
▸ exportJSON(): SerializedListItemNode
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
packages/lexical-list/src/LexicalListItemNode.ts:138
extractWithChild
▸ extractWithChild(child
, selection
): boolean
Parameters
Name | Type |
---|---|
child | LexicalNode |
selection | BaseSelection |
Returns
boolean
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:387
getChecked
▸ getChecked(): undefined
| boolean
Returns
undefined
| boolean
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:316
getIndent
▸ getIndent(): number
Returns
number
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:338
getValue
▸ getValue(): number
Returns
number
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:305
insertAfter
▸ insertAfter(node
, restoreSelection?
): LexicalNode
Inserts a node after this LexicalNode (as the next sibling).
Parameters
Name | Type | Default value | Description |
---|---|---|---|
node | 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
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:208
insertNewAfter
▸ insertNewAfter(_
, restoreSelection?
): ParagraphNode
| ListItemNode
Parameters
Name | Type | Default value |
---|---|---|
_ | RangeSelection | undefined |
restoreSelection | boolean | true |
Returns
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:254
isParentRequired
▸ isParentRequired(): true
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
true
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:402
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
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:238
replace
▸ replace<N
>(replaceWithNode
, 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 |
---|---|---|
replaceWithNode | 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
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:164
setChecked
▸ setChecked(checked?
): void
Parameters
Name | Type |
---|---|
checked? | boolean |
Returns
void
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:329
setIndent
▸ setIndent(indent
): this
Parameters
Name | Type |
---|---|
indent | number |
Returns
this
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:355
setValue
▸ setValue(value
): void
Parameters
Name | Type |
---|---|
value | number |
Returns
void
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:311
toggleChecked
▸ toggleChecked(): void
Returns
void
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:334
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
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:85
clone
▸ clone(node
): ListItemNode
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 | ListItemNode |
Returns
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:64
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
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:60
importDOM
▸ importDOM(): null
| DOMConversionMap
Returns
null
| DOMConversionMap
Overrides
ElementNode.importDOM
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:112
importJSON
▸ importJSON(serializedNode
): ListItemNode
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 | SerializedListItemNode |
Returns
Overrides
Defined in
packages/lexical-list/src/LexicalListItemNode.ts:121
transform
▸ transform(): (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
fn
▸ (node
): void
Parameters
Name | Type |
---|---|
node | LexicalNode |
Returns
void