Module: @lexical/list
Classes
Type Aliases
ListType
Ƭ ListType: "number"
| "bullet"
| "check"
Defined in
lexical-list/src/LexicalListNode.ts:44
SerializedListItemNode
Ƭ SerializedListItemNode: Spread
<{ checked
: boolean
| undefined
; value
: number
}, SerializedElementNode
>
Defined in
lexical-list/src/LexicalListItemNode.ts:50
SerializedListNode
Ƭ SerializedListNode: Spread
<{ listType
: ListType
; start
: number
; tag
: ListNodeTagType
}, SerializedElementNode
>
Defined in
lexical-list/src/LexicalListNode.ts:35
Variables
INSERT_CHECK_LIST_COMMAND
• Const
INSERT_CHECK_LIST_COMMAND: LexicalCommand
<void
>
Defined in
INSERT_ORDERED_LIST_COMMAND
• Const
INSERT_ORDERED_LIST_COMMAND: LexicalCommand
<void
>
Defined in
INSERT_UNORDERED_LIST_COMMAND
• Const
INSERT_UNORDERED_LIST_COMMAND: LexicalCommand
<void
>
Defined in
REMOVE_LIST_COMMAND
• Const
REMOVE_LIST_COMMAND: LexicalCommand
<void
>
Defined in
Functions
$createListItemNode
▸ $createListItemNode(checked?
): ListItemNode
Creates a new List Item node, passing true/false will convert it to a checkbox input.
Parameters
Name | Type | Description |
---|---|---|
checked? | boolean | Is the List Item a checkbox and, if so, is it checked? undefined/null: not a checkbox, true/false is a checkbox and checked/unchecked, respectively. |
Returns
The new List Item.
Defined in
lexical-list/src/LexicalListItemNode.ts:548
$createListNode
▸ $createListNode(listType
, start?
): ListNode
Creates a ListNode of listType.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
listType | ListType | undefined | The type of list to be created. Can be 'number', 'bullet', or 'check'. |
start | number | 1 | Where an ordered list starts its count, start = 1 if left undefined. |
Returns
The new ListNode
Defined in
lexical-list/src/LexicalListNode.ts:324
$getListDepth
▸ $getListDepth(listNode
): number
Checks the depth of listNode from the root node.
Parameters
Name | Type | Description |
---|---|---|
listNode | ListNode | The ListNode to be checked. |
Returns
number
The depth of the ListNode.
Defined in
$handleListInsertParagraph
▸ $handleListInsertParagraph(): boolean
Attempts to insert a ParagraphNode at selection and selects the new node. The selection must contain a ListItemNode or a node that does not already contain text. If its grandparent is the root/shadow root, it will get the ListNode (which should be the parent node) and insert the ParagraphNode as a sibling to the ListNode. If the ListNode is nested in a ListItemNode instead, it will add the ParagraphNode after the grandparent ListItemNode. Throws an invariant if the selection is not a child of a ListNode.
Returns
boolean
true if a ParagraphNode was inserted succesfully, false if there is no selection or the selection does not contain a ListItemNode or the node already holds text.
Defined in
lexical-list/src/formatList.ts:498
$isListItemNode
▸ $isListItemNode(node
): node is ListItemNode
Checks to see if the node is a ListItemNode.
Parameters
Name | Type | Description |
---|---|---|
node | undefined | null | LexicalNode | The node to be checked. |
Returns
node is ListItemNode
true if the node is a ListItemNode, false otherwise.
Defined in
lexical-list/src/LexicalListItemNode.ts:557
$isListNode
▸ $isListNode(node
): node is ListNode
Checks to see if the node is a ListNode.
Parameters
Name | Type | Description |
---|---|---|
node | undefined | null | LexicalNode | The node to be checked. |
Returns
node is ListNode
true if the node is a ListNode, false otherwise.
Defined in
lexical-list/src/LexicalListNode.ts:333
insertList
▸ insertList(editor
, listType
): void
Inserts a new ListNode. If the selection's anchor node is an empty ListItemNode and is a child of the root/shadow root, it will replace the ListItemNode with a ListNode and the old ListItemNode. Otherwise it will replace its parent with a new ListNode and re-insert the ListItemNode and any previous children. If the selection's anchor node is not an empty ListItemNode, it will add a new ListNode or merge an existing ListNode, unless the the node is a leaf node, in which case it will attempt to find a ListNode up the branch and replace it with a new ListNode, or create a new ListNode at the nearest root/shadow root.
Parameters
Name | Type | Description |
---|---|---|
editor | LexicalEditor | The lexical editor. |
listType | ListType | The type of list, "number" | "bullet" | "check". |
Returns
void
Defined in
lexical-list/src/formatList.ts:93
removeList
▸ removeList(editor
): void
Searches for the nearest ancestral ListNode and removes it. If selection is an empty ListItemNode it will remove the whole list, including the ListItemNode. For each ListItemNode in the ListNode, removeList will also generate new ParagraphNodes in the removed ListNode's place. Any child node inside a ListItemNode will be appended to the new ParagraphNodes.
Parameters
Name | Type | Description |
---|---|---|
editor | LexicalEditor | The lexical editor. |
Returns
void