Blocks: right-click context menu with Cut/Copy/Paste/Delete
Blocks: right-click context menu with Cut/Copy/Paste/Delete
#9 in Riparion/riparion-editor — merged 2026-06-04
What
Right-clicking a rendered block now opens a context menu (dx catalog context_menu) with Cut / Copy / Paste / Delete, wired in the markdown example through the system clipboard.
How
The library stays widget-free (per the Cargo.toml stance):
src/lib.rs— new optionalwrap_block: Option<Callback<BlockChrome, Element>>prop onBlockEditor. The host receives aBlockChrome(block index, markdown source, the rendered child to wrap, anddelete/insert_aftercallbacks) for each inactive block, in both arrange and editing modes — never the active textarea.None(default) is fully back-compatible.- Structural ops
delete_block/insert_block_aftermirroradd_block's frozen-vs-resplit duality (mutate the frozen snapshot while a block is active; re-split +rejoin_normalizedwhen idle), with active-index adjustment. Pure coresdelete_and_normalize/insert_after_and_normalizeare unit-tested (4 new tests, 24 total). examples/markdown/— vendorscontext_menuviadx components add --module-path examples/markdown/components context_menu(upstream demo-only trigger styles stripped;css_modulepath rewritten for the example location). Cut/Copy write the block's markdown to the OS clipboard and Paste reads it back viadocument::eval+navigator.clipboard(best-effort, console-warn on denial). Multi-paragraph pastes re-split into proper blocks.
Verified
Headless-browser run against dx serve --example markdown --features web:
- menu opens at the pointer with the four items; Copy/Cut land on the real OS clipboard; Paste inserts below the right-clicked block; Delete removes it
- left-click-to-edit, Esc, and drag-handle reorder all unaffected
- deleting every block leaves an empty, still-usable editor ("+ New block")
cargo test,cargo check(default /--features web/ example on host +wasm32-unknown-unknown), clippy all green
🤖 Generated with Claude Code
Last updated 2026-06-05
Links to this note
Credits
Merged pull requests, newest first.