UNPKG

@mescius/dsimageviewer

Version:

Document Solutions Image Viewer

109 lines (108 loc) 3.65 kB
/// <reference path="../../vendor/i18next.d.ts" /> //@ts-ignore import { i18n } from "i18next"; import { IImageLayer } from "../Layers"; import { IImageViewer, IViewerPlugin, ImageFormatCode } from "../Models"; /** * Base class for image viewer plugins providing common functionality. * @implements {IViewerPlugin} */ export declare class ImageViewerPluginBase implements IViewerPlugin { /** * Unique identifier for the plugin. * @type {string} */ id: string; /** * Flag indicating whether the plugin has been initialized. * @protected * @type {boolean} */ protected _initialized: boolean; /** * The paint layer associated with the plugin. * @protected * @type {IImageLayer} */ protected _paintLayer: IImageLayer; /** * Reference to the image viewer instance. * @protected * @type {IImageViewer} */ protected _viewer: IImageViewer; /** * Gets the internationalization (i18n) instance from the viewer. * @returns {i18n} The i18n instance. */ get in17n(): i18n; /** * Viewer instance identifier. * @ignore exclude from docs. **/ get instanceId(): string; /** * Returns true if the image is loaded into the viewer and the image format is supported by the plugin. **/ get isReady(): boolean; /** * Natural image size. **/ get naturalSize(): { width: number; height: number; }; /** * Gets the paint layer containing the HTML canvas for drawing the image. **/ get paintLayer(): IImageLayer; /** * Gets the image viewer instance. * @returns {IImageViewer} The image viewer instance. */ get viewer(): IImageViewer; /** * Initializes the plugin with the given image viewer. * @param {IImageViewer} viewer - The image viewer instance to associate with this plugin. * @returns {void} */ initialize(viewer: IImageViewer): void; /** * Cleans up resources and disposes the plugin. * @returns {void} */ dispose(): void; /** * Determines whether the specified image format is supported for modifications. * * @param {ImageFormatCode | string} imageFormat - The image format to check, either as an enum value or string. * @param {boolean} [allowUnknown=false] - If true, allows unknown formats (ImageFormatCode.Default) to be considered supported. * @returns {boolean} True if the format is supported for modifications, false otherwise. * * @remarks * The following formats are explicitly not supported: * - TIFF (ImageFormatCode.TIFF) * - SVG (ImageFormatCode.SVG) * - ICO (ImageFormatCode.ICO) * - GIF (ImageFormatCode.GIF) * * @example * // Check if PNG is supported * const supported = isImageFormatSupported(ImageFormatCode.PNG); * * @example * // Check if an unknown format is supported (returns false by default) * const supported = isImageFormatSupported('custom-format'); * * @example * // Check if an unknown format is supported (returns true when allowUnknown is true) * const supported = isImageFormatSupported('custom-format', true); */ isImageFormatSupported(imageFormat: ImageFormatCode | string, allowUnknown?: boolean): boolean; /** * Removes and disposes the active paint layer. * If no paint layer exists, this method does nothing. * @returns {void} */ removePaintLayer(): void; }