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

adjust_text_size
Move every open document by points, each staying inside the range against its own base.
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.
reset_text_size
Give every document back to the size its app set it at.
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.
set_text_size
editor::set_text_size(cx, my_steps) — call once at boot.
text_size_adjustment
What every document is currently set away from its base by, in points.

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.