AssetUtil
Table of contents
Abstract base class for defining asset-type-specific behavior.
Each asset type (image, video, bookmark, etc.) has a corresponding AssetUtil that handles type-specific operations like determining supported MIME types and creating assets from files.
Constructor
Constructs a new instance of the AssetUtil class
Parameters
| Name | Description |
|---|---|
|
Properties
migrations
static migrations?: LegacyMigrations | MigrationSequence | TLPropsMigrations;props
static props?: RecordProps<TLUnknownAsset>;type
The type of the asset util, which should match the asset's type.
static type: string;editor
editor: Editor;options
Options for this asset util. Override this to provide customization options for your asset. Use AssetUtil.configure to customize existing asset utils.
options: {};Methods
configure( )
Configure this asset util's options.
static configure<T extends TLAssetUtilConstructor<any, any>>(
this: T,
options: T extends new (...args: any[]) => {
options: infer Options;
}
? Partial<Options>
: never,
): T;Parameters
| Name | Description |
|---|---|
| |
| |
Returns
T;acceptsMimeType( )
Check whether this asset type accepts a given MIME type.
acceptsMimeType(mimeType: string): boolean;Parameters
| Name | Description |
|---|---|
| |
Returns
boolean;getAssetFromFile( )
Create an asset from a file. Return null if this asset type can't handle the file.
getAssetFromFile(_file: File, _assetId: TLAssetId): Promise<Asset | null>;Parameters
| Name | Description |
|---|---|
| |
|
Returns
Promise<Asset | null>;getDefaultProps( )
Get the default props for an asset of this type.
abstract getDefaultProps(): Asset["props"];getSupportedMimeTypes( )
Get the MIME types that this asset type supports. Return an empty array if this asset type doesn't support files (e.g. bookmarks).
getSupportedMimeTypes(): readonly string[];