Bullet list
Turn paragraphs into an unordered list.
bullet_list() wraps paragraphs in a list with bullet markers. It uses the shared List item plugin for each entry.
Try it
Section titled “Try it”Install
Section titled “Install”cargo add gpdoc-plugin-bullet-list gpdoc-plugin-list-itemExample
Section titled “Example”Register the list container and the item type it accepts. Use this configuration in the Quickstart editor.
use gpdoc::{EditorConfig, PluginViewExt, ViewPlugin};use gpdoc_plugin_paragraph::paragraph;use gpdoc_plugin_list_item::list_item;use gpdoc_plugin_bullet_list::{bullet_list, bullet_list_body};
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(list_item()) .plugin(bullet_list().with_view(bullets_view)) .build() .expect("configure editor");
fn bullets_view() -> ViewPlugin { bullet_list_body(|block, _, _| block.content)}Type - followed by a space to start a bullet list.
Compose a bullet list
Section titled “Compose a bullet list”Wrap the whole list with bullet_list_body. The list item view supplies each bullet and its editable body.
Anatomy
Section titled “Anatomy”bullet_list_body(...)└── div() Your wrapper └── block.content Editable items with their bullet markersWrap the list items
Section titled “Wrap the list items”Replace bullets_view in the example above.
use gpui::{div, prelude::*};
fn bullets_view() -> ViewPlugin { bullet_list_body(|block, _, _| { div().child(block.content) })}Wrap a paragraph in a bullet list
Section titled “Wrap a paragraph in a bullet list”use gpdoc::{Editor, Node};
let mut editor = Editor::from_document(&config, vec![Node::textblock("paragraph", "Keep a changelog")])?;editor.run(gpdoc_plugin_bullet_list::Toggle)?;
assert_eq!(editor.document().blocks()[0].kind, "bulletList");Settings
Section titled “Settings”gpdoc_plugin_bullet_list::bullet_list() takes no options. Register it with paragraph() and list_item(). A bulletList has no attributes and contains one or more listItem nodes.
Commands
Section titled “Commands”toggleBulletList
Section titled “toggleBulletList”With a caret in a paragraph, make it a bullet. Select across paragraphs to create several items. Toggling inside a top-level bullet list lifts the selected items back into paragraphs. Inside a compatible list of another type, the command converts the list to bullets.
editor.run(gpdoc_plugin_bullet_list::Toggle)?;wrapInBulletList
Section titled “wrapInBulletList”Wrap the selected paragraphs in one list, preserving their text and inline marks. Adjacent bullet lists join the new items.
editor.run(gpdoc_plugin_bullet_list::Wrap)?;Keyboard shortcuts
Section titled “Keyboard shortcuts”| Shortcut | Command |
|---|---|
| Mod + Shift + 8 | toggleBulletList |
At the start of a paragraph, type -, +, or * followed by a space. The input rule replaces the marker with a bullet.