wyuc 09f490cffe
feat(renderer/editing): marquee multi-select + multi-element drag (#851 Part A) (#888)
* feat(renderer/editing): marquee multi-select + multi-element drag (#851 Part A)

Completes the selection model half of the Part A scope:

- core/marquee.ts: normalized min/max marquee rect (collapses the
  reference implementation's four quadrant branches into one
  contain/intersect predicate pair), rotation-aware AABB hit-testing,
  lock exclusion, all-or-nothing group cohesion.
- Blank-canvas capture surface + MarqueeBox chrome + useMarqueeGesture:
  rubber-band selection with the 5-canvas-unit both-axes threshold —
  below it a blank click clears the selection (previously blank clicks
  did nothing at all).
- Click modifiers on elements (ctrl/shift/meta): add when outside the
  selection, remove when inside (guarded against emptying); a plain
  pointer-down on an already-selected element keeps the selection, sets
  it primary, and arms a multi-element drag.
- core/drag.ts computeMultiDragMove: rigid translation of the selected
  set — snap computed on the union bounding box, the corrected delta
  applied to every member; selected elements excluded from snap
  candidates. Commit emits ONE element.updateMany intent (the declared
  batch member, previously unused) = one host undo entry; single-element
  drags keep emitting element.update.

Multi-selections still show no resize/rotate handles (group scaling is
a later slice; the #881 gate is re-asserted in tests).

Part of #851 (Part A) / #720 Phase 3.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(renderer/editing): review round — unified selection resolver, group cohesion on click, safer capture surface (#851)

- Locked elements are never translated by a multi-drag (they may sit in
  a host-controlled selection for feedback; they stay put and remain
  snap candidates).
- Marquee hit-testing of lines uses an AABB over start/end plus any
  present broken/curve/cubic control points — the visible path of a
  bent line can bow outside its chord, which the plain element range
  misses. Conservative by the Bezier convex-hull argument.
- The click modifier table moved into a shared pure resolver
  (core/selection.ts) used by both box and line pointer-down paths, so
  a ctrl-click on a line now adds/removes it instead of replacing the
  selection; the resolver also expands clicks to whole groups
  (select/add/remove act on the group unit), keeps primaryId when it
  survives a subtraction, and drags carry the group.
- Blank capture surface: only on editable mounts (select-only mounts
  keep native touch panning), and only for the main button — a
  right-click no longer clears the selection.
- Shift held mid-drag now engages the dominant-axis lock (previously
  dead plumbing); shift at pointer-down remains a selection modifier.
- Marquee release decisions read the live selection (ref refreshed per
  render) instead of the pointer-down closure; computeMultiDragMove
  guards the empty set.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(renderer/editing): review round — selection features decoupled from mutability, shared line bounds, group closure (#851)

- The blank capture surface renders for any selection-capable mount
  (marquee and blank-click-clear are pure selection features);
  touchAction none applies only on editable mounts, so select-only
  hosts keep native touch panning and gain mouse/pen marquee.
- The control-point-aware line bounds moved to the editing geometry
  layer (getEditingElementRange / getEditingElementListRange) and are
  now shared by marquee hit-testing, the multi-drag union snap box, and
  align-line candidates — a bowed line selects and snaps with one bbox.
- resolveClickSelection group-closes the incoming controlled selection,
  so a host-supplied partial group can no longer produce a drag that
  splits the group; the resolver's no-op emit survives only when the
  incoming selection was already cohesive.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(renderer/editing): review round — visual snap bounds for lines, touch gating on all hit layers (#851)

- Align-line candidates now come from getVisualElementRange: exact
  rendered bounds for lines (polyline elbows are vertices; quadratic and
  cubic curves contribute their Bezier axis extrema), so a guide line is
  never emitted for geometry the curve does not render. The conservative
  control-point hull remains for marquee hit-testing and the multi-drag
  union box — hull answers 'could this be here' (selection must never
  miss), visual answers 'what the user sees aligns'.
- The editability-conditional touchAction now covers every editing hit
  layer (box hit targets, locked blockers, line stroke paths), not just
  the blank surface: a select-only mount preserves native touch panning
  wherever the swipe starts, while tap-to-select keeps working.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(renderer/editing): broken2 visual bounds mirror the rendered orthogonal elbows (#851)

The renderer never draws through the raw broken2 point — the path
builder derives orthogonal elbows from it by orientation. The visual
range branch now mirrors getLineElementPath's elbow coordinates exactly
(documented to stay in lockstep), so align-line candidates for broken2
lines match the rendered path; the raw point survives only in the
conservative hull used by marquee/union. Regression pins the rendered
AABB for the elbow case that previously reported an invisible bottom
edge.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: 杨慎 <117187635+cosarah@users.noreply.github.com>
2026-07-09 22:07:58 +08:00
..