Repository navigation
Operate on and move selected block ranges #482
Description
Summary
Make a hierarchical block selection operable as one contiguous structural range after #478 provides the selection primitive. Clipboard, deletion, replacement, keyboard movement, and drag reordering must act on complete selected blocks without flattening content, detaching nested children, or losing Markdown meaning.
This remains separate from selection entry because transaction normalization, clipboard representations, drag behavior, command state, and history form a distinct implementation and verification boundary.
Expected behavior
- Copy exports the selected sibling blocks as one structural slice with Leafdown's normal plain-text and HTML clipboard representations. A selected list item includes its complete nested subtree.
- Cut and Delete or Backspace remove the selected sibling range in one undoable action. They restore the remembered text-selection bookmark when it remains valid; otherwise they place the nearest editable caret at the surviving structural boundary.
- Typing or pasting over a block selection replaces the range through the selection's structural replacement semantics rather than concatenating block text. Parent containers remain schema-valid and empty-container behavior follows Validate nested sibling block selection and local gutter targeting #483.
Alt+UpandAlt+Downmove the selected range within its current parent while preserving order, nested content, selection direction, and a mapped selection after the move.- Dragging a handle moves the current block or selected sibling range within the same parent, using the same valid-target and no-op rules as keyboard movement. Cross-depth reparenting is deferred.
- Cross-parent selection retains exact directional endpoints and supplies the open structural slice between them, so operations preserve the intended range without absorbing adjacent list items.
- Tables and other indivisible objects operate atomically. Native table-cell clipboard and deletion behavior retains precedence for
CellSelection. - The existing selection context popup exposes valid Cut, Copy, Paste or replacement, Delete, block conversion, and movement commands; inline-only actions are absent. Command state reflects document boundaries and invalid targets.
- Operations preserve supported authored form, list and blockquote structure, source-projection guarantees, dirty state, and native Undo or Redo behavior.
Related context
- Related issues or pull requests: Define structural block selection interactions and local gutter ownership #477 selects the operation set and post-operation behavior. Validate nested sibling block selection and local gutter targeting #483 validates nested replacement and normalization. Implement hierarchical block selection and local gutter interaction #478 provides the custom selection, local handle, decorations, and popup integration. Add hierarchical keyboard selection for blocks #481 owns keyboard selection rather than structural movement. Determine whether whole-block selection is viable and what it costs source projection #420 establishes the projection and history boundary.
- Project origin: block selection, deletion, and movement have been shaped out of the
Advanced selection and structural editingdraft; that draft retains only sentence, word-boundary, and selected-word-match ideas. - Documentation:
docs/specification.mdowns clipboard and editor interaction behavior;docs/reference.mdalready reserves Select block, Delete block, and Move block up or down commands.
Done when
- Copy, Cut, Delete, Backspace, typing, and paste operate on the selected structural sibling slice with the accepted post-operation bookmark or caret.
- Complete list items carry their nested children, nested sibling ranges remain inside their parent, and blockquotes preserve their container structure.
-
Alt+UpandAlt+Downmove the selected range as one unit and correctly disable at parent boundaries or invalid targets. - Handle drag reorders one block or the selected range within one parent and shares validation with keyboard movement.
- Undo and Redo restore document content and the mapped selection or caret for every included operation.
- Tables, code blocks, images, horizontal rules, and other atomic blocks preserve structure and Markdown round trips;
CellSelectionretains native ownership. - Clipboard interoperability covers Leafdown HTML, plain Markdown text, internal paste, and external paste replacement.
- The context popup shows selection-valid structural actions and command enabled state without a second handle menu.
- Focused automated coverage and
pnpm check:frontendpass; manual Tauri verification covers native clipboard transport, popup commands, nested ranges, and drag behavior. -
docs/specification.md,docs/reference.md, andCHANGELOG.mddescribe the shipped operations and shortcuts.
Notes
Implementation direction
Use the custom selection's content and replacement contract as the common boundary for clipboard, deletion, and replacement. Keep movement transactions structural and map the selection bookmark through them; do not recreate blocks from serialized text. Consume the open-slice and endpoint contract proved by #483 rather than distributing cross-parent special cases across individual commands.
Out of scope
- Selection representation, painting, local gutters, popup anchoring, and pointer entry owned by Implement hierarchical block selection and local gutter interaction #478.
- Hierarchical
Mod+A,Escape, arrow extension, and Enter behavior owned by Add hierarchical keyboard selection for blocks #481. - Duplicate block, cross-depth reparenting, non-contiguous movement, and cross-document drag.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
feat: operate on and move selected block ranges (#500)
Azganoth commentedon Sep 22, 2026
Native OS clipboard transport manually verified by the maintainer. PR #500 is merged; the issue is complete.
test: verify hierarchical block selection as one workflow (#501)