Blockquote
Wrap one or more selected blocks in a quote.
blockquote() wraps one or more blocks in a quote. The wrapped blocks keep their text and structure.
Try it
Section titled “Try it”Install
Section titled “Install”cargo add gpdoc-plugin-blockquoteExample
Section titled “Example”Register the quote alongside the paragraph it can wrap. Use this configuration in the Quickstart editor.
use gpdoc::{EditorConfig, PluginViewExt, ViewPlugin};use gpdoc_plugin_paragraph::paragraph;use gpdoc_plugin_blockquote::{blockquote, quote_block};
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(blockquote().with_view(quote_view)) .build() .expect("configure editor");
fn quote_view() -> ViewPlugin { quote_block(|block, _, _| block.content)}At the start of a paragraph, type > followed by a space. The paragraph becomes the first block in the quote.
Compose a blockquote
Section titled “Compose a blockquote”Place the quoted blocks inside one wrapper. Nested paragraphs and lists keep their block views.
Anatomy
Section titled “Anatomy”quote_block(...)└── div() Your wrapper └── block.content Editable paragraphs, lists, and nested quotesWrap the quoted blocks
Section titled “Wrap the quoted blocks”Replace quote_view in the example above.
use gpui::{div, prelude::*};
fn quote_view() -> ViewPlugin { quote_block(|block, _, _| { div().child(block.content) })}Wrap a paragraph
Section titled “Wrap a paragraph”use gpdoc::{Editor, Node};
let paragraph = Node::textblock("paragraph", "The launch is on Friday.");let mut editor = Editor::from_document(&config, vec![paragraph.clone()])?;
editor.run(gpdoc_plugin_blockquote::Set)?;assert_eq!(editor.document().blocks()[0].kind, "blockquote");
editor.run(gpdoc_plugin_blockquote::Unset)?;assert_eq!(editor.document().blocks(), &[paragraph]);Commands
Section titled “Commands”setBlockquote
Section titled “setBlockquote”Wrap the selected sibling blocks in a single quote. A caret targets its paragraph. A selection spanning parts of two paragraphs includes both whole paragraphs. A gap selection supplies no blocks to wrap.
editor.run(gpdoc_plugin_blockquote::Set)?;unsetBlockquote
Section titled “unsetBlockquote”Remove the nearest quote that contains the entire selection. Its child blocks remain in order.
editor.run(gpdoc_plugin_blockquote::Unset)?;toggleBlockquote
Section titled “toggleBlockquote”Unwrap an enclosing quote when possible. Otherwise, wrap the selected blocks. Use this command for a single Quote button.
editor.run(gpdoc_plugin_blockquote::Toggle)?;Keyboard shortcuts
Section titled “Keyboard shortcuts”| Shortcut | Action |
|---|---|
| Mod + Shift + B | Toggle the quote around the selection. |
Start a quote while typing
Section titled “Start a quote while typing”Type > followed by a space at the start of a paragraph. The editor removes the marker and wraps the paragraph.