Inline block-swap live-preview markdown editor
Inline block-swap live-preview markdown editor
#34 in Riparion/riparion-cms — merged 2026-06-02
Summary
Replaces the side-by-side markdown preview with an inline, Typora/Obsidian-style block-swap editor: the document renders as styled markdown blocks, and the block you're editing swaps to a raw <textarea> in place. Pure Dioxus — no contenteditable, no JS engine (just web-sys for caret/selection).
The editor lives in its own repo (Riparion/riparion-editor) and is consumed here as a git dependency, like arium-dioxus and dx-dnd.
Editor (riparion-editor crate)
- Block-swap editing — rendered blocks; the active one is a textarea. App-agnostic: the host injects
render_block+is_atomic, so the crate pins no markdown dialect.bodystays the single source of truth (save path unchanged). - Lossless block model —
split_blocks/join_blocksround-trip byte-for-byte (respecting fenced code + atomic embed lines). - Keyboard editing (web): double-Enter starts a new block below with the caret in it; column-preserving cross-block arrow navigation; selection formatting — type
*_`~to wrap, plusCmd/Ctrl+B/+I/+K(link). - Drag-to-reorder via
dx-dnd; auto-growing textarea; discoverable + New block.
App integration
MarkdownPanegains a Live / Raw toggle (Live default mountsBlockEditorwired to the realparse_body+render_segmentspipeline); public signature unchanged, soposts.rsis untouched.mdx::is_embed_lineexposes embed detection for the editor's atomic predicate.- Syntax highlighting in the live preview: a
#[post("/api/highlight-block")]server fn reuses the published-pageparse_body_highlighted(syntect stays server-only);EditorBlockfetches highlighted segments only for code-fence blocks and renders prose instantly client-side. - Repo is no longer a workspace (the editor moved out); reverts to a plain package.
Verification
- clippy
-D warningsclean: wasmweb, serversqlite, serverpostgres cargo fmt --checkclean · server tests pass (26)- Manual end-to-end steps captured locally in
TODO_VERIFICATION.md(gitignored)
Note: interactive behaviors (caret follow, arrow nav, drag, selection formatting, highlighting) are best confirmed by running the app at
/admin/posts/new.
🤖 Generated with Claude Code
Last updated 2026-06-02
Links to this note
Credits
Merged pull requests, newest first.