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.

Structs§

Anchor
A comment’s range in the document, and which wash it paints.
CommentId
The app’s key for a thread. Opaque — nothing here looks inside one.
Editor
History
Layout
What the editor lays the document out with.
Step
The state a step restores, which is a whole moment rather than a diff.

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.
Source
A picture with no address of its own, and what the app is asked about.

Constants§

DEFAULT_UNDO_LIMIT
How many steps a document keeps.

Functions§

init
Install the editor’s key bindings. Scoped to the editor’s own key context, so binding tab here does not make tab mean “indent” for the whole app.
set_image_store
editor::set_image_store(cx, my_store) — call once at boot. Without it a screenshot cannot be pasted at all: there is nowhere to put the bytes, and a document holds a URL.
set_layout
editor::set_layout(cx, my_layout) — call once at boot.

Type Aliases§

ImageStore
The URL to write down for source, and None for one the app will not keep — a dropped file then stays where it already is, and a screenshot is let go.