Skip to main content

Module block_editor

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
BlockContent
What one block shows, as the owning model says.
BlockEditor
DocumentPosition
A UTF-8 byte position in a block document.
DocumentSelection
Direction-preserving document selection. Self::ordered provides its normalized start/end pair for editing and serialization.
FindReplaceBatch
One search snapshot, with byte ranges into its blocks.
FindReplaceTarget
A captured find match. Canonical hosts validate this snapshot before writing.
ImagePasteRequest
A clipboard image and its original target. Capturing the intent never edits the document; hosts must validate bytes before applying a replacement.
TransclusionPreview
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§

BlockEditOp
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.
BlockKind
Each CodeBlock stores one authored source line. It may wrap visually; Enter creates the next source row without changing existing line breaks.
CursorPlacement
EditScope
Which blocks the person may have changed, as BlockEditor::take_edit_scope reports it.
ImagePasteTarget
Stable IDs and source snapshots prevent a delayed paste from deleting a different selection or text inserted by a collaborator.
LinkTarget

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 Numbered block, 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§

PresenceKeyFn
Maps a block id to the presence key collaborators address it by.