@mescius/dspdfviewer
Version:
Document Solutions PDF Viewer
91 lines (90 loc) • 3.14 kB
TypeScript
export declare function getShadowRootOrDocument(elem?: HTMLElement): HTMLDocument | ShadowRoot;
export declare function closestShadowRootOrBody(element: HTMLElement): HTMLBodyElement | ShadowRoot;
/**
* Checks if element is nested within parent element on any level.
* @param parent
* @param child
*/
export declare function isDescendant(child: Element, parent: Element): boolean;
/**
* Find correct event target.
* @param e
*/
export declare function getEventTarget(e: any): any;
export declare function isInputArea(el: HTMLElement): boolean;
/**
* Cross-browser element.classList.contains
* @param element HTML DOM element
* @param className Class name without dot.
*/
export declare function classListContains(element: HTMLElement, className: string): boolean;
/**
* Search parent element by class name.
* @param el HTML DOM element
* @param className Class name without dot.
*/
export declare function findSelfOrAncestor(el: HTMLElement | null, className: string): HTMLElement | null;
/**
* Search parent element by attribute name.
* @param el HTML DOM element
* @param className Attribute name.
*/
export declare function findSelfOrAncestorAttr(el: HTMLElement | null, attrName: string): HTMLElement | null;
/**
* Get element's numerical index in its parent element.
* @param el HTML DOM element
*/
export declare function findElementIndex(el: Element): number;
export declare function isTouchEventsEnabled(): boolean;
export type DomEventCoordinates = {
pageX: number;
pageY: number;
clientX: number;
clientY: number;
};
export declare function getEventCoordinates(event: MouseEvent | TouchEvent | PointerEvent): DomEventCoordinates;
export declare function reversePopupRotation(popupWrapperToRotate: HTMLElement, rotation: number, iconToRotate?: HTMLElement): void;
/**
* Simulate mouse event.
* @param element
* @param eventType
*/
export declare function triggerMouseEvent(element: Element, eventType: string): void;
export declare function triggerFullStackClick(element: Element): void;
/**
* Removes most dangerous tags from html string.
**/
export declare function sanitizeHTML(input: any): any;
/**
* Returns the highest accessible window (`top` or `parent`) without throwing.
*
* Safely handles cross-origin iframe scenarios where accessing `window.top`
* or `window.parent` may throw a `SecurityError`.
*
* Fallback order:
* - `window.top` (if accessible)
* - `window.parent` (if accessible)
* - current `window`
*
* See DOC-7339
*
* @ignore
*/
export declare function getSafeTopWindow(): Window;
/**
* Resolves a global option from the window hierarchy in a safe way.
*
* The lookup prioritizes the current `window` and falls back to the highest
* accessible parent window (`top` or `parent`) when running inside iframes.
*
* Designed to work in cross-origin environments without throwing
* `SecurityError` exceptions.
*
* See DOC-7339
*
* @ignore
*
* @param key - The global option name to resolve.
* @returns The resolved option value, or `null` if not found.
*/
export declare function resolveGlobalWindowOption<T = unknown>(key: string): T | null;