@mocanvas/editor · interface

TLAssetUtilLike

interface TLAssetUtilLike

What the editor requires of an asset util.

Everything but type is optional, so a util that only resolves URLs — the common case for an app pointing at its own CDN — is three lines long.


Properties · 5

getMimeTypes?(): readonly string[]

MIME types it can build an asset from.

getShapeType?(): string | undefined

The shape type to create when one of these assets is dropped.

resolve?(asset: Asset, editor: Editor): string | null | Promise<string | null>

Turn an asset record into a URL the canvas can paint.

readonly type: string

The Asset["type"] this util handles.

upload?(file: File, editor: Editor): Promise<Asset>

Turn a file into an asset record.

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.