ImageAssetUtil

See source code
Table of contents

Extends AssetUtil<TLImageAsset>.

class ImageAssetUtil extends AssetUtil<TLImageAsset> {}

Constructor

Constructs a new instance of the AssetUtil class

Parameters

NameDescription

editor

Editor;

Properties

migrations

static
static migrations: import("@tldraw/store").MigrationSequence;

props

static
static props: {
  fileSize: import("@tldraw/validate").Validator<number | undefined>;
  h: import("@tldraw/validate").Validator<number>;
  isAnimated: import("@tldraw/validate").Validator<boolean>;
  mimeType: import("@tldraw/validate").Validator<null | string>;
  name: import("@tldraw/validate").Validator<string>;
  pixelRatio: import("@tldraw/validate").Validator<number | undefined>;
  src: import("@tldraw/validate").Validator<null | string>;
  w: import("@tldraw/validate").Validator<number>;
};

type

static
static type: "image";

editor

editor: Editor;

options

options: {
  maxDimension: number;
  supportedMimeTypes: null | readonly string[];
};

Methods

configure( )

static

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

NameDescription

this

T;

options

T extends new (...args: any[]) => {
  options: infer Options;
}
  ? Partial<Options>
  : never;

Returns

T;

acceptsMimeType( )

Check whether this asset type accepts a given MIME type.

acceptsMimeType(mimeType: string): boolean;

Parameters

NameDescription

mimeType

string;

Returns

boolean;

getAssetFromFile( )

getAssetFromFile(
  file: File,
  assetId: TLAssetId,
): Promise<null | TLImageAsset>;

Parameters

NameDescription

file

File;

assetId

Returns

Promise<null | TLImageAsset>;

getDefaultProps( )

getDefaultProps(): TLImageAsset["props"];

getSupportedMimeTypes( )

getSupportedMimeTypes(): readonly string[];

Prev
HighlightShapeUtil
Next
ImageShapeUtil