import { ImageFormatCode, ImageLayer, ImageViewerAPI, ImageViewerPluginAPI, PluginType, Size } from "./ImageViewer"; /** * Page tools toolbar button key. */ export type PageToolButtonKey = "rotate-image" | "flip-horizontal" | "flip-vertical" | "crop-image" | "resize-image" | "$split" | "edit-undo" | "edit-redo"; /** * PageToolsPlugin options. */ export type PageToolsPluginOptions = { /** * The position where the "Page tools" button should be inserted. Use `false` or `-1` to skip insertion. Undefined means the position will be determined automatically. */ buttonPosition?: number | false; /** * The page tools toolbar layout. * @default * Default layout: * ["rotate-image", "flip-horizontal", "flip-vertical", "crop-image", "resize-image"] * @example * ```javascript * * * * ``` */ toolbarLayout?: PageToolButtonKey[]; }; /** * Defines Page Tools Plugin API. * @ignore exclude API interface from docs since it is documented by implementing class. */ export interface PageToolsPluginAPI extends ImageViewerPluginAPI { /** * Plugin options */ options: PageToolsPluginOptions; /** * Gets current rotation in degrees. */ readonly totalRotation: number; /** * Rotate image. * @param angle Angle to rotate an image. */ rotate(angle: number): Promise; /** * Crop image. * @param {number} x Leftmost point of a new image rectangle * @param {number} y Topmost point of a new image rectangle * @param {number} width Width a new image rectangle * @param {number} height Height a new image rectangle * @returns {Promise} Whether transformation was applied successfully or not. */ crop(x: number, y: number, width: number, height: number): Promise; /** * Resize image. * @param {number} width New image width. * @param {number} height New image height * @param {boolean} keepAspectRatio Explicitly defines a need of keeping an original image aspect ratio. Defaults to true. */ resize(width: number, height: number, keepAspectRatio: boolean): Promise; /** * Flip image. * @param {boolean} horizontal Flip horizontally. True by default. * @param {boolean} horizontal Flip horizontally. False by default. * @returns {Promise} Whether transformation was applied successfully or not. */ flip(horizontal: boolean, vertical: boolean): Promise; /** * Flip image horizontally. * @returns {Promise} Whether transformation was applied successfully or not. */ flipHorizontal(): Promise; /** * Flip image vertically. * @returns {Promise} Whether transformation was applied successfully or not. */ flipVertical(): Promise; } /** * Page Tools Plugin. * Adds the "Page tools" button. * @example * ```html * * * * ``` */ export declare class PageToolsPlugin implements PageToolsPluginAPI { constructor(options?: PageToolsPluginOptions); viewer: ImageViewerAPI; options: PageToolsPluginOptions; totalRotation: number; rotate(angle: number): Promise; crop(x: number, y: number, width: number, height: number): Promise; resize(width: number, height: number, keepAspectRatio: boolean): Promise; flip(horizontal: boolean, vertical: boolean): Promise; flipHorizontal(): Promise; flipVertical(): Promise; paintLayer: ImageLayer; isReady: boolean; naturalSize: Size; isImageFormatSupported(imageFormat: string | ImageFormatCode, allowUnknown?: boolean): boolean; dispose(): void; removePaintLayer(): void; id: PluginType; initialize(viewer: ImageViewerAPI): void; } declare global { interface Window { PageToolsPlugin: typeof PageToolsPlugin; } }