ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
37 lines (36 loc) • 1.75 kB
TypeScript
/**
* #3306 Keeps the id references of a viewer (`for`, `aria-labelledby`, `aria-controls`, ...) inside the viewer.
*
* With several viewers on one page, every viewer renders the same ids. The browser resolves an id
* reference to the first element with that id on the page, so the labels, descriptions and popups
* of the second viewer would point into the first one. The ids themselves stay as they are (the
* CSS and pdf.js rely on them); instead, every reference that resolves to an element outside this
* viewer is re-pointed at this viewer's element with ARIA element reflection
* (`element.ariaLabelledByElements = [...]`). A label's `for` becomes an `aria-labelledby`
* reference plus a click handler.
*
* References that already resolve correctly are left alone, so the first viewer on the page - and
* every single-viewer page - is never changed. Browsers without element reflection keep the plain
* id references.
*/
export declare class ViewerLocalReferences {
private readonly host;
private observer;
private updateScheduled;
private readonly labelClickHandlers;
constructor(host: HTMLElement);
static isSupported(): boolean;
/** fixes the current references, and the ones added later */
start(): void;
/** stops watching. References fixed so far stay fixed: they point into this viewer, which is never wrong. */
stop(): void;
destroy(): void;
/** re-points every reference of this viewer that resolves to an element outside the viewer */
update(): void;
private fixReference;
/** a label's `for` would label (and click) the first viewer's control */
private replaceLabelFor;
private findInViewer;
private isRelevant;
private scheduleUpdate;
}