@react-pdf-kit/viewer 2.9.1-rc.1 → 2.9.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnnotationLayer-oDu2B4X1.js +114 -0
- package/dist/TextLayer-Bp1CDIIa.js +126 -0
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/RPPage.js +2 -2
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +44 -39
- package/dist/types/utils/pdfOperationTracker.d.ts +3 -0
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +66 -63
- package/dist/utils/pdfOperationTracker.js +17 -0
- package/package.json +1 -1
- package/dist/AnnotationLayer-CyOYh0Tw.js +0 -113
- package/dist/TextLayer-BTyy2RqD.js +0 -125
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { AnnotationSubType as e } from "./utils/types.js";
|
|
2
|
+
import { trackPdfOperation as t } from "./utils/pdfOperationTracker.js";
|
|
3
|
+
import { useDocumentContext as n } from "./contexts/RPDocumentContext.js";
|
|
4
|
+
import { useInitialStateContext as r } from "./contexts/InitialStateContext.js";
|
|
5
|
+
import { useScrollModeContext as i } from "./contexts/ScrollModeContext.js";
|
|
6
|
+
import { r as a } from "./PaginationContext-DIzsZhFd.js";
|
|
7
|
+
import { usePrintContext as o } from "./contexts/PrintContext.js";
|
|
8
|
+
import { SimpleLinkService as s } from "./utils/link_service.js";
|
|
9
|
+
import { annotationEventsHandler as c, bindLayerEvents as l, enhanceLinkAccessibility as u, fixTabIndexAccessibility as d, handleAnnotationWidget as f, insertDateText as p, unbindLayerEvents as m } from "./utils/annotations.js";
|
|
10
|
+
import { useFileDownload as h } from "./utils/hooks/useFileDownload.js";
|
|
11
|
+
import { useCallback as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
12
|
+
import { AnnotationLayer as x } from "pdfjs-dist";
|
|
13
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
14
|
+
import './assets/AnnotationLayer.css';//#region lib/components/page/AnnotationLayer.module.css
|
|
15
|
+
var C = { "rp-annotation-layer": "_rp-annotation-layer_foiun_1" }, w = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/", T = (T) => {
|
|
16
|
+
let { pageNumber: E } = T, D = y(null), { pages: O, pdf: k } = n(), { interactiveForm: A } = r(), j = y(), [M, N] = b(), { goToPage: P } = a(), { scrollMode: F } = i(), { print: I } = o(), { download: L } = h(), R = y(null), z = v(() => O.get(E), [O, E]), B = v(() => z?.page.getViewport(), [z]);
|
|
17
|
+
_(() => {
|
|
18
|
+
j.current &&= (j.current.div.replaceChildren(), void 0);
|
|
19
|
+
}, [k]), _(() => {
|
|
20
|
+
z && t(k, z.page.getAnnotations()).then((e) => {
|
|
21
|
+
j.current = void 0, N(e), D.current && (D.current.innerText = "");
|
|
22
|
+
});
|
|
23
|
+
}, [z]);
|
|
24
|
+
let V = g((e) => {
|
|
25
|
+
!M || !k || (p(D.current), c(e, k, M).then((e) => {
|
|
26
|
+
e?.data?.action === "Print" ? I() : e?.data?.action === "SaveAs" && L();
|
|
27
|
+
}));
|
|
28
|
+
}, [
|
|
29
|
+
k,
|
|
30
|
+
M,
|
|
31
|
+
F,
|
|
32
|
+
I,
|
|
33
|
+
L
|
|
34
|
+
]);
|
|
35
|
+
return _(() => {
|
|
36
|
+
if (!z || !M) return;
|
|
37
|
+
let t = z.page.getViewport();
|
|
38
|
+
if (j.current) {
|
|
39
|
+
j.current.update({ viewport: t.clone({ dontFlip: !0 }) });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let n = /* @__PURE__ */ new Map([]);
|
|
43
|
+
for (let r of M) {
|
|
44
|
+
let { annotationType: i } = r;
|
|
45
|
+
switch (i) {
|
|
46
|
+
case e.Widget:
|
|
47
|
+
f(r, t, n);
|
|
48
|
+
break;
|
|
49
|
+
default: break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let r = new AbortController();
|
|
53
|
+
return (async () => {
|
|
54
|
+
j.current &&= (j.current.div.replaceChildren(), void 0), D.current && (D.current.innerText = ""), j.current = new x({
|
|
55
|
+
div: D.current,
|
|
56
|
+
accessibilityManager: void 0,
|
|
57
|
+
annotationCanvasMap: void 0,
|
|
58
|
+
annotationEditorUIManager: void 0,
|
|
59
|
+
structTreeLayer: null,
|
|
60
|
+
page: z.page,
|
|
61
|
+
viewport: t.clone({ dontFlip: !0 }),
|
|
62
|
+
commentManager: void 0,
|
|
63
|
+
linkService: new s(k, P),
|
|
64
|
+
annotationStorage: k?.annotationStorage
|
|
65
|
+
}), D.current && m(D.current, V);
|
|
66
|
+
let e = await k?.hasJSActions(), n = await k?.getFieldObjects();
|
|
67
|
+
if (r.signal.aborted) throw "abort";
|
|
68
|
+
return j.current?.render({
|
|
69
|
+
annotations: M,
|
|
70
|
+
annotationStorage: k?.annotationStorage,
|
|
71
|
+
hasJSActions: e,
|
|
72
|
+
fieldObjects: n,
|
|
73
|
+
div: D.current,
|
|
74
|
+
viewport: t.clone({ dontFlip: !0 }),
|
|
75
|
+
page: z.page,
|
|
76
|
+
imageResourcesPath: w,
|
|
77
|
+
renderForms: A ?? !0,
|
|
78
|
+
linkService: new s(k, P),
|
|
79
|
+
downloadManager: null,
|
|
80
|
+
enableScripting: !1
|
|
81
|
+
});
|
|
82
|
+
})().then(() => {
|
|
83
|
+
D.current && (l(D.current, V), d(D.current), u(D.current), R.current && R.current.disconnect(), R.current = new MutationObserver(() => {
|
|
84
|
+
D.current && (d(D.current), u(D.current));
|
|
85
|
+
}), R.current.observe(D.current, {
|
|
86
|
+
childList: !0,
|
|
87
|
+
subtree: !0,
|
|
88
|
+
attributes: !0,
|
|
89
|
+
attributeFilter: ["tabindex", "href"]
|
|
90
|
+
}));
|
|
91
|
+
}).catch((e) => {
|
|
92
|
+
if (e !== "abort") throw e;
|
|
93
|
+
}).finally(() => {
|
|
94
|
+
j.current = void 0;
|
|
95
|
+
}), () => {
|
|
96
|
+
r.abort("clear"), D.current && m(D.current, V), R.current &&= (R.current.disconnect(), null);
|
|
97
|
+
};
|
|
98
|
+
}, [
|
|
99
|
+
k,
|
|
100
|
+
M,
|
|
101
|
+
V,
|
|
102
|
+
P
|
|
103
|
+
]), /* @__PURE__ */ S("div", {
|
|
104
|
+
"data-rp": `page-${E}-annotationLayer`,
|
|
105
|
+
style: {
|
|
106
|
+
width: `${B?.width}px`,
|
|
107
|
+
height: `${B?.height}px`
|
|
108
|
+
},
|
|
109
|
+
className: C["rp-annotation-layer"],
|
|
110
|
+
ref: D
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { T as t };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { trackPdfOperation as e } from "./utils/pdfOperationTracker.js";
|
|
2
|
+
import { useDocumentContext as t } from "./contexts/RPDocumentContext.js";
|
|
3
|
+
import { highlightMatches as n, resetDivs as r } from "./utils/highlight.js";
|
|
4
|
+
import { useSearchContext as i } from "./contexts/SearchContext.js";
|
|
5
|
+
import { useCallback as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
6
|
+
import * as u from "pdfjs-dist";
|
|
7
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
8
|
+
import './assets/TextLayer.css';var f = {
|
|
9
|
+
"rp-text-layer": "_rp-text-layer_1cfxj_1",
|
|
10
|
+
selecting: "_selecting_1cfxj_18",
|
|
11
|
+
markedContent: "_markedContent_1cfxj_58",
|
|
12
|
+
"rp-text-layer-text": "_rp-text-layer-text_1cfxj_82"
|
|
13
|
+
}, p = (p) => {
|
|
14
|
+
let { pageNumber: m } = p, { pages: h, pdf: g } = t(), _ = c(null), { matches: v, currentMatch: y } = i(), [b, x] = l([]), S = c(), C = c(), w = c([]), T = s(() => v.filter((e) => e.pageIndex === m - 1), [v, m]), E = a((e, t, i = !1) => {
|
|
15
|
+
if (i && r(e, t), !T.length) {
|
|
16
|
+
w.current = [], x([]);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
x(n(T, e, t));
|
|
20
|
+
}, [T]), D = c(), O = c(!1), k = a(() => Array.from(document.querySelectorAll("[data-rp$=\"-textLayer\"]")), []);
|
|
21
|
+
o(() => ((() => {
|
|
22
|
+
if (D.current) return;
|
|
23
|
+
D.current = new AbortController();
|
|
24
|
+
let { signal: e } = D.current, t = () => {
|
|
25
|
+
k().forEach((e) => {
|
|
26
|
+
let t = e.querySelector(".endOfContent");
|
|
27
|
+
t && (e.appendChild(t), t.style.width = "", t.style.height = "", e.classList.remove(f.selecting));
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
document.addEventListener("pointerdown", () => {
|
|
31
|
+
O.current = !0;
|
|
32
|
+
}, { signal: e }), document.addEventListener("pointerup", () => {
|
|
33
|
+
O.current = !1, t();
|
|
34
|
+
}, { signal: e }), window.addEventListener("blur", () => {
|
|
35
|
+
O.current = !1, t();
|
|
36
|
+
}, { signal: e }), document.addEventListener("keyup", () => {
|
|
37
|
+
O.current || t();
|
|
38
|
+
}, { signal: e });
|
|
39
|
+
let n = null;
|
|
40
|
+
document.addEventListener("selectionchange", () => {
|
|
41
|
+
let e = document.getSelection();
|
|
42
|
+
if (!e) return;
|
|
43
|
+
if (e.rangeCount === 0) {
|
|
44
|
+
t();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
let r = /* @__PURE__ */ new Set();
|
|
48
|
+
for (let t = 0; t < e.rangeCount; t++) {
|
|
49
|
+
let n = e.getRangeAt(t);
|
|
50
|
+
k().forEach((e) => {
|
|
51
|
+
n.intersectsNode(e) && !r.has(e) && r.add(e);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
k().forEach((e) => {
|
|
55
|
+
if (r.has(e)) e.classList.add(f.selecting);
|
|
56
|
+
else {
|
|
57
|
+
let t = e.querySelector(".endOfContent");
|
|
58
|
+
t && (e.appendChild(t), t.style.width = "", t.style.height = "", e.classList.remove(f.selecting));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
let i = e.getRangeAt(0), a = n && (i.compareBoundaryPoints(Range.END_TO_END, n) === 0 || i.compareBoundaryPoints(Range.START_TO_END, n) === 0) ? i.startContainer : i.endContainer;
|
|
62
|
+
a.nodeType === Node.TEXT_NODE && (a = a.parentNode);
|
|
63
|
+
let o = a.parentElement?.closest(`.${f["rp-text-layer"]}`), s = o?.querySelector(".endOfContent");
|
|
64
|
+
s && o && (s.style.width = o.style.width, s.style.height = o.style.height, a.parentElement?.insertBefore(s, a.nextSibling)), n = i.cloneRange();
|
|
65
|
+
}, { signal: e });
|
|
66
|
+
})(), () => {
|
|
67
|
+
D.current?.abort(), D.current = void 0;
|
|
68
|
+
}), [k]);
|
|
69
|
+
let A = a(() => {
|
|
70
|
+
_.current && _.current.classList.add(f.selecting);
|
|
71
|
+
}, []), j = a(() => {
|
|
72
|
+
_.current && _.current.classList.remove(f.selecting);
|
|
73
|
+
}, []);
|
|
74
|
+
return o(() => {
|
|
75
|
+
if (w.current.forEach((e) => {
|
|
76
|
+
e.classList.remove("selected");
|
|
77
|
+
}), !b.length || !y || y.pageIndex !== m - 1) return;
|
|
78
|
+
let e = T.findIndex((e) => JSON.stringify(e) === JSON.stringify(y));
|
|
79
|
+
if (e === -1) return;
|
|
80
|
+
let t = b.filter((t) => t.index === e);
|
|
81
|
+
t.length && (w.current = t.map((e) => e.element), t.forEach((e) => {
|
|
82
|
+
e.element.classList.add("selected");
|
|
83
|
+
}));
|
|
84
|
+
}, [
|
|
85
|
+
y,
|
|
86
|
+
b,
|
|
87
|
+
T
|
|
88
|
+
]), o(() => {
|
|
89
|
+
let t = h.get(m);
|
|
90
|
+
if (!t || !_.current) return;
|
|
91
|
+
let n = _.current;
|
|
92
|
+
return S.current && S.current.cancel(), e(g, t.page.getTextContent()).then((e) => {
|
|
93
|
+
let r = t.page.getViewport({ scale: 1 });
|
|
94
|
+
return S.current = new u.TextLayer({
|
|
95
|
+
viewport: r,
|
|
96
|
+
textContentSource: e,
|
|
97
|
+
container: n
|
|
98
|
+
}), C.current = e, n && (n.innerText = ""), S.current.render();
|
|
99
|
+
}).then(() => {
|
|
100
|
+
[].slice.call(n.children).forEach((e) => {
|
|
101
|
+
e.classList.add(f["rp-text-layer-text"]), e.setAttribute("data-rp", "rp-text-layer-text");
|
|
102
|
+
});
|
|
103
|
+
let e = S.current?.textDivs;
|
|
104
|
+
e && C.current && E(C.current, e);
|
|
105
|
+
let t = document.createElement("div");
|
|
106
|
+
t.className = "endOfContent", _.current?.appendChild(t);
|
|
107
|
+
}).catch(() => {}), () => {
|
|
108
|
+
S.current?.cancel();
|
|
109
|
+
};
|
|
110
|
+
}, [h, m]), o(() => {
|
|
111
|
+
[].slice.call(_.current.children).forEach((e) => {
|
|
112
|
+
e.classList.add(f["rp-text-layer-text"]);
|
|
113
|
+
});
|
|
114
|
+
let e = S.current?.textDivs;
|
|
115
|
+
e && C.current && E(C.current, e, !0);
|
|
116
|
+
}, [E]), /* @__PURE__ */ d("div", {
|
|
117
|
+
"data-rp-text-layer": !0,
|
|
118
|
+
"data-rp": `page-${m}-textLayer`,
|
|
119
|
+
className: f["rp-text-layer"],
|
|
120
|
+
ref: _,
|
|
121
|
+
onMouseDown: A,
|
|
122
|
+
onMouseUp: j
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
//#endregion
|
|
126
|
+
export { p as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../AnnotationLayer-
|
|
1
|
+
import { t as e } from "../../AnnotationLayer-oDu2B4X1.js";
|
|
2
2
|
export { e as AnnotationLayer };
|
|
@@ -5,8 +5,8 @@ import { useLayerContext as r } from "../../contexts/LayerContext.js";
|
|
|
5
5
|
import { useLoaderContext as i } from "../../contexts/LoaderContext.js";
|
|
6
6
|
import { withRef as a } from "../../utils/withRef.js";
|
|
7
7
|
import { n as o, t as s } from "../../CanvasLayer-CJqCJ30J.js";
|
|
8
|
-
import { t as c } from "../../TextLayer-
|
|
9
|
-
import { t as l } from "../../AnnotationLayer-
|
|
8
|
+
import { t as c } from "../../TextLayer-Bp1CDIIa.js";
|
|
9
|
+
import { t as l } from "../../AnnotationLayer-oDu2B4X1.js";
|
|
10
10
|
import { t as u } from "../../TextHighlightLayer-3vIZbRyL.js";
|
|
11
11
|
import { CustomElement as d } from "./CustomElement.js";
|
|
12
12
|
import { useCallback as f, useEffect as p, useImperativeHandle as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../TextLayer-
|
|
1
|
+
import { t as e } from "../../TextLayer-Bp1CDIIa.js";
|
|
2
2
|
export { e as TextLayer };
|
|
@@ -1,60 +1,65 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { trackPdfOperation as e } from "../utils/pdfOperationTracker.js";
|
|
2
|
+
import { useDocumentContext as t } from "./RPDocumentContext.js";
|
|
3
|
+
import { r as n } from "../PaginationContext-DIzsZhFd.js";
|
|
4
|
+
import { Queue as r } from "../utils/Queue.js";
|
|
5
|
+
import { renderPage as i } from "../utils/renderPage.js";
|
|
6
|
+
import { createContext as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
7
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
7
8
|
//#region lib/contexts/RenderQueueProvider.tsx
|
|
8
|
-
var
|
|
9
|
-
let
|
|
10
|
-
|
|
9
|
+
var p = a(null), m = ({ children: a }) => {
|
|
10
|
+
let s = u(!1), m = u(/* @__PURE__ */ new Map()), [h, g] = d([]), _ = o((e) => {
|
|
11
|
+
g((t) => [...t, {
|
|
11
12
|
id: e.page.pageNumber.toString(),
|
|
12
13
|
data: e,
|
|
13
14
|
priority: 0
|
|
14
15
|
}]);
|
|
15
|
-
}, []),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
}, []), v = l(() => new r(_), [_]), { focusedPage: y } = n(), { pdf: b } = t(), x = u(b);
|
|
17
|
+
c(() => {
|
|
18
|
+
x.current = b;
|
|
19
|
+
}, [b]);
|
|
20
|
+
let S = o((t) => {
|
|
21
|
+
s.current = !0;
|
|
22
|
+
let n = m.current.get(t.id);
|
|
23
|
+
n && (n.cancel(), m.current.delete(t.id));
|
|
24
|
+
let r;
|
|
20
25
|
try {
|
|
21
|
-
|
|
26
|
+
r = i(t.data.page, t.data.canvasElem, t.data.options);
|
|
22
27
|
} catch {
|
|
23
|
-
return
|
|
28
|
+
return t.data.onRenderTask?.(null), Promise.resolve();
|
|
24
29
|
}
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
}).catch((
|
|
28
|
-
|
|
30
|
+
return m.current.set(t.id, r), t.data.onRenderTask?.(r), e(x.current, r.promise).then(() => {
|
|
31
|
+
t.data.canvasElem.hidden = !1, t.data.onLoaded && t.data.onLoaded();
|
|
32
|
+
}).catch((e) => {
|
|
33
|
+
e.name !== "RenderingCancelledException" && console.error(`Error rendering page ${t.data.page.pageNumber}:`, e);
|
|
29
34
|
}).finally(() => {
|
|
30
|
-
|
|
35
|
+
m.current.delete(t.id), t.data.onRenderTask?.(null);
|
|
31
36
|
});
|
|
32
37
|
}, []);
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
}, [
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
if (
|
|
38
|
+
return c(() => {
|
|
39
|
+
m.current.forEach((e) => e.cancel()), m.current.clear(), v.clear(), g(v.peekAll());
|
|
40
|
+
}, [b, v]), c(() => {
|
|
41
|
+
y && (v.changePagePriority(`^page-${y}`, 0), v.changePagePriority(`^thumbnail-${y}`, 1));
|
|
42
|
+
}, [y]), c(() => {
|
|
43
|
+
if (v.isEmpty() || s.current) return;
|
|
39
44
|
let e = () => {
|
|
40
|
-
let t =
|
|
41
|
-
t ?
|
|
45
|
+
let t = v.dequeue();
|
|
46
|
+
t ? S(t).catch(() => {}).finally(() => {
|
|
42
47
|
e();
|
|
43
|
-
}) : (
|
|
48
|
+
}) : (s.current = !1, g(v.peekAll()));
|
|
44
49
|
};
|
|
45
50
|
e();
|
|
46
51
|
}, [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
]), /* @__PURE__ */
|
|
51
|
-
value:
|
|
52
|
-
children:
|
|
52
|
+
v,
|
|
53
|
+
S,
|
|
54
|
+
h
|
|
55
|
+
]), /* @__PURE__ */ f(p.Provider, {
|
|
56
|
+
value: v,
|
|
57
|
+
children: a
|
|
53
58
|
});
|
|
54
|
-
},
|
|
55
|
-
let e =
|
|
59
|
+
}, h = () => {
|
|
60
|
+
let e = s(p);
|
|
56
61
|
if (!e) throw Error("RenderQueue not found");
|
|
57
62
|
return e;
|
|
58
63
|
};
|
|
59
64
|
//#endregion
|
|
60
|
-
export {
|
|
65
|
+
export { p as RenderQueueContext, m as RenderQueueProvider, h as useRenderQueue };
|
|
@@ -3,7 +3,7 @@ import { LicenseType as t } from "../types.js";
|
|
|
3
3
|
import { appConsole as n } from "../appConsole.js";
|
|
4
4
|
import { useCallback as r, useEffect as i, useState as a } from "react";
|
|
5
5
|
//#region lib/utils/hooks/useLicense.ts
|
|
6
|
-
var o = /* @__PURE__ */ new Date("2026-08-25T06:
|
|
6
|
+
var o = /* @__PURE__ */ new Date("2026-08-25T06:35:46.374Z"), s = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvIokvErJ0Fctu0jduSAx\ngr+5Har/VSuZLlOunS28hnlqqA+OF1apHL7RYkjBosS15yvviYdLrVWYHpHnoY4b\nHLQ9I6YX6FMB9T/VbB4xLdVdKvfi8r49aTScl5EKuSpgpPgz2VSJTfvVGcRuth/Y\nBm7PPGYdL2l2gvKDxchmmsHFPukGki9L4JOUeIVX0GXAxabENckaEH/iC1NZhX+W\nvXnpHeHuIIKlZ16LSivXNgo6BH2Z3GFdg4G3cAaXr6qNP8fsacYNqv2SpTW1viFD\nvzcGRabN25gpJAp9/syeScefWH3OiJY1lmw88oTiJbjIoiq6AkPhfn3G9mF54nvR\nkwIDAQAB\n-----END PUBLIC KEY-----", c = "Please visit https://app.react-pdf-kit.dev to generate a new license key.", l = {
|
|
7
7
|
invalidLicense: `You are currently using without a valid license. ${c}`,
|
|
8
8
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${c}`,
|
|
9
9
|
expired: `Your license key has expired. ${c}`,
|
|
@@ -5,92 +5,95 @@ import { useConfigContext as n } from "../../contexts/ConfigContext.js";
|
|
|
5
5
|
import { appConsole as r } from "../appConsole.js";
|
|
6
6
|
import { useDocumentPasswordContext as i } from "../../contexts/DocumentPasswordContext.js";
|
|
7
7
|
import { BROWSER_NOT_SUPPORTED_MESSAGE as a, INVALID_OR_CORRUPTED_PDF_MESSAGE as o, WASM_URL_REQUIRED_CONSOLE_MESSAGE as s, WASM_URL_REQUIRED_MESSAGE as c } from "../const.js";
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
8
|
+
import { trackPdfOperation as l, waitForPdfOperations as u } from "../pdfOperationTracker.js";
|
|
9
|
+
import { useEffect as d, useRef as f, useState as p } from "react";
|
|
10
|
+
import * as m from "pdfjs-dist";
|
|
10
11
|
//#region lib/utils/hooks/useLoadPdf.ts
|
|
11
|
-
var
|
|
12
|
-
function
|
|
13
|
-
return e.some((t, n) => t ===
|
|
12
|
+
var h = new TextEncoder().encode("/JPXDecode");
|
|
13
|
+
function g(e) {
|
|
14
|
+
return e.some((t, n) => t === h[0] ? h.every((t, r) => e[n + r] === t) : !1);
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function _(e) {
|
|
16
17
|
let t = Error(o);
|
|
17
18
|
return t.cause = e, t;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function v() {
|
|
20
21
|
return Error(c);
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function y(e) {
|
|
23
24
|
let t = Error(a);
|
|
24
25
|
return t.cause = e, t;
|
|
25
26
|
}
|
|
26
|
-
var
|
|
27
|
-
let [
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
if (!
|
|
32
|
-
|
|
33
|
-
let t =
|
|
27
|
+
var b = (a, o, c = {}) => {
|
|
28
|
+
let [h, b] = p(), { workerUrlAdded: x, wasmUrl: S, iccUrl: C, standardFontDataUrl: w } = n(), [T, E] = p(/* @__PURE__ */ new Map()), D = f(), [O, k] = p(0), [A, j] = p(!1), [M, N] = p(), { password: P, passwordError: F, setPasswordError: I, passwordRequired: L, setPasswordRequired: R } = i(), { onLoadError: z, onLoaded: B, onLoadProgress: V, disableAutoFetch: H, disableStream: U, rangeChunkSize: W, withCredentials: G, httpHeaders: K } = c;
|
|
29
|
+
return d(() => {
|
|
30
|
+
V && V(O);
|
|
31
|
+
}, [O, V]), d(() => {
|
|
32
|
+
if (!x || !a) return;
|
|
33
|
+
k(0), N(void 0), D.current = Date.now();
|
|
34
|
+
let t = D.current, n = {
|
|
34
35
|
url: a,
|
|
35
36
|
cMapPacked: o?.isCompressed ?? !0,
|
|
36
37
|
...o?.url && { cMapUrl: o.url },
|
|
37
|
-
...
|
|
38
|
-
...
|
|
39
|
-
...
|
|
40
|
-
...
|
|
41
|
-
...
|
|
42
|
-
...
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
-
iccUrl:
|
|
38
|
+
...P && { password: P },
|
|
39
|
+
...H !== void 0 && { disableAutoFetch: H },
|
|
40
|
+
...U !== void 0 && { disableStream: U },
|
|
41
|
+
...W !== void 0 && { rangeChunkSize: W },
|
|
42
|
+
...G !== void 0 && { withCredentials: G },
|
|
43
|
+
...K !== void 0 && { httpHeaders: K },
|
|
44
|
+
...S && { wasmUrl: S },
|
|
45
|
+
...C && {
|
|
46
|
+
iccUrl: C,
|
|
46
47
|
useWorkerFetch: !0
|
|
47
48
|
},
|
|
48
|
-
...
|
|
49
|
-
verbosity:
|
|
49
|
+
...w && { standardFontDataUrl: w },
|
|
50
|
+
verbosity: m.VerbosityLevel.ERRORS
|
|
50
51
|
};
|
|
51
52
|
try {
|
|
52
|
-
let i =
|
|
53
|
+
let i = m.getDocument(n);
|
|
53
54
|
i.onProgress = (e) => {
|
|
54
|
-
if (t ===
|
|
55
|
+
if (t === D.current) {
|
|
55
56
|
let { loaded: t, total: n } = e;
|
|
56
|
-
|
|
57
|
+
k(n ? Math.min(100, Math.round(t / n * 100)) : 0);
|
|
57
58
|
}
|
|
58
|
-
},
|
|
59
|
-
let a = i.promise.then(async (n) => !
|
|
59
|
+
}, j(!0), b(void 0);
|
|
60
|
+
let a, o = i.promise.then(async (n) => (a = n, !S && g(await n.getData()) ? (t === D.current && (b(void 0), N(e.WASM_URL_REQUIRED)), r.error(s), z?.(v()), n) : (t === D.current && (b(n), k(100)), B && B(n), R(!1), I(""), n))).catch((t) => {
|
|
60
61
|
if (t instanceof Error && t.name === "PasswordException") {
|
|
61
62
|
let e = t.code;
|
|
62
|
-
|
|
63
|
-
} else t instanceof Error && t.name === "InvalidPDFException" &&
|
|
63
|
+
R(!0), e === m.PasswordResponses.INCORRECT_PASSWORD ? I("Incorrect password") : I(void 0);
|
|
64
|
+
} else t instanceof Error && t.name === "InvalidPDFException" && P ? (R(!0), I("Incorrect password")) : t instanceof Error && t.name === "InvalidPDFException" ? (N(e.INVALID_OR_CORRUPTED_PDF), z?.(_(t))) : z && z(t);
|
|
64
65
|
}).finally(() => {
|
|
65
|
-
|
|
66
|
+
j(!1);
|
|
66
67
|
});
|
|
67
68
|
return () => {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
o.finally(() => {
|
|
70
|
+
(a ? u(a) : Promise.resolve()).finally(() => {
|
|
71
|
+
i.destroy();
|
|
72
|
+
});
|
|
70
73
|
});
|
|
71
74
|
};
|
|
72
75
|
} catch (t) {
|
|
73
|
-
|
|
76
|
+
N(e.NOT_SUPPORTED), z?.(y(t));
|
|
74
77
|
}
|
|
75
78
|
}, [
|
|
76
79
|
a,
|
|
77
|
-
y,
|
|
78
|
-
b,
|
|
79
80
|
x,
|
|
80
81
|
S,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
C,
|
|
83
|
+
w,
|
|
84
|
+
P,
|
|
85
|
+
z,
|
|
86
|
+
B
|
|
87
|
+
]), d(() => {
|
|
88
|
+
if (L) return;
|
|
86
89
|
let n = /* @__PURE__ */ new Map();
|
|
87
|
-
if (!
|
|
88
|
-
|
|
90
|
+
if (!h || A) {
|
|
91
|
+
E(n);
|
|
89
92
|
return;
|
|
90
93
|
}
|
|
91
|
-
let r =
|
|
94
|
+
let r = h.numPages, i = [];
|
|
92
95
|
for (let e = 1; e <= r; e++) {
|
|
93
|
-
let t =
|
|
96
|
+
let t = l(h, h.getPage(e));
|
|
94
97
|
i.push(t);
|
|
95
98
|
}
|
|
96
99
|
Promise.allSettled(i).then((e) => {
|
|
@@ -104,24 +107,24 @@ var v = (a, o, c = {}) => {
|
|
|
104
107
|
thumbnailScale: i,
|
|
105
108
|
defaultRotation: a.rotation
|
|
106
109
|
});
|
|
107
|
-
}),
|
|
110
|
+
}), E(n);
|
|
108
111
|
}).catch((t) => {
|
|
109
|
-
|
|
112
|
+
b(void 0), N(e.INVALID_OR_CORRUPTED_PDF), z?.(_(t));
|
|
110
113
|
});
|
|
111
114
|
}, [
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
h,
|
|
116
|
+
A,
|
|
117
|
+
L,
|
|
118
|
+
z
|
|
116
119
|
]), {
|
|
117
|
-
pdf:
|
|
118
|
-
pages:
|
|
119
|
-
loading:
|
|
120
|
-
error:
|
|
121
|
-
loadingProgress:
|
|
122
|
-
passwordRequired:
|
|
123
|
-
passwordError:
|
|
120
|
+
pdf: h,
|
|
121
|
+
pages: T,
|
|
122
|
+
loading: A,
|
|
123
|
+
error: M,
|
|
124
|
+
loadingProgress: O,
|
|
125
|
+
passwordRequired: L,
|
|
126
|
+
passwordError: F
|
|
124
127
|
};
|
|
125
128
|
};
|
|
126
129
|
//#endregion
|
|
127
|
-
export {
|
|
130
|
+
export { b as useLoadPdf };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region lib/utils/pdfOperationTracker.ts
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (!t) return n;
|
|
5
|
+
let r = e.get(t);
|
|
6
|
+
r || (r = /* @__PURE__ */ new Set(), e.set(t, r));
|
|
7
|
+
let i = n.then(() => void 0, () => void 0);
|
|
8
|
+
return r.add(i), i.finally(() => {
|
|
9
|
+
r?.delete(i);
|
|
10
|
+
}), n;
|
|
11
|
+
}
|
|
12
|
+
function n(t) {
|
|
13
|
+
let n = e.get(t);
|
|
14
|
+
return !n || n.size === 0 ? Promise.resolve() : Promise.allSettled(Array.from(n)).then(() => void 0);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { t as trackPdfOperation, n as waitForPdfOperations };
|
package/package.json
CHANGED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { AnnotationSubType as e } from "./utils/types.js";
|
|
2
|
-
import { useDocumentContext as t } from "./contexts/RPDocumentContext.js";
|
|
3
|
-
import { useInitialStateContext as n } from "./contexts/InitialStateContext.js";
|
|
4
|
-
import { useScrollModeContext as r } from "./contexts/ScrollModeContext.js";
|
|
5
|
-
import { r as i } from "./PaginationContext-DIzsZhFd.js";
|
|
6
|
-
import { usePrintContext as a } from "./contexts/PrintContext.js";
|
|
7
|
-
import { SimpleLinkService as o } from "./utils/link_service.js";
|
|
8
|
-
import { annotationEventsHandler as s, bindLayerEvents as c, enhanceLinkAccessibility as l, fixTabIndexAccessibility as u, handleAnnotationWidget as d, insertDateText as f, unbindLayerEvents as p } from "./utils/annotations.js";
|
|
9
|
-
import { useFileDownload as m } from "./utils/hooks/useFileDownload.js";
|
|
10
|
-
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
11
|
-
import { AnnotationLayer as b } from "pdfjs-dist";
|
|
12
|
-
import { jsx as x } from "react/jsx-runtime";
|
|
13
|
-
import './assets/AnnotationLayer.css';//#region lib/components/page/AnnotationLayer.module.css
|
|
14
|
-
var S = { "rp-annotation-layer": "_rp-annotation-layer_foiun_1" }, C = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/", w = (w) => {
|
|
15
|
-
let { pageNumber: T } = w, E = v(null), { pages: D, pdf: O } = t(), { interactiveForm: k } = n(), A = v(), [j, M] = y(), { goToPage: N } = i(), { scrollMode: P } = r(), { print: F } = a(), { download: I } = m(), L = v(null), R = _(() => D.get(T), [D, T]), z = _(() => R?.page.getViewport(), [R]);
|
|
16
|
-
g(() => {
|
|
17
|
-
A.current &&= (A.current.div.replaceChildren(), void 0);
|
|
18
|
-
}, [O]), g(() => {
|
|
19
|
-
R && R.page.getAnnotations().then((e) => {
|
|
20
|
-
A.current = void 0, M(e), E.current && (E.current.innerText = "");
|
|
21
|
-
});
|
|
22
|
-
}, [R]);
|
|
23
|
-
let B = h((e) => {
|
|
24
|
-
!j || !O || (f(E.current), s(e, O, j).then((e) => {
|
|
25
|
-
e?.data?.action === "Print" ? F() : e?.data?.action === "SaveAs" && I();
|
|
26
|
-
}));
|
|
27
|
-
}, [
|
|
28
|
-
O,
|
|
29
|
-
j,
|
|
30
|
-
P,
|
|
31
|
-
F,
|
|
32
|
-
I
|
|
33
|
-
]);
|
|
34
|
-
return g(() => {
|
|
35
|
-
if (!R || !j) return;
|
|
36
|
-
let t = R.page.getViewport();
|
|
37
|
-
if (A.current) {
|
|
38
|
-
A.current.update({ viewport: t.clone({ dontFlip: !0 }) });
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
let n = /* @__PURE__ */ new Map([]);
|
|
42
|
-
for (let r of j) {
|
|
43
|
-
let { annotationType: i } = r;
|
|
44
|
-
switch (i) {
|
|
45
|
-
case e.Widget:
|
|
46
|
-
d(r, t, n);
|
|
47
|
-
break;
|
|
48
|
-
default: break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
let r = new AbortController();
|
|
52
|
-
return (async () => {
|
|
53
|
-
A.current &&= (A.current.div.replaceChildren(), void 0), E.current && (E.current.innerText = ""), A.current = new b({
|
|
54
|
-
div: E.current,
|
|
55
|
-
accessibilityManager: void 0,
|
|
56
|
-
annotationCanvasMap: void 0,
|
|
57
|
-
annotationEditorUIManager: void 0,
|
|
58
|
-
structTreeLayer: null,
|
|
59
|
-
page: R.page,
|
|
60
|
-
viewport: t.clone({ dontFlip: !0 }),
|
|
61
|
-
commentManager: void 0,
|
|
62
|
-
linkService: new o(O, N),
|
|
63
|
-
annotationStorage: O?.annotationStorage
|
|
64
|
-
}), E.current && p(E.current, B);
|
|
65
|
-
let e = await O?.hasJSActions(), n = await O?.getFieldObjects();
|
|
66
|
-
if (r.signal.aborted) throw "abort";
|
|
67
|
-
return A.current?.render({
|
|
68
|
-
annotations: j,
|
|
69
|
-
annotationStorage: O?.annotationStorage,
|
|
70
|
-
hasJSActions: e,
|
|
71
|
-
fieldObjects: n,
|
|
72
|
-
div: E.current,
|
|
73
|
-
viewport: t.clone({ dontFlip: !0 }),
|
|
74
|
-
page: R.page,
|
|
75
|
-
imageResourcesPath: C,
|
|
76
|
-
renderForms: k ?? !0,
|
|
77
|
-
linkService: new o(O, N),
|
|
78
|
-
downloadManager: null,
|
|
79
|
-
enableScripting: !1
|
|
80
|
-
});
|
|
81
|
-
})().then(() => {
|
|
82
|
-
E.current && (c(E.current, B), u(E.current), l(E.current), L.current && L.current.disconnect(), L.current = new MutationObserver(() => {
|
|
83
|
-
E.current && (u(E.current), l(E.current));
|
|
84
|
-
}), L.current.observe(E.current, {
|
|
85
|
-
childList: !0,
|
|
86
|
-
subtree: !0,
|
|
87
|
-
attributes: !0,
|
|
88
|
-
attributeFilter: ["tabindex", "href"]
|
|
89
|
-
}));
|
|
90
|
-
}).catch((e) => {
|
|
91
|
-
if (e !== "abort") throw e;
|
|
92
|
-
}).finally(() => {
|
|
93
|
-
A.current = void 0;
|
|
94
|
-
}), () => {
|
|
95
|
-
r.abort("clear"), E.current && p(E.current, B), L.current &&= (L.current.disconnect(), null);
|
|
96
|
-
};
|
|
97
|
-
}, [
|
|
98
|
-
O,
|
|
99
|
-
j,
|
|
100
|
-
B,
|
|
101
|
-
N
|
|
102
|
-
]), /* @__PURE__ */ x("div", {
|
|
103
|
-
"data-rp": `page-${T}-annotationLayer`,
|
|
104
|
-
style: {
|
|
105
|
-
width: `${z?.width}px`,
|
|
106
|
-
height: `${z?.height}px`
|
|
107
|
-
},
|
|
108
|
-
className: S["rp-annotation-layer"],
|
|
109
|
-
ref: E
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
//#endregion
|
|
113
|
-
export { w as t };
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { useDocumentContext as e } from "./contexts/RPDocumentContext.js";
|
|
2
|
-
import { highlightMatches as t, resetDivs as n } from "./utils/highlight.js";
|
|
3
|
-
import { useSearchContext as r } from "./contexts/SearchContext.js";
|
|
4
|
-
import { useCallback as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
5
|
-
import * as l from "pdfjs-dist";
|
|
6
|
-
import { jsx as u } from "react/jsx-runtime";
|
|
7
|
-
import './assets/TextLayer.css';var d = {
|
|
8
|
-
"rp-text-layer": "_rp-text-layer_1cfxj_1",
|
|
9
|
-
selecting: "_selecting_1cfxj_18",
|
|
10
|
-
markedContent: "_markedContent_1cfxj_58",
|
|
11
|
-
"rp-text-layer-text": "_rp-text-layer-text_1cfxj_82"
|
|
12
|
-
}, f = (f) => {
|
|
13
|
-
let { pageNumber: p } = f, { pages: m } = e(), h = s(null), { matches: g, currentMatch: _ } = r(), [v, y] = c([]), b = s(), x = s(), S = s([]), C = o(() => g.filter((e) => e.pageIndex === p - 1), [g, p]), w = i((e, r, i = !1) => {
|
|
14
|
-
if (i && n(e, r), !C.length) {
|
|
15
|
-
S.current = [], y([]);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
y(t(C, e, r));
|
|
19
|
-
}, [C]), T = s(), E = s(!1), D = i(() => Array.from(document.querySelectorAll("[data-rp$=\"-textLayer\"]")), []);
|
|
20
|
-
a(() => ((() => {
|
|
21
|
-
if (T.current) return;
|
|
22
|
-
T.current = new AbortController();
|
|
23
|
-
let { signal: e } = T.current, t = () => {
|
|
24
|
-
D().forEach((e) => {
|
|
25
|
-
let t = e.querySelector(".endOfContent");
|
|
26
|
-
t && (e.appendChild(t), t.style.width = "", t.style.height = "", e.classList.remove(d.selecting));
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
document.addEventListener("pointerdown", () => {
|
|
30
|
-
E.current = !0;
|
|
31
|
-
}, { signal: e }), document.addEventListener("pointerup", () => {
|
|
32
|
-
E.current = !1, t();
|
|
33
|
-
}, { signal: e }), window.addEventListener("blur", () => {
|
|
34
|
-
E.current = !1, t();
|
|
35
|
-
}, { signal: e }), document.addEventListener("keyup", () => {
|
|
36
|
-
E.current || t();
|
|
37
|
-
}, { signal: e });
|
|
38
|
-
let n = null;
|
|
39
|
-
document.addEventListener("selectionchange", () => {
|
|
40
|
-
let e = document.getSelection();
|
|
41
|
-
if (!e) return;
|
|
42
|
-
if (e.rangeCount === 0) {
|
|
43
|
-
t();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
let r = /* @__PURE__ */ new Set();
|
|
47
|
-
for (let t = 0; t < e.rangeCount; t++) {
|
|
48
|
-
let n = e.getRangeAt(t);
|
|
49
|
-
D().forEach((e) => {
|
|
50
|
-
n.intersectsNode(e) && !r.has(e) && r.add(e);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
D().forEach((e) => {
|
|
54
|
-
if (r.has(e)) e.classList.add(d.selecting);
|
|
55
|
-
else {
|
|
56
|
-
let t = e.querySelector(".endOfContent");
|
|
57
|
-
t && (e.appendChild(t), t.style.width = "", t.style.height = "", e.classList.remove(d.selecting));
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
let i = e.getRangeAt(0), a = n && (i.compareBoundaryPoints(Range.END_TO_END, n) === 0 || i.compareBoundaryPoints(Range.START_TO_END, n) === 0) ? i.startContainer : i.endContainer;
|
|
61
|
-
a.nodeType === Node.TEXT_NODE && (a = a.parentNode);
|
|
62
|
-
let o = a.parentElement?.closest(`.${d["rp-text-layer"]}`), s = o?.querySelector(".endOfContent");
|
|
63
|
-
s && o && (s.style.width = o.style.width, s.style.height = o.style.height, a.parentElement?.insertBefore(s, a.nextSibling)), n = i.cloneRange();
|
|
64
|
-
}, { signal: e });
|
|
65
|
-
})(), () => {
|
|
66
|
-
T.current?.abort(), T.current = void 0;
|
|
67
|
-
}), [D]);
|
|
68
|
-
let O = i(() => {
|
|
69
|
-
h.current && h.current.classList.add(d.selecting);
|
|
70
|
-
}, []), k = i(() => {
|
|
71
|
-
h.current && h.current.classList.remove(d.selecting);
|
|
72
|
-
}, []);
|
|
73
|
-
return a(() => {
|
|
74
|
-
if (S.current.forEach((e) => {
|
|
75
|
-
e.classList.remove("selected");
|
|
76
|
-
}), !v.length || !_ || _.pageIndex !== p - 1) return;
|
|
77
|
-
let e = C.findIndex((e) => JSON.stringify(e) === JSON.stringify(_));
|
|
78
|
-
if (e === -1) return;
|
|
79
|
-
let t = v.filter((t) => t.index === e);
|
|
80
|
-
t.length && (S.current = t.map((e) => e.element), t.forEach((e) => {
|
|
81
|
-
e.element.classList.add("selected");
|
|
82
|
-
}));
|
|
83
|
-
}, [
|
|
84
|
-
_,
|
|
85
|
-
v,
|
|
86
|
-
C
|
|
87
|
-
]), a(() => {
|
|
88
|
-
let e = m.get(p);
|
|
89
|
-
if (!e || !h.current) return;
|
|
90
|
-
let t = h.current;
|
|
91
|
-
return b.current && b.current.cancel(), e.page.getTextContent().then((n) => {
|
|
92
|
-
let r = e.page.getViewport({ scale: 1 });
|
|
93
|
-
return b.current = new l.TextLayer({
|
|
94
|
-
viewport: r,
|
|
95
|
-
textContentSource: n,
|
|
96
|
-
container: t
|
|
97
|
-
}), x.current = n, t && (t.innerText = ""), b.current.render();
|
|
98
|
-
}).then(() => {
|
|
99
|
-
[].slice.call(t.children).forEach((e) => {
|
|
100
|
-
e.classList.add(d["rp-text-layer-text"]), e.setAttribute("data-rp", "rp-text-layer-text");
|
|
101
|
-
});
|
|
102
|
-
let e = b.current?.textDivs;
|
|
103
|
-
e && x.current && w(x.current, e);
|
|
104
|
-
let n = document.createElement("div");
|
|
105
|
-
n.className = "endOfContent", h.current?.appendChild(n);
|
|
106
|
-
}).catch(() => {}), () => {
|
|
107
|
-
b.current?.cancel();
|
|
108
|
-
};
|
|
109
|
-
}, [m, p]), a(() => {
|
|
110
|
-
[].slice.call(h.current.children).forEach((e) => {
|
|
111
|
-
e.classList.add(d["rp-text-layer-text"]);
|
|
112
|
-
});
|
|
113
|
-
let e = b.current?.textDivs;
|
|
114
|
-
e && x.current && w(x.current, e, !0);
|
|
115
|
-
}, [w]), /* @__PURE__ */ u("div", {
|
|
116
|
-
"data-rp-text-layer": !0,
|
|
117
|
-
"data-rp": `page-${p}-textLayer`,
|
|
118
|
-
className: d["rp-text-layer"],
|
|
119
|
-
ref: h,
|
|
120
|
-
onMouseDown: O,
|
|
121
|
-
onMouseUp: k
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
125
|
-
export { f as t };
|