Module block_editor
Expand description
BlockEditor: a stack of RichTextLine-backed blocks (paragraph, heading, lists, code,
divider) with split-on-Enter, merge-on-Backspace, arrow-key navigation and markdown-shortcut
promotion (# -> H1, etc). No demotion once a block is a heading, and promotion only fires on
an empty paragraph, matching the slash-menu convention.
Modules§
- references
- References in the block editor’s text, and the editor as the described component
(
ui.BlockEditor): rich text shown read-only (tilolang’srich_text(value)), and a document’s body edited through the field a view binds it to (itsbody).
Structs§
- Block
- Block
Content - What one block shows, as the owning model says.
- Block
Editor - Document
Position - A UTF-8 byte position in a block document.
- Document
Selection - Direction-preserving document selection.
Self::orderedprovides its normalized start/end pair for editing and serialization. - Find
Replace Batch - One search snapshot, with byte ranges into its blocks.
- Find
Replace Target - A captured find match. Canonical hosts validate this snapshot before writing.
- Image
Paste Request - A clipboard image and its original target. Capturing the intent never edits the document; hosts must validate bytes before applying a replacement.
- RowControl
- A control a host adds to every block’s accessibility row (a rich-text surface’s Duplicate button), built with the row and kept with it.
- Slash
Request - A slash command the editor’s host carries out
(
BlockEditor::take_slash_request): which, on which block, and the block’s text once its/queryis gone. - Transclusion
Preview - Display-only, bounded projection for a live page embed. The source CRDT keeps only the stable UUID mark; hosts refresh this projection on sync.
Enums§
- Block
Edit Op - A semantic, UUID-addressed mutation emitted by the optional action bridge. It intentionally contains no Automerge object ids, making it safe to replay on another replica or use from apps with a different document layout.
- Block
Kind - Each
CodeBlockstores one authored source line. It may wrap visually; Enter creates the next source row without changing existing line breaks. - Callout
Kind - The five alerts GitHub-flavoured Markdown defines, in its order.
- Cursor
Placement - Edit
Scope - Which blocks the person may have changed, as
BlockEditor::take_edit_scopereports it. - Find
Replace - What the window’s search asked to replace, for the host that owns the blocks: it validates the snapshot against its own and applies it as one undoable edit.
- Image
Paste Target - Stable IDs and source snapshots prevent a delayed paste from deleting a different selection or text inserted by a collaborator.
- Link
Target
Constants§
- IMAGE_
VIEWPORT_ FRACTION - The share of the host’s visible height an image preview may take at most, aspect kept: a large picture never fills the editor.
- LIST_
INDENT_ STEP_ PX - Matches the 28px indent step Notion uses in its dense block view.
- MAX_
LIST_ INDENT - Deeper nesting runs off the panel’s right edge.
Functions§
- block_
presence_ key - Keyed by the block’s stable CRDT id (never its position), so a peer’s caret/selection stays on the same block when blocks are inserted, removed or moved above it on either side.
- blocks_
from_ html - The blocks
htmlshows: what a formatted paste brings in. Empty when it shows no words. - blocks_
to_ html blocksas an HTML fragment: what a formatted copy offers.- document_
selection_ presence_ key - A document selection uses one transport frame: the start block’s stable id and the number of blocks it spans after that block live in the key, the existing selection payload carries the endpoint bytes. Compact enough for the live presence anchor bound (64 bytes with a UUID block id).
- legacy_
block_ id - Deterministic stable ID for a legacy block map that has no persisted
id. - numbered_
ordinals - 1-based ordinal per
Numberedblock, 0 for non-numbered rows. Numbered per contiguous run at each indent level: a deeper level restarts under its parent. A different list kind resets its own level and deeper levels, while preserving the numbering of its ancestors.
Type Aliases§
- Presence
KeyFn - Maps a block id to the presence key collaborators address it by.