āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/udecode/plate/(plugins)/(elements)/list-classic ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
title: List Classic docs:
This List Classic plugin - Traditional HTML-spec lists with strict nesting rules:
ul/ol > li)The List plugin - Flexible indentation-based lists:
Choose based on your needs:
HTML-compliant lists:
ul/ol > li structureList types:
Drag & drop:
Shortcuts:
-, *, 1., [ ]) to create listsLimitations (use the List plugin for these features):
For a more flexible, Word-like approach, see the List plugin.
</PackageInfo>The fastest way to add list functionality is with the ListKit, which includes pre-configured list plugins with Plate UI components and keyboard shortcuts.
BulletedListElement: Renders unordered list elements.NumberedListElement: Renders ordered list elements.TaskListElement: Renders task list elements with checkboxes.Add the kit to your plugins:
import { createPlateEditor } from 'platejs/react';
import { ListKit } from '@/components/editor/plugins/list-classic-kit';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
...ListKit,
],
});
</Steps>
npm install @platejs/list-classic
Include the list plugins in your Plate plugins array when creating the editor.
import { ListPlugin, BulletedListPlugin, NumberedListPlugin, TaskListPlugin, ListItemPlugin } from '@platejs/list-classic/react';
import { createPlateEditor } from 'platejs/react';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ListPlugin,
BulletedListPlugin,
NumberedListPlugin,
TaskListPlugin,
ListItemPlugin,
],
});
Configure the plugins with custom components and keyboard shortcuts.
import { ListPlugin, BulletedListPlugin, NumberedListPlugin, TaskListPlugin, ListItemPlugin } from '@platejs/list-classic/react';
import { createPlateEditor } from 'platejs/react';
import { BulletedListElement, NumberedListElement, TaskListElement } from '@/components/ui/list-classic-node';
const editor = createPlateEditor({
plugins: [
// ...otherPlugins,
ListPlugin,
BulletedListPlugin.configure({
node: { component: BulletedListElement },
shortcuts: { toggle: { keys: 'mod+alt+5' } },
}),
NumberedListPlugin.configure({
node: { component: NumberedListElement },
shortcuts: { toggle: { keys: 'mod+alt+6' } },
}),
TaskListPlugin.configure({
node: { component: TaskListElement },
shortcuts: { toggle: { keys: 'mod+alt+7' } },
}),
ListItemPlugin,
],
});
node.component: Assigns BulletedListElement, NumberedListElement, and TaskListElement to render list elements.shortcuts.toggle: Defines keyboard shortcuts to toggle list types (mod+alt+5 for bulleted, mod+alt+6 for numbered, mod+alt+7 for task lists).You can add ListToolbarButton to your Toolbar to create and manage lists.
When using the ListPlugin, use the turn-into-toolbar-classic-button which includes all list types (bulleted, numbered, and task lists).
When using the ListPlugin, use the insert-toolbar-classic-button which includes all list types (bulleted, numbered, and task lists).
ListPluginBulletedListPluginPlugin for unordered (bulleted) lists.
NumberedListPluginPlugin for ordered (numbered) lists.
TaskListPluginPlugin for task lists with checkboxes.
ListItemPluginPlugin for list items.
ListItemContentPluginPlugin for list item content.
tf.ul.toggle()Toggles a bulleted list (ul).
Example Shortcut: Mod+Alt+5
tf.ol.toggle()Toggles an ordered list (ol).
Example Shortcut: Mod+Alt+6
tf.taskList.toggle()Toggles a task list with checkboxes.
Example Shortcut: Mod+Alt+7
getHighestEmptyListFinds the highest end list that can be deleted. The path of the list should be different from diffListPath. If the highest end list has 2 or more items, returns liPath. It traverses up the parent lists until:
diffListPathgetListItemEntryReturns the nearest li and ul/ol wrapping node entries for a given path (default = selection).
getListRootSearches upward for root list element.
<API name="getListRoot"> <APIParameters> <APIItem name="at" type="Path | TRange | Point | null" optional> Location to start search from. - **Default:** `editor.selection` </APIItem> </APIParameters> <APIReturns type="ElementEntry | undefined"> Root list element entry. </APIReturns> </API>getListTypesGets array of supported list types.
<API name="getListTypes"> <APIReturns type="string[]"> Array of supported list types. </APIReturns> </API>moveListSiblingsAfterCursorMoves list siblings after cursor to specified path.
<API name="moveListSiblingsAfterCursor"> <APIOptions type="options"> <APIItem name="at" type="Path"> Cursor position path. </APIItem> <APIItem name="to" type="Path"> Destination path. </APIItem> </APIOptions> <APIReturns type="number"> Number of siblings moved. </APIReturns> </API>removeFirstListItemRemoves first list item if not nested and not first child.
<API name="removeFirstListItem"> <APIOptions type="options"> <APIItem name="list" type="ElementEntry"> List entry containing item. </APIItem> <APIItem name="listItem" type="ElementEntry"> List item to remove. </APIItem> </APIOptions> <APIReturns type="boolean"> Whether item was removed. </APIReturns> </API>removeListItemRemoves list item and moves sublist to parent if any.
<API name="removeListItem"> <APIOptions type="RemoveListItemOptions"> <APIItem name="list" type="ElementEntry"> List entry containing item. </APIItem> <APIItem name="listItem" type="ElementEntry"> List item to remove. </APIItem> <APIItem name="reverse" type="boolean" optional> Whether to reverse sublist items. - **Default:** `true` </APIItem> </APIOptions> <APIReturns type="boolean"> Whether item was removed. </APIReturns> </API>someListChecks if selection is inside list of specific type.
<API name="someList"> <APIParameters> <APIItem name="type" type="string"> List type to check. </APIItem> </APIParameters> <APIReturns type="boolean"> Whether selection is in specified list type. </APIReturns> </API>unindentListItemsDecreases indentation level of list items.
<API name="unindentListItems"> <APIOptions type="UnindentListItemsOptions"> Target path for unindenting. </APIOptions> </API>unwrapListRemoves list formatting from selected items.
<API name="unwrapList"> <APIOptions type="options"> <APIItem name="at" type="Path" optional> Target path for unwrapping. </APIItem> </APIOptions> </API>useListToolbarButtonA behavior hook for a list toolbar button.
<API name="useListToolbarButton"> <APIState> <APIItem name="pressed" type="boolean"> Button pressed state. </APIItem> <APIItem name="nodeType" type="string"> List node type. - **Default:** `BulletedListPlugin.key` </APIItem> </APIState> <APIReturns type="object"> <APIItem name="props" type="object"> Props for toolbar button. </APIItem> <APISubList> <APISubListItem parent="props" name="pressed" type="boolean"> Button pressed state. </APISubListItem> <APISubListItem parent="props" name="onClick" type="function"> Handler to toggle list and focus editor. </APISubListItem> </APISubList> </APIReturns> </API>useTodoListElementStateHook to manage task list item state.
<API name="useTodoListElementState"> <APIState> <APIItem name="element" type="TTodoListItemElement"> Task list item element. </APIItem> </APIState> <APIReturns type="object"> <APIItem name="checked" type="boolean"> Whether the task item is checked. </APIItem> <APIItem name="readOnly" type="boolean"> Whether the editor is in read-only mode. </APIItem> <APIItem name="onCheckedChange" type="function"> Handler to toggle the checked state. </APIItem> </APIReturns> </API>useTodoListElementHook to get props for task list item checkbox.
<API name="useTodoListElement"> <APIState> <APIItem name="checked" type="boolean"> Whether the task item is checked. </APIItem> <APIItem name="readOnly" type="boolean"> Whether the editor is in read-only mode. </APIItem> <APIItem name="onCheckedChange" type="function"> Handler to toggle the checked state. </APIItem> </APIState> <APIReturns type="object"> <APIItem name="checkboxProps" type="object"> Props to be spread on the checkbox component. </APIItem> </APIReturns> </API>ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā