TLAssetShape
Union type of all shapes that reference assets through an assetId property. Includes image shapes, video shapes, and any other shapes that depend on external assets.
type TLAssetShape = ExtractShapeByProps<{
assetId: TLAssetId;
}>;Example
// Function that works with any asset-based shape
function handleAssetShape(shape: TLAssetShape) {
const assetId = shape.props.assetId;
if (assetId) {
const asset = editor.getAsset(assetId);
// Handle the asset...
}
}
// Use with image or video shapes
const imageShape: TLImageShape = { props: { assetId: "asset:img1" } };
const videoShape: TLVideoShape = { props: { assetId: "asset:vid1" } };
handleAssetShape(imageShape); // Works
handleAssetShape(videoShape); // WorksPrev
TLAssetPartialNext
TLBinding