Skip to content
gpdoc
Playground

Focus

Highlight the block containing the selection anchor while the editor has focus.

Click either quoted paragraph. The highlight follows the paragraph containing the caret.

Terminal window
cargo add gpdoc-plugin-focus
use gpdoc_plugin_focus::{FocusMode, focus, paint_focus};
use gpdoc_plugin_paragraph::paragraph;
let config = gpdoc::EditorConfig::builder()
.plugin(paragraph())
.plugin(focus(FocusMode::Deepest).with_view(paint_focus))
.build()
.expect("configure editor");

Pass your own painter to .with_view(...) to change the appearance. It receives the selected block’s bounds, window, and app. With FocusMode::All, the plugin calls it once for each visible enclosing block.

Place the caret in a paragraph inside a blockquote. FocusMode::Deepest highlights the paragraph. Use Shallowest for the outermost enclosing block or All to paint each enclosing block. Moving focus out of the editor hides the highlight.

focus/src/lib.rs