Skip to content

Add a handle to the curved connector to change its trajectory#9175

Open
formicoidea wants to merge 1 commit into
toeverything:mainfrom
formicoidea:connectorHandles
Open

Add a handle to the curved connector to change its trajectory#9175
formicoidea wants to merge 1 commit into
toeverything:mainfrom
formicoidea:connectorHandles

Conversation

@formicoidea
Copy link
Copy Markdown

Summary

  • Add a draggable handle on Curve connectors at t=0.5 on the Bézier curve, allowing users to adjust the curve trajectory by dragging
  • The handle stores a curveControlPoint (absolute IVec) on ConnectorElementModel via @field(), persisted through Yjs/CRDT
  • The Bézier is recalculated so the curve passes exactly through the control point (WYSIWYG point de passage)
  • The control point transforms proportionally on resize/rotate and translates on move
  • Cleared automatically when connector mode changes

Changes

File Change
connector/connector.ts (model) New @field() curveControlPoint: IVec | null, handled in moveTo() and resize()
connector-handle.ts New _renderCurveMidpointHandle(), _startCurveMidpointDrag(), _bindCurveMidpointEvents()
connector-manager.ts New _applyCurveControlPoint() — recalculates Bézier control vectors so curve passes through point at t=0.5
connector-watcher.ts Watch curveControlPoint changes, clear on mode change
view.ts Stash/pop curveControlPoint during resize and rotate

Design decisions

  • Single handle at t=0.5 — keeps the UX simple, one draggable point per curve
  • Point de passage (WYSIWYG) — the curve passes exactly through the handle position, not a traditional Bézier control point that "pulls" the curve
  • Semi-persistent — stored in absolute coordinates, proportionally transformed via matrix when endpoints move (consistent with resizePath)
  • Drag in component — follows existing endpoint handle pattern (pointerdown/pointermove/pointerup directly in connector-handle.ts)
  • Single undo entry per drag (mousedown → mouseup grouped via captureSync())

Test plan

  • Select a Curve connector → handle appears at midpoint of the curve
  • Drag the handle → curve reshapes to pass through the dragged position
  • Move a connected block → curve control point transforms proportionally
  • Resize selection containing a curve connector → control point scales correctly
  • Change connector mode (Curve → Straight → Curve) → control point is cleared
  • Undo/redo after dragging → reverts correctly
  • Multi-select connectors → handle does NOT appear (only on single selection)

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocksuite Ready Ready Preview, Comment Mar 22, 2026 6:23pm

Request Review

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 22, 2026

@formicoidea is attempting to deploy a commit to the toeverything Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant