@react-pdf-kit/viewer 0.0.0-experimental.1 → 0.0.0-experimental.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/README.md +84 -49
- package/dist/{Combination-54a77a7a.js → Combination-17ab8af1.js} +184 -187
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +8 -8
- package/dist/components/RPConfig.js +5 -7
- package/dist/components/RPController.js +76 -77
- package/dist/components/RPDropFileZone.js +4 -3
- package/dist/components/RPPages.js +577 -573
- package/dist/components/RPProvider.js +2 -2
- package/dist/components/layout/RPDefaultLayout.js +10 -9
- package/dist/components/layout/RPLayout.js +10 -9
- package/dist/components/layout/WrapperLayout.js +4 -3
- package/dist/components/layout/sidebar/RPSidebar.js +8 -7
- package/dist/components/layout/sidebar/Thumbnail.js +4 -3
- package/dist/components/layout/sidebar/Thumbnails.js +4 -3
- package/dist/components/layout/toolbar/DarkModeTool.js +4 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +43 -34
- package/dist/components/layout/toolbar/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/FileUploadTool.js +10 -9
- package/dist/components/layout/toolbar/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/MenuItem.js +6 -6
- package/dist/components/layout/toolbar/MenuSeparator.js +6 -6
- package/dist/components/layout/toolbar/MostPageTool.js +10 -9
- package/dist/components/layout/toolbar/OtherTool.js +10 -9
- package/dist/components/layout/toolbar/Paginate.js +8 -7
- package/dist/components/layout/toolbar/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/RPMenuItem.js +6 -6
- package/dist/components/layout/toolbar/RPMoreOptions.js +10 -9
- package/dist/components/layout/toolbar/RPToolbar.js +10 -9
- package/dist/components/layout/toolbar/RPToolbarEnd.js +10 -9
- package/dist/components/layout/toolbar/RotateTool.js +10 -9
- package/dist/components/layout/toolbar/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/SearchCloseButton.js +4 -4
- package/dist/components/layout/toolbar/SearchResultNavigator.js +23 -30
- package/dist/components/layout/toolbar/SearchTool.js +104 -100
- package/dist/components/layout/toolbar/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/ThumbnailTool.js +8 -7
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
- package/dist/components/layout/toolbar/ToolbarDefault.js +10 -9
- package/dist/components/layout/toolbar/ToolbarLayout.js +10 -9
- package/dist/components/layout/toolbar/ViewModeTool.js +6 -6
- package/dist/components/layout/toolbar/ZoomTool.js +10 -9
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +9 -8
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +10 -11
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +8 -7
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +10 -11
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +4 -4
- package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/InputPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/LastPageTool.js +10 -11
- package/dist/components/layout/toolbar/tools/NextPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PageScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +8 -7
- package/dist/components/layout/toolbar/tools/PrintTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +8 -7
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +8 -7
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +8 -7
- package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +4 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +8 -7
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +20 -19
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +8 -7
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +10 -9
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +8 -7
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +10 -9
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +6 -6
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +6 -6
- package/dist/components/page/AnnotationLayer.js +25 -24
- package/dist/components/page/CanvasLayer.js +38 -54
- package/dist/components/page/CustomElement.js +4 -3
- package/dist/components/page/DualPage.js +2 -2
- package/dist/components/page/DualPageWithCover.js +2 -2
- package/dist/components/page/RPPage.js +35 -35
- package/dist/components/page/SinglePage.js +2 -2
- package/dist/components/page/TextHighlightLayer.js +16 -15
- package/dist/components/page/TextLayer.js +27 -28
- package/dist/components/ui/Checkbox.js +2 -2
- package/dist/components/ui/DropDown.js +6 -6
- package/dist/components/ui/Input.js +10 -10
- package/dist/components/ui/LoadingIndicator.js +8 -7
- package/dist/components/ui/RPTooltip.js +197 -411
- package/dist/contexts/DimensionPagesContext.js +28 -56
- package/dist/contexts/DropFileZoneContext.js +5 -4
- package/dist/contexts/ElementPageContext.js +6 -5
- package/dist/contexts/FileInputContext.js +6 -5
- package/dist/contexts/HighlightContext.js +6 -5
- package/dist/contexts/InitialStateContext.js +6 -8
- package/dist/contexts/PagesRotateContext.js +6 -5
- package/dist/contexts/PaginationContext.js +6 -5
- package/dist/contexts/PrintContext.js +17 -16
- package/dist/contexts/RPDocumentContext.js +14 -13
- package/dist/contexts/RenderQueueProvider.js +14 -13
- package/dist/contexts/RotationContext.js +9 -8
- package/dist/contexts/SearchContext.js +6 -5
- package/dist/contexts/ThumbnailsContext.js +5 -4
- package/dist/contexts/ZoomContext.js +6 -5
- package/dist/{index-c0faa594.js → index-113053cf.js} +2 -2
- package/dist/index-11f3cd64.js +983 -0
- package/dist/{index-e3ee9457.js → index-23911b43.js} +6 -6
- package/dist/{index-655864a7.js → index-ada501c4.js} +1 -1
- package/dist/index-d0f0aa9a.js +1542 -0
- package/dist/main.js +47 -47
- package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
- package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
- package/dist/types/contexts/RenderQueueProvider.d.ts +1 -2
- package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
- package/dist/types/main.d.ts +3 -1
- package/dist/types/utils/annotations.d.ts +2 -2
- package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
- package/dist/types/utils/highlight.d.ts +5 -5
- package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
- package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
- package/dist/types/utils/hooks/useLoadWorker.d.ts +5 -1
- package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
- package/dist/types/utils/hooks/useWatermark.d.ts +1 -1
- package/dist/types/utils/link_service.d.ts +2 -3
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +7 -8
- package/dist/utils/highlight.js +36 -36
- package/dist/utils/hooks/useFileDownload.js +6 -5
- package/dist/utils/hooks/useHighlight.js +78 -40
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +96 -70
- package/dist/utils/hooks/useLoadWorker.js +4 -14
- package/dist/utils/hooks/usePageRotateContext.js +8 -7
- package/dist/utils/hooks/usePaginate.js +4 -3
- package/dist/utils/hooks/usePinch.js +44 -90
- package/dist/utils/hooks/usePresentPage.js +4 -3
- package/dist/utils/hooks/usePrint.js +71 -72
- package/dist/utils/hooks/useRotate.js +4 -3
- package/dist/utils/hooks/useScrollToPage.js +4 -3
- package/dist/utils/hooks/useSearch.js +16 -15
- package/dist/utils/hooks/useThumbnail.js +18 -17
- package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
- package/dist/utils/hooks/useWatermark.js +43 -61
- package/dist/utils/injectPrintCSS.js +4 -3
- package/dist/utils/link_service.js +18 -19
- package/dist/utils/renderPage.js +14 -14
- package/package.json +2 -3
- package/dist/contexts/SmoothScaleContext.js +0 -67
- package/dist/floating-ui.react-dom-5ec29bd6.js +0 -1327
- package/dist/index-4baea9b5.js +0 -1198
- package/dist/types/contexts/SmoothScaleContext.d.ts +0 -16
- package/dist/types/utils/hooks/useAccumulateFactor.d.ts +0 -9
- package/dist/utils/hooks/useAccumulateFactor.js +0 -17
|
@@ -6,7 +6,8 @@ import { ORGANIZATION_ALLOWED_FEATURES_MESSAGE as R } from "../const.js";
|
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
7
|
import "../../contexts/RPDocumentContext.js";
|
|
8
8
|
import "./useLoadPdf.js";
|
|
9
|
-
import "
|
|
9
|
+
import "@pdf-viewer/pdfium";
|
|
10
|
+
import "@pdf-viewer/pdfium/compat";
|
|
10
11
|
import "../getThumbnailViewport.js";
|
|
11
12
|
import "../../contexts/ConfigContext.js";
|
|
12
13
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -19,8 +20,8 @@ import "../../contexts/RotationContext.js";
|
|
|
19
20
|
import "../../contexts/InitialStateContext.js";
|
|
20
21
|
import "../../contexts/EventCallbackContext.js";
|
|
21
22
|
import "./useLicense.js";
|
|
22
|
-
const
|
|
23
|
-
const { setSinglePageRotate: r } = c(), { type: i, validating:
|
|
23
|
+
const W = () => {
|
|
24
|
+
const { setSinglePageRotate: r } = c(), { type: i, validating: m } = u(), n = a(() => i !== f.Developer, [i]), p = l(
|
|
24
25
|
(s, t) => {
|
|
25
26
|
r((o) => {
|
|
26
27
|
const e = typeof t == "function" ? t(o[s] || 0) : t;
|
|
@@ -32,11 +33,11 @@ const U = () => {
|
|
|
32
33
|
},
|
|
33
34
|
[r]
|
|
34
35
|
);
|
|
35
|
-
return { rotate: a(() =>
|
|
36
|
-
} :
|
|
36
|
+
return { rotate: a(() => m !== !1 ? () => {
|
|
37
|
+
} : n ? p : () => {
|
|
37
38
|
console.error(R);
|
|
38
|
-
}, [
|
|
39
|
+
}, [m, n, p]) };
|
|
39
40
|
};
|
|
40
41
|
export {
|
|
41
|
-
|
|
42
|
+
W as usePageRotateContext
|
|
42
43
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "../types.js";
|
|
3
|
-
import { b as
|
|
3
|
+
import { b as J } from "../../PaginationContext-9217cab4.js";
|
|
4
4
|
import "../../contexts/ViewModeContext.js";
|
|
5
5
|
import "../../contexts/ScrollModeContext.js";
|
|
6
6
|
import "./useDebounce.js";
|
|
@@ -10,7 +10,8 @@ import "../../de_DE-a553b162.js";
|
|
|
10
10
|
import "react/jsx-runtime";
|
|
11
11
|
import "../../contexts/RPDocumentContext.js";
|
|
12
12
|
import "./useLoadPdf.js";
|
|
13
|
-
import "
|
|
13
|
+
import "@pdf-viewer/pdfium";
|
|
14
|
+
import "@pdf-viewer/pdfium/compat";
|
|
14
15
|
import "../getThumbnailViewport.js";
|
|
15
16
|
import "../../contexts/ConfigContext.js";
|
|
16
17
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -33,5 +34,5 @@ import "../getZoomLevel.js";
|
|
|
33
34
|
import "../../contexts/RotationContext.js";
|
|
34
35
|
import "../../contexts/PagesRotateContext.js";
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
J as usePaginate
|
|
37
38
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useAccumulateFactor as D } from "./useAccumulateFactor.js";
|
|
1
|
+
import { useState as E, useRef as T, useCallback as c, useEffect as i } from "react";
|
|
2
|
+
import { useDebounce as g } from "./useDebounce.js";
|
|
3
|
+
import { useZoomContext as A } from "../../contexts/ZoomContext.js";
|
|
5
4
|
import "react/jsx-runtime";
|
|
6
5
|
import "../types.js";
|
|
7
6
|
import "../../de_DE-a553b162.js";
|
|
@@ -9,7 +8,8 @@ import "../appConsole.js";
|
|
|
9
8
|
import "../../contexts/InitialStateContext.js";
|
|
10
9
|
import "../../contexts/RPDocumentContext.js";
|
|
11
10
|
import "./useLoadPdf.js";
|
|
12
|
-
import "
|
|
11
|
+
import "@pdf-viewer/pdfium";
|
|
12
|
+
import "@pdf-viewer/pdfium/compat";
|
|
13
13
|
import "../getThumbnailViewport.js";
|
|
14
14
|
import "../../contexts/ConfigContext.js";
|
|
15
15
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -23,93 +23,47 @@ import "../../contexts/ViewModeContext.js";
|
|
|
23
23
|
import "../../contexts/RotationContext.js";
|
|
24
24
|
import "../../contexts/GlobalCurrentPage.js";
|
|
25
25
|
import "../../contexts/EventCallbackContext.js";
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
a.current = v;
|
|
31
|
-
}, [v]);
|
|
32
|
-
const p = u(
|
|
33
|
-
(e) => {
|
|
34
|
-
const t = a.current, o = Math.max(z, Math.min(B, t * e)), r = Math.round(o * 100);
|
|
35
|
-
d(r);
|
|
36
|
-
},
|
|
37
|
-
[d]
|
|
38
|
-
), S = u(
|
|
39
|
-
(e) => {
|
|
40
|
-
const t = a.current, o = e ? 3 : -3, r = Math.round(t * 100 + o);
|
|
41
|
-
d(Math.max(25, Math.min(1e3, r)));
|
|
42
|
-
},
|
|
43
|
-
[d]
|
|
44
|
-
);
|
|
45
|
-
i(() => {
|
|
46
|
-
const e = (o) => {
|
|
47
|
-
o.key === "Control" && (E.current = !0);
|
|
48
|
-
}, t = (o) => {
|
|
49
|
-
o.key === "Control" && (E.current = !1);
|
|
50
|
-
};
|
|
51
|
-
return window.addEventListener("keydown", e), window.addEventListener("keyup", t), () => {
|
|
52
|
-
window.removeEventListener("keydown", e), window.removeEventListener("keyup", t);
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
const w = u(
|
|
26
|
+
const _ = (o) => {
|
|
27
|
+
const { currentZoom: L, setZoomLevel: w } = A(), [D, m] = E(0), d = g(D, 100), [s, b] = E(!1), r = T(null), u = c((e) => {
|
|
28
|
+
m(e ? (t) => t + 3 : (t) => t - 3);
|
|
29
|
+
}, []), a = c(
|
|
56
30
|
(e) => {
|
|
57
|
-
if (!e.ctrlKey
|
|
31
|
+
if (!e.ctrlKey)
|
|
58
32
|
return;
|
|
59
33
|
e.preventDefault();
|
|
60
|
-
const t =
|
|
61
|
-
|
|
62
|
-
const o = Math.exp(-e.deltaY / 100);
|
|
63
|
-
if (e.ctrlKey && !E.current && e.deltaMode === WheelEvent.DOM_DELTA_PIXEL && e.deltaX === 0 && Math.abs(o - 1) < 0.05) {
|
|
64
|
-
const c = C(a.current, o);
|
|
65
|
-
c !== 1 && c !== 0 && p(c);
|
|
66
|
-
} else {
|
|
67
|
-
const c = e.deltaY < 0;
|
|
68
|
-
S(c);
|
|
69
|
-
}
|
|
34
|
+
const t = e.deltaY < 0;
|
|
35
|
+
u(t);
|
|
70
36
|
},
|
|
71
|
-
[
|
|
72
|
-
)
|
|
37
|
+
[u]
|
|
38
|
+
);
|
|
39
|
+
i(() => {
|
|
40
|
+
if (d) {
|
|
41
|
+
const e = Math.round(L * 100 + d);
|
|
42
|
+
m(0), w(e > 25 ? e : 25);
|
|
43
|
+
}
|
|
44
|
+
}, [d]);
|
|
45
|
+
const v = (e, t) => {
|
|
46
|
+
const n = e.clientX - t.clientX, l = e.clientY - t.clientY;
|
|
47
|
+
return Math.sqrt(n * n + l * l);
|
|
48
|
+
}, f = c(
|
|
73
49
|
(e) => {
|
|
74
50
|
if (!s || e.touches.length !== 2)
|
|
75
51
|
return;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
touch0X: t.screenX,
|
|
79
|
-
touch0Y: t.screenY,
|
|
80
|
-
touch1X: o.screenX,
|
|
81
|
-
touch1Y: o.screenY
|
|
82
|
-
}, m.current = !1, e.preventDefault();
|
|
52
|
+
const t = v(e.touches[0], e.touches[1]);
|
|
53
|
+
r.current = t, e.preventDefault();
|
|
83
54
|
},
|
|
84
55
|
[s]
|
|
85
|
-
),
|
|
86
|
-
|
|
87
|
-
}, [
|
|
56
|
+
), h = c(() => {
|
|
57
|
+
r.current = null;
|
|
58
|
+
}, []), p = c(
|
|
88
59
|
(e) => {
|
|
89
|
-
if (!s || e.touches.length !== 2 ||
|
|
90
|
-
return;
|
|
91
|
-
let [t, o] = Array.from(e.touches);
|
|
92
|
-
t.identifier > o.identifier && ([t, o] = [o, t]);
|
|
93
|
-
const r = l.current, c = r.touch1X - r.touch0X, I = r.touch1Y - r.touch0Y, T = Math.hypot(c, I) || 1, F = o.screenX - t.screenX, P = o.screenY - t.screenY, x = Math.hypot(F, P) || 1, R = O / (window.devicePixelRatio || 1);
|
|
94
|
-
if (!m.current && Math.abs(T - x) <= R)
|
|
95
|
-
return;
|
|
96
|
-
if (l.current = {
|
|
97
|
-
touch0X: t.screenX,
|
|
98
|
-
touch0Y: t.screenY,
|
|
99
|
-
touch1X: o.screenX,
|
|
100
|
-
touch1Y: o.screenY
|
|
101
|
-
}, !m.current) {
|
|
102
|
-
m.current = !0;
|
|
60
|
+
if (!s || e.touches.length !== 2 || r.current === null)
|
|
103
61
|
return;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const _ = (t.clientX + o.clientX) / 2, b = (t.clientY + o.clientY) / 2;
|
|
107
|
-
h.current = { x: _, y: b };
|
|
108
|
-
const K = x / T, Y = M(a.current, K);
|
|
109
|
-
Y !== 1 && Y !== 0 && p(Y);
|
|
62
|
+
const t = v(e.touches[0], e.touches[1]), n = t - r.current, l = Math.abs(n) > 5, S = n > 0;
|
|
63
|
+
l && (u(S), r.current = t, e.preventDefault());
|
|
110
64
|
},
|
|
111
|
-
[
|
|
112
|
-
),
|
|
65
|
+
[u, s]
|
|
66
|
+
), y = () => {
|
|
113
67
|
document.activeElement instanceof HTMLElement && document.activeElement.blur();
|
|
114
68
|
};
|
|
115
69
|
i(() => {
|
|
@@ -120,28 +74,28 @@ const O = 35, z = 0.25, B = 10, Ee = (n) => {
|
|
|
120
74
|
document.body.style.touchAction = "";
|
|
121
75
|
}, [s]), i(() => {
|
|
122
76
|
const e = () => {
|
|
123
|
-
const t = document.activeElement,
|
|
124
|
-
|
|
77
|
+
const t = document.activeElement, n = !!(t != null && t.closest('[data-rp="container"]'));
|
|
78
|
+
b(n);
|
|
125
79
|
};
|
|
126
80
|
return window.addEventListener("focusin", e), window.addEventListener("focusout", e), e(), () => {
|
|
127
81
|
window.removeEventListener("focusin", e), window.removeEventListener("focusout", e);
|
|
128
82
|
};
|
|
129
83
|
}, []), i(() => {
|
|
130
|
-
if (!
|
|
84
|
+
if (!o)
|
|
131
85
|
return;
|
|
132
86
|
const e = (t) => {
|
|
133
|
-
|
|
87
|
+
o.contains(t.target) || y();
|
|
134
88
|
};
|
|
135
89
|
return document.addEventListener("scroll", e), () => {
|
|
136
90
|
document.removeEventListener("scroll", e);
|
|
137
91
|
};
|
|
138
|
-
}, [
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
141
|
-
|
|
92
|
+
}, [o]), i(() => {
|
|
93
|
+
if (o)
|
|
94
|
+
return o.addEventListener("wheel", a, { passive: !1 }), o.addEventListener("touchstart", f, { passive: !1 }), o.addEventListener("touchmove", p, { passive: !1 }), o.addEventListener("touchend", h, { passive: !1 }), () => {
|
|
95
|
+
o.removeEventListener("wheel", a), o.removeEventListener("touchstart", f), o.removeEventListener("touchmove", p), o.removeEventListener("touchend", h);
|
|
142
96
|
};
|
|
143
|
-
}, [
|
|
97
|
+
}, [o, a, f, p, h]);
|
|
144
98
|
};
|
|
145
99
|
export {
|
|
146
|
-
|
|
100
|
+
_ as usePinch
|
|
147
101
|
};
|
|
@@ -10,7 +10,8 @@ import "react/jsx-runtime";
|
|
|
10
10
|
import "../appConsole.js";
|
|
11
11
|
import "../../contexts/RPDocumentContext.js";
|
|
12
12
|
import "./useLoadPdf.js";
|
|
13
|
-
import "
|
|
13
|
+
import "@pdf-viewer/pdfium";
|
|
14
|
+
import "@pdf-viewer/pdfium/compat";
|
|
14
15
|
import "../getThumbnailViewport.js";
|
|
15
16
|
import "../../contexts/ConfigContext.js";
|
|
16
17
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -32,7 +33,7 @@ import "../../contexts/VirtualScrollContext.js";
|
|
|
32
33
|
import "../../contexts/VirtualGridContext.js";
|
|
33
34
|
import "../smoothScrollTo.js";
|
|
34
35
|
import "../getScrollDistance.js";
|
|
35
|
-
const
|
|
36
|
+
const bt = (f, Y, n, W) => {
|
|
36
37
|
const P = x(), { contentRef: E } = N(), { heights: h, widths: l } = v(), { setFocusedPage: b } = _(), [S, R] = C([]), { targetScrollPage: L } = G(), i = q(S, 0, 500), I = D(() => {
|
|
37
38
|
const c = W === M.DUAL_PAGE_WITH_COVER, { rowsHeight: r, columnsWidth: o } = A({ heights: h, widths: l }, f, c);
|
|
38
39
|
return h.map((m, t) => {
|
|
@@ -86,5 +87,5 @@ const Wt = (f, Y, n, W) => {
|
|
|
86
87
|
}, [n, g]);
|
|
87
88
|
};
|
|
88
89
|
export {
|
|
89
|
-
|
|
90
|
+
bt as usePresentPage
|
|
90
91
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useState as g, useRef as k, useEffect as
|
|
1
|
+
import { useState as g, useRef as k, useEffect as x, useCallback as P } from "react";
|
|
2
2
|
import { useDocumentContext as q } from "../../contexts/RPDocumentContext.js";
|
|
3
|
-
import { PixelsPerInch as
|
|
3
|
+
import { PixelsPerInch as V, AnnotationMode as O } from "@pdf-viewer/pdfium/compat";
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "./useLoadPdf.js";
|
|
6
|
+
import "@pdf-viewer/pdfium";
|
|
6
7
|
import "../types.js";
|
|
7
8
|
import "../../de_DE-a553b162.js";
|
|
8
9
|
import "../getThumbnailViewport.js";
|
|
@@ -12,21 +13,19 @@ import "../appConsole.js";
|
|
|
12
13
|
import "./usePdfProperties.js";
|
|
13
14
|
import "../convertPdfDate.js";
|
|
14
15
|
import "../formatFileSize.js";
|
|
15
|
-
const
|
|
16
|
-
const { pdf: l, pages: f } = q(), [
|
|
16
|
+
const ne = () => {
|
|
17
|
+
const { pdf: l, pages: f } = q(), [T, E] = g({
|
|
17
18
|
loadedPages: 0,
|
|
18
19
|
totalPages: 0,
|
|
19
20
|
percentage: 0
|
|
20
|
-
}), [
|
|
21
|
-
|
|
21
|
+
}), [A, y] = g(!1), [R, b] = g(!1), [M, S] = g(null), [Z, w] = g(void 0), i = k(!1);
|
|
22
|
+
x(() => {
|
|
22
23
|
i.current;
|
|
23
24
|
}, [i]);
|
|
24
|
-
const
|
|
25
|
-
document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
|
|
26
|
-
const e = document.querySelector(".rp-print-zone");
|
|
27
|
-
e && e.remove();
|
|
25
|
+
const C = P(() => {
|
|
26
|
+
document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing"), document.querySelector(".rp-print-zone");
|
|
28
27
|
}, []), s = P(() => {
|
|
29
|
-
i.current = !1, y(!1), b(!1),
|
|
28
|
+
i.current = !1, y(!1), b(!1), S(null), w(void 0), E({
|
|
30
29
|
loadedPages: 0,
|
|
31
30
|
totalPages: 0,
|
|
32
31
|
percentage: 0
|
|
@@ -35,24 +34,24 @@ const re = () => {
|
|
|
35
34
|
i.current = !0;
|
|
36
35
|
}, I = async ({
|
|
37
36
|
scratchCanvas: e,
|
|
38
|
-
pdfDocument:
|
|
37
|
+
pdfDocument: r,
|
|
39
38
|
pageNumber: t,
|
|
40
|
-
viewerPdfPage:
|
|
41
|
-
printResolution:
|
|
42
|
-
optionalContentConfigPromise:
|
|
43
|
-
printAnnotationStoragePromise:
|
|
39
|
+
viewerPdfPage: n,
|
|
40
|
+
printResolution: o,
|
|
41
|
+
optionalContentConfigPromise: c,
|
|
42
|
+
printAnnotationStoragePromise: d
|
|
44
43
|
}) => {
|
|
45
44
|
if (i.current) {
|
|
46
45
|
s();
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
|
-
const
|
|
50
|
-
e.width = Math.floor(
|
|
48
|
+
const a = o / V.PDF;
|
|
49
|
+
e.width = Math.floor(n.width * a), e.height = Math.floor(n.height * a);
|
|
51
50
|
const p = e.getContext("2d");
|
|
52
51
|
p.save(), p.fillStyle = "rgb(255, 255, 255)", p.fillRect(0, 0, e.width, e.height), p.restore();
|
|
53
|
-
const [
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const [u, h] = await Promise.all([
|
|
53
|
+
r.getPage(t),
|
|
54
|
+
d
|
|
56
55
|
]);
|
|
57
56
|
if (i.current) {
|
|
58
57
|
s();
|
|
@@ -61,84 +60,84 @@ const re = () => {
|
|
|
61
60
|
const v = {
|
|
62
61
|
canvas: e,
|
|
63
62
|
canvasContext: p,
|
|
64
|
-
transform: [
|
|
65
|
-
viewport:
|
|
63
|
+
transform: [a, 0, 0, a, 0, 0],
|
|
64
|
+
viewport: u.getViewport({ scale: 1, rotation: n.rotation }),
|
|
66
65
|
intent: "print",
|
|
67
|
-
annotationMode:
|
|
68
|
-
optionalContentConfigPromise:
|
|
69
|
-
printAnnotationStorage:
|
|
66
|
+
annotationMode: O.ENABLE_STORAGE,
|
|
67
|
+
optionalContentConfigPromise: c,
|
|
68
|
+
printAnnotationStorage: h
|
|
70
69
|
};
|
|
71
70
|
try {
|
|
72
|
-
return
|
|
73
|
-
} catch (
|
|
74
|
-
throw
|
|
71
|
+
return u.render(v).promise;
|
|
72
|
+
} catch (m) {
|
|
73
|
+
throw console.error(m), m;
|
|
75
74
|
}
|
|
76
75
|
}, L = P(() => {
|
|
77
76
|
const e = window.print;
|
|
78
|
-
return new Promise((
|
|
79
|
-
const t = (
|
|
77
|
+
return new Promise((r) => {
|
|
78
|
+
const t = (c) => {
|
|
80
79
|
setTimeout(() => {
|
|
81
|
-
e.call(window), setTimeout(() =>
|
|
80
|
+
e.call(window), setTimeout(() => c(), 20);
|
|
82
81
|
}, 0);
|
|
83
82
|
};
|
|
84
83
|
if (document.querySelector(".rp-print-zone")) {
|
|
85
|
-
t(
|
|
84
|
+
t(r);
|
|
86
85
|
return;
|
|
87
86
|
}
|
|
88
|
-
const
|
|
89
|
-
document.querySelector(".rp-print-zone") && (t(
|
|
87
|
+
const o = new MutationObserver(() => {
|
|
88
|
+
document.querySelector(".rp-print-zone") && (t(r), o.disconnect());
|
|
90
89
|
});
|
|
91
|
-
|
|
90
|
+
o.observe(document.body, { childList: !0, subtree: !0 });
|
|
92
91
|
});
|
|
93
92
|
}, []), z = (e) => {
|
|
94
|
-
const
|
|
95
|
-
return t.classList.add("rp-print-page"),
|
|
96
|
-
},
|
|
93
|
+
const r = document.createElement("img"), t = document.createElement("div");
|
|
94
|
+
return t.classList.add("rp-print-page"), r.src = e.toDataURL(), t.appendChild(r), t;
|
|
95
|
+
}, D = (e, r) => {
|
|
97
96
|
const t = document.createElement("div");
|
|
98
97
|
t.classList.add("rp-print-zone");
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
|
|
98
|
+
const n = document.createElement("style"), o = r.get(1);
|
|
99
|
+
if (o) {
|
|
100
|
+
const c = o.page.getViewport({ scale: 1 }), { width: d, height: a } = c;
|
|
101
|
+
n.innerHTML = `@page { size: ${d}pt ${a}pt; margin: 0; }`;
|
|
103
102
|
}
|
|
104
|
-
return t.appendChild(
|
|
103
|
+
return t.appendChild(n), t.append(...e), t;
|
|
105
104
|
}, N = P(
|
|
106
105
|
async (e) => {
|
|
107
106
|
if (!l)
|
|
108
107
|
return;
|
|
109
108
|
s();
|
|
110
|
-
const
|
|
111
|
-
(
|
|
112
|
-
const t = document.createElement("canvas"),
|
|
109
|
+
const r = e && "visibleDefaultProgress" in e ? e : void 0;
|
|
110
|
+
(r == null ? void 0 : r.visibleDefaultProgress) !== void 0 ? w(r.visibleDefaultProgress) : w(!0);
|
|
111
|
+
const t = document.createElement("canvas"), n = [];
|
|
113
112
|
try {
|
|
114
113
|
l.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
|
|
115
|
-
const
|
|
114
|
+
const c = l.getOptionalContentConfig({ intent: "print" }), d = Promise.resolve(
|
|
116
115
|
l.annotationStorage.print ?? void 0
|
|
117
|
-
),
|
|
118
|
-
for (const [
|
|
116
|
+
), a = f.size;
|
|
117
|
+
for (const [u, h] of f) {
|
|
119
118
|
if (i.current) {
|
|
120
119
|
s();
|
|
121
120
|
return;
|
|
122
121
|
}
|
|
123
|
-
const v =
|
|
122
|
+
const v = h.page.getViewport({ scale: 1 });
|
|
124
123
|
if (await I({
|
|
125
124
|
scratchCanvas: t,
|
|
126
125
|
pdfDocument: l,
|
|
127
|
-
pageNumber:
|
|
126
|
+
pageNumber: u,
|
|
128
127
|
viewerPdfPage: v,
|
|
129
128
|
printResolution: 150,
|
|
130
|
-
optionalContentConfigPromise:
|
|
131
|
-
printAnnotationStoragePromise:
|
|
129
|
+
optionalContentConfigPromise: c,
|
|
130
|
+
printAnnotationStoragePromise: d
|
|
132
131
|
}), i.current) {
|
|
133
132
|
s();
|
|
134
133
|
return;
|
|
135
134
|
}
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
const X = parseFloat((
|
|
135
|
+
const m = z(t);
|
|
136
|
+
n.push(m);
|
|
137
|
+
const X = parseFloat((n.length / a * 100).toFixed(2));
|
|
139
138
|
E({
|
|
140
|
-
loadedPages:
|
|
141
|
-
totalPages:
|
|
139
|
+
loadedPages: u,
|
|
140
|
+
totalPages: a,
|
|
142
141
|
percentage: X
|
|
143
142
|
});
|
|
144
143
|
}
|
|
@@ -146,33 +145,33 @@ const re = () => {
|
|
|
146
145
|
s();
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
149
|
-
const p =
|
|
148
|
+
const p = D(n, f);
|
|
150
149
|
document.body.appendChild(p), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), y(!0), await L();
|
|
151
|
-
} catch (
|
|
152
|
-
b(!0),
|
|
150
|
+
} catch (o) {
|
|
151
|
+
b(!0), o instanceof Error && S(o);
|
|
153
152
|
} finally {
|
|
154
153
|
t.height = 0, t.width = 0;
|
|
155
154
|
}
|
|
156
155
|
},
|
|
157
|
-
[l, f, i, s,
|
|
156
|
+
[l, f, i, s, D, L]
|
|
158
157
|
);
|
|
159
|
-
return
|
|
158
|
+
return x(() => {
|
|
160
159
|
const e = () => {
|
|
161
|
-
s(),
|
|
160
|
+
s(), C();
|
|
162
161
|
};
|
|
163
162
|
return window.addEventListener("afterprint", e, !0), () => {
|
|
164
163
|
window.removeEventListener("afterprint", e, !0);
|
|
165
164
|
};
|
|
166
|
-
}, [
|
|
165
|
+
}, [C, s]), {
|
|
167
166
|
print: N,
|
|
168
167
|
cancel: F,
|
|
169
|
-
progress:
|
|
170
|
-
isComplete:
|
|
171
|
-
isError:
|
|
172
|
-
error:
|
|
173
|
-
showDefaultProgress:
|
|
168
|
+
progress: T,
|
|
169
|
+
isComplete: A,
|
|
170
|
+
isError: R,
|
|
171
|
+
error: M,
|
|
172
|
+
showDefaultProgress: Z
|
|
174
173
|
};
|
|
175
174
|
};
|
|
176
175
|
export {
|
|
177
|
-
|
|
176
|
+
ne as usePrint
|
|
178
177
|
};
|
|
@@ -5,7 +5,8 @@ import "../appConsole.js";
|
|
|
5
5
|
import "../../contexts/InitialStateContext.js";
|
|
6
6
|
import "../../contexts/RPDocumentContext.js";
|
|
7
7
|
import "./useLoadPdf.js";
|
|
8
|
-
import "
|
|
8
|
+
import "@pdf-viewer/pdfium";
|
|
9
|
+
import "@pdf-viewer/pdfium/compat";
|
|
9
10
|
import "../types.js";
|
|
10
11
|
import "../../de_DE-a553b162.js";
|
|
11
12
|
import "../getThumbnailViewport.js";
|
|
@@ -14,7 +15,7 @@ import "../../contexts/DocumentPasswordContext.js";
|
|
|
14
15
|
import "./usePdfProperties.js";
|
|
15
16
|
import "../convertPdfDate.js";
|
|
16
17
|
import "../formatFileSize.js";
|
|
17
|
-
const
|
|
18
|
+
const j = () => {
|
|
18
19
|
const { setRotate: t } = p(), i = r(() => {
|
|
19
20
|
t((o) => (o + 90) % 360);
|
|
20
21
|
}, [t]), m = r(() => {
|
|
@@ -23,5 +24,5 @@ const g = () => {
|
|
|
23
24
|
return { handleRotateClockwise: i, handleRotateCounterclockwise: m };
|
|
24
25
|
};
|
|
25
26
|
export {
|
|
26
|
-
|
|
27
|
+
j as useRotate
|
|
27
28
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "../../contexts/ScrollModeContext.js";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as H } from "../../PaginationContext-9217cab4.js";
|
|
4
4
|
import "../../contexts/ViewModeContext.js";
|
|
5
5
|
import "../types.js";
|
|
6
6
|
import "../../contexts/VirtualScrollContext.js";
|
|
@@ -16,7 +16,8 @@ import "../../contexts/InitialStateContext.js";
|
|
|
16
16
|
import "../../de_DE-a553b162.js";
|
|
17
17
|
import "../../contexts/RPDocumentContext.js";
|
|
18
18
|
import "./useLoadPdf.js";
|
|
19
|
-
import "
|
|
19
|
+
import "@pdf-viewer/pdfium";
|
|
20
|
+
import "@pdf-viewer/pdfium/compat";
|
|
20
21
|
import "../getThumbnailViewport.js";
|
|
21
22
|
import "../../contexts/ConfigContext.js";
|
|
22
23
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -33,5 +34,5 @@ import "../getZoomLevel.js";
|
|
|
33
34
|
import "../../contexts/RotationContext.js";
|
|
34
35
|
import "../../contexts/PagesRotateContext.js";
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
H as useScrollToPage
|
|
37
38
|
};
|
|
@@ -6,8 +6,8 @@ import { useScrollModeContext as ct } from "../../contexts/ScrollModeContext.js"
|
|
|
6
6
|
import { useDocumentContext as it } from "../../contexts/RPDocumentContext.js";
|
|
7
7
|
import { useZoomContext as at } from "../../contexts/ZoomContext.js";
|
|
8
8
|
import { u as mt } from "../../PaginationContext-9217cab4.js";
|
|
9
|
-
import { useViewModeContext as
|
|
10
|
-
import { useDimensionPagesContext as
|
|
9
|
+
import { useViewModeContext as pt } from "../../contexts/ViewModeContext.js";
|
|
10
|
+
import { useDimensionPagesContext as ut } from "../../contexts/DimensionPagesContext.js";
|
|
11
11
|
import { useLayoutContainer as lt } from "../../contexts/LayoutContainerContext.js";
|
|
12
12
|
import { getScrollDistance as F } from "../getScrollDistance.js";
|
|
13
13
|
import { getWordPositionInPage as ft } from "../getWordPositionInPage.js";
|
|
@@ -18,7 +18,8 @@ import "react/jsx-runtime";
|
|
|
18
18
|
import "../appConsole.js";
|
|
19
19
|
import "../../contexts/InitialStateContext.js";
|
|
20
20
|
import "./useLoadPdf.js";
|
|
21
|
-
import "
|
|
21
|
+
import "@pdf-viewer/pdfium";
|
|
22
|
+
import "@pdf-viewer/pdfium/compat";
|
|
22
23
|
import "../getThumbnailViewport.js";
|
|
23
24
|
import "../../contexts/ConfigContext.js";
|
|
24
25
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -35,8 +36,8 @@ import "../../contexts/VirtualGridContext.js";
|
|
|
35
36
|
import "../smoothScrollTo.js";
|
|
36
37
|
import "../../contexts/SmoothScrollContext.js";
|
|
37
38
|
import "../calculatePage.js";
|
|
38
|
-
const
|
|
39
|
-
const [
|
|
39
|
+
const $t = (O = {}, U = "") => {
|
|
40
|
+
const [p, q] = C(U), [B, y] = C(!1), { pdf: _, pages: S } = it(), { widths: f, heights: R } = ut(), w = b(!p), { currentZoom: A } = at(), [s, g] = C([]), { setFocusedPage: D } = mt(), { columnCount: G, viewMode: V } = pt(), { pageRotate: v } = gt(), [c, i] = C(0), { pageScrollElementRef: W, virtualScrollableElementRef: Z } = st(), { scrollMode: h } = ct(), { pagesRef: L } = lt(), J = b({}), m = b(0), K = H(() => c === 0 ? null : s[c - 1], [c, s]), a = H(() => s.length, [s]), u = I(
|
|
40
41
|
(e) => {
|
|
41
42
|
if (e === 0)
|
|
42
43
|
return;
|
|
@@ -100,19 +101,19 @@ const Yt = (O = {}, U = "") => {
|
|
|
100
101
|
]
|
|
101
102
|
);
|
|
102
103
|
z(() => {
|
|
103
|
-
c &&
|
|
104
|
+
c && u(c);
|
|
104
105
|
}, [c]);
|
|
105
106
|
const Q = I(() => {
|
|
106
107
|
i((e) => {
|
|
107
108
|
let t;
|
|
108
109
|
return a ? e + 1 > a ? t = 1 : t = e + 1 : t = 0, m.current = t, t;
|
|
109
|
-
}), m.current === 1 &&
|
|
110
|
-
}, [a,
|
|
110
|
+
}), m.current === 1 && u(m.current);
|
|
111
|
+
}, [a, u]), X = I(() => {
|
|
111
112
|
i((e) => {
|
|
112
113
|
let t;
|
|
113
114
|
return a ? e - 1 <= 0 ? t = a : t = e - 1 : t = 0, m.current = t, t;
|
|
114
|
-
}), m.current === 1 &&
|
|
115
|
-
}, [a,
|
|
115
|
+
}), m.current === 1 && u(m.current);
|
|
116
|
+
}, [a, u]), j = I(async (e) => {
|
|
116
117
|
if (!e)
|
|
117
118
|
return {};
|
|
118
119
|
const t = e.numPages, o = {};
|
|
@@ -125,7 +126,7 @@ const Yt = (O = {}, U = "") => {
|
|
|
125
126
|
return o;
|
|
126
127
|
}, []);
|
|
127
128
|
return z(() => {
|
|
128
|
-
if (!
|
|
129
|
+
if (!p) {
|
|
129
130
|
w.current = !0, g([]), i(0);
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
@@ -133,7 +134,7 @@ const Yt = (O = {}, U = "") => {
|
|
|
133
134
|
J.current = e;
|
|
134
135
|
const o = Object.keys(e).reduce((r, n) => {
|
|
135
136
|
const l = nt(
|
|
136
|
-
[
|
|
137
|
+
[p],
|
|
137
138
|
e[n],
|
|
138
139
|
Number(n) - 1,
|
|
139
140
|
O
|
|
@@ -144,8 +145,8 @@ const Yt = (O = {}, U = "") => {
|
|
|
144
145
|
}).catch(() => {
|
|
145
146
|
g([]), i(0);
|
|
146
147
|
}).finally(() => y(!1));
|
|
147
|
-
}, [
|
|
148
|
-
search:
|
|
148
|
+
}, [p, j, _, O]), {
|
|
149
|
+
search: p,
|
|
149
150
|
setSearch: q,
|
|
150
151
|
loading: B,
|
|
151
152
|
matches: s,
|
|
@@ -158,5 +159,5 @@ const Yt = (O = {}, U = "") => {
|
|
|
158
159
|
};
|
|
159
160
|
};
|
|
160
161
|
export {
|
|
161
|
-
|
|
162
|
+
$t as useSearch
|
|
162
163
|
};
|