@react-pdf-kit/viewer 2.9.2 → 2.10.0-beta.1
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-lagF0zYo.js +116 -0
- package/dist/{Button-DBu3SaMk.js → Button-B_yuVBQ_.js} +1 -1
- package/dist/{Checkbox-CSIEUyO8.js → Checkbox-BVARFFLh.js} +2 -2
- package/dist/{Combination-11kyhTGt.js → Combination-ILTe_xfZ.js} +2 -2
- package/dist/{Container-BuamPhw4.js → Container-CY9sCoDd.js} +1 -1
- package/dist/{DocumentDialog-cRr9sSSH.js → DocumentDialog-CYKsfOE1.js} +4 -4
- package/dist/{DropDown-CM6xEwZC.js → DropDown-DEnDtOIT.js} +2 -2
- package/dist/{Input-Dpo1Xfxe.js → Input-CVjTHdhy.js} +1 -1
- package/dist/{LoaderIcon-B3ddfd0D.js → LoaderIcon-SD35XFV2.js} +1 -1
- package/dist/{LoadingIndicator-0E8WHnSN.js → LoadingIndicator-SLpllUQ1.js} +1 -1
- package/dist/{MenuItem-lItnKNd5.js → MenuItem-DEd62cAM.js} +2 -2
- package/dist/{MenuSeparator-CaFxd8b5.js → MenuSeparator-BVQWugN3.js} +1 -1
- package/dist/{PasswordModal-CxHFn0pB.js → PasswordModal-BCjtXHN4.js} +1 -1
- package/dist/{RPDropFileZone-Bq1bzWmO.js → RPDropFileZone-lI-AmN-1.js} +3 -3
- package/dist/{RPPages-BZwgKgfJ.js → RPPages-BVSFaPUT.js} +2 -2
- package/dist/{RPTooltip-QWwWh4HW.js → RPTooltip-KdCUxOyM.js} +3 -3
- package/dist/TextHighlightLayer-BMhYl-9Q.js +162 -0
- package/dist/{TextLayer-Bp1CDIIa.js → TextLayer-CUtANGvL.js} +2 -2
- package/dist/{Thumbnail-BXMk0OWF.js → Thumbnail-BDGp0xdd.js} +3 -3
- package/dist/{Thumbnails-BIuN8LZ8.js → Thumbnails-C6maORBh.js} +1 -1
- package/dist/XfaLayer.module-w4FOd2dm.js +4 -0
- package/dist/assets/XfaLayer.css +1 -0
- package/dist/assets/style.js +1 -1
- package/dist/components/RPController.js +1 -1
- package/dist/components/RPDropFileZone.js +1 -1
- package/dist/components/RPPages.js +1 -1
- package/dist/components/RPProvider.js +1 -1
- package/dist/components/icons/DarkPdfIcon.js +1 -1
- package/dist/components/icons/LightPdfIcon.js +1 -1
- package/dist/components/icons/LoaderIcon.js +1 -1
- package/dist/components/layout/Container.js +1 -1
- package/dist/components/layout/LayoutContainer.js +2 -2
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +5 -5
- package/dist/components/layout/RPLayout.js +5 -5
- package/dist/components/layout/SkipLink.js +1 -1
- package/dist/components/layout/WrapperLayout.js +1 -1
- package/dist/components/layout/sidebar/CustomThumbnailElement.js +1 -1
- package/dist/components/layout/sidebar/RPSidebar.js +4 -4
- package/dist/components/layout/sidebar/RPSplitter.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +1 -1
- package/dist/components/layout/sidebar/Thumbnails.js +1 -1
- package/dist/components/layout/toolbar/DarkModeTool.js +2 -2
- package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
- package/dist/components/layout/toolbar/DocumentProperties.js +3 -3
- package/dist/components/layout/toolbar/FileDownloadTool.js +3 -3
- package/dist/components/layout/toolbar/FileUploadTool.js +3 -3
- package/dist/components/layout/toolbar/FullScreenTool.js +3 -3
- package/dist/components/layout/toolbar/MenuItem.js +1 -1
- package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
- package/dist/components/layout/toolbar/MostPageTool.js +5 -5
- package/dist/components/layout/toolbar/OtherTool.js +7 -7
- package/dist/components/layout/toolbar/Paginate.js +4 -4
- package/dist/components/layout/toolbar/PrintTool.js +3 -3
- package/dist/components/layout/toolbar/PropertyItem.js +1 -1
- package/dist/components/layout/toolbar/RPMenuItem.js +3 -3
- package/dist/components/layout/toolbar/RPMoreOptions.js +7 -7
- package/dist/components/layout/toolbar/RPToolbar.js +2 -2
- package/dist/components/layout/toolbar/RotateTool.js +5 -5
- package/dist/components/layout/toolbar/ScrollModeTool.js +3 -3
- package/dist/components/layout/toolbar/SearchCloseButton.js +3 -3
- package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -3
- package/dist/components/layout/toolbar/SearchTool.js +7 -7
- package/dist/components/layout/toolbar/SelectionModeTool.js +4 -4
- package/dist/components/layout/toolbar/ThumbnailTool.js +2 -2
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +4 -4
- package/dist/components/layout/toolbar/ViewModeTool.js +4 -4
- package/dist/components/layout/toolbar/ZoomTool.js +8 -8
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -3
- package/dist/components/layout/toolbar/tools/DualPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -3
- package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
- package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +2 -2
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +3 -3
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +2 -2
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +2 -2
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +2 -2
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +7 -7
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +2 -2
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +1 -1
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +5 -5
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +5 -5
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +3 -3
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +4 -4
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +4 -4
- package/dist/components/page/AnnotationLayer.js +1 -1
- package/dist/components/page/CanvasLayer.js +1 -1
- package/dist/components/page/RPPage.js +54 -52
- package/dist/components/page/TextHighlightLayer.js +1 -1
- package/dist/components/page/TextLayer.js +1 -1
- package/dist/components/page/XfaLayer.js +86 -0
- package/dist/components/ui/Button.js +1 -1
- package/dist/components/ui/Checkbox.js +1 -1
- package/dist/components/ui/DropDown.js +1 -1
- package/dist/components/ui/Input.js +1 -1
- package/dist/components/ui/LoadingIndicator.js +1 -1
- package/dist/components/ui/PasswordModal.js +1 -1
- package/dist/components/ui/RPTooltip.js +1 -1
- package/dist/contexts/LoaderContext.js +1 -1
- package/dist/contexts/RenderQueueProvider.js +46 -43
- package/dist/{dist-CNbFpoT1.js → dist-BgFO-PWQ.js} +1 -1
- package/dist/{dist-VbpVNBs6.js → dist-CtoH1CMU.js} +4 -4
- package/dist/{dist-B2hwhF6G.js → dist-D6Fk7CTS.js} +3 -3
- package/dist/{dist-BfuBBQ14.js → dist-SBjhcXgf.js} +1 -1
- package/dist/icons.js +3 -3
- package/dist/{main-DCzVrq0G.js → main-DrddwgsH.js} +3 -3
- package/dist/main.js +4 -4
- package/dist/{style-dcYpxEeL.js → style-DW_uCDpt.js} +1 -1
- package/dist/types/components/page/XfaLayer.d.ts +6 -0
- package/dist/types/utils/pdfOperationTracker.d.ts +20 -0
- package/dist/utils/annotations.js +72 -71
- package/dist/utils/highlight.js +4 -2
- package/dist/utils/hooks/useFileDownload.js +10 -6
- package/dist/utils/hooks/useHighlight.js +43 -42
- package/dist/utils/hooks/useLicense.js +2 -2
- package/dist/utils/hooks/useLoadPdf.js +66 -64
- package/dist/utils/hooks/usePdfProperties.js +33 -32
- package/dist/utils/hooks/usePrint.js +123 -88
- package/dist/utils/hooks/useSearch.js +87 -83
- package/dist/utils/hooks/useWatermark.js +1 -1
- package/dist/utils/injectPrintCSS.js +1 -1
- package/dist/utils/link_service.js +33 -17
- package/dist/utils/pdfOperationTracker.js +27 -4
- package/package.json +1 -1
- package/dist/AnnotationLayer-oDu2B4X1.js +0 -114
- package/dist/TextHighlightLayer-3vIZbRyL.js +0 -157
- /package/dist/{CanvasLayer-C3gb8EXu.js → CanvasLayer-DkVH-tX2.js} +0 -0
- /package/dist/{CustomThumbnailElement-C2quEICO.js → CustomThumbnailElement-BxTSbzpP.js} +0 -0
- /package/dist/{DarkPdfIcon-B5ehd9CV.js → DarkPdfIcon-2aDGWxuA.js} +0 -0
- /package/dist/{LightPdfIcon-DL8MYtWQ.js → LightPdfIcon-LatCGY0T.js} +0 -0
- /package/dist/{MostPageTool.module-BRVv-sGz.js → MostPageTool.module-BP2BMoK8.js} +0 -0
- /package/dist/{OtherTool.module-BQY9Nfqz.js → OtherTool.module-CMbI70sn.js} +0 -0
- /package/dist/{Paginate.module-DhE7N8AA.js → Paginate.module-DxXyYoYp.js} +0 -0
- /package/dist/{PropertyItem-evJWWmWZ.js → PropertyItem-CmRC2e5Z.js} +0 -0
- /package/dist/{RPLayout.module-BH5r8dDc.js → RPLayout.module-DLX1UwA3.js} +0 -0
- /package/dist/{RPSplitter-C63X9M8w.js → RPSplitter-DGnDuwsT.js} +0 -0
- /package/dist/{RPToolbar.module-BwqWLviy.js → RPToolbar.module-ODOa9FwW.js} +0 -0
- /package/dist/{RotateTool.module-DH5yWbvM.js → RotateTool.module-BHFeo1yn.js} +0 -0
- /package/dist/{SearchTool.module-DY8Ucfb_.js → SearchTool.module-BQDBENlo.js} +0 -0
- /package/dist/{SkipLink-Dj83gZdk.js → SkipLink-mnqFQj0O.js} +0 -0
- /package/dist/{ToolbarLayout.module-Zo715dbb.js → ToolbarLayout.module-BC9eQ9LN.js} +0 -0
- /package/dist/{WrapperLayout-Dcd9l9xH.js → WrapperLayout-NjsBnUaz.js} +0 -0
- /package/dist/{ZoomTool.module-BrIPy8pO.js → ZoomTool.module-DO-r2IDy.js} +0 -0
- /package/dist/{clsx-DSGuh5YW.js → clsx-BD2qMUU1.js} +0 -0
- /package/dist/{dist-CgoP608h.js → dist-DjD1zIE0.js} +0 -0
- /package/dist/{lib-CSInlR9T.js → lib-DTkzWIMS.js} +0 -0
- /package/dist/{useWatermark-CvAAf66v.js → useWatermark-DlRNcg9p.js} +0 -0
|
@@ -1,125 +1,129 @@
|
|
|
1
1
|
import { ScrollMode as e } from "../types.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
2
|
+
import { runPdfOperation as t } from "../pdfOperationTracker.js";
|
|
3
|
+
import { useDocumentContext as n } from "../../contexts/RPDocumentContext.js";
|
|
4
|
+
import { useScrollModeContext as r } from "../../contexts/ScrollModeContext.js";
|
|
5
|
+
import { useViewModeContext as i } from "../../contexts/ViewModeContext.js";
|
|
6
|
+
import { useVirtualScrollContext as a } from "../../contexts/VirtualScrollContext.js";
|
|
7
|
+
import { useLayoutContainer as o } from "../../contexts/LayoutContainerContext.js";
|
|
8
|
+
import { useZoomContext as s } from "../../contexts/ZoomContext.js";
|
|
9
|
+
import { usePagesRotateContext as c } from "../../contexts/PagesRotateContext.js";
|
|
10
|
+
import { useDimensionPagesContext as l } from "../../contexts/DimensionPagesContext.js";
|
|
11
|
+
import { useSmoothScrollContext as u } from "../../contexts/SmoothScrollContext.js";
|
|
12
|
+
import { buildDocumentLayout as d, getPagePlacement as f } from "../documentLayout.js";
|
|
13
|
+
import { r as p } from "../../PaginationContext-DIzsZhFd.js";
|
|
14
|
+
import { findMatches as m } from "../highlight.js";
|
|
15
|
+
import { getWordPositionInPage as h } from "../getWordPositionInPage.js";
|
|
16
|
+
import { useCallback as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
16
17
|
//#region lib/utils/hooks/useSearch.ts
|
|
17
|
-
var
|
|
18
|
-
let [
|
|
18
|
+
var x = (x = {}, S = "") => {
|
|
19
|
+
let [C, w] = b(S), [T, E] = b(!1), { pdf: D, pages: O } = n(), { widths: k, heights: A } = l(), j = y(!C), { currentZoom: M } = s(), [N, P] = b([]), { setFocusedPage: F } = p(), { viewMode: I } = i(), { pageRotate: L } = c(), [R, z] = b(0), { pageScrollElementRef: B, virtualScrollableElementRef: V } = a(), { scrollMode: H } = r(), { pagesRef: U } = o(), { scrollBehavior: W } = u(), G = y({}), K = y(0), q = v(() => R === 0 ? null : N[R - 1], [R, N]), J = v(() => N.length, [N]), Y = g((t) => {
|
|
19
20
|
if (t === 0) return;
|
|
20
|
-
let n =
|
|
21
|
-
if (!n || !
|
|
22
|
-
let r =
|
|
23
|
-
if (!r || !
|
|
24
|
-
let i =
|
|
25
|
-
if (
|
|
26
|
-
let a =
|
|
21
|
+
let n = N[t - 1];
|
|
22
|
+
if (!n || !O) return;
|
|
23
|
+
let r = V || B;
|
|
24
|
+
if (!r || !U) return;
|
|
25
|
+
let i = O.get(n.page);
|
|
26
|
+
if (H === e.PAGE_SCROLLING && F(n.page), !i) return;
|
|
27
|
+
let a = d({
|
|
27
28
|
pageDimensions: {
|
|
28
|
-
widths:
|
|
29
|
-
heights:
|
|
29
|
+
widths: k,
|
|
30
|
+
heights: A
|
|
30
31
|
},
|
|
31
32
|
viewportWidth: r.clientWidth,
|
|
32
33
|
viewportHeight: r.clientHeight,
|
|
33
|
-
scrollMode:
|
|
34
|
-
viewMode:
|
|
34
|
+
scrollMode: H,
|
|
35
|
+
viewMode: I,
|
|
35
36
|
focusedPage: n.page
|
|
36
|
-
}), o =
|
|
37
|
+
}), o = f(a, n.page);
|
|
37
38
|
if (!o) return;
|
|
38
39
|
let s = {
|
|
39
|
-
height:
|
|
40
|
-
width:
|
|
41
|
-
}, c =
|
|
40
|
+
height: A[n.page - 1],
|
|
41
|
+
width: k[n.page - 1]
|
|
42
|
+
}, c = L[n.page], { leftInPage: l, topInPage: u } = i.page.isPureXfa ? {
|
|
43
|
+
leftInPage: 0,
|
|
44
|
+
topInPage: 0
|
|
45
|
+
} : h(s, U, n.rect, M, c), p = a.offsetLeft + o.left + l, m = a.offsetTop + o.top + u, g = {
|
|
42
46
|
left: Math.max(p, 0),
|
|
43
|
-
top: Math.max(
|
|
47
|
+
top: Math.max(m, 0)
|
|
44
48
|
};
|
|
45
49
|
r.scrollTo({
|
|
46
50
|
...g,
|
|
47
|
-
behavior:
|
|
51
|
+
behavior: W
|
|
48
52
|
});
|
|
49
53
|
}, [
|
|
50
|
-
D,
|
|
51
|
-
P,
|
|
52
54
|
O,
|
|
55
|
+
F,
|
|
53
56
|
k,
|
|
57
|
+
A,
|
|
58
|
+
H,
|
|
59
|
+
I,
|
|
54
60
|
V,
|
|
55
|
-
F,
|
|
56
61
|
B,
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
U,
|
|
63
|
+
N,
|
|
59
64
|
M,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
U
|
|
65
|
+
L,
|
|
66
|
+
W
|
|
63
67
|
]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
let
|
|
68
|
-
|
|
68
|
+
_(() => {
|
|
69
|
+
R && Y(R);
|
|
70
|
+
}, [R]);
|
|
71
|
+
let X = g(() => {
|
|
72
|
+
z((e) => {
|
|
69
73
|
let t;
|
|
70
|
-
return t =
|
|
71
|
-
}),
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
+
return t = J ? e + 1 > J ? 1 : e + 1 : 0, K.current = t, t;
|
|
75
|
+
}), K.current === 1 && Y(K.current);
|
|
76
|
+
}, [J, Y]), Z = g(() => {
|
|
77
|
+
z((e) => {
|
|
74
78
|
let t;
|
|
75
|
-
return t =
|
|
76
|
-
}),
|
|
77
|
-
}, [
|
|
79
|
+
return t = J ? e - 1 <= 0 ? J : e - 1 : 0, K.current = t, t;
|
|
80
|
+
}), K.current === 1 && Y(K.current);
|
|
81
|
+
}, [J, Y]), Q = g(async (e) => {
|
|
78
82
|
if (!e) return {};
|
|
79
|
-
let
|
|
80
|
-
for (let
|
|
81
|
-
if (
|
|
82
|
-
let
|
|
83
|
-
|
|
83
|
+
let n = e.numPages, r = {};
|
|
84
|
+
for (let i = 1; i <= n; i++) {
|
|
85
|
+
if (j.current) throw "close pop over";
|
|
86
|
+
let n = await t(e, () => e.getPage(i));
|
|
87
|
+
r[i.toString()] = await t(e, () => n.getTextContent());
|
|
84
88
|
}
|
|
85
|
-
return
|
|
89
|
+
return r;
|
|
86
90
|
}, []);
|
|
87
|
-
return
|
|
88
|
-
if (!
|
|
89
|
-
|
|
91
|
+
return _(() => {
|
|
92
|
+
if (!C) {
|
|
93
|
+
j.current = !0, P([]), z(0);
|
|
90
94
|
return;
|
|
91
95
|
}
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
j.current = !1, E(!0), P([]), z(0), Q(D).then((e) => {
|
|
97
|
+
G.current = e;
|
|
94
98
|
let t = Object.keys(e).reduce((t, n) => {
|
|
95
|
-
let r =
|
|
99
|
+
let r = m([C], e[n], Number(n) - 1, x).map((e, t) => ({
|
|
96
100
|
...e,
|
|
97
101
|
page: Number(n),
|
|
98
102
|
pageMatchIdx: t
|
|
99
103
|
}));
|
|
100
104
|
return [...t, ...r];
|
|
101
105
|
}, []);
|
|
102
|
-
|
|
106
|
+
P(t), z(+!!t.length);
|
|
103
107
|
}).catch(() => {
|
|
104
|
-
|
|
105
|
-
}).finally(() =>
|
|
108
|
+
P([]), z(0);
|
|
109
|
+
}).finally(() => E(!1));
|
|
106
110
|
}, [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
C,
|
|
112
|
+
Q,
|
|
113
|
+
D,
|
|
114
|
+
x
|
|
111
115
|
]), {
|
|
112
|
-
search:
|
|
113
|
-
setSearch:
|
|
114
|
-
loading:
|
|
115
|
-
matches:
|
|
116
|
-
totalMatches:
|
|
117
|
-
currentMatchPosition:
|
|
118
|
-
currentMatch:
|
|
119
|
-
nextMatch:
|
|
120
|
-
prevMatch:
|
|
121
|
-
setCurrentMatchPosition:
|
|
116
|
+
search: C,
|
|
117
|
+
setSearch: w,
|
|
118
|
+
loading: T,
|
|
119
|
+
matches: N,
|
|
120
|
+
totalMatches: J,
|
|
121
|
+
currentMatchPosition: R,
|
|
122
|
+
currentMatch: q,
|
|
123
|
+
nextMatch: X,
|
|
124
|
+
prevMatch: Z,
|
|
125
|
+
setCurrentMatchPosition: z
|
|
122
126
|
};
|
|
123
127
|
};
|
|
124
128
|
//#endregion
|
|
125
|
-
export {
|
|
129
|
+
export { x as useSearch };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../../useWatermark-
|
|
1
|
+
import { t as e } from "../../useWatermark-DlRNcg9p.js";
|
|
2
2
|
export { e as useWatermark };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
function e() {
|
|
3
3
|
if (typeof document > "u" || document.getElementById("rp-print-style")) return;
|
|
4
4
|
let e = document.createElement("style");
|
|
5
|
-
e.id = "rp-print-style", e.textContent = "\n @page { margin: 0; }\n\n .rp-print-zone { display: none; }\n\n @media print {\n .rp-print-html-printing { height: 100%; }\n .rp-print-body-printing { background: rgb(0 0 0 / 0) none; height: 100% !important; margin: 0 !important; display: block !important; }\n .rp-print-body-printing
|
|
5
|
+
e.id = "rp-print-style", e.textContent = "\n @page { margin: 0; }\n\n .rp-print-zone { display: none; }\n\n @media print {\n .rp-print-html-printing { height: 100%; }\n .rp-print-body-printing { background: rgb(0 0 0 / 0) none; height: 100% !important; margin: 0 !important; display: block !important; }\n .rp-print-body-printing > *:not(.rp-print-zone) { display: none; }\n .rp-print-zone { display: block; height: 100%; }\n .rp-print-page { display: flex; align-items: center; flex-direction: column; justify-content: center; height: 100%; width: 100%; page-break-after: always; page-break-inside: avoid; }\n .rp-print-page:last-child { page-break-after: auto; }\n .rp-print-page-content { position: relative; flex: 0 0 auto; }\n .rp-print-page:not(.rp-print-xfa-page) img, .rp-print-page canvas { display: block; max-width: 100%; max-height: 100%; direction: ltr; }\n .rp-print-page.rp-print-xfa-page { display: block; position: relative; }\n .rp-print-xfa-page .xfaPage { position: absolute; }\n }\n ", document.head.appendChild(e);
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { e as injectPrintCSS };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isPdfDestroyed as e, isPdfDocumentDestroyedError as t, runPdfOperation as n } from "./pdfOperationTracker.js";
|
|
1
2
|
//#region lib/utils/link_service.ts
|
|
2
|
-
var
|
|
3
|
+
var r = class {
|
|
3
4
|
externalLinkEnabled;
|
|
4
5
|
pdfDocument;
|
|
5
6
|
constructor(e, t) {
|
|
@@ -19,26 +20,41 @@ var e = class {
|
|
|
19
20
|
get isInPresentationMode() {
|
|
20
21
|
return !1;
|
|
21
22
|
}
|
|
22
|
-
async goToDestination(
|
|
23
|
-
let
|
|
24
|
-
if (
|
|
25
|
-
|
|
23
|
+
async goToDestination(r) {
|
|
24
|
+
let i, a;
|
|
25
|
+
if (typeof r == "string") {
|
|
26
|
+
let a = this.pdfDocument;
|
|
27
|
+
if (!a || e(a)) return;
|
|
28
|
+
try {
|
|
29
|
+
i = await n(a, () => a.getDestination(r));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (t(e)) return;
|
|
32
|
+
throw e;
|
|
33
|
+
}
|
|
34
|
+
} else i = await r;
|
|
35
|
+
if (!Array.isArray(i)) {
|
|
36
|
+
console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${r}".`);
|
|
26
37
|
return;
|
|
27
38
|
}
|
|
28
|
-
let [
|
|
29
|
-
if (
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
let [o] = i;
|
|
40
|
+
if (o && typeof o == "object") {
|
|
41
|
+
if (a = this.pdfDocument?.cachedPageNumber(o), !a) {
|
|
42
|
+
let i = this.pdfDocument;
|
|
43
|
+
if (!i || e(i)) return;
|
|
44
|
+
try {
|
|
45
|
+
a = (await n(i, () => i.getPageIndex(o)) || 0) + 1;
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (t(e)) return;
|
|
48
|
+
console.error(`goToDestination: "${o}" is not a valid page reference, for dest="${r}".`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
|
-
} else Number.isInteger(
|
|
37
|
-
if (!
|
|
38
|
-
console.error(`goToDestination: "${
|
|
52
|
+
} else Number.isInteger(o) && (a = o + 1);
|
|
53
|
+
if (!a || a < 1 || a > this.pagesCount) {
|
|
54
|
+
console.error(`goToDestination: "${a}" is not a valid page number, for dest="${r}".`);
|
|
39
55
|
return;
|
|
40
56
|
}
|
|
41
|
-
this.goToPage(
|
|
57
|
+
this.goToPage(a);
|
|
42
58
|
}
|
|
43
59
|
goToPage(e) {}
|
|
44
60
|
goToXY(e, t, n, r = {}) {}
|
|
@@ -57,4 +73,4 @@ var e = class {
|
|
|
57
73
|
cachePageRef(e, t) {}
|
|
58
74
|
};
|
|
59
75
|
//#endregion
|
|
60
|
-
export {
|
|
76
|
+
export { r as SimpleLinkService };
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
//#region lib/utils/pdfOperationTracker.ts
|
|
2
|
-
var e = /* @__PURE__ */ new WeakMap()
|
|
3
|
-
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakSet(), n = class extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("PDF document has been destroyed"), this.name = "PdfDocumentDestroyedError";
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
function r(e) {
|
|
8
|
+
return e instanceof n;
|
|
9
|
+
}
|
|
10
|
+
function i(e) {
|
|
11
|
+
t.add(e);
|
|
12
|
+
}
|
|
13
|
+
function a(e) {
|
|
14
|
+
return e ? t.has(e) ? !0 : e.loadingTask?.destroyed === !0 : !1;
|
|
15
|
+
}
|
|
16
|
+
function o(t, n) {
|
|
4
17
|
if (!t) return n;
|
|
5
18
|
let r = e.get(t);
|
|
6
19
|
r || (r = /* @__PURE__ */ new Set(), e.set(t, r));
|
|
@@ -9,9 +22,19 @@ function t(t, n) {
|
|
|
9
22
|
r?.delete(i);
|
|
10
23
|
}), n;
|
|
11
24
|
}
|
|
12
|
-
function
|
|
25
|
+
function s(e, t) {
|
|
26
|
+
if (a(e)) return Promise.reject(new n());
|
|
27
|
+
let r;
|
|
28
|
+
try {
|
|
29
|
+
r = t();
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return Promise.reject(e);
|
|
32
|
+
}
|
|
33
|
+
return o(e, r);
|
|
34
|
+
}
|
|
35
|
+
function c(t) {
|
|
13
36
|
let n = e.get(t);
|
|
14
37
|
return !n || n.size === 0 ? Promise.resolve() : Promise.allSettled(Array.from(n)).then(() => void 0);
|
|
15
38
|
}
|
|
16
39
|
//#endregion
|
|
17
|
-
export {
|
|
40
|
+
export { n as PdfDocumentDestroyedError, a as isPdfDestroyed, r as isPdfDocumentDestroyedError, i as markPdfDestroying, s as runPdfOperation, o as trackPdfOperation, c as waitForPdfOperations };
|
package/package.json
CHANGED
|
@@ -1,114 +0,0 @@
|
|
|
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 };
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { useDocumentContext as e } from "./contexts/RPDocumentContext.js";
|
|
2
|
-
import { isMatchEntireWord as t } from "./utils/highlight.js";
|
|
3
|
-
import { useHighlightContext as n } from "./contexts/HighlightContext.js";
|
|
4
|
-
import { normalizeSingleKeyword as r, sortHighlightPosition as i, unwrap as a } from "./components/page/searchHighlight.js";
|
|
5
|
-
import { useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
6
|
-
import { Fragment as u, jsx as d } from "react/jsx-runtime";
|
|
7
|
-
import './assets/TextHighlightLayer.css';//#region lib/components/page/TextHighlightLayer.module.css
|
|
8
|
-
var f = { "rp-text-highlight": "_rp-text-highlight_jdkf8_1" }, p = ({ pageNumber: p, viewport: m }) => {
|
|
9
|
-
let [h, g] = l(), { pages: _ } = e(), { highlightKeywords: v } = n(), y = c(null), [b, x] = l(null), [S, C] = l([]);
|
|
10
|
-
o(() => {
|
|
11
|
-
y.current && x(y.current.parentElement);
|
|
12
|
-
}, [y]), o(() => {
|
|
13
|
-
(async () => {
|
|
14
|
-
let e = _.get(p);
|
|
15
|
-
!e || !y.current || g(await e.page.getTextContent());
|
|
16
|
-
})();
|
|
17
|
-
}, [_, p]);
|
|
18
|
-
let w = s(() => v ? v.map((e) => ({
|
|
19
|
-
...r(e.keyword, e.options?.matchCase, e.options?.wholeWords),
|
|
20
|
-
color: e.highlightColor
|
|
21
|
-
})) : [], [v]);
|
|
22
|
-
function T(e, t) {
|
|
23
|
-
if (!e) return;
|
|
24
|
-
let n = `[data-rp="page-${t}-textLayer"]`;
|
|
25
|
-
return new Promise((t) => {
|
|
26
|
-
let r = e.querySelector(n);
|
|
27
|
-
if (r) {
|
|
28
|
-
t(r);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
new MutationObserver((r, i) => {
|
|
32
|
-
let a = e.querySelector(n);
|
|
33
|
-
a && (t(a), i.disconnect());
|
|
34
|
-
}).observe(e, {
|
|
35
|
-
childList: !0,
|
|
36
|
-
subtree: !0
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function E(e) {
|
|
41
|
-
return new Promise((t) => {
|
|
42
|
-
let n = e.querySelectorAll("[data-rp=\"rp-text-layer-text\"]");
|
|
43
|
-
if (n.length) {
|
|
44
|
-
t(Array.from(n));
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
new MutationObserver((n, r) => {
|
|
48
|
-
let i = e.querySelectorAll(".rp-text-layer-text");
|
|
49
|
-
i.length && (t(Array.from(i)), r.disconnect());
|
|
50
|
-
}).observe(e, {
|
|
51
|
-
childList: !0,
|
|
52
|
-
subtree: !0
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
let D = (e, t, n, r) => {
|
|
57
|
-
let i = document.createRange(), o = n.firstChild;
|
|
58
|
-
if (!o || o.nodeType !== Node.TEXT_NODE) return null;
|
|
59
|
-
let s = o.textContent?.length ?? 0, c = r[0].charIdxInSpan, l = r.length === 1 ? c : r[r.length - 1].charIdxInSpan;
|
|
60
|
-
if (c > s || l + 1 > s) return null;
|
|
61
|
-
i.setStart(o, c), i.setEnd(o, l + 1);
|
|
62
|
-
let u = document.createElement("span");
|
|
63
|
-
u.style.width = "auto", i.surroundContents(u);
|
|
64
|
-
let d = u.getBoundingClientRect(), f = e.getBoundingClientRect(), p = f.height, m = f.width, h = 100 * (d.left - f.left) / m, g = 100 * (d.top - f.top) / p, _ = 100 * d.height / p, v = 100 * d.width / m;
|
|
65
|
-
return a(u), {
|
|
66
|
-
keywordStr: t,
|
|
67
|
-
left: h,
|
|
68
|
-
top: g,
|
|
69
|
-
height: _,
|
|
70
|
-
width: v,
|
|
71
|
-
pageHeight: p,
|
|
72
|
-
pageWidth: m
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
async function O(e, t) {
|
|
76
|
-
let n = await T(b, e);
|
|
77
|
-
if (!n) return;
|
|
78
|
-
let r = await E(n);
|
|
79
|
-
r.length && C(k(n, t, r, r.map((e) => e.tagName === "BR" ? " " : e.textContent).reduce((e, t, n) => e.concat(t.split("").map((e, t) => ({
|
|
80
|
-
char: e,
|
|
81
|
-
charIdxInSpan: t,
|
|
82
|
-
spanIdx: n
|
|
83
|
-
}))), [{
|
|
84
|
-
char: "",
|
|
85
|
-
charIdxInSpan: 0,
|
|
86
|
-
spanIdx: 0
|
|
87
|
-
}]).slice(1)));
|
|
88
|
-
}
|
|
89
|
-
let k = (e, n, r, a) => {
|
|
90
|
-
let o = n.length;
|
|
91
|
-
if (!a.length || !o) return [];
|
|
92
|
-
let s = [], c = a.map((e) => e.char).join("");
|
|
93
|
-
return w.forEach((n) => {
|
|
94
|
-
let { keyword: i, regExp: o, wholeWords: l, color: u } = n, d = i;
|
|
95
|
-
if (!d.trim()) return;
|
|
96
|
-
let f = o.flags.indexOf("g") === -1 ? new RegExp(o, `${o.flags}g`) : o, p, m = [];
|
|
97
|
-
for (; (p = f.exec(c)) !== null;) l && !t(c, p.index, p[0].length) || m.push({
|
|
98
|
-
keyword: f,
|
|
99
|
-
startIndex: p.index,
|
|
100
|
-
endIndex: f.lastIndex
|
|
101
|
-
});
|
|
102
|
-
let h = m.map((e) => ({
|
|
103
|
-
keyword: e.keyword,
|
|
104
|
-
indexes: a.slice(e.startIndex, e.endIndex),
|
|
105
|
-
color: u
|
|
106
|
-
}));
|
|
107
|
-
for (let t of h) {
|
|
108
|
-
let n = t.indexes.reduce((e, t) => (e[t.spanIdx] = (e[t.spanIdx] || []).concat([t]), e), {});
|
|
109
|
-
for (let i of Object.values(n)) if (i.length !== 1 || i[0].char.trim() !== "") {
|
|
110
|
-
let n = i, a = r[n[0].spanIdx], o = D(e, d, a, n);
|
|
111
|
-
if (o) {
|
|
112
|
-
let { left: e, top: n } = o;
|
|
113
|
-
if (s.find((t) => t.left === e && t.top === n)) continue;
|
|
114
|
-
s.push({
|
|
115
|
-
...o,
|
|
116
|
-
highlightColor: t.color
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}), s.sort(i), s;
|
|
122
|
-
};
|
|
123
|
-
return o(() => {
|
|
124
|
-
(async () => {
|
|
125
|
-
if (!v || v.length === 0) {
|
|
126
|
-
C([]);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
await O(p, v);
|
|
131
|
-
} catch (e) {
|
|
132
|
-
console.error(e);
|
|
133
|
-
}
|
|
134
|
-
})();
|
|
135
|
-
}, [
|
|
136
|
-
!0,
|
|
137
|
-
v,
|
|
138
|
-
p,
|
|
139
|
-
h,
|
|
140
|
-
m
|
|
141
|
-
]), /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d("div", {
|
|
142
|
-
ref: y,
|
|
143
|
-
"data-rp": `page-${p}-textHighlightLayer`,
|
|
144
|
-
children: S.map((e, t) => /* @__PURE__ */ d("div", {
|
|
145
|
-
className: f["rp-text-highlight"],
|
|
146
|
-
style: {
|
|
147
|
-
top: `${e.top}%`,
|
|
148
|
-
left: `${e.left}%`,
|
|
149
|
-
width: `${e.width}%`,
|
|
150
|
-
height: `${e.height}%`,
|
|
151
|
-
backgroundColor: e.highlightColor
|
|
152
|
-
}
|
|
153
|
-
}, t))
|
|
154
|
-
}) });
|
|
155
|
-
};
|
|
156
|
-
//#endregion
|
|
157
|
-
export { p as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|