Skip to main content

Module: @lexical/list

Classes

Type Aliases

ListType

Ƭ ListType: "number" | "bullet" | "check"

Defined in

packages/lexical-list/src/LexicalListNode.ts:49


SerializedListItemNode

Ƭ SerializedListItemNode: Spread<{ checked: boolean | undefined ; value: number }, SerializedElementNode>

Defined in

packages/lexical-list/src/LexicalListItemNode.ts:45


SerializedListNode

Ƭ SerializedListNode: Spread<{ listType: ListType ; start: number ; tag: ListNodeTagType }, SerializedElementNode>

Defined in

packages/lexical-list/src/LexicalListNode.ts:40

Variables

INSERT_CHECK_LIST_COMMAND

Const INSERT_CHECK_LIST_COMMAND: LexicalCommand<void>

Defined in

packages/lexical-list/src/index.ts:50


INSERT_ORDERED_LIST_COMMAND

Const INSERT_ORDERED_LIST_COMMAND: LexicalCommand<void>

Defined in

packages/lexical-list/src/index.ts:47


INSERT_UNORDERED_LIST_COMMAND

Const INSERT_UNORDERED_LIST_COMMAND: LexicalCommand<void>

Defined in

packages/lexical-list/src/index.ts:45


REMOVE_LIST_COMMAND

Const REMOVE_LIST_COMMAND: LexicalCommand<void>

Defined in

packages/lexical-list/src/index.ts:53

Functions

$createListItemNode

$createListItemNode(checked?): ListItemNode

Creates a new List Item node, passing true/false will convert it to a checkbox input.

Parameters

NameTypeDescription
checked?booleanIs 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

ListItemNode

The new List Item.

Defined in

packages/lexical-list/src/LexicalListItemNode.ts:539


$createListNode

$createListNode(listType, start?): ListNode

Creates a ListNode of listType.

Parameters

NameTypeDefault valueDescription
listTypeListTypeundefinedThe type of list to be created. Can be 'number', 'bullet', or 'check'.
startnumber1Where an ordered list starts its count, start = 1 if left undefined.

Returns

ListNode

The new ListNode

Defined in

packages/lexical-list/src/LexicalListNode.ts:354


$getListDepth

$getListDepth(listNode): number

Checks the depth of listNode from the root node.

Parameters

NameTypeDescription
listNodeListNodeThe ListNode to be checked.

Returns

number

The depth of the ListNode.

Defined in

packages/lexical-list/src/utils.ts:27


$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

packages/lexical-list/src/formatList.ts:473


$isListItemNode

$isListItemNode(node): node is ListItemNode

Checks to see if the node is a ListItemNode.

Parameters

NameTypeDescription
nodeundefined | null | LexicalNodeThe node to be checked.

Returns

node is ListItemNode

true if the node is a ListItemNode, false otherwise.

Defined in

packages/lexical-list/src/LexicalListItemNode.ts:548


$isListNode

$isListNode(node): node is ListNode

Checks to see if the node is a ListNode.

Parameters

NameTypeDescription
nodeundefined | null | LexicalNodeThe node to be checked.

Returns

node is ListNode

true if the node is a ListNode, false otherwise.

Defined in

packages/lexical-list/src/LexicalListNode.ts:363


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

NameTypeDescription
editorLexicalEditorThe lexical editor.
listTypeListTypeThe type of list, "number" | "bullet" | "check".

Returns

void

Defined in

packages/lexical-list/src/formatList.ts:65


registerList

registerList(editor): () => void

Parameters

NameType
editorLexicalEditor

Returns

fn

▸ (): void

Returns

void

Defined in

packages/lexical-list/src/index.ts:57


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

NameTypeDescription
editorLexicalEditorThe lexical editor.

Returns

void

Defined in

packages/lexical-list/src/formatList.ts:227