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. Promotion only fires on an empty paragraph, matching the slash-menu convention.
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.
- 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. - Cursor
Placement - Edit
Scope - Which blocks the person may have changed, as
BlockEditor::take_edit_scopereports it. - 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§
- 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.
- 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.