Skip to content

feat(editor): add experimental onDropOnCanvas option#7911

Merged
steveruizok merged 6 commits intomainfrom
feat/drop-on-canvas-option-clean
Feb 13, 2026
Merged

feat(editor): add experimental onDropOnCanvas option#7911
steveruizok merged 6 commits intomainfrom
feat/drop-on-canvas-option-clean

Conversation

@steveruizok
Copy link
Copy Markdown
Collaborator

@steveruizok steveruizok commented Feb 13, 2026

In order to let consumers intercept and customize drag-and-drop behavior on the canvas, this PR adds an experimental__onDropOnCanvas callback to TldrawOptions.

The callback receives the page-space drop coordinates and the original drag event. Returning true prevents the default file/URL drop handling, giving consumers full control over what happens when content is dropped on the canvas.

This also refactors the onDrop handler to compute the page point once and reuse it for both file and URL drops.

Change type

  • feature

Test plan

  1. Create a tldraw instance with experimental__onDropOnCanvas set to a function that returns true
  2. Drop a file on the canvas — the default file handling should be skipped
  3. Create a tldraw instance without the option set
  4. Drop a file on the canvas — default handling should work as before
  • Unit tests
  • End to end tests

Release notes

  • Add experimental experimental__onDropOnCanvas option to intercept canvas drop events

API changes

  • Added TldrawOptions.experimental__onDropOnCanvas callback for intercepting canvas drop events

Note

Medium Risk
Touches core drag-and-drop event handling on the canvas; while gated behind an optional callback, it can change how external content drops are processed if misused.

Overview
Adds an experimental TldrawOptions.experimental__onDropOnCanvas callback that receives the page-space drop point and the original DragEvent, and can return true to stop the editor’s default drop behavior.

Updates the canvas onDrop handler to compute the drop point once, invoke the callback if present, and otherwise continue with existing file/URL putExternalContent handling. Public API reports and defaultTldrawOptions are updated to expose the new option.

Written by Cursor Bugbot for commit e16014e. This will update automatically on new commits. Configure here.

Add an experimental__onDropOnCanvas callback to TldrawOptions that lets
consumers intercept drag-and-drop events on the canvas. The callback
receives the page-space drop point and the original drag event, and can
return true to prevent the default file/URL drop handling.

This also refactors the onDrop handler to compute the page point once
and reuse it for both file and URL drops.
@huppy-bot huppy-bot bot added the feature New feature label Feb 13, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 13, 2026

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

Project Deployment Actions Updated (UTC)
examples Ready Ready Preview Feb 13, 2026 0:21am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
analytics Ignored Ignored Preview Feb 13, 2026 0:21am
chat-template Ignored Ignored Preview Feb 13, 2026 0:21am
tldraw-docs Ignored Ignored Preview Feb 13, 2026 0:21am
tldraw-shader Ignored Ignored Preview Feb 13, 2026 0:21am
workflow-template Ignored Ignored Preview Feb 13, 2026 0:21am

Request Review

@steveruizok steveruizok added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 6345b52 Feb 13, 2026
16 checks passed
@steveruizok steveruizok deleted the feat/drop-on-canvas-option-clean branch February 13, 2026 12:42
github-merge-queue bot pushed a commit that referenced this pull request Feb 14, 2026
In order to keep the release notes current for the upcoming SDK release,
this PR updates `apps/docs/content/releases/next.mdx` with documentation
for recently merged changes.

### Changes

- Add "What's new" section for the experimental `onDropOnCanvas` canvas
drop handler (#7911)
- Add API change entry for `TldrawOptions.experimental__onDropOnCanvas`
- Update release intro paragraph to mention the new drop handler
- Add bug fix entry for CJS compatibility regression from ESM-only rbush
(#7905)
- Add bug fix entry for zero pen pressure on tablets affecting draw
shapes (#5693)

### Change type

- [x] `docs`

### Test plan

- [ ] Verify the release notes render correctly on the docs site

### Release notes

- Update next release notes with experimental canvas drop handler, CJS
fix, and tablet pressure fix
huppy-bot bot pushed a commit that referenced this pull request Feb 14, 2026
In order to keep the release notes current for the upcoming SDK release,
this PR updates `apps/docs/content/releases/next.mdx` with documentation
for recently merged changes.

### Changes

- Add "What's new" section for the experimental `onDropOnCanvas` canvas
drop handler (#7911)
- Add API change entry for `TldrawOptions.experimental__onDropOnCanvas`
- Update release intro paragraph to mention the new drop handler
- Add bug fix entry for CJS compatibility regression from ESM-only rbush
(#7905)
- Add bug fix entry for zero pen pressure on tablets affecting draw
shapes (#5693)

### Change type

- [x] `docs`

### Test plan

- [ ] Verify the release notes render correctly on the docs site

### Release notes

- Update next release notes with experimental canvas drop handler, CJS
fix, and tablet pressure fix
github-merge-queue bot pushed a commit that referenced this pull request Mar 18, 2026
In order to publish the v4.5.0 release notes and record the v4.4.1
patch, this PR archives release notes and resets `next.mdx` for the next
cycle.

**v4.5.0.mdx** (new file):
- Archived from `next.mdx` with full frontmatter, keywords, and GitHub
release link
- Featured sections: click-through on transparent image pixels (#7942),
breaking `EmbedShapeUtil.configure()` change (#8034)
- API changes: `Editor.getResizeScaleFactor()` (#8042),
`TLImageAsset.pixelRatio` (#8163), `sanitizeSvg` (#7896),
`experimental__onDropOnCanvas` (#7911), enum-to-const refactoring
(#8084)
- 6 improvements and 20 bug fixes from production

**v4.4.0.mdx:**
- Add v4.4.1 patch release section with tooltip positioning fix (#8171)
- Add v4.4.1 to keywords

**next.mdx:**
- Reset with `last_version: v4.5.0` and empty content

### Change type

- [x] `other`

### Code changes

| Section       | LOC change    |
| ------------- | ------------- |
| Documentation | +128 / -107   |
huppy-bot bot pushed a commit that referenced this pull request Mar 18, 2026
In order to publish the v4.5.0 release notes and record the v4.4.1
patch, this PR archives release notes and resets `next.mdx` for the next
cycle.

**v4.5.0.mdx** (new file):
- Archived from `next.mdx` with full frontmatter, keywords, and GitHub
release link
- Featured sections: click-through on transparent image pixels (#7942),
breaking `EmbedShapeUtil.configure()` change (#8034)
- API changes: `Editor.getResizeScaleFactor()` (#8042),
`TLImageAsset.pixelRatio` (#8163), `sanitizeSvg` (#7896),
`experimental__onDropOnCanvas` (#7911), enum-to-const refactoring
(#8084)
- 6 improvements and 20 bug fixes from production

**v4.4.0.mdx:**
- Add v4.4.1 patch release section with tooltip positioning fix (#8171)
- Add v4.4.1 to keywords

**next.mdx:**
- Reset with `last_version: v4.5.0` and empty content

### Change type

- [x] `other`

### Code changes

| Section       | LOC change    |
| ------------- | ------------- |
| Documentation | +128 / -107   |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant