@mescius/dsimageviewer
Version:
Document Solutions Image Viewer
238 lines (237 loc) • 8.7 kB
TypeScript
import { CancellationToken, PluginModel } from "@dt/core-viewer";
import { ImageMimeType } from "../Utils/ImageFormatUtils";
/**
* Image format name.
**/
export declare type ImageFormatName = "jpg" | "png" | "tiff" | "gif" | "bmp" | "ico" | "svg" | "webp";
/**
* Image format type code.
**/
export declare enum ImageFormatCode {
/**
* Default or unknown image format.
**/
Default = 0,
/**
* JPEG. Joint Photographic Experts Group image.
**/
JPEG = 1,
/**
* PNG. Portable Network Graphics.
**/
PNG = 2,
/**
* TIFF. Tagged Image File Format. Supports image frames.
**/
TIFF = 3,
/**
* GIF. Graphics Interchange Format.
**/
GIF = 4,
/**
* BMP. Bitmap Picture.
**/
BMP = 5,
/**
* ICO. The ICO file format is an image file format for computer icons in Microsoft Windows.
**/
ICO = 6,
/**
* SVG. Scalable Vector Graphics.
**/
SVG = 7,
/**
* WebP image format.
**/
WEBP = 8
}
/**
* Open parameters.
**/
export declare type OpenParameters = {
/**
* Image format type.
* Use the imageFormat parameter when the viewer cannot automatically determine the image format.
* @description Available image formats are: 1 = JPEG, 2 = PNG, 3 = TIFF, 4 = GIF, 5 = BMP, 6 = ICO, 7 = SVG, 8 = WEBP
* @example
* ```javascript
* // Open TIFF image from URL.
* viewer.open("http://localhost/getimage?id=1&fmt=3", { imageFormat: 3 });
* // or:
* viewer.open("http://localhost/getimage?id=1&fmt=3", { imageFormat: "tiff" });
* ```
**/
imageFormat?: ImageFormatCode | ImageFormatName | ImageFormatCode;
/**
* Image DPI. DPI value is used to determine the quality and resolution of the image.
* @default 96
* @example
* ```javascript
* viewer.open("sample.png", { imageDPI: 72 });
* ```
**/
imageDPI?: number;
/**
* Optional. Friendly file name.
* @example
* ```javascript
* viewer.open("/getSampleImage", { fileName: "sample.png" });
* ```
**/
fileName?: string;
};
/**
* Log level available to client.
* @ignore exclude from docs
**/
export declare type LogLevel = 'None' | 'Critical' | 'Error' | 'Warning' | 'Information' | 'Debug' | 'Trace';
/**
*
* @ignore exclude from docs
**/
export declare type CopyBufferData = {
type: 'any' | 'empty';
data?: any;
};
/**
* The name of the GcImageViewer's feature.
* Used by the disableFeatures option.
* @ignore exclude from docs
**/
export declare type ViewerFeatureName = 'DragAndDrop' | 'Print';
/**
* Interface for communicating viewer when document rendering is in progress.
* @ignore exclude from docs.
**/
export interface GcImageViewerRunEventsSink {
inProgress?: boolean;
/** Rendering started. */
start(): any;
/** Changes current status and provides additional progress info. */
progress(message: PluginModel.ProgressMessage): Promise<void>;
/** Loading completed. */
completed(framesCount: number): any;
/** Instruct viewer to reset cached page data for particular page or range of pages */
invalidatePage(index: number, count?: number): void;
/** Provides cancellation token for rendering routine. The latter should check cancellation status and cancel rendering as soon as possible. */
cancel: CancellationToken;
/** Reports the error to user/UI. */
reportError(params: {
readonly severity?: "error" | "warn" | "info" | "debug";
readonly message: string;
readonly details?: string;
}): void;
}
/**
* Keyboard shortcut definition.
**/
export declare type KeyboardShortcutDefinition = {
/**
* Optional key code.
**/
keyCode?: number;
/**
* Specifies whether the Ctrl key should be pressed.
**/
ctrl?: boolean;
/**
* Specifies whether the Shift key should be pressed.
**/
shift?: boolean;
/**
* Specifies whether the Alt key should be pressed.
**/
alt?: boolean;
/**
* Specifies whether the Meta key should be pressed.
**/
meta?: boolean;
/**
* Shotcut action.
**/
tool: KeyboardShortcutTool | Function;
};
/**
* Available tool names.
**/
export declare type KeyboardShortcutTool = "zoomIn" | "zoomOut" | "zoomActualSize" | "zoomPageWidth" | "rotate" | "rotateBackward" | "open" | "print" | "undo" | "redo" | "confirmChanges" | "cancelChanges" | "save";
/**
* Options for saving an image.
*
* @typedef {Object} SaveOptions
* @property {ImageFormatCode} [convertToFormat] - The target format code to convert the image to during saving.
* @property {string} [fileName] - The desired file name for the saved image.
* @property {boolean} [initial] - Indicates whether to retrieve the original version of the image.
*/
export declare type SaveOptions = {
convertToFormat?: ImageFormatCode | ImageMimeType;
fileName?: string;
original?: boolean;
};
/**
* Options for the Save As menu.
* @typedef {Object} SaveAsMenuOptions
* @property {ImageMimeType[]} [availableFormats] - List of available formats for saving. Leave undefined to detect supported formats automatically.
*/
export declare type SaveAsMenuOptions = {
/**
* List of available formats for saving. Leave undefined to detect supported formats automatically.
*/
availableFormats?: ImageMimeType[];
};
/**
* Options for customizing the behavior and appearance of the "Save" button.
*/
export declare type SaveButtonOptions = {
/**
* Configuration for the "Save As" menu. Set to false to hide the "Save As" menu.
* @property {boolean | { availableFormats?: (MimeTypeName | string)[] | undefined, hideOptions?: boolean }} saveAsMenu - Options for the "Save As" menu.
* - `availableFormats`: List of available formats for saving. Leave undefined to detect supported formats automatically.
* - `hideOptions`: Flag to hide additional options in the "Save As" menu. If true, the "Initial version" option will be hidden.
*/
saveAsMenu?: boolean | SaveAsMenuOptions;
} & SaveOptions;
/**
* Union type representing all possible cursor styles for the application.
* Includes standard CSS cursor values and custom application-specific cursors.
*
* @typedef {string} GlobalCursorType
*
* @property {"pointer"} pointer - Standard pointer cursor (hand icon)
* @property {"default"} default - Default arrow cursor
* @property {"text"} text - Text input I-beam cursor
* @property {"move"} move - Move/pan cursor (four-way arrow)
* @property {"not-allowed"} not-allowed - Action not allowed cursor
*
* @property {"n-resize"} n-resize - North resize cursor
* @property {"e-resize"} e-resize - East resize cursor
* @property {"s-resize"} s-resize - South resize cursor
* @property {"w-resize"} w-resize - West resize cursor
* @property {"ne-resize"} ne-resize - Northeast resize cursor
* @property {"nw-resize"} nw-resize - Northwest resize cursor
* @property {"se-resize"} se-resize - Southeast resize cursor
* @property {"sw-resize"} sw-resize - Southwest resize cursor
* @property {"ew-resize"} ew-resize - East-west resize cursor
* @property {"ns-resize"} ns-resize - North-south resize cursor
* @property {"nesw-resize"} nesw-resize - Northeast-southwest resize cursor
* @property {"nwse-resize"} nwse-resize - Northwest-southeast resize cursor
*
* @property {"rotate"} rotate - Custom rotate cursor (application-specific)
* @property {"grab"} grab - Grab/open hand cursor
* @property {"grabbing"} grabbing - Grabbing/closed hand cursor
* @property {"zoom-in"} zoom-in - Zoom in/magnify cursor
* @property {"zoom-out"} zoom-out - Zoom out cursor
* @property {"wait"} wait - Wait/busy cursor
* @property {"crosshair"} crosshair - Precision selection crosshair cursor
*
* @example
* // Type-safe cursor assignment
* const resizeCursor: GlobalCursorType = 'nwse-resize';
*
* @example
* // Function parameter typing
* function setCursor(cursor: GlobalCursorType) {
* document.body.style.cursor = cursor;
* }
*/
export declare type GlobalCursorType = "pointer" | "default" | "text" | "move" | "not-allowed" | "n-resize" | "e-resize" | "s-resize" | "w-resize" | "ne-resize" | "nw-resize" | "se-resize" | "sw-resize" | "ew-resize" | "ns-resize" | "nesw-resize" | "nwse-resize" | "rotate" | "grab" | "grabbing" | "zoom-in" | "zoom-out" | "wait" | "crosshair";