Combine list plugins
Install bullet, ordered, and task lists together.
Install
Section titled “Install”cargo add gpdoc-plugin-bullet-list gpdoc-plugin-ordered-list gpdoc-plugin-list-itemcargo add gpdoc-plugin-task-list gpdoc-plugin-list-keymapTry it
Section titled “Try it”Bullet and ordered lists share list_item(). Checklists use task_item(). Register both item types with paragraph() and add list_keymap() for keyboard shortcuts at list boundaries.
Example
Section titled “Example”In a Quickstart project, create a checklist from a typed marker.
use gpdoc::{Editor, EditorConfig, Node};use gpdoc_plugin_bullet_list::bullet_list;use gpdoc_plugin_list_item::list_item;use gpdoc_plugin_list_keymap::list_keymap;use gpdoc_plugin_ordered_list::ordered_list;use gpdoc_plugin_paragraph::paragraph;use gpdoc_plugin_task_list::{task_item, task_list};
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(bullet_list()) .plugin(list_item()) .plugin(list_keymap()) .plugin(ordered_list()) .plugin(task_item()) .plugin(task_list()) .build()?;let mut editor = Editor::from_document(&config, vec![Node::textblock("paragraph", "")])?;editor.insert_text("[ ] ")?;editor.insert_text("Review the copy")?;
assert_eq!(editor.document().blocks()[0].kind, "taskList");The space after [ ] triggers the input rule. The second call inserts the label inside the new unchecked item.
Settings
Section titled “Settings”To allow a task item to contain another list, enable nested task items.
Commands
Section titled “Commands”Switch list type
Section titled “Switch list type”With the caret inside a bullet list, run the task list toggle to convert it to a checklist.
editor.run(gpdoc_plugin_task_list::Toggle)?;List plugins
Section titled “List plugins”| Registration | Commands and where to use them |
|---|---|
bullet_list() |
wrapInBulletList wraps paragraphs. toggleBulletList also lifts bullet items or converts a compatible list. |
ordered_list() |
wrapInOrderedList and toggleOrderedList work on the corresponding paragraphs or list. For a new list, pass an integer start (default 1) and an optional string type (default null). |
list_item() |
splitListItem splits at a text selection in one paragraph. sinkListItem nests the item under its preceding sibling. liftListItem moves it up a level. |
task_list() and task_item() |
toggleTaskList wraps paragraphs, lifts task items, or converts a compatible list. Inside a task item, splitTaskItem splits its paragraph and liftTaskItem lifts the item. New items default to checked = false. |
list_keymap() |
With a caret at an item boundary, listBackspace lifts or joins and listDelete joins forward. At the start of a block after a list, listTab moves the block into the preceding item when the schema permits it. |
Keyboard shortcuts
Section titled “Keyboard shortcuts”Use Mod + Shift + 8 for bullets, Mod + Shift + 7 for numbering, and Mod + Shift + 9 for a checklist. Inside an item, Enter splits at the caret. On an empty item it lifts the item one level.
At the start of an empty paragraph, type -, 1., or [ ] followed by a space to create a bullet, numbered step, or unchecked task.