@mocanvas/mocanvas · class
declare class EmbedShapeUtil extends BaseBoxShapeUtil<EmbedShape>This one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.
Methods · 12
canEdit(_shape: EmbedShape): boolean"Editing" an embed is not typing into it — the shape has no text of its own. It is the state in which the embedded page takes the pointer, and it is the state the iframe above waits for.
Saying no here left that state unreachable, so the frame stayed inert for good and the embed was a picture of a page rather than a page: a video that would not play, a map that would not pan. Saying yes gives an embed the same two-step every canvas uses for something that wants the pointer for itself — one click selects the shape and its handles, a double click hands the pointer over, and clicking away takes it back.
component(shape: EmbedShape): ReactNodeget embedConfig(): EmbedConfigThe per-service settings this util was configured with, keyed by EmbedDefinition.type.
Always an object, so a definition can index it without a guard. This is
where an api key belongs: a definition is handed its own entry and never
reaches for process.env itself, which would put the secret in every
bundle that imported the definition and make it the same for every editor
on the page.
getDefaultProps(): EmbedShapePropsgetEmbedDefinitions(): readonly EmbedDefinition[]The permit list in force for this util; see EmbedShapeOptions.embedDefinitions.
getEmbedMatch(shape: EmbedShape): EmbedMatch | nullThis shape's permit-list entry and iframe url, or null when it has none.
getGeometry(shape: EmbedShape): Geometry2dgetIndicatorPath(shape: EmbedShape): Path2DgetRenderStyle(_shape: EmbedShape): StyleWords | nullAn iframe is not a quad: embeds always render through the DOM overlay.
isAspectRatioLocked(shape: EmbedShape): booleanAn embed whose service declared a fixed content shape resizes proportionally; anything else is a free box.
onBeforeCreate(next: EmbedShape): EmbedShape | voidA new embed is created at its service's content ratio, keeping the width it was asked for. Nothing happens for a service with no declared ratio.
resolveAspectRatio(shape: EmbedShape): number | undefinedThe width ÷ height this embed's content wants, or undefined when nothing
has an opinion about it.
Public because the app needs the same answer the util uses: a "fit to
content" command, a paste handler placing a new embed, a layout engine
reserving a slot. It comes from the matching definition's
EmbedDefinition.sizeToContentAspectRatio; a url off the permit
list, or a service with no fixed shape, answers undefined.
Properties · 5
static migrations: _mocanvas_editor.PropsMigrationsstatic options: EmbedShapeOptionsreadonly options: EmbedShapeOptionsstatic props: _mocanvas_editor.RecordProps<EmbedShape>static type: "embed"mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.