Overview
The List extension provides support for flexible list structures including bullet lists, ordered lists, task lists, and collapsible toggle lists. Built on top ofprosemirror-flat-list, it offers a flat list structure that simplifies nested list operations.
Installation
Basic Usage
List Types
The extension supports four types of lists:Bullet Lists
Unordered lists with bullet points.Ordered Lists
Numbered lists with optional custom starting numbers.Task Lists
Checkable task items with checked/unchecked states.Toggle Lists
Collapsible lists that can be expanded or collapsed.Commands
The List extension provides the following commands:toggleList
Toggles a list on or off at the current selection.kind:'bullet' | 'ordered' | 'task' | 'toggle'- The type of listorder:number | null- Optional starting number for ordered listschecked:boolean- Whether task list items are checkedcollapsed:boolean- Whether toggle lists are collapsed
wrapInList
Wraps the current selection in a list.insertList
Inserts a new list node.indentList
Indents the current list item.dedentList
Dedents (unindents) the current list item.splitList
Splits the current list item at the cursor position.unwrapList
Removes the list wrapper from the current selection.moveList
Moves the current list item up or down.toggleCollapsed
Toggles the collapsed state of a toggle list.Attributes
List nodes support the following attributes:Input Rules
The extension automatically applies input rules for quick list creation:- Type
-or*at the start of a line to create a bullet list - Type
1.or1)to create an ordered list - Type
[ ]to create an unchecked task list - Type
[x]to create a checked task list
Keyboard Shortcuts
The extension includes default keyboard shortcuts:- Tab: Indent list item
- Shift+Tab: Dedent list item
- Enter: Split list item or exit list
- Mod+Shift+8: Toggle bullet list
- Mod+Shift+9: Toggle ordered list
Serialization
The extension includes a DOM serializer for proper HTML output:Advanced Features
Drag and Drop
The extension includes a drop indicator for visual feedback when dragging list items.Nested Lists
Lists can be nested to any depth using the indent and dedent commands:Complete Example
Related Extensions
- Use with
defineDoc()anddefineParagraph()for complete document structure - Combine with text formatting extensions like
defineBold()anddefineItalic()