Skip to content

Region-scoped select-all and cross-host selection delete#14

Merged
namedgraph merged 2 commits into
masterfrom
feature/select-all
Jul 11, 2026
Merged

Region-scoped select-all and cross-host selection delete#14
namedgraph merged 2 commits into
masterfrom
feature/select-all

Conversation

@namedgraph

Copy link
Copy Markdown
Member

Summary

Each block being its own contenteditable host meant the browser confined selections to a single block: Ctrl+A never escaped it, and a mouse sweep across blocks painted but could not be deleted. This PR gives the editor its own cross-host selection handling, Google-Docs style.

  • Two-stage Ctrl/Cmd+A — stage 1 stays native (the browser scopes select-all to the focused host); once the host is fully selected (or empty), the next press selects all blocks of the region as a document-level range. Ctrl+A away from a caret — body focus, fresh load, a focused image island — selects the active region too (local:active-root() precedence); native page select-all only when no editable region exists. The selection never reaches the host page.
  • One delete machine (src/select.xsl, dispatched from edit.xsl's host/body/image keydown) serves stage-2 selections and mouse sweeps alike. Block-granular, never one raw deleteContents: fully covered blocks removed whole; partial edge hosts trimmed via host-scoped sub-ranges; composites holding a range boundary keep their grid — covered cells cleared, flow cells collapse back to text hosts (B3/B4 doctrine) — while a fully covered composite goes whole; non-composite edge remnants merge Docs-style with the caret at the seam (never with pre); emptied containers pruned, chrome re-injected, an emptied region reseeded with a fresh paragraph.
  • Region discipline — the range clamps to a single region (one gesture = one region-keyed undo entry); other regions stay byte-identical.
  • Suppression — typing/Enter/Tab/paste over a cross-host selection are inert (type-to-replace is future work); Ctrl+C and plain arrows stay native.
  • Help modal documents select-all, selection delete and undo.

Test plan

  • New tests/browser/select.mjs (registered in run.mjs): both Ctrl+A escalation routes and the away-from-caret paths (body, engaged-region precedence, image island), sweep deletes with Backspace/Delete parity, seam-caret merge semantics, same-list item merge, composite partial/full coverage, cross-region clamping, gesture suppression — every mutating case checked against the I1–I5 invariants and an exact one-undo baseline restore.
  • Full browser matrix (12 suites incl. invariants) and the headless suites pass; no extractor/canonical changes.

🤖 Generated with Claude Code

namedgraph and others added 2 commits July 11, 2026 08:16
Two-stage Ctrl/Cmd+A (Docs-style): native in-host select-all is stage 1;
a fully-selected or empty host escalates to a document-level range over
all blocks of the region. Ctrl+A away from a caret - body focus, fresh
load, a focused image island - selects the active region too; native
page select-all only when no editable region exists.

One block-granular delete machine (select.xsl) serves stage-2 selections
and mouse sweeps alike, from host or body focus: fully covered blocks
are removed whole, partial edge hosts get host-scoped sub-range deletes,
composites holding a range boundary keep their grid (covered cells
cleared, flow cells collapse back to text hosts), non-composite edge
remnants merge Docs-style with the caret at the seam, emptied containers
are pruned, chrome is re-injected and an emptied region is reseeded with
a fresh paragraph. The range clamps to a single region - one gesture,
one region-keyed undo entry. Typing, Enter, Tab and paste over a
cross-host selection are suppressed; copy and plain arrows stay native.

New browser suite select.mjs covers both Ctrl+A routes, sweep deletes,
merge/composite/clamp semantics and the I1-I5 invariants with exact
one-undo baseline restores after every mutating case.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@namedgraph namedgraph merged commit f1ebdb8 into master Jul 11, 2026
2 checks passed
@namedgraph namedgraph deleted the feature/select-all branch July 11, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant