photo-editor
Version:
Simple and customizable photo editor for web applications.
46 lines (42 loc) • 1.73 kB
TypeScript
import { EventEmitter } from 'eventemitter3';
import { T as Tool } from './Tool-CjhrEUet.js';
export { a as ToolOptions } from './Tool-CjhrEUet.js';
type SourceType = "current-canvas" | "canvas" | "img" | "base64";
type SourceParams<CurrentSource extends SourceType> = CurrentSource extends "base64" ? {
source: string;
} : CurrentSource extends "canvas" ? {
source: HTMLCanvasElement;
} : CurrentSource extends "img" ? {
source: HTMLImageElement;
} : {};
type PhotoEditorOptions<Tools extends Record<string, typeof Tool>, CurrentSource extends SourceType> = {
sourceType?: CurrentSource;
tools: Tools;
} & SourceParams<CurrentSource>;
declare class PhotoEditor<Tools extends Record<string, typeof Tool>, ToolKey extends string & keyof Tools, CurrentSource extends SourceType = "current-canvas"> extends EventEmitter {
_el: HTMLCanvasElement | null;
_options: PhotoEditorOptions<Tools, CurrentSource> | null;
_currentState: number;
_states: string[];
_enabledToolId: ToolKey | null;
_touched: boolean;
_destroyed: boolean;
tools: {
[key in ToolKey]: InstanceType<Tools[key]>;
};
constructor(el: HTMLCanvasElement, editorOptions: PhotoEditorOptions<Tools, CurrentSource>);
_init(): Promise<void>;
_initTools(): void;
_pushState: (state: string) => void;
_updateState: (state: string) => void;
_drawCurrentState(): Promise<void>;
destroy(): void;
getCurrentState(): string;
enableTool(toolId: ToolKey): void;
disableTool: () => void;
toggleTool(toolId: ToolKey): void;
touch: () => void;
undo(): void;
redo(): void;
}
export { PhotoEditor, type PhotoEditorOptions, type SourceParams, type SourceType, Tool };