@mocanvas/mocanvas · class
declare abstract class BuiltInAssetUtil<A extends Asset>The shared half of the three utils below.
Deliberately not exported: the documented base class is AssetUtil in the
editor package, and exporting a second class under a different name here
would give apps two bases to choose between. When the editor's AssetUtil
lands, these three change their extends clause and nothing else — they
already have its documented members.
Methods · 11
acceptsMimeType(mimeType: string): booleanWhether this util claims mimeType. Case-insensitive.
static configure<C extends AssetUtilClass>(this: C, options: object): CThis util with options merged over its defaults, as a new class.
Nothing is mutated, so two editors on one page can register differently configured copies of the same asset type.
constructor(editor: Editor)abstract getAssetFromFile(file: File, assetId: Asset["id"]): Promise<A | null>Build an asset record from a file, or null when it cannot.
abstract getDefaultProps(): A["props"]The props a freshly created asset of this type starts with.
getMimeTypes(): readonly string[]Alias of getSupportedMimeTypes, under the name the editor's registry calls.
abstract getShapeType(): stringThe shape type an asset of this type is dropped as.
abstract getSupportedMimeTypes(): readonly string[]The MIME types this util can build an asset from.
resolve(asset: Asset): string | nullThe URL the canvas should paint this asset from.
get type(): A["type"]upload(file: File, _editor: Editor): Promise<Asset>Build an asset for file, for the editor's registry.
Properties · 6
readonly editor: Editorstatic migrations?: objectHow this asset type's props have changed over time.
static options?: objectThe defaults every instance starts its options from.
readonly options: AssetUtilOptionsstatic props?: objectProp validators for this asset type. Read by the store when it builds the schema.
static type: stringMentioned here
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.