UNPKG

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.

61 lines (60 loc) • 3.1 kB
import { IPDFViewerApplication } from './options/pdf-viewer-application'; /** * #3315 Tells screen readers which page the user has navigated to ("Page 5 of 53"), opt-in via * `pdfDefaultOptions.announcePageChanges`. * * Only explicit navigation is announced: a key typed in the viewer, a click on a link, an outline * entry or a thumbnail, the paging buttons (`nextpage`, `previouspage`, `firstpage`, `lastpage`) and * `[page]` set by the application (`expectNavigation()`). Scrolling, the initial load and the page * number field (the user typed the number) stay silent. Several page changes in a row (holding * PageDown) are announced once, when the page has settled. * * pdf.js's `pagechanging` doesn't say what caused it. So a navigation intent and the page change * that follows within `INTENT_WINDOW_MS` count as one navigation. The paging buttons are the * exception: pdf.js changes the page before their event-bus listeners run, so their event may * also arrive right after the page change (`BUTTON_EVENT_LAG_MS`). An announcement consumes both * the intent and the page change. * * Framework-free on purpose: no Angular dependency. */ export declare class PageChangeAnnouncer { private readonly host; private readonly app; private readonly announce; private readonly isEnabled; /** How far apart a navigation intent and the page change it causes may be (book mode flips for 1 s). */ static readonly INTENT_WINDOW_MS = 1500; /** How long the page has to stay the same before it's announced. */ static readonly SETTLE_MS = 400; /** How long after the page change the event of a paging button may arrive (pdf.js dispatches it in the same task). */ static readonly BUTTON_EVENT_LAG_MS = 100; private static readonly NAVIGATION_EVENTS; /** The keys pdf.js turns pages with (`onKeyDown` in `web/app.js`). */ private static readonly NAVIGATION_KEYS; /** Letter shortcuts of pdf.js, without Ctrl, Meta or Alt. */ private static readonly NAVIGATION_LETTERS; private intentAt; private pageChangedAt; private timer; private readonly abortController; constructor(host: HTMLElement, app: IPDFViewerApplication, announce: (message: string) => void, isEnabled: () => boolean); /** The next page change is a navigation the user asked for (e.g. `[page]` set by the application). */ expectNavigation(): void; destroy(): void; private onPageChanging; /** pdf.js has already changed the page when the event of a paging button arrives. */ private onPagingButton; private onKeyDown; /** * The rule pdf.js uses (`isKeyForThisViewer` in the fork's `web/app.js`): a key typed in a viewer * belongs to that viewer; a key typed outside every viewer belongs to the active viewer, or to * every viewer when none is marked active (a single viewer on the page). */ private isKeyForThisViewer; private onClick; private static isNavigationKey; private static isTextEntry; private scheduleAnnouncement; private announceCurrentPage; private translate; }