Skip to content

Operate on and move selected block ranges #482

Closed

Description

@Azganoth

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+Up and Alt+Down move 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

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+Up and Alt+Down move 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; CellSelection retains 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:frontend pass; manual Tauri verification covers native clipboard transport, popup commands, nested ranges, and drag behavior.
  • docs/specification.md, docs/reference.md, and CHANGELOG.md describe 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

Activity

  1. self-assigned this
    on Sep 20, 2026
  2. moved this from Backlog to Blocked in Leafdownon Sep 20, 2026
  3. moved this from Blocked to In Progress in Leafdownon Sep 22, 2026
  4. moved this from In Progress to Review in Leafdownon Sep 22, 2026
  5. Azganoth commented on Sep 22, 2026

    @Azganoth
    OwnerAuthor

    Native OS clipboard transport manually verified by the maintainer. PR #500 is merged; the issue is complete.

  6. moved this from Review to Done in Leafdownon Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FeatureNew feature or request

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions