UNPKG

@mescius/dsimageviewer

Version:

Document Solutions Image Viewer

156 lines (155 loc) 7.76 kB
import { GlobalCursorType } from "../Models/Types"; import { GcSelectionEdge } from "../Models/SelectionBoxTypes"; export declare function generateUid(caller?: string): string; export declare function isTypedArray(arr: any): boolean; export declare function isDomNode(o: any): any; /** * Merge everything from sourceObj to destinationObj, returns destinationObj. * Note, by default, non-empty primitive values are NOT preserved in the destination object. * @param destinationObj Destination object * @param sourceVal Source object * @param preserveNonEmpty Set to true if you don't want to replace non-empty primitive values. */ export declare function mergeObject(destinationObj: any, sourceVal: any, preserveNonEmpty?: boolean, cloneDomNodes?: boolean): any; export declare function cloneObject(obj: any): any; export declare function getTransformMatrix(viewBox: number[], rotation: number, scaleX: number, scaleY: number, ignoreRotate?: boolean): number[]; export declare function adjustCoordinates(realViewBox: number[], point: number[], rotation: number, inverse?: boolean, fromBottomLeft?: boolean, scale?: number): number[]; /** * Applies the transform to the rectangle and finds the minimum axially * aligned bounding box. * @param r * @param m */ export declare function getAxialAlignedBoundingBox(r: any, m: any): number[]; /** * Apply matrix transform. * @param p x, y point * @param m transform matrix */ export declare function applyTransform(p: number[], m: number[]): number[]; /** * Apply inverse matrix transformation. * @param p x, y point * @param m transform matrix */ export declare function applyInverseTransform(p: number[], m: number[]): number[]; export declare function inverseTransform(m: number[]): number[]; /** * Change bounds origin. * @param bounds * @param viewBox * @param destOrigin */ export declare function changeRectangleOrigin(bounds: number[], viewBox: number[], destOrigin?: 'TopLeft' | 'BottomLeft'): number[]; export declare function changeOriginToBottom(top: number, view: number[]): number; export declare function changeOriginToTop(bottom: number, view: number[]): number; export declare function formatRelativeDate(date: Date | null, in17n: any): any; export declare function humanReadableFileSize(size: number, in17n: any): string; export declare function getDefaultUserName(): string; export declare function getActiveUserName(options?: any): string; export declare function setActiveUserName(userName: string, setBy: 'annotation_editor' | 'user'): void; export declare function attachHeadJs(src: string, id?: string, ownerDoc?: ShadowRoot | Document): Promise<any>; export declare function stripHtmlTags(s: any): string; export declare function attachHeadCss(css: any, id?: string, ownerDoc?: ShadowRoot | Document): void; export declare function detachHeadJs(id: string, ownerDoc?: ShadowRoot | Document): void; export declare function detachHeadCss(id: string, ownerDoc?: ShadowRoot | Document): void; export declare function moveInkLists(inkLists: { x: number; y: number; }[][], deltaX: number, deltaY: number): void; export declare function getAccentTextColor(): string; export declare function sortedIndex(array: number[], value: number): number; export declare function logMessage(msg: string): void; export declare function logError(msg: any): void; export declare function insertFirst(parent: HTMLElement, insertElem: HTMLElement): void; /** * getStandardizedLanguageKey - Function for obtaining a standardized language key. * @param lng - Language key in ISO 639-1 format (e.g., 'en', 'ja', 'ru', 'zh', 'de') or 'auto' for automatic detection. * @param fallbackLng - Optional, fall-back language key. * @returns The standardized language key (e.g., 'en', 'ja', 'ru', 'zh', 'de') or the fallback language name if the language key cannot be standardized. */ export declare function getStandardizedLanguageKey(lng: string | undefined, fallbackLng?: string | undefined): string; /** * cleanseRichText: Removes outer XML tags and dangerous elements from rich text. * * This function takes a string of rich text, typically extracted from an XML document, * and cleanses it by removing the outer XML tags and any dangerous elements present. * Dangerous elements include <script>, <iframe>, <object>, <embed>, <form>, <input>, * <textarea>, <select>, <option>, and <button>. These elements are considered potentially * harmful and are stripped from the text. * * @param {string} text - The rich text string to be cleansed. * @returns {string} The cleansed rich text without the outer XML tags and dangerous elements. **/ export declare function cleanseRichText(text?: string): string; /** * Download file using specified URL. * @param blobUrl * @param filename */ export declare function downloadUrl(fileUrl: string, filename?: string): boolean; /** * Download binary data. * @param data * @param filename * @param contentType */ export declare function downloadData(data: Blob | BlobPart | Uint8Array | ArrayBuffer | ArrayBufferView | string, filename?: string, contentType?: string): boolean; /** * Sets a global cursor style for the specified element using data-attribute * @param {HTMLElement | string} element - Target DOM element or CSS selector string * @param {GlobalCursorType} cursorType - Type of cursor to apply (from predefined types) * @returns {void} * @example * // Set resize cursor on viewer host * setGlobalCursor('.gc-viewer-host', 'nwse-resize'); * * // Set custom rotate cursor on body * setGlobalCursor(document.body, 'rotate'); */ export declare function setGlobalCursor(element: HTMLElement | Element | string, cursorType: GlobalCursorType): void; /** * Resets cursor to default by removing data-cursor attribute * @param {HTMLElement | string} element - Target DOM element or CSS selector string * @returns {void} * @example * // Reset cursor on viewer host * resetGlobalCursor('.gc-viewer-host'); */ export declare function resetGlobalCursor(element: HTMLElement | Element | string): void; /** * Toggles cursor state - sets specified cursor or resets to default * @param {HTMLElement | string} element - Target DOM element or CSS selector string * @param {GlobalCursorType | false} cursorType - Cursor type to apply, or false to reset * @returns {void} * @example * // Toggle rotate cursor on click * toggleGlobalCursor(buttonElement, isRotating ? 'rotate' : false); */ export declare function toggleGlobalCursor(element: HTMLElement | Element | string, cursorType: GlobalCursorType | false): void; /** * Maps selection edges to appropriate cursor styles. * @param {GcSelectionEdge} edge - The selection edge to map * @returns {GlobalCursorType} Corresponding cursor type * * @example * // Get cursor for northeast resize handle * getCursorForEdge('ne'); // Returns 'nesw-resize' * * @example * // Usage in event handlers * element.addEventListener('mouseenter', (e) => { * const edge = e.target.getAttribute('data-edge'); * viewer.setCursor(getCursorForEdge(edge)); * }); */ export declare function getCursorForEdge(edge: GcSelectionEdge): GlobalCursorType; /** * Adjusts the selection edge based on the current rotation angle. * Handles 90° increments (0°, 90°, 180°, 270°) for edge transformation. * * @param {GcSelectionEdge} originalEdge - The original edge from data attribute * @param {number} rotationAngle - Current rotation angle in degrees * @returns {GcSelectionEdge} - Adjusted edge after rotation consideration */ export declare function adjustEdgeForRotation(originalEdge: GcSelectionEdge, rotationAngle: number): GcSelectionEdge;