Skip to content

feat(assets): dnd kit for asset-to-timeline drag - #75

Merged
thisiscsim merged 1 commit into
mainfrom
feat/dnd-kit-assets
Aug 7, 2026
Merged

thisiscsim merged 1 commit into
mainfrom
feat/dnd-kit-assets

Conversation

@thisiscsim

Copy link
Copy Markdown
Owner

Summary

Per feedback: the Assets-tab drag now runs on dnd kit (@dnd-kit/react 0.5) instead of native HTML5 drag-and-drop.

  • Sources: clip cells and audio rows are useDraggable with type = asset kind and the asset id as data; dragged items dim and dnd kit's feedback plugin renders the drag preview.
  • Targets: timeline lanes are useDroppable with type-based accept (video lanes ← video assets, audio lanes ← audio, text lanes accept nothing — their clips are sketched). Accepting lanes get an accent highlight while hovered.
  • Drop resolution: the Timeline listens via useDragDropMonitor and computes the drop time from the lane's rect + operation.position.current.x at the current zoom; placement logic (video clip push, placeAudioOnTrack) is unchanged. Ref-forwarded handlers keep closures fresh regardless of the library's registration timing.
  • The provider wraps the editor shell only; ASSET_MIME and all native dataTransfer plumbing are removed. Keyboard-sensor accessibility comes with the kit.

Dependency change — restart npm run dev so vite picks up the new package.

Test plan

  • typecheck / test (146) / build / lint / format — green
  • Manual: drag clips onto the video lane at several zoom levels (drop lands at pointer time), audio onto audio lanes, confirm text lanes reject, chip drag/trim within lanes unaffected

Made with Cursor

Replaces the native HTML5 dataTransfer drag between the Assets tab and
the timeline with @dnd-kit/react. Asset cells and audio rows become
useDraggable sources typed by asset kind, lanes become useDroppable
targets with built-in type acceptance (video lanes take video, audio
lanes audio, text lanes nothing), and the Timeline resolves drops itself
through useDragDropMonitor — computing the drop time from the lane rect
and pointer position at the current zoom, with refs keeping the handler
fresh across renders. dnd kit's default feedback replaces the browser
drag ghost, accepting lanes highlight while hovered, dragged items dim,
and the keyboard sensor makes the flow accessible for free. The
ASSET_MIME constant and native drop plumbing are gone.

Co-authored-by: Cursor <cursoragent@cursor.com>
@thisiscsim
thisiscsim merged commit 458d12c into main Aug 7, 2026
1 check passed
@thisiscsim
thisiscsim deleted the feat/dnd-kit-assets branch August 7, 2026 19:07
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