Expand description
A Notion-style block editor for gpui, over the markdown document model.
ⓘ
editor::init(cx); // once, at startup
let editor = cx.new(|cx| editor::Editor::new("# Title", cx));markdown holds the document, its markdown wire form, and the painting —
all of it testable without a window. What lives here is the half that needs
one: focus, keys, the platform input handler, the mouse, undo, and the menus.
Modules§
- keys
- The keymap: every action the editor answers to, and the chords bound to it.
Structs§
- Anchor
- A range in the document, and which wash it paints.
- Anchor
Id - The app’s key for a comment or a highlight. Opaque — nothing here looks inside one.
- Chrome
- Which of the editor’s own affordances are on.
- Editor
- Formatting
- What a toolbar reads to light itself, in one call.
- Handles
- History
- Image
Store - Who owns the pictures a document points at.
- Layout
- What the editor lays the document out with.
- Mention
- One row of the mention menu.
- Paste
Context - The destination snapshot; the editor entity is being updated during the call.
- SlashAt
- The block a
SlashAction::Runrow was picked for. - Slash
Row - One row of the slash menu.
- Step
- The state a step restores, which is a whole moment rather than a diff.
- Text
Size - How far the chords move a document, in points — the unit a settings field is written in, so the two never need converting between.
Enums§
- Edit
Kind - What an edit did, so a run of the same kind can coalesce into one step instead of giving the document back a character at a time.
- Editor
Event - What the editor tells its host about.
- Mode
- Which form the document is being edited in.
- Paste
Content - Content applied through normal editing and undo.
- Slash
Action - What picking a slash or block menu row does.
- Slash
Item - An item of the slash or block menu.
- Source
- A picture with no address of its own, and what the app is asked about.
Constants§
- CONTEXT
- DEFAULT_
UNDO_ LIMIT - How many steps a document keeps.
- HIGHLIGHT_
MARK - The custom mark
ToggleHighlighttoggles. It does nothing until the app registers a mark under this name withmarkdown::AppExt::set_marks.
Traits§
- AppExt
- Configuration carried by the application. Import as
use editor::AppExt as _;.
Functions§
- block_
menu_ defaults - The slash menu’s default blocks under “Turn into”, then Duplicate and Delete under “Block”.
- init
- Install the editor’s key bindings —
bindings, bound. - slash_
defaults - The editor’s blocks as slash items, each under its glyph, the quotes and
callouts behind one
Quotegroup. - turns
- Every block a block can be turned into, and what each is called — the
vocabulary the slash menu and the block menu both offer, for an app building
a menu of its own. Pair with
Editor::set_block, which is what both of bezel’s own menus call.
Type Aliases§
- Mention
Source - The rows for what has been typed after the trigger, best first. Asked at paint.
- Paste
Handler - Called once before default clipboard handling.
Nonekeeps that behavior. The entity identifies the editor; do not read or update it during the call. Use the snapshot andcx.image_store()when callingImageStore::keep. - Slash
Run - What a
SlashAction::Runrow calls.