UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

129 lines (128 loc) 2.91 kB
var u = Object.defineProperty; var c = (o, e, t) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t; var i = (o, e, t) => (c(o, typeof e != "symbol" ? e + "" : e, t), t); class f { constructor(e, t) { i(this, "externalLinkEnabled"); i(this, "pdfDocument"); this.externalLinkEnabled = !0, this.pdfDocument = e, this.goToPage = t; } /** * @type {number} */ get pagesCount() { var e; return ((e = this.pdfDocument) == null ? void 0 : e.numPages) ?? 0; } /** * @type {number} */ get page() { return 0; } /** * @param {number} _value */ set page(e) { } /** * @type {number} */ get rotation() { return 0; } /** * @param {number} _value */ set rotation(e) { } /** * @type {boolean} */ get isInPresentationMode() { return !1; } /** * @param {string|Array} _dest - The named, or explicit, PDF destination. */ async goToDestination(e) { var r, s, g; let t, n; if (typeof e == "string" ? t = await ((r = this.pdfDocument) == null ? void 0 : r.getDestination(e)) : t = await e, !Array.isArray(t)) { console.error( `goToDestination: "${t}" is not a valid destination array, for dest="${e}".` ); return; } const [a] = t; if (a && typeof a == "object") { if (n = (s = this.pdfDocument) == null ? void 0 : s.cachedPageNumber(a), !n) try { n = (await ((g = this.pdfDocument) == null ? void 0 : g.getPageIndex(a)) || 0) + 1; } catch { console.error( `goToDestination: "${a}" is not a valid page reference, for dest="${e}".` ); return; } } else Number.isInteger(a) && (n = a + 1); if (!n || n < 1 || n > this.pagesCount) { console.error( `goToDestination: "${n}" is not a valid page number, for dest="${e}".` ); return; } this.goToPage(n); } /** * @param {number|string} _val - The page number, or page label. */ goToPage(e) { } /** * @param {HTMLAnchorElement} link * @param {string} url * @param {boolean} [_newWindow] */ addLinkAttributes(e, t, n = !1) { } /** * @param _dest - The PDF destination object. * @returns {string} The hyperlink to the PDF object. */ getDestinationHash(e) { return "#"; } /** * @param _hash - The PDF parameters/hash. * @returns {string} The hyperlink to the PDF object. */ getAnchorUrl(e) { return "#"; } /** * @param {string} _hash */ setHash(e) { } /** * @param {string} _action */ executeNamedAction(e) { } /** * @param {Object} _action */ executeSetOCGState(e) { } /** * @param {number} _pageNum - page number. * @param {Object} _pageRef - reference to the page. */ cachePageRef(e, t) { } } export { f as SimpleLinkService };