Skip to content

Add hierarchical keyboard selection for blocks #481

Description

@Azganoth

Summary

Add progressive keyboard entry and extension for hierarchical block selection after #478 provides the selection primitive. Focused-editor Mod+A climbs Leafdown's structural scopes instead of jumping directly to the whole document, while Escape, arrows, and Enter make the same nested selection model usable without a gutter.

This remains separate from the core selection because editor keymaps, the app-visible Select all command, tables, nested parents, context-popup and preview dismissal, caret restoration, and source projection require one focused precedence contract.

Expected behavior

  • With focus in ordinary editor content, the first Mod+A selects the nearest eligible block at the caret's structural depth. Repeating it selects that block's sibling group, then promotes to the containing eligible block and continues outward until the whole document is selected. Repeating at the widest scope is stable.
  • A complete list item is one escalation scope and includes its nested children. Nested list items participate at their own depth. Blockquotes expose the container and eligible child scopes validated by Validate nested sibling block selection and local gutter targeting #483. Tables remain atomic and native table or CellSelection behavior retains precedence inside them.
  • Edit > Select all continues to select the complete document immediately; progressive behavior belongs to the focused-editor keyboard gesture.
  • A keyboard-created block selection opens or repositions the existing selection context popup while focus stays in the editor. Menu key or Shift+F10 moves focus into that same popup; there is no handle-specific menu.
  • Escape first dismisses an open context popup or footnote preview and leaves the selection standing. With no dismissible surface open, it enters block selection from the current caret or text range, or exits block selection and restores the remembered text-selection bookmark when valid; otherwise it resolves the nearest editable caret.
  • Up and Down move the selection head through eligible siblings at the current parent. Shift+Up and Shift+Down extend or retract the contiguous range while preserving anchor and direction. Enter restores editing at the remembered caret or a valid caret in the head block.
  • Entering block selection finalizes active source projection before changing selection. Popup and preview dismissal remains earlier in key handling, and non-editor focused controls retain native behavior.
  • Keyboard changes announce the selected block type, sibling count, or promoted scope while focus remains in the editor.

Related context

Done when

  • Focused-editor Mod+A progresses from the nearest eligible block through sibling and containing scopes to the whole document, following Validate nested sibling block selection and local gutter targeting #483's node map.
  • Complete list items, nested list items, blockquotes, atomic objects, tables, and CellSelection have explicit escalation coverage.
  • Edit > Select all still selects the whole document immediately and reports correct command state.
  • Escape, Up, Down, Shift+Up, Shift+Down, and Enter implement entry, navigation, extension, reversal, exit, and caret restoration.
  • The existing context popup opens or refreshes for keyboard selection, retains editor focus until explicitly invoked, and dismisses before selection changes.
  • Source projection finalizes before block selection and preserves Determine whether whole-block selection is viable and what it costs source projection #420/Validate nested sibling block selection and local gutter targeting #483 history guarantees.
  • Node selection, ordinary text selection, native table behavior, popup or preview focus, and non-editor controls retain their shortcut ownership.
  • Selection changes announce block type, count, or promoted scope.
  • Focused automated coverage and pnpm check:frontend pass; manual Tauri verification covers the complete key sequence on Windows.
  • docs/specification.md, docs/reference.md, and CHANGELOG.md describe the shipped behavior.

Notes

Implementation direction

Handle progressive Mod+A in the focused editor keymap rather than changing the app command behind Edit > Select all. Determine the next scope from the current selection and resolved eligible-parent chain, not from timing between key presses. Respect event.defaultPrevented so a more specific editor owner can win before structural escalation.

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. changed the title [-]Add progressive keyboard selection for whole blocks[/-] [+]Add hierarchical keyboard selection for blocks[/+] on Sep 20, 2026
  4. moved this from Blocked to In Progress in Leafdownon Sep 22, 2026
  5. moved this from In Progress to Review in Leafdownon Sep 22, 2026
  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