View as Markdown

API reference: @salmonui/editors/image-editor

ImageEditorActionsinterface

import type { ImageEditorActions } from '@salmonui/editors/image-editor';
interface ImageEditorActions {
    toBlob(options?: ImageEditorExportOptions): Promise<Blob | null>;
    toDataURL(options?: ImageEditorExportOptions): Promise<string | null>;
    toImageData(): Promise<ImageData | null>;
    open(source: ImageEditorSource): void;
    undo(): void;
    redo(): void;
    reset(): void;
    zoomTo(zoom: number): void;
    select(id: string | null): void;
    setTool(tool: ImageEditorTool): void;
    getSize(): {
        width: number;
        height: number;
    } | null;
    focus(): void;
}

actionsRef: imperative operations.

ImageEditorActions members (12)
NameSignatureDescription
toBlobtoBlob(options?: ImageEditorExportOptions): Promise<Blob | null>;

The edited image at output size; null when nothing is loaded or onBeforeExport cancelled.

toDataURLtoDataURL(options?: ImageEditorExportOptions): Promise<string | null>;
toImageDatatoImageData(): Promise<ImageData | null>;
openopen(source: ImageEditorSource): void;

Opens another image; the edit starts over.

undoundo(): void;
redoredo(): void;
resetreset(): void;
zoomTozoomTo(zoom: number): void;

Proposes a committed zoom (clamped to minZoom / maxZoom).

selectselect(id: string | null): void;

Selects an annotation by id (null clears).

setToolsetTool(tool: ImageEditorTool): void;
getSizegetSize(): { width: number; height: number; } | null;

Output size of the current edit, or null before load.

focusfocus(): void;

Focuses the canvas.