@react-pdf-kit/viewer 0.0.0-experimental.8 → 0.0.0-experimental.9
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/RPLayout.module-7766e0b4.js +14 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +15 -15
- package/dist/components/RPConfig.js +11 -12
- package/dist/components/RPController.js +26 -21
- package/dist/components/RPDropFileZone.js +8 -7
- package/dist/components/RPPages.js +360 -351
- package/dist/components/RPProvider.js +24 -20
- package/dist/components/layout/LayoutContainer.js +1 -1
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +7 -4
- package/dist/components/layout/RPLayout.js +7 -4
- package/dist/components/layout/WrapperLayout.js +4 -3
- package/dist/components/layout/sidebar/RPSidebar.js +4 -3
- package/dist/components/layout/sidebar/Thumbnail.js +4 -3
- package/dist/components/layout/sidebar/Thumbnails.js +4 -3
- package/dist/components/layout/toolbar/DocumentDialog.js +6 -5
- package/dist/components/layout/toolbar/FileDownloadTool.js +4 -3
- package/dist/components/layout/toolbar/FileUploadTool.js +4 -3
- package/dist/components/layout/toolbar/MostPageTool.js +4 -3
- package/dist/components/layout/toolbar/OtherTool.js +4 -3
- package/dist/components/layout/toolbar/Paginate.js +4 -3
- package/dist/components/layout/toolbar/PrintTool.js +4 -3
- package/dist/components/layout/toolbar/RPMoreOptions.js +4 -3
- package/dist/components/layout/toolbar/RPToolbar.js +6 -3
- package/dist/components/layout/toolbar/RPToolbarEnd.js +4 -3
- package/dist/components/layout/toolbar/RotateTool.js +4 -3
- package/dist/components/layout/toolbar/SearchResultNavigator.js +6 -3
- package/dist/components/layout/toolbar/SearchTool.js +6 -3
- package/dist/components/layout/toolbar/ThumbnailTool.js +4 -3
- package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
- package/dist/components/layout/toolbar/ToolbarDefault.js +6 -3
- package/dist/components/layout/toolbar/ToolbarLayout.js +6 -3
- package/dist/components/layout/toolbar/ZoomTool.js +4 -3
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -3
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +9 -5
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -3
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +4 -3
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +9 -5
- package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/LastPageTool.js +9 -5
- package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/PrintTool.js +4 -3
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +4 -3
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +4 -3
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -3
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +4 -3
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +14 -13
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +4 -3
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +6 -3
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -3
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +4 -3
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +4 -3
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +4 -3
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +4 -3
- package/dist/components/page/AnnotationLayer.js +69 -72
- package/dist/components/page/CanvasLayer.js +4 -3
- package/dist/components/page/CustomElement.js +4 -3
- package/dist/components/page/DualPage.js +11 -5
- package/dist/components/page/DualPageWithCover.js +11 -5
- package/dist/components/page/RPPage.js +12 -6
- package/dist/components/page/SinglePage.js +11 -5
- package/dist/components/page/TextHighlightLayer.js +86 -178
- package/dist/components/page/TextLayer.js +125 -170
- package/dist/components/ui/LoadingIndicator.js +8 -7
- package/dist/contexts/DimensionPagesContext.js +6 -5
- 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 +10 -7
- 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 +6 -5
- package/dist/contexts/RotationContext.js +9 -8
- package/dist/contexts/SearchContext.js +8 -5
- package/dist/contexts/TextSelectionContext.js +191 -0
- package/dist/contexts/ThumbnailsContext.js +5 -4
- package/dist/contexts/ZoomContext.js +6 -5
- package/dist/main.js +116 -113
- 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 -1
- package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
- package/dist/types/contexts/TextSelectionContext.d.ts +14 -0
- package/dist/types/main.d.ts +1 -1
- package/dist/types/utils/annotations.d.ts +2 -2
- package/dist/types/utils/geometryCache.d.ts +15 -0
- package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
- package/dist/types/utils/glyphHitTest.d.ts +12 -0
- 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/useTextSelection.d.ts +12 -3
- package/dist/types/utils/link_service.d.ts +2 -3
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/selectionUtils.d.ts +30 -0
- package/dist/types/utils/types.d.ts +5 -7
- package/dist/utils/geometryCache.js +32 -0
- package/dist/utils/glyphHitTest.js +29 -0
- package/dist/utils/highlight.js +184 -158
- package/dist/utils/hooks/useCopyText.js +60 -22
- package/dist/utils/hooks/useFileDownload.js +6 -5
- package/dist/utils/hooks/useHighlight.js +35 -33
- package/dist/utils/hooks/useLicense.js +62 -62
- package/dist/utils/hooks/useLoadPdf.js +102 -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 +11 -10
- package/dist/utils/hooks/usePresentPage.js +4 -3
- package/dist/utils/hooks/usePrint.js +74 -78
- package/dist/utils/hooks/useRotate.js +4 -3
- package/dist/utils/hooks/useScrollToPage.js +4 -3
- package/dist/utils/hooks/useSearch.js +18 -15
- package/dist/utils/hooks/useTextSelection.js +2 -73
- package/dist/utils/hooks/useThumbnail.js +18 -17
- package/dist/utils/hooks/useVirtualReactWindow.js +4 -3
- package/dist/utils/link_service.js +18 -19
- package/dist/utils/renderPage.js +1 -1
- package/dist/utils/selectionUtils.js +96 -0
- package/package.json +2 -3
- package/dist/RPLayout.module-b4b23e29.js +0 -14
- package/dist/types/utils/hooks/useFlickerSelectText.d.ts +0 -1
- package/dist/utils/hooks/useFlickerSelectText.js +0 -25
|
@@ -3,7 +3,8 @@ import { createContext as k, useState as d, useCallback as s, useEffect as l, us
|
|
|
3
3
|
import { usePrint as y } from "../utils/hooks/usePrint.js";
|
|
4
4
|
import "./RPDocumentContext.js";
|
|
5
5
|
import "../utils/hooks/useLoadPdf.js";
|
|
6
|
-
import "
|
|
6
|
+
import "@pdf-viewer/pdfium";
|
|
7
|
+
import "@pdf-viewer/pdfium/compat";
|
|
7
8
|
import "../utils/types.js";
|
|
8
9
|
import "../de_DE-a553b162.js";
|
|
9
10
|
import "../utils/getThumbnailViewport.js";
|
|
@@ -24,14 +25,14 @@ const g = k({
|
|
|
24
25
|
setOnComplete: (r) => r(),
|
|
25
26
|
setOnError: (r) => {
|
|
26
27
|
try {
|
|
27
|
-
const
|
|
28
|
-
r(
|
|
29
|
-
} catch (
|
|
30
|
-
console.error("Error in setOnError callback:",
|
|
28
|
+
const o = new Error("Print error occurred");
|
|
29
|
+
r(o);
|
|
30
|
+
} catch (o) {
|
|
31
|
+
console.error("Error in setOnError callback:", o);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
}),
|
|
34
|
-
const [
|
|
34
|
+
}), L = ({ children: r }) => {
|
|
35
|
+
const [o, O] = d(null), [e, p] = d(null), { print: m, cancel: a, progress: n, isComplete: u, isError: P, error: i, showDefaultProgress: f } = y(), C = s((t) => {
|
|
35
36
|
t && typeof t == "function" && p(() => t);
|
|
36
37
|
}, []), c = s(
|
|
37
38
|
(t) => {
|
|
@@ -41,17 +42,17 @@ const g = k({
|
|
|
41
42
|
), x = s((t) => {
|
|
42
43
|
O(() => t);
|
|
43
44
|
}, []), E = s(() => {
|
|
44
|
-
|
|
45
|
-
}, [
|
|
45
|
+
e && (e(), p(null));
|
|
46
|
+
}, [e]);
|
|
46
47
|
l(() => {
|
|
47
|
-
u &&
|
|
48
|
-
}, [u,
|
|
48
|
+
u && e && E();
|
|
49
|
+
}, [u, e, E]), l(() => {
|
|
49
50
|
P && c((t) => {
|
|
50
51
|
console.error(t);
|
|
51
52
|
});
|
|
52
53
|
}, [P]), l(() => {
|
|
53
|
-
n &&
|
|
54
|
-
}, [n,
|
|
54
|
+
n && o && o(n);
|
|
55
|
+
}, [n, o]);
|
|
55
56
|
const h = w(
|
|
56
57
|
() => ({
|
|
57
58
|
print: m,
|
|
@@ -65,7 +66,7 @@ const g = k({
|
|
|
65
66
|
[m, a, x, C, c, n, f]
|
|
66
67
|
);
|
|
67
68
|
return /* @__PURE__ */ b(g.Provider, { value: h, children: r });
|
|
68
|
-
},
|
|
69
|
+
}, N = () => {
|
|
69
70
|
const r = v(g);
|
|
70
71
|
if (!r)
|
|
71
72
|
throw new Error("usePrintContext must be used within a PrintProvider");
|
|
@@ -73,6 +74,6 @@ const g = k({
|
|
|
73
74
|
};
|
|
74
75
|
export {
|
|
75
76
|
g as PrintContext,
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
L as PrintProvider,
|
|
78
|
+
N as usePrintContext
|
|
78
79
|
};
|
|
@@ -3,7 +3,8 @@ import { createContext as M, useState as l, useEffect as j, useMemo as k, useCon
|
|
|
3
3
|
import { useLoadPdf as E } from "../utils/hooks/useLoadPdf.js";
|
|
4
4
|
import { usePdfProperties as L } from "../utils/hooks/usePdfProperties.js";
|
|
5
5
|
import { appConsole as R } from "../utils/appConsole.js";
|
|
6
|
-
import "
|
|
6
|
+
import "@pdf-viewer/pdfium";
|
|
7
|
+
import "@pdf-viewer/pdfium/compat";
|
|
7
8
|
import "../utils/types.js";
|
|
8
9
|
import "../de_DE-a553b162.js";
|
|
9
10
|
import "../utils/getThumbnailViewport.js";
|
|
@@ -21,9 +22,9 @@ const u = M({
|
|
|
21
22
|
loading: !1,
|
|
22
23
|
loaderProgress: 0,
|
|
23
24
|
error: void 0
|
|
24
|
-
}),
|
|
25
|
+
}), T = ({
|
|
25
26
|
children: t,
|
|
26
|
-
src:
|
|
27
|
+
src: o,
|
|
27
28
|
characterMap: c,
|
|
28
29
|
onLoadError: P,
|
|
29
30
|
onLoaded: g,
|
|
@@ -33,7 +34,7 @@ const u = M({
|
|
|
33
34
|
rangeChunkSize: v,
|
|
34
35
|
loaderImage: S
|
|
35
36
|
}) => {
|
|
36
|
-
const [
|
|
37
|
+
const [e, i] = l(o), [r, s] = l(), { pdf: n, pages: p, loading: m, loadingProgress: d, error: f } = E(e, c, {
|
|
37
38
|
onLoadError: P,
|
|
38
39
|
onLoaded: g,
|
|
39
40
|
onLoadProgress: x,
|
|
@@ -41,14 +42,14 @@ const u = M({
|
|
|
41
42
|
disableStream: h,
|
|
42
43
|
rangeChunkSize: v,
|
|
43
44
|
loaderImage: S
|
|
44
|
-
}), a = L(
|
|
45
|
+
}), a = L(e, n, r);
|
|
45
46
|
j(() => {
|
|
46
|
-
s(
|
|
47
|
-
}, [
|
|
47
|
+
s(o == null ? void 0 : o.split("/").pop()), i(o);
|
|
48
|
+
}, [o]);
|
|
48
49
|
const D = k(() => ({
|
|
49
50
|
pdf: n,
|
|
50
51
|
pages: p,
|
|
51
|
-
pdfSrc:
|
|
52
|
+
pdfSrc: e,
|
|
52
53
|
setPdfSrc: i,
|
|
53
54
|
pdfProperties: a,
|
|
54
55
|
setFilename: s,
|
|
@@ -56,14 +57,14 @@ const u = M({
|
|
|
56
57
|
loading: m,
|
|
57
58
|
loaderProgress: d,
|
|
58
59
|
error: f
|
|
59
|
-
}), [n, p,
|
|
60
|
-
return /* @__PURE__ */ F(u.Provider, { value: D, children:
|
|
61
|
-
},
|
|
60
|
+
}), [n, p, e, a, r, m, d, f]);
|
|
61
|
+
return /* @__PURE__ */ F(u.Provider, { value: D, children: e ? t : null });
|
|
62
|
+
}, U = () => {
|
|
62
63
|
const t = w(u);
|
|
63
64
|
return t.pdfSrc || R.error("Please use this hooks inside children component of RPDocument"), t;
|
|
64
65
|
};
|
|
65
66
|
export {
|
|
66
|
-
|
|
67
|
+
T as DocumentProvider,
|
|
67
68
|
u as default,
|
|
68
|
-
|
|
69
|
+
U as useDocumentContext
|
|
69
70
|
};
|
|
@@ -3,7 +3,7 @@ import { createContext as l, useRef as g, useState as P, useCallback as s, useMe
|
|
|
3
3
|
import { Queue as v } from "../utils/Queue.js";
|
|
4
4
|
import { renderPage as x } from "../utils/renderPage.js";
|
|
5
5
|
import { u as y } from "../PaginationContext-9217cab4.js";
|
|
6
|
-
import "
|
|
6
|
+
import "@pdf-viewer/pdfium/compat";
|
|
7
7
|
import "../utils/types.js";
|
|
8
8
|
import "../de_DE-a553b162.js";
|
|
9
9
|
import "./ScrollModeContext.js";
|
|
@@ -11,6 +11,7 @@ import "../utils/appConsole.js";
|
|
|
11
11
|
import "./InitialStateContext.js";
|
|
12
12
|
import "./RPDocumentContext.js";
|
|
13
13
|
import "../utils/hooks/useLoadPdf.js";
|
|
14
|
+
import "@pdf-viewer/pdfium";
|
|
14
15
|
import "../utils/getThumbnailViewport.js";
|
|
15
16
|
import "./ConfigContext.js";
|
|
16
17
|
import "./DocumentPasswordContext.js";
|
|
@@ -34,7 +35,7 @@ import "./PagesRotateContext.js";
|
|
|
34
35
|
import "./SmoothScrollContext.js";
|
|
35
36
|
import "../utils/getScrollDistance.js";
|
|
36
37
|
import "../utils/calculatePage.js";
|
|
37
|
-
const c = l(null),
|
|
38
|
+
const c = l(null), me = ({ children: o }) => {
|
|
38
39
|
const m = g(!1), [d, n] = P([]), p = s((e) => {
|
|
39
40
|
n((r) => [...r, { id: e.page.pageNumber.toString(), data: e, priority: 0 }]);
|
|
40
41
|
}, []), t = R(() => new v(p), [p]), { focusedPage: i } = y(), u = s((e) => (m.current = !0, x(
|
|
@@ -59,7 +60,7 @@ const c = l(null), ie = ({ children: o }) => {
|
|
|
59
60
|
};
|
|
60
61
|
e();
|
|
61
62
|
}, [t, u, d]), /* @__PURE__ */ f(c.Provider, { value: t, children: o });
|
|
62
|
-
},
|
|
63
|
+
}, ne = () => {
|
|
63
64
|
const o = h(c);
|
|
64
65
|
if (!o)
|
|
65
66
|
throw new Error("RenderQueue not found");
|
|
@@ -67,6 +68,6 @@ const c = l(null), ie = ({ children: o }) => {
|
|
|
67
68
|
};
|
|
68
69
|
export {
|
|
69
70
|
c as RenderQueueContext,
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
me as RenderQueueProvider,
|
|
72
|
+
ne as useRenderQueue
|
|
72
73
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as p, useContext as a, useState as u, useEffect as c, useMemo as f } from "react";
|
|
3
3
|
import { appConsole as d } from "../utils/appConsole.js";
|
|
4
4
|
import { useInitialStateContext as x } from "./InitialStateContext.js";
|
|
5
5
|
import { useDocumentContext as C } from "./RPDocumentContext.js";
|
|
6
6
|
import "../utils/hooks/useLoadPdf.js";
|
|
7
|
-
import "
|
|
7
|
+
import "@pdf-viewer/pdfium";
|
|
8
|
+
import "@pdf-viewer/pdfium/compat";
|
|
8
9
|
import "../utils/types.js";
|
|
9
10
|
import "../de_DE-a553b162.js";
|
|
10
11
|
import "../utils/getThumbnailViewport.js";
|
|
@@ -17,22 +18,22 @@ const n = p({
|
|
|
17
18
|
rotate: 0,
|
|
18
19
|
setRotate: () => {
|
|
19
20
|
}
|
|
20
|
-
}),
|
|
21
|
+
}), w = () => {
|
|
21
22
|
const t = a(n);
|
|
22
23
|
return typeof (t == null ? void 0 : t.rotate) > "u" && d.error("Please use this hooks inside children component of RPProvider"), t;
|
|
23
|
-
},
|
|
24
|
+
}, z = ({ children: t }) => {
|
|
24
25
|
const { initialRotation: o = 0 } = x(), { pdf: r } = C(), [i, e] = u(o);
|
|
25
26
|
c(() => {
|
|
26
27
|
r && e(o);
|
|
27
28
|
}, [r, o]);
|
|
28
|
-
const
|
|
29
|
+
const m = f(() => ({
|
|
29
30
|
rotate: i,
|
|
30
31
|
setRotate: e
|
|
31
32
|
}), [i, e]);
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ s(n.Provider, { value: m, children: t });
|
|
33
34
|
};
|
|
34
35
|
export {
|
|
35
36
|
n as RotateContext,
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
z as RotateProvider,
|
|
38
|
+
w as useRotationContext
|
|
38
39
|
};
|
|
@@ -5,13 +5,16 @@ import "../utils/types.js";
|
|
|
5
5
|
import "../de_DE-a553b162.js";
|
|
6
6
|
import "../utils/highlight.js";
|
|
7
7
|
import "../utils/charators.js";
|
|
8
|
+
import "../utils/selectionUtils.js";
|
|
9
|
+
import "../utils/geometryCache.js";
|
|
8
10
|
import "./VirtualScrollContext.js";
|
|
9
11
|
import "./ScrollModeContext.js";
|
|
10
12
|
import "../utils/appConsole.js";
|
|
11
13
|
import "./InitialStateContext.js";
|
|
12
14
|
import "./RPDocumentContext.js";
|
|
13
15
|
import "../utils/hooks/useLoadPdf.js";
|
|
14
|
-
import "
|
|
16
|
+
import "@pdf-viewer/pdfium";
|
|
17
|
+
import "@pdf-viewer/pdfium/compat";
|
|
15
18
|
import "../utils/getThumbnailViewport.js";
|
|
16
19
|
import "./ConfigContext.js";
|
|
17
20
|
import "./DocumentPasswordContext.js";
|
|
@@ -52,7 +55,7 @@ const o = x({
|
|
|
52
55
|
searchOptions: {},
|
|
53
56
|
setSearchOptions: (t) => t,
|
|
54
57
|
setCurrentMatchPosition: (t) => t
|
|
55
|
-
}),
|
|
58
|
+
}), ct = ({
|
|
56
59
|
children: t,
|
|
57
60
|
initialSearch: i
|
|
58
61
|
}) => {
|
|
@@ -88,9 +91,9 @@ const o = x({
|
|
|
88
91
|
children: t
|
|
89
92
|
}
|
|
90
93
|
);
|
|
91
|
-
},
|
|
94
|
+
}, at = () => C(o);
|
|
92
95
|
export {
|
|
93
96
|
o as SearchContext,
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
ct as SearchProvider,
|
|
98
|
+
at as useSearchContext
|
|
96
99
|
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as K, useContext as O, useRef as l, useState as Q, useCallback as f, useEffect as _, useMemo as B } from "react";
|
|
3
|
+
import { glyphAt as q } from "../utils/glyphHitTest.js";
|
|
4
|
+
import { rectsForRange as A, textForRange as E, expandToWordBoundary as L, expandToLineBoundary as $ } from "../utils/selectionUtils.js";
|
|
5
|
+
import { geometryCache as k } from "../utils/geometryCache.js";
|
|
6
|
+
import { useEventCallbackContext as ee } from "./EventCallbackContext.js";
|
|
7
|
+
import { useZoomContext as te } from "./ZoomContext.js";
|
|
8
|
+
import "../utils/types.js";
|
|
9
|
+
import "../de_DE-a553b162.js";
|
|
10
|
+
import "../utils/appConsole.js";
|
|
11
|
+
import "./InitialStateContext.js";
|
|
12
|
+
import "./RPDocumentContext.js";
|
|
13
|
+
import "../utils/hooks/useLoadPdf.js";
|
|
14
|
+
import "@pdf-viewer/pdfium";
|
|
15
|
+
import "@pdf-viewer/pdfium/compat";
|
|
16
|
+
import "../utils/getThumbnailViewport.js";
|
|
17
|
+
import "./ConfigContext.js";
|
|
18
|
+
import "./DocumentPasswordContext.js";
|
|
19
|
+
import "../utils/hooks/usePdfProperties.js";
|
|
20
|
+
import "../utils/convertPdfDate.js";
|
|
21
|
+
import "../utils/formatFileSize.js";
|
|
22
|
+
import "../utils/constants.js";
|
|
23
|
+
import "../utils/getZoomLevel.js";
|
|
24
|
+
import "./LayoutContainerContext.js";
|
|
25
|
+
import "./ViewModeContext.js";
|
|
26
|
+
import "./RotationContext.js";
|
|
27
|
+
import "./GlobalCurrentPage.js";
|
|
28
|
+
import "../utils/hooks/useDebounce.js";
|
|
29
|
+
const ne = {
|
|
30
|
+
handlePointerDown: () => {
|
|
31
|
+
},
|
|
32
|
+
handlePointerMove: () => {
|
|
33
|
+
},
|
|
34
|
+
handlePointerUp: () => {
|
|
35
|
+
},
|
|
36
|
+
getPageSelectionRects: () => [],
|
|
37
|
+
isSelecting: !1,
|
|
38
|
+
selectedText: "",
|
|
39
|
+
selectionVersion: 0,
|
|
40
|
+
clearSelection: () => {
|
|
41
|
+
}
|
|
42
|
+
}, z = K(ne), Ve = () => O(z), Fe = ({ children: G }) => {
|
|
43
|
+
const { onTextSelect: C } = ee(), { currentZoom: P } = te(), h = l(null), R = l(null), g = l(!1), y = l(/* @__PURE__ */ new Map()), S = l(""), m = l(0), F = l(0), D = l({ x: 0, y: 0 }), I = l(0), w = l(0), M = l(-1), [N, V] = Q(0), T = f(
|
|
44
|
+
(e, n) => {
|
|
45
|
+
const o = n.getBoundingClientRect();
|
|
46
|
+
return { x: e.clientX - o.left, y: e.clientY - o.top };
|
|
47
|
+
},
|
|
48
|
+
[]
|
|
49
|
+
), b = f(
|
|
50
|
+
(e, n) => {
|
|
51
|
+
const o = /* @__PURE__ */ new Map();
|
|
52
|
+
let a = "";
|
|
53
|
+
if (e.pageIndex === n.pageIndex) {
|
|
54
|
+
const i = k.get(e.pageIndex);
|
|
55
|
+
if (i) {
|
|
56
|
+
const c = A(i, e.charIndex, n.charIndex);
|
|
57
|
+
c.length > 0 && o.set(e.pageIndex, c), a = E(i, e.charIndex, n.charIndex);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
const i = e.pageIndex < n.pageIndex, c = Math.min(e.pageIndex, n.pageIndex), t = Math.max(e.pageIndex, n.pageIndex);
|
|
61
|
+
for (let r = c; r <= t; r++) {
|
|
62
|
+
const u = k.get(r);
|
|
63
|
+
if (!u || u.totalCharCount === 0)
|
|
64
|
+
continue;
|
|
65
|
+
const d = u.totalCharCount - 1;
|
|
66
|
+
let x, p;
|
|
67
|
+
r === e.pageIndex ? (x = e.charIndex, p = i ? d : 0) : r === n.pageIndex ? (x = i ? 0 : d, p = n.charIndex) : (x = 0, p = d);
|
|
68
|
+
const s = A(u, x, p);
|
|
69
|
+
s.length > 0 && o.set(r, s);
|
|
70
|
+
const j = E(u, x, p);
|
|
71
|
+
a && j && (a += `
|
|
72
|
+
`), a += j;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
y.current = o, S.current = a, V((i) => i + 1);
|
|
76
|
+
},
|
|
77
|
+
[]
|
|
78
|
+
), X = f(
|
|
79
|
+
(e, n, o) => {
|
|
80
|
+
const { x: a, y: i } = T(n, o), c = k.get(e);
|
|
81
|
+
if (!c)
|
|
82
|
+
return;
|
|
83
|
+
const t = q(c, a, i);
|
|
84
|
+
if (!t) {
|
|
85
|
+
h.current = null, R.current = null, y.current = /* @__PURE__ */ new Map(), S.current = "", V((s) => s + 1);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const r = Date.now(), u = Math.abs(n.clientX - D.current.x), d = Math.abs(n.clientY - D.current.y);
|
|
89
|
+
r - F.current < 500 && u < 5 && d < 5 ? m.current = m.current % 3 + 1 : m.current = 1, F.current = r, D.current = { x: n.clientX, y: n.clientY };
|
|
90
|
+
let x, p;
|
|
91
|
+
if (m.current === 2) {
|
|
92
|
+
const s = L(c, t.charIndex);
|
|
93
|
+
x = { pageIndex: e, charIndex: s.start }, p = { pageIndex: e, charIndex: s.end }, I.current = s.start, w.current = s.end, M.current = e;
|
|
94
|
+
} else if (m.current === 3) {
|
|
95
|
+
const s = $(c, t.charIndex);
|
|
96
|
+
x = { pageIndex: e, charIndex: s.start }, p = { pageIndex: e, charIndex: s.end }, I.current = s.start, w.current = s.end, M.current = e;
|
|
97
|
+
} else
|
|
98
|
+
x = { pageIndex: e, charIndex: t.charIndex }, p = { pageIndex: e, charIndex: t.charIndex };
|
|
99
|
+
h.current = x, R.current = p, g.current = !0, o.setPointerCapture(n.pointerId), b(x, p);
|
|
100
|
+
},
|
|
101
|
+
[T, b]
|
|
102
|
+
), Y = f(
|
|
103
|
+
(e, n, o) => {
|
|
104
|
+
if (!g.current || !h.current)
|
|
105
|
+
return;
|
|
106
|
+
const { x: a, y: i } = T(n, o), c = k.get(e);
|
|
107
|
+
if (!c)
|
|
108
|
+
return;
|
|
109
|
+
const t = q(c, a, i);
|
|
110
|
+
if (!t)
|
|
111
|
+
return;
|
|
112
|
+
let r = t.charIndex;
|
|
113
|
+
const u = h.current;
|
|
114
|
+
if (m.current === 2 && e === M.current) {
|
|
115
|
+
const d = L(c, t.charIndex);
|
|
116
|
+
t.charIndex < I.current ? (r = d.start, h.current = { pageIndex: u.pageIndex, charIndex: w.current }) : (r = d.end, h.current = { pageIndex: u.pageIndex, charIndex: I.current });
|
|
117
|
+
} else if (m.current === 3 && e === M.current) {
|
|
118
|
+
const d = $(c, t.charIndex);
|
|
119
|
+
t.charIndex < I.current ? (r = d.start, h.current = { pageIndex: u.pageIndex, charIndex: w.current }) : (r = d.end, h.current = { pageIndex: u.pageIndex, charIndex: I.current });
|
|
120
|
+
}
|
|
121
|
+
R.current = { pageIndex: e, charIndex: r }, b(h.current, R.current);
|
|
122
|
+
},
|
|
123
|
+
[T, b]
|
|
124
|
+
), Z = f(() => {
|
|
125
|
+
if (!g.current)
|
|
126
|
+
return;
|
|
127
|
+
g.current = !1;
|
|
128
|
+
const e = S.current;
|
|
129
|
+
if (e && C) {
|
|
130
|
+
const n = [];
|
|
131
|
+
for (const [o, a] of y.current.entries()) {
|
|
132
|
+
const i = o + 1, c = document.querySelector(`[data-rp="page-${i}"]`), t = c == null ? void 0 : c.getBoundingClientRect();
|
|
133
|
+
n.push({
|
|
134
|
+
pageNumber: i,
|
|
135
|
+
pageBasedBoundingRects: a.map((r) => ({
|
|
136
|
+
left: r.x,
|
|
137
|
+
bottom: r.y + r.height,
|
|
138
|
+
width: r.width,
|
|
139
|
+
height: r.height
|
|
140
|
+
})),
|
|
141
|
+
pageDimension: {
|
|
142
|
+
width: (t == null ? void 0 : t.width) ?? 0,
|
|
143
|
+
height: (t == null ? void 0 : t.height) ?? 0
|
|
144
|
+
},
|
|
145
|
+
pagePositionInWindow: {
|
|
146
|
+
x: (t == null ? void 0 : t.left) ?? 0,
|
|
147
|
+
y: (t == null ? void 0 : t.top) ?? 0
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
n.sort((o, a) => o.pageNumber - a.pageNumber), C({
|
|
152
|
+
text: e,
|
|
153
|
+
pageSelections: n
|
|
154
|
+
});
|
|
155
|
+
} else
|
|
156
|
+
C && !e && C(null);
|
|
157
|
+
}, [C]), v = f(() => {
|
|
158
|
+
h.current = null, R.current = null, g.current = !1, y.current = /* @__PURE__ */ new Map(), S.current = "", V((e) => e + 1);
|
|
159
|
+
}, []), U = l(P);
|
|
160
|
+
_(() => {
|
|
161
|
+
P !== U.current && (U.current = P, v());
|
|
162
|
+
}, [P, v]);
|
|
163
|
+
const W = f(
|
|
164
|
+
(e) => y.current.get(e) ?? [],
|
|
165
|
+
[]
|
|
166
|
+
), H = B(
|
|
167
|
+
() => ({
|
|
168
|
+
handlePointerDown: X,
|
|
169
|
+
handlePointerMove: Y,
|
|
170
|
+
handlePointerUp: Z,
|
|
171
|
+
getPageSelectionRects: W,
|
|
172
|
+
isSelecting: g.current,
|
|
173
|
+
selectedText: S.current,
|
|
174
|
+
selectionVersion: N,
|
|
175
|
+
clearSelection: v
|
|
176
|
+
}),
|
|
177
|
+
[
|
|
178
|
+
X,
|
|
179
|
+
Y,
|
|
180
|
+
Z,
|
|
181
|
+
W,
|
|
182
|
+
N,
|
|
183
|
+
v
|
|
184
|
+
]
|
|
185
|
+
);
|
|
186
|
+
return /* @__PURE__ */ J(z.Provider, { value: H, children: G });
|
|
187
|
+
};
|
|
188
|
+
export {
|
|
189
|
+
Fe as TextSelectionProvider,
|
|
190
|
+
Ve as useTextSelectionContext
|
|
191
|
+
};
|
|
@@ -3,7 +3,8 @@ import { createContext as s, useContext as l, useState as c } from "react";
|
|
|
3
3
|
import { useThumbnail as d } from "../utils/hooks/useThumbnail.js";
|
|
4
4
|
import "./RPDocumentContext.js";
|
|
5
5
|
import "../utils/hooks/useLoadPdf.js";
|
|
6
|
-
import "
|
|
6
|
+
import "@pdf-viewer/pdfium";
|
|
7
|
+
import "@pdf-viewer/pdfium/compat";
|
|
7
8
|
import "../utils/types.js";
|
|
8
9
|
import "../de_DE-a553b162.js";
|
|
9
10
|
import "../utils/getThumbnailViewport.js";
|
|
@@ -23,7 +24,7 @@ const e = s({
|
|
|
23
24
|
setActive: (t) => {
|
|
24
25
|
},
|
|
25
26
|
active: !1
|
|
26
|
-
}),
|
|
27
|
+
}), w = () => l(e), y = ({
|
|
27
28
|
children: t,
|
|
28
29
|
initialThumbnailsVisible: o
|
|
29
30
|
}) => {
|
|
@@ -38,6 +39,6 @@ const e = s({
|
|
|
38
39
|
};
|
|
39
40
|
export {
|
|
40
41
|
e as ThumbnailContext,
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
y as ThumbnailProvider,
|
|
43
|
+
w as useThumbnailContext
|
|
43
44
|
};
|
|
@@ -13,7 +13,8 @@ import { useGlobalCurrentPage as K } from "./GlobalCurrentPage.js";
|
|
|
13
13
|
import { useDebounce as Q } from "../utils/hooks/useDebounce.js";
|
|
14
14
|
import "../de_DE-a553b162.js";
|
|
15
15
|
import "../utils/hooks/useLoadPdf.js";
|
|
16
|
-
import "
|
|
16
|
+
import "@pdf-viewer/pdfium";
|
|
17
|
+
import "@pdf-viewer/pdfium/compat";
|
|
17
18
|
import "../utils/getThumbnailViewport.js";
|
|
18
19
|
import "./ConfigContext.js";
|
|
19
20
|
import "./DocumentPasswordContext.js";
|
|
@@ -26,10 +27,10 @@ const W = M({
|
|
|
26
27
|
currentZoom: 1,
|
|
27
28
|
setZoomLevel: () => {
|
|
28
29
|
}
|
|
29
|
-
}),
|
|
30
|
+
}), Pe = () => {
|
|
30
31
|
const m = O(W);
|
|
31
32
|
return typeof m.currentZoom != "number" && _.warn("Please use this hooks inside children component of RPProvider"), m;
|
|
32
|
-
},
|
|
33
|
+
}, Ze = ({ children: m }) => {
|
|
33
34
|
const { initialScale: b = J.PAGE_FIT } = j(), [s, H] = u(b), { pages: l } = F(), { pagesRef: t } = k(), { viewMode: p } = q(), [V, z] = u({
|
|
34
35
|
width: (t == null ? void 0 : t.clientWidth) || 0,
|
|
35
36
|
height: (t == null ? void 0 : t.clientHeight) || 0
|
|
@@ -102,6 +103,6 @@ const W = M({
|
|
|
102
103
|
};
|
|
103
104
|
export {
|
|
104
105
|
W as ZoomContext,
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
Ze as ZoomProvider,
|
|
107
|
+
Pe as useZoomContext
|
|
107
108
|
};
|