Skip to content

Add EmbedShapeOptions to EmbedShapeUtil#8034

Merged
mimecuvalo merged 6 commits intomainfrom
mime/embed-shape-options
Mar 10, 2026
Merged

Add EmbedShapeOptions to EmbedShapeUtil#8034
mimecuvalo merged 6 commits intomainfrom
mime/embed-shape-options

Conversation

@mimecuvalo
Copy link
Copy Markdown
Member

@mimecuvalo mimecuvalo commented Feb 19, 2026

Summary

We're migrating more to using options/configure on shapes.

  • Adds EmbedShapeOptions interface to EmbedShapeUtil, following the same options pattern used by TextShapeUtil, DrawShapeUtil, FrameShapeUtil, and others
  • Replaces the static mutable embedDefinitions field and setEmbedDefinitions() with instance-level options.embedDefinitions (defaulting to DEFAULT_EMBED_DEFINITIONS)
  • Updates the Tldraw component's embeds prop to use configure() internally instead of mutating static state

Users can now add, augment, or override the default embed definitions via configure:

// Add custom embeds alongside defaults
const shapeUtils = [
  EmbedShapeUtil.configure({
    embedDefinitions: [...DEFAULT_EMBED_DEFINITIONS, myCustomEmbed],
  }),
]

// Override all definitions
const shapeUtils = [
  EmbedShapeUtil.configure({ embedDefinitions: myCustomEmbeds }),
]

// Filter out specific defaults
const shapeUtils = [
  EmbedShapeUtil.configure({
    embedDefinitions: DEFAULT_EMBED_DEFINITIONS.filter(d => d.type !== 'tldraw'),
  }),
]

Breaking changes

  • EmbedShapeUtil.setEmbedDefinitions() is deprecated (use configure() instead)

Test plan

  • Typecheck passes
  • All 198 embed tests pass
  • API report updated automatically

🤖 Generated with Claude Code

Change type

  • improvement

API changes

  • add options.embedDefinitions to EmbedShapeUtil
  • deprecate static setEmbedDefinitions

Note

Medium Risk
Touches how embed definitions are sourced and configured, which could change behavior when multiple editors/util instances or legacy embeds usage rely on the previous global static state.

Overview
Moves embed definition configuration from global static state on EmbedShapeUtil to instance-level options.embedDefinitions (defaulting to DEFAULT_EMBED_DEFINITIONS), aligning embeds with the existing configure()/options pattern used by other shape utils.

Adds a public EmbedShapeOptions type export, keeps EmbedShapeUtil.setEmbedDefinitions(...) as deprecated legacy plumbing, and marks the Tldraw embeds prop as deprecated in favor of configuring EmbedShapeUtil via configure(); API report and package exports are updated accordingly.

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

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 19, 2026

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

Project Deployment Actions Updated (UTC)
examples Ready Ready Preview Mar 10, 2026 11:40am
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
analytics Ignored Ignored Preview Mar 10, 2026 11:40am
chat-template Ignored Ignored Preview Mar 10, 2026 11:40am
tldraw-docs Ignored Ignored Preview Mar 10, 2026 11:40am
tldraw-shader Ignored Ignored Preview Mar 10, 2026 11:40am
workflow-template Ignored Ignored Preview Mar 10, 2026 11:40am

Request Review

@huppy-bot
Copy link
Copy Markdown
Contributor

huppy-bot bot commented Feb 19, 2026

API Changes Check Passed

Great! The PR description now includes the required "### API changes" section. This helps reviewers and SDK users understand the impact of your changes.

Replace the static mutable embedDefinitions field with the standard
options pattern used by other shape utils. Users can now customize embed
definitions via EmbedShapeUtil.configure({ embedDefinitions: [...] }).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mimecuvalo mimecuvalo force-pushed the mime/embed-shape-options branch from db6a188 to 98682db Compare February 20, 2026 12:15
@mimecuvalo mimecuvalo marked this pull request as ready for review February 20, 2026 12:18
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
multiplayer-template d245937 Feb 28 2026, 01:38 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
agent-template d245937 Feb 28 2026, 01:38 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
image-pipeline-template d245937 Feb 28 2026, 01:38 PM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Feb 28, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
multiplayer-template f564ec3 Mar 10 2026, 11:41 AM

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Static legacy field silently overrides instance configure() options
    • Inverted priority order in getEmbedDefs() to check instance options first, then legacy static field, then default, ensuring configure() API always takes precedence over deprecated setEmbedDefinitions().

Create PR

Or push these changes by commenting:

@cursor push 97986fd932
Preview (97986fd932)
diff --git a/packages/tldraw/api-report.api.md b/packages/tldraw/api-report.api.md
--- a/packages/tldraw/api-report.api.md
+++ b/packages/tldraw/api-report.api.md
@@ -1394,7 +1394,7 @@
 
 // @public (undocumented)
 export interface EmbedShapeOptions {
-    readonly embedDefinitions: readonly TLEmbedDefinition[];
+    readonly embedDefinitions?: readonly TLEmbedDefinition[];
 }
 
 // @public

diff --git a/packages/tldraw/src/lib/shapes/embed/EmbedShapeUtil.tsx b/packages/tldraw/src/lib/shapes/embed/EmbedShapeUtil.tsx
--- a/packages/tldraw/src/lib/shapes/embed/EmbedShapeUtil.tsx
+++ b/packages/tldraw/src/lib/shapes/embed/EmbedShapeUtil.tsx
@@ -39,7 +39,7 @@
 /** @public */
 export interface EmbedShapeOptions {
 	/** The embed definitions to use for this shape util. */
-	readonly embedDefinitions: readonly TLEmbedDefinition[]
+	readonly embedDefinitions?: readonly TLEmbedDefinition[]
 }
 
 /** @public */
@@ -48,9 +48,7 @@
 	static override props = embedShapeProps
 	static override migrations = embedShapeMigrations
 
-	override options: EmbedShapeOptions = {
-		embedDefinitions: DEFAULT_EMBED_DEFINITIONS,
-	}
+	override options: EmbedShapeOptions = {}
 
 	override canEditWhileLocked(shape: TLEmbedShape) {
 		const result = this.getEmbedDefinition(shape.props.url)
@@ -66,7 +64,11 @@
 	}
 
 	private getEmbedDefs(): readonly TLEmbedDefinition[] {
-		return EmbedShapeUtil.legacyEmbedDefinitions ?? this.options.embedDefinitions
+		return (
+			this.options.embedDefinitions ??
+			EmbedShapeUtil.legacyEmbedDefinitions ??
+			DEFAULT_EMBED_DEFINITIONS
+		)
 	}
 
 	getEmbedDefinitions(): readonly TLEmbedDefinition[] {
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@mimecuvalo mimecuvalo enabled auto-merge March 10, 2026 11:38
@mimecuvalo mimecuvalo added this pull request to the merge queue Mar 10, 2026
Merged via the queue into main with commit 585739d Mar 10, 2026
25 of 26 checks passed
@mimecuvalo mimecuvalo deleted the mime/embed-shape-options branch March 10, 2026 11:49
github-merge-queue bot pushed a commit that referenced this pull request Mar 10, 2026
followup to #8034
not sure how this passed merge queue

### Change type

- [ ] `bugfix`
- [ ] `improvement`
- [ ] `feature`
- [ ] `api`
- [x] `other`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Updates an examples-only integration to the new embed configuration
API; no core logic changes, but the sample could break if the util is
misconfigured.
> 
> **Overview**
> Updates the `CustomEmbedExample` to use the latest embed configuration
approach by configuring `EmbedShapeUtil` with the custom
`embedDefinitions` and passing it to `Tldraw` via `shapeUtils`.
> 
> Removes usage of the `embeds` prop on `Tldraw` and adjusts the
example’s imports/docs accordingly.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
31d6fa5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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

improvement Product improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants