Skip to main content

Crate editor

Crate editor 

Source
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.
AnchorId
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.
History
ImageStore
Who owns the pictures a document points at.
Layout
What the editor lays the document out with.
Mention
One row of the @ menu.
PasteContext
The destination snapshot; the editor entity is being updated during the call.
SlashAt
The block a SlashAction::Run row was picked in.
SlashRow
One row of the slash menu.
Step
The state a step restores, which is a whole moment rather than a diff.
TextSize
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§

EditKind
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.
EditorEvent
What the editor tells its host about.
Mode
Which form the document is being edited in.
PasteContent
Content applied through normal editing and undo.
SlashAction
What picking a slash row does.
SlashItem
An item of the slash 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 ToggleHighlight toggles. It does nothing until the app registers a mark under this name with markdown::AppExt::set_marks.

Traits§

AppExt
Configuration carried by the application. Import as use editor::AppExt as _;.

Functions§

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 Quote group.
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§

MentionSource
The rows for what has been typed after the @, best first. Asked at paint.
PasteHandler
Called once before default clipboard handling. None keeps that behavior. The entity identifies the editor; do not read or update it during the call. Use the snapshot and cx.image_store() when calling ImageStore::keep.
SlashRun
What a SlashAction::Run row calls.