Skip to content

Commit 97986fd

Browse files
committed
Fix: Prioritize instance-level embedDefinitions over static legacy field
Make embedDefinitions optional in EmbedShapeOptions and invert priority order in getEmbedDefs() to check instance options first, then legacy static field, then default. This ensures configure() API works correctly even when deprecated setEmbedDefinitions() has been called globally.
1 parent d245937 commit 97986fd

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/tldraw/api-report.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ export interface EmbedDefinition {
13941394

13951395
// @public (undocumented)
13961396
export interface EmbedShapeOptions {
1397-
readonly embedDefinitions: readonly TLEmbedDefinition[];
1397+
readonly embedDefinitions?: readonly TLEmbedDefinition[];
13981398
}
13991399

14001400
// @public

packages/tldraw/src/lib/shapes/embed/EmbedShapeUtil.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const getSandboxPermissions = (permissions: TLEmbedShapePermissions) => {
3939
/** @public */
4040
export interface EmbedShapeOptions {
4141
/** The embed definitions to use for this shape util. */
42-
readonly embedDefinitions: readonly TLEmbedDefinition[]
42+
readonly embedDefinitions?: readonly TLEmbedDefinition[]
4343
}
4444

4545
/** @public */
@@ -48,9 +48,7 @@ export class EmbedShapeUtil extends BaseBoxShapeUtil<TLEmbedShape> {
4848
static override props = embedShapeProps
4949
static override migrations = embedShapeMigrations
5050

51-
override options: EmbedShapeOptions = {
52-
embedDefinitions: DEFAULT_EMBED_DEFINITIONS,
53-
}
51+
override options: EmbedShapeOptions = {}
5452

5553
override canEditWhileLocked(shape: TLEmbedShape) {
5654
const result = this.getEmbedDefinition(shape.props.url)
@@ -66,7 +64,11 @@ export class EmbedShapeUtil extends BaseBoxShapeUtil<TLEmbedShape> {
6664
}
6765

6866
private getEmbedDefs(): readonly TLEmbedDefinition[] {
69-
return EmbedShapeUtil.legacyEmbedDefinitions ?? this.options.embedDefinitions
67+
return (
68+
this.options.embedDefinitions ??
69+
EmbedShapeUtil.legacyEmbedDefinitions ??
70+
DEFAULT_EMBED_DEFINITIONS
71+
)
7072
}
7173

7274
getEmbedDefinitions(): readonly TLEmbedDefinition[] {

0 commit comments

Comments
 (0)