Skip to content
gpdoc
Playground

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.

Terminal window
cargo add gpdoc-plugin-blockquote

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.

Place the quoted blocks inside one wrapper. Nested paragraphs and lists keep their block views.

quote_block(...)
└── div() Your wrapper
└── block.content Editable paragraphs, lists, and nested quotes

Replace quote_view in the example above.

use gpui::{div, prelude::*};
fn quote_view() -> ViewPlugin {
quote_block(|block, _, _| {
div().child(block.content)
})
}
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]);

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)?;

Remove the nearest quote that contains the entire selection. Its child blocks remain in order.

editor.run(gpdoc_plugin_blockquote::Unset)?;

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)?;
Shortcut Action
Mod + Shift + B Toggle the quote around the selection.

Type > followed by a space at the start of a paragraph. The editor removes the marker and wraps the paragraph.

blockquote/src/lib.rs