[fix] embeds (#1578)
This PR fixes embeds to remove the `doesResize` prop when creating embeds / converting between bookmarks and embeds. ### Change Type - [x] `patch` — Bug fix [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version ### Test Plan 1. Create an embed 2. Convert between bookmark and embed
This commit is contained in:
parent
b65aef5cf2
commit
e3b00e7c11
2 changed files with 21 additions and 22 deletions
|
@ -4,6 +4,7 @@ import {
|
||||||
EmbedDefinition,
|
EmbedDefinition,
|
||||||
TLAsset,
|
TLAsset,
|
||||||
TLAssetId,
|
TLAssetId,
|
||||||
|
TLEmbedShape,
|
||||||
TLShapePartial,
|
TLShapePartial,
|
||||||
createShapeId,
|
createShapeId,
|
||||||
} from '@tldraw/tlschema'
|
} from '@tldraw/tlschema'
|
||||||
|
@ -150,25 +151,21 @@ export class ExternalContentManager {
|
||||||
const position =
|
const position =
|
||||||
point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.viewportPageCenter)
|
point ?? (editor.inputs.shiftKey ? editor.inputs.currentPagePoint : editor.viewportPageCenter)
|
||||||
|
|
||||||
const { width, height, doesResize } = embed
|
const { width, height } = embed
|
||||||
|
|
||||||
editor.createShapes(
|
const shapePartial: TLShapePartial<TLEmbedShape> = {
|
||||||
[
|
id: createShapeId(),
|
||||||
{
|
type: 'embed',
|
||||||
id: createShapeId(),
|
x: position.x - (width || 450) / 2,
|
||||||
type: 'embed',
|
y: position.y - (height || 450) / 2,
|
||||||
x: position.x - (width || 450) / 2,
|
props: {
|
||||||
y: position.y - (height || 450) / 2,
|
w: width,
|
||||||
props: {
|
h: height,
|
||||||
w: width,
|
url,
|
||||||
h: height,
|
},
|
||||||
doesResize: doesResize,
|
}
|
||||||
url,
|
|
||||||
},
|
editor.createShapes([shapePartial], true)
|
||||||
},
|
|
||||||
],
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
DEFAULT_BOOKMARK_WIDTH,
|
DEFAULT_BOOKMARK_WIDTH,
|
||||||
Editor,
|
Editor,
|
||||||
EmbedShapeUtil,
|
EmbedShapeUtil,
|
||||||
|
TLEmbedShape,
|
||||||
TLShapeId,
|
TLShapeId,
|
||||||
TLShapePartial,
|
TLShapePartial,
|
||||||
TLTextShape,
|
TLTextShape,
|
||||||
|
@ -314,14 +315,14 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
||||||
if (!embedInfo) continue
|
if (!embedInfo) continue
|
||||||
if (!embedInfo.definition) continue
|
if (!embedInfo.definition) continue
|
||||||
|
|
||||||
const { width, height, doesResize } = embedInfo.definition
|
const { width, height } = embedInfo.definition
|
||||||
|
|
||||||
const newPos = new Vec2d(shape.x, shape.y)
|
const newPos = new Vec2d(shape.x, shape.y)
|
||||||
newPos.rot(-shape.rotation)
|
newPos.rot(-shape.rotation)
|
||||||
newPos.add(new Vec2d(shape.props.w / 2 - width / 2, shape.props.h / 2 - height / 2))
|
newPos.add(new Vec2d(shape.props.w / 2 - width / 2, shape.props.h / 2 - height / 2))
|
||||||
newPos.rot(shape.rotation)
|
newPos.rot(shape.rotation)
|
||||||
|
|
||||||
createList.push({
|
const shapeToCreate: TLShapePartial<TLEmbedShape> = {
|
||||||
id: createShapeId(),
|
id: createShapeId(),
|
||||||
type: 'embed',
|
type: 'embed',
|
||||||
x: newPos.x,
|
x: newPos.x,
|
||||||
|
@ -331,9 +332,10 @@ export function ActionsProvider({ overrides, children }: ActionsProviderProps) {
|
||||||
url: url,
|
url: url,
|
||||||
w: width,
|
w: width,
|
||||||
h: height,
|
h: height,
|
||||||
doesResize,
|
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
|
createList.push(shapeToCreate)
|
||||||
deleteList.push(shape.id)
|
deleteList.push(shape.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue