@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
|
@@ -6,7 +6,8 @@ import { usePagesRotateContext as q } from "../../contexts/PagesRotateContext.js
|
|
|
6
6
|
import { useRenderQueue as L } from "../../contexts/RenderQueueProvider.js";
|
|
7
7
|
import { useInitialStateContext as k } from "../../contexts/InitialStateContext.js";
|
|
8
8
|
import "../../utils/hooks/useLoadPdf.js";
|
|
9
|
-
import "
|
|
9
|
+
import "@pdf-viewer/pdfium";
|
|
10
|
+
import "@pdf-viewer/pdfium/compat";
|
|
10
11
|
import "../../utils/types.js";
|
|
11
12
|
import "../../de_DE-a553b162.js";
|
|
12
13
|
import "../../utils/getThumbnailViewport.js";
|
|
@@ -35,7 +36,7 @@ import "../../contexts/DimensionPagesContext.js";
|
|
|
35
36
|
import "../../contexts/SmoothScrollContext.js";
|
|
36
37
|
import "../../utils/getScrollDistance.js";
|
|
37
38
|
import "../../utils/calculatePage.js";
|
|
38
|
-
const
|
|
39
|
+
const nt = (d) => {
|
|
39
40
|
const { pageNumber: t, onLoaded: n, onLoading: o } = d, r = p(null), { pages: e } = C(), { pageRotate: a } = q(), v = p(), { currentZoom: m } = R(), { interactiveForm: s } = k(), i = L(), u = p(`page-${t}`);
|
|
40
41
|
return x(() => {
|
|
41
42
|
if (!e || m === 0)
|
|
@@ -67,5 +68,5 @@ const pt = (d) => {
|
|
|
67
68
|
}, [e, t, a, m, o, n, i, s]), /* @__PURE__ */ l("canvas", { "data-rp": `page-${t}-canvas`, ref: r });
|
|
68
69
|
};
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
+
nt as CanvasLayer
|
|
71
72
|
};
|
|
@@ -7,7 +7,8 @@ import "../../contexts/DimensionPagesContext.js";
|
|
|
7
7
|
import "../../utils/appConsole.js";
|
|
8
8
|
import "../../contexts/RPDocumentContext.js";
|
|
9
9
|
import "../../utils/hooks/useLoadPdf.js";
|
|
10
|
-
import "
|
|
10
|
+
import "@pdf-viewer/pdfium";
|
|
11
|
+
import "@pdf-viewer/pdfium/compat";
|
|
11
12
|
import "../../utils/getThumbnailViewport.js";
|
|
12
13
|
import "../../contexts/ConfigContext.js";
|
|
13
14
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -41,7 +42,7 @@ const a = ({ child: t }) => {
|
|
|
41
42
|
(o = r.current) == null || o.removeChild(t);
|
|
42
43
|
};
|
|
43
44
|
}, [t]), /* @__PURE__ */ m("div", { ref: r });
|
|
44
|
-
},
|
|
45
|
+
}, Y = ({ pageNumber: t }) => {
|
|
45
46
|
const { elementList: r } = f(), i = u(null), o = l(() => {
|
|
46
47
|
var e;
|
|
47
48
|
return (e = r[t]) == null ? void 0 : e.map((p, n) => p instanceof HTMLElement ? /* @__PURE__ */ m(a, { child: p }, n) : /* @__PURE__ */ m("div", { children: p }, n));
|
|
@@ -49,5 +50,5 @@ const a = ({ child: t }) => {
|
|
|
49
50
|
return o ? /* @__PURE__ */ m(s, { children: /* @__PURE__ */ m("div", { ref: i, "data-rp": `page-${t}-customElement`, children: o.map((e) => e) }) }) : null;
|
|
50
51
|
};
|
|
51
52
|
export {
|
|
52
|
-
|
|
53
|
+
Y as CustomElement
|
|
53
54
|
};
|
|
@@ -9,7 +9,8 @@ import "../../utils/appConsole.js";
|
|
|
9
9
|
import "../../contexts/InitialStateContext.js";
|
|
10
10
|
import "../../contexts/RPDocumentContext.js";
|
|
11
11
|
import "../../utils/hooks/useLoadPdf.js";
|
|
12
|
-
import "
|
|
12
|
+
import "@pdf-viewer/pdfium";
|
|
13
|
+
import "@pdf-viewer/pdfium/compat";
|
|
13
14
|
import "../../utils/getThumbnailViewport.js";
|
|
14
15
|
import "../../contexts/ConfigContext.js";
|
|
15
16
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -38,11 +39,16 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
38
39
|
import "../../utils/Queue.js";
|
|
39
40
|
import "../../utils/renderPage.js";
|
|
40
41
|
import "./TextLayer.js";
|
|
41
|
-
import "../../utils/highlight.js";
|
|
42
|
-
import "../../utils/charators.js";
|
|
43
42
|
import "../../contexts/SearchContext.js";
|
|
44
43
|
import "../../utils/hooks/useSearch.js";
|
|
44
|
+
import "../../utils/highlight.js";
|
|
45
|
+
import "../../utils/charators.js";
|
|
46
|
+
import "../../utils/selectionUtils.js";
|
|
47
|
+
import "../../utils/geometryCache.js";
|
|
45
48
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
+
import "../../contexts/TextSelectionContext.js";
|
|
50
|
+
import "../../utils/glyphHitTest.js";
|
|
51
|
+
import "../../contexts/SelectionModeContext.js";
|
|
46
52
|
import "./AnnotationLayer.js";
|
|
47
53
|
import "../../contexts/PrintContext.js";
|
|
48
54
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -67,7 +73,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
67
73
|
import "../../utils/hooks/useLicense.js";
|
|
68
74
|
import "../../utils/getElementPositionInPage.js";
|
|
69
75
|
import "../../utils/withRef.js";
|
|
70
|
-
const
|
|
76
|
+
const Et = h(({ widths: m, heights: s }) => {
|
|
71
77
|
const { focusedPage: r, totalPages: n } = l(), a = e(() => {
|
|
72
78
|
const t = [], o = Math.ceil(r / 2) * 2 - 1;
|
|
73
79
|
if (t.push(o), o + 1 <= n) {
|
|
@@ -95,5 +101,5 @@ const Rt = h(({ widths: m, heights: s }) => {
|
|
|
95
101
|
return /* @__PURE__ */ u("div", { style: { width: g, position: "relative" }, children: a.map((t, o) => /* @__PURE__ */ u(f, { style: p[o], pageNumber: t }, t)) });
|
|
96
102
|
});
|
|
97
103
|
export {
|
|
98
|
-
|
|
104
|
+
Et as DualPage
|
|
99
105
|
};
|
|
@@ -9,7 +9,8 @@ import "../../utils/appConsole.js";
|
|
|
9
9
|
import "../../contexts/InitialStateContext.js";
|
|
10
10
|
import "../../contexts/RPDocumentContext.js";
|
|
11
11
|
import "../../utils/hooks/useLoadPdf.js";
|
|
12
|
-
import "
|
|
12
|
+
import "@pdf-viewer/pdfium";
|
|
13
|
+
import "@pdf-viewer/pdfium/compat";
|
|
13
14
|
import "../../utils/getThumbnailViewport.js";
|
|
14
15
|
import "../../contexts/ConfigContext.js";
|
|
15
16
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -38,11 +39,16 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
38
39
|
import "../../utils/Queue.js";
|
|
39
40
|
import "../../utils/renderPage.js";
|
|
40
41
|
import "./TextLayer.js";
|
|
41
|
-
import "../../utils/highlight.js";
|
|
42
|
-
import "../../utils/charators.js";
|
|
43
42
|
import "../../contexts/SearchContext.js";
|
|
44
43
|
import "../../utils/hooks/useSearch.js";
|
|
44
|
+
import "../../utils/highlight.js";
|
|
45
|
+
import "../../utils/charators.js";
|
|
46
|
+
import "../../utils/selectionUtils.js";
|
|
47
|
+
import "../../utils/geometryCache.js";
|
|
45
48
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
+
import "../../contexts/TextSelectionContext.js";
|
|
50
|
+
import "../../utils/glyphHitTest.js";
|
|
51
|
+
import "../../contexts/SelectionModeContext.js";
|
|
46
52
|
import "./AnnotationLayer.js";
|
|
47
53
|
import "../../contexts/PrintContext.js";
|
|
48
54
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -67,7 +73,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
67
73
|
import "../../utils/hooks/useLicense.js";
|
|
68
74
|
import "../../utils/getElementPositionInPage.js";
|
|
69
75
|
import "../../utils/withRef.js";
|
|
70
|
-
const
|
|
76
|
+
const Qt = b(({ widths: o, heights: a }) => {
|
|
71
77
|
const { focusedPage: l, totalPages: m } = y(), i = f(() => {
|
|
72
78
|
const t = [];
|
|
73
79
|
if (l === 1)
|
|
@@ -127,5 +133,5 @@ const Et = b(({ widths: o, heights: a }) => {
|
|
|
127
133
|
return /* @__PURE__ */ h("div", { style: W, children: i.map((t, r) => /* @__PURE__ */ h(I, { style: x[r], pageNumber: t }, t)) });
|
|
128
134
|
});
|
|
129
135
|
export {
|
|
130
|
-
|
|
136
|
+
Qt as DualPageWithCover
|
|
131
137
|
};
|
|
@@ -12,7 +12,8 @@ import { usePagesRotateContext as D } from "../../contexts/PagesRotateContext.js
|
|
|
12
12
|
import { CustomElement as M } from "./CustomElement.js";
|
|
13
13
|
import { withRef as O } from "../../utils/withRef.js";
|
|
14
14
|
import "../../utils/hooks/useLoadPdf.js";
|
|
15
|
-
import "
|
|
15
|
+
import "@pdf-viewer/pdfium";
|
|
16
|
+
import "@pdf-viewer/pdfium/compat";
|
|
16
17
|
import "../../utils/types.js";
|
|
17
18
|
import "../../de_DE-a553b162.js";
|
|
18
19
|
import "../../utils/getThumbnailViewport.js";
|
|
@@ -43,11 +44,16 @@ import "../../utils/hooks/useDebounce.js";
|
|
|
43
44
|
import "../../contexts/SmoothScrollContext.js";
|
|
44
45
|
import "../../utils/getScrollDistance.js";
|
|
45
46
|
import "../../utils/calculatePage.js";
|
|
46
|
-
import "../../utils/highlight.js";
|
|
47
|
-
import "../../utils/charators.js";
|
|
48
47
|
import "../../contexts/SearchContext.js";
|
|
49
48
|
import "../../utils/hooks/useSearch.js";
|
|
49
|
+
import "../../utils/highlight.js";
|
|
50
|
+
import "../../utils/charators.js";
|
|
51
|
+
import "../../utils/selectionUtils.js";
|
|
52
|
+
import "../../utils/geometryCache.js";
|
|
50
53
|
import "../../utils/getWordPositionInPage.js";
|
|
54
|
+
import "../../contexts/TextSelectionContext.js";
|
|
55
|
+
import "../../utils/glyphHitTest.js";
|
|
56
|
+
import "../../contexts/SelectionModeContext.js";
|
|
51
57
|
import "../../contexts/PrintContext.js";
|
|
52
58
|
import "../../utils/hooks/usePrint.js";
|
|
53
59
|
import "../../utils/link_service.js";
|
|
@@ -70,7 +76,7 @@ const a = {
|
|
|
70
76
|
"rp-page-wrapper": "_rp-page-wrapper_ii91u_1",
|
|
71
77
|
"rp-page": "_rp-page_ii91u_1",
|
|
72
78
|
"rp-loader-wrapper": "_rp-loader-wrapper_ii91u_15"
|
|
73
|
-
},
|
|
79
|
+
}, ar = O((h, w) => {
|
|
74
80
|
const { pageNumber: t, style: x, ...L } = h, { pages: p } = j(), { pageRotate: s } = D(), { textLayer: $ } = T(), { currentZoom: m } = Z(), { LoaderImageComponent: n } = k(), i = g(p.get(t)), [v, c] = l(!1), u = g(null), [r, y] = l({
|
|
75
81
|
width: 0,
|
|
76
82
|
height: 0
|
|
@@ -112,7 +118,7 @@ const a = {
|
|
|
112
118
|
...x,
|
|
113
119
|
"--rp-rotate": `${e}deg`,
|
|
114
120
|
"--rp-page-rotate-translate": `${C}`,
|
|
115
|
-
"--user-unit":
|
|
121
|
+
"--user-unit": 1,
|
|
116
122
|
"--scale-factor": m,
|
|
117
123
|
"--total-scale-factor": "calc(var(--scale-factor) * var(--user-unit))"
|
|
118
124
|
},
|
|
@@ -139,5 +145,5 @@ const a = {
|
|
|
139
145
|
);
|
|
140
146
|
});
|
|
141
147
|
export {
|
|
142
|
-
|
|
148
|
+
ar as RPPage
|
|
143
149
|
};
|
|
@@ -9,7 +9,8 @@ import "../../utils/appConsole.js";
|
|
|
9
9
|
import "../../contexts/InitialStateContext.js";
|
|
10
10
|
import "../../contexts/RPDocumentContext.js";
|
|
11
11
|
import "../../utils/hooks/useLoadPdf.js";
|
|
12
|
-
import "
|
|
12
|
+
import "@pdf-viewer/pdfium";
|
|
13
|
+
import "@pdf-viewer/pdfium/compat";
|
|
13
14
|
import "../../utils/getThumbnailViewport.js";
|
|
14
15
|
import "../../contexts/ConfigContext.js";
|
|
15
16
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -38,11 +39,16 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
38
39
|
import "../../utils/Queue.js";
|
|
39
40
|
import "../../utils/renderPage.js";
|
|
40
41
|
import "./TextLayer.js";
|
|
41
|
-
import "../../utils/highlight.js";
|
|
42
|
-
import "../../utils/charators.js";
|
|
43
42
|
import "../../contexts/SearchContext.js";
|
|
44
43
|
import "../../utils/hooks/useSearch.js";
|
|
44
|
+
import "../../utils/highlight.js";
|
|
45
|
+
import "../../utils/charators.js";
|
|
46
|
+
import "../../utils/selectionUtils.js";
|
|
47
|
+
import "../../utils/geometryCache.js";
|
|
45
48
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
+
import "../../contexts/TextSelectionContext.js";
|
|
50
|
+
import "../../utils/glyphHitTest.js";
|
|
51
|
+
import "../../contexts/SelectionModeContext.js";
|
|
46
52
|
import "./AnnotationLayer.js";
|
|
47
53
|
import "../../contexts/PrintContext.js";
|
|
48
54
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -67,7 +73,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
67
73
|
import "../../utils/hooks/useLicense.js";
|
|
68
74
|
import "../../utils/getElementPositionInPage.js";
|
|
69
75
|
import "../../utils/withRef.js";
|
|
70
|
-
const
|
|
76
|
+
const Ao = ({ widths: t, heights: r }) => {
|
|
71
77
|
const { focusedPage: o } = n(), p = m(() => ({
|
|
72
78
|
position: "absolute",
|
|
73
79
|
width: t(o - 1),
|
|
@@ -85,5 +91,5 @@ const Ro = ({ widths: t, heights: r }) => {
|
|
|
85
91
|
);
|
|
86
92
|
};
|
|
87
93
|
export {
|
|
88
|
-
|
|
94
|
+
Ao as SinglePage
|
|
89
95
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useDocumentContext as
|
|
4
|
-
import { useHighlightContext as
|
|
5
|
-
import { normalizeSingleKeyword as
|
|
6
|
-
import { isMatchEntireWord as
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useState as $, useEffect as k, useMemo as y } from "react";
|
|
3
|
+
import { useDocumentContext as _ } from "../../contexts/RPDocumentContext.js";
|
|
4
|
+
import { useHighlightContext as L } from "../../contexts/HighlightContext.js";
|
|
5
|
+
import { normalizeSingleKeyword as M } from "./searchHighlight.js";
|
|
6
|
+
import { isMatchEntireWord as T } from "../../utils/highlight.js";
|
|
7
|
+
import { geometryCache as w } from "../../utils/geometryCache.js";
|
|
8
|
+
import { rectsForRange as G } from "../../utils/selectionUtils.js";
|
|
7
9
|
import "../../utils/hooks/useLoadPdf.js";
|
|
8
|
-
import "
|
|
10
|
+
import "@pdf-viewer/pdfium";
|
|
11
|
+
import "@pdf-viewer/pdfium/compat";
|
|
9
12
|
import "../../utils/types.js";
|
|
10
13
|
import "../../de_DE-a553b162.js";
|
|
11
14
|
import "../../utils/getThumbnailViewport.js";
|
|
@@ -18,181 +21,86 @@ import "../../utils/formatFileSize.js";
|
|
|
18
21
|
import "../../utils/hooks/useHighlight.js";
|
|
19
22
|
import "../../utils/charators.js";
|
|
20
23
|
import "../../utils/const.js";
|
|
21
|
-
const
|
|
22
|
-
"rp-text-highlight": "_rp-text-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!e || !C.current)
|
|
31
|
-
return;
|
|
32
|
-
const n = await e.page.getTextContent();
|
|
33
|
-
v(n);
|
|
34
|
-
})();
|
|
35
|
-
}, [R, w]);
|
|
36
|
-
const j = Q(() => d ? d.map((t) => {
|
|
37
|
-
var e, n;
|
|
38
|
-
return {
|
|
39
|
-
...Y(t.keyword, (e = t.options) == null ? void 0 : e.matchCase, (n = t.options) == null ? void 0 : n.wholeWords),
|
|
40
|
-
color: t.highlightColor
|
|
41
|
-
};
|
|
42
|
-
}) : [], [d]);
|
|
43
|
-
function D(t, e) {
|
|
44
|
-
if (!t)
|
|
45
|
-
return;
|
|
46
|
-
const n = `[data-rp="page-${e}-textLayer"]`;
|
|
47
|
-
return new Promise((r) => {
|
|
48
|
-
const s = t.querySelector(n);
|
|
49
|
-
if (s) {
|
|
50
|
-
r(s);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
new MutationObserver((i, c) => {
|
|
54
|
-
const l = t.querySelector(n);
|
|
55
|
-
l && (r(l), c.disconnect());
|
|
56
|
-
}).observe(t, { childList: !0, subtree: !0 });
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function K(t) {
|
|
60
|
-
return new Promise((e) => {
|
|
61
|
-
const n = t.querySelectorAll(
|
|
62
|
-
'[data-rp="rp-text-layer-text"]'
|
|
63
|
-
);
|
|
64
|
-
if (n.length) {
|
|
65
|
-
e(Array.from(n));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
new MutationObserver((s, o) => {
|
|
69
|
-
const i = t.querySelectorAll(
|
|
70
|
-
".rp-text-layer-text"
|
|
71
|
-
);
|
|
72
|
-
i.length && (e(Array.from(i)), o.disconnect());
|
|
73
|
-
}).observe(t, { childList: !0, subtree: !0 });
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
const W = (t, e, n, r) => {
|
|
77
|
-
var I;
|
|
78
|
-
const s = document.createRange(), o = n.firstChild;
|
|
79
|
-
if (!o || o.nodeType !== Node.TEXT_NODE)
|
|
80
|
-
return null;
|
|
81
|
-
const i = ((I = o.textContent) == null ? void 0 : I.length) ?? 0, c = r[0].charIdxInSpan, l = r.length === 1 ? c : r[r.length - 1].charIdxInSpan;
|
|
82
|
-
if (c > i || l + 1 > i)
|
|
83
|
-
return null;
|
|
84
|
-
s.setStart(o, c), s.setEnd(o, l + 1);
|
|
85
|
-
const h = document.createElement("span");
|
|
86
|
-
h.style.width = "auto", s.surroundContents(h);
|
|
87
|
-
const a = h.getBoundingClientRect(), f = t.getBoundingClientRect(), m = f.height, p = f.width, x = 100 * (a.left - f.left) / p, E = 100 * (a.top - f.top) / m, S = 100 * a.height / m, g = 100 * a.width / p;
|
|
88
|
-
return tt(h), {
|
|
89
|
-
keywordStr: e,
|
|
90
|
-
left: x,
|
|
91
|
-
top: E,
|
|
92
|
-
height: S,
|
|
93
|
-
width: g,
|
|
94
|
-
pageHeight: m,
|
|
95
|
-
pageWidth: p
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
async function z(t, e) {
|
|
99
|
-
const n = await D(P, t);
|
|
100
|
-
if (!n)
|
|
24
|
+
const C = {
|
|
25
|
+
"rp-text-highlight-layer": "_rp-text-highlight-layer_1gqf0_1",
|
|
26
|
+
"rp-text-highlight": "_rp-text-highlight_1gqf0_1"
|
|
27
|
+
}, Z = ({ pageNumber: n, viewport: p }) => {
|
|
28
|
+
const i = n - 1, { pages: h } = _(), { highlightKeywords: s } = L(), [r, m] = $(null);
|
|
29
|
+
k(() => {
|
|
30
|
+
const e = w.get(i);
|
|
31
|
+
if (e) {
|
|
32
|
+
m(e);
|
|
101
33
|
return;
|
|
102
|
-
const r = await K(n);
|
|
103
|
-
if (r.length) {
|
|
104
|
-
const s = r.map((i) => i.tagName === "BR" ? " " : i.textContent).reduce(
|
|
105
|
-
(i, c, l) => i.concat(
|
|
106
|
-
c.split("").map((h, a) => ({
|
|
107
|
-
char: h,
|
|
108
|
-
charIdxInSpan: a,
|
|
109
|
-
spanIdx: l
|
|
110
|
-
}))
|
|
111
|
-
),
|
|
112
|
-
[
|
|
113
|
-
{
|
|
114
|
-
char: "",
|
|
115
|
-
charIdxInSpan: 0,
|
|
116
|
-
spanIdx: 0
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
).slice(1), o = B(n, e, r, s);
|
|
120
|
-
b(o);
|
|
121
34
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
35
|
+
const o = h.get(n);
|
|
36
|
+
if (!o)
|
|
37
|
+
return;
|
|
38
|
+
const t = o.page.getViewport({ scale: (p.width > 0, 1) }), g = o.page.getPageGeometry(t);
|
|
39
|
+
w.set(i, g), m(g);
|
|
40
|
+
}, [h, n, i, p]);
|
|
41
|
+
const c = y(() => s ? s.map((e) => {
|
|
42
|
+
var o, t;
|
|
43
|
+
return {
|
|
44
|
+
...M(e.keyword, (o = e.options) == null ? void 0 : o.matchCase, (t = e.options) == null ? void 0 : t.wholeWords),
|
|
45
|
+
color: e.highlightColor
|
|
46
|
+
};
|
|
47
|
+
}) : [], [s]), a = y(() => {
|
|
48
|
+
if (!r || !c.length)
|
|
126
49
|
return [];
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
for (; (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const I = g.indexes.reduce(
|
|
148
|
-
(u, y) => (u[y.spanIdx] = (u[y.spanIdx] || []).concat([y]), u),
|
|
149
|
-
{}
|
|
150
|
-
);
|
|
151
|
-
for (const u of Object.values(I))
|
|
152
|
-
if (u.length !== 1 || u[0].char.trim() !== "") {
|
|
153
|
-
const y = u, F = n[y[0].spanIdx], T = W(
|
|
154
|
-
t,
|
|
155
|
-
m,
|
|
156
|
-
F,
|
|
157
|
-
y
|
|
158
|
-
);
|
|
159
|
-
if (T) {
|
|
160
|
-
const { left: X, top: G } = T;
|
|
161
|
-
if (o.find((L) => L.left === X && L.top === G))
|
|
162
|
-
continue;
|
|
163
|
-
o.push({ ...T, highlightColor: g.color });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}), o.sort(Z), o;
|
|
168
|
-
};
|
|
169
|
-
return H(() => {
|
|
170
|
-
(async () => {
|
|
171
|
-
if (!d || d.length === 0) {
|
|
172
|
-
b([]);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
try {
|
|
176
|
-
await z(w, d);
|
|
177
|
-
} catch (e) {
|
|
178
|
-
console.error(e);
|
|
179
|
-
}
|
|
180
|
-
})();
|
|
181
|
-
}, [M, d, w, $, O]), /* @__PURE__ */ k(J, { children: /* @__PURE__ */ k("div", { ref: C, "data-rp": `page-${w}-textHighlightLayer`, children: _.map((t, e) => /* @__PURE__ */ k(
|
|
182
|
-
"div",
|
|
183
|
-
{
|
|
184
|
-
className: nt["rp-text-highlight"],
|
|
185
|
-
style: {
|
|
186
|
-
top: `${t.top}%`,
|
|
187
|
-
left: `${t.left}%`,
|
|
188
|
-
width: `${t.width}%`,
|
|
189
|
-
height: `${t.height}%`,
|
|
190
|
-
backgroundColor: t.highlightColor
|
|
50
|
+
if (r.totalCharCount === 0)
|
|
51
|
+
return [];
|
|
52
|
+
const e = r.runs.map((t) => t.text).join(""), o = [];
|
|
53
|
+
for (const t of c) {
|
|
54
|
+
if (!t.keyword.trim())
|
|
55
|
+
continue;
|
|
56
|
+
const g = t.regExp.flags.indexOf("g") === -1 ? new RegExp(t.regExp, `${t.regExp.flags}g`) : t.regExp;
|
|
57
|
+
let l;
|
|
58
|
+
for (; (l = g.exec(e)) !== null; ) {
|
|
59
|
+
if (t.wholeWords && !T(e, l.index, l[0].length))
|
|
60
|
+
continue;
|
|
61
|
+
const x = E(r, l.index), f = E(r, l.index + l[0].length - 1);
|
|
62
|
+
if (x >= 0 && f >= 0) {
|
|
63
|
+
const u = G(r, x, f);
|
|
64
|
+
u.length > 0 && o.push({
|
|
65
|
+
rects: u,
|
|
66
|
+
color: t.color ?? "rgba(255, 235, 59, 0.4)",
|
|
67
|
+
keyword: t.keyword
|
|
68
|
+
});
|
|
69
|
+
}
|
|
191
70
|
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
71
|
+
}
|
|
72
|
+
return o;
|
|
73
|
+
}, [r, c]);
|
|
74
|
+
return a.length === 0 ? null : /* @__PURE__ */ d("div", { "data-rp": `page-${n}-textHighlightLayer`, className: C["rp-text-highlight-layer"], children: a.map(
|
|
75
|
+
(e, o) => e.rects.map((t, g) => /* @__PURE__ */ d(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
className: C["rp-text-highlight"],
|
|
79
|
+
style: {
|
|
80
|
+
position: "absolute",
|
|
81
|
+
left: `${t.x}px`,
|
|
82
|
+
top: `${t.y}px`,
|
|
83
|
+
width: `${t.width}px`,
|
|
84
|
+
height: `${t.height}px`,
|
|
85
|
+
backgroundColor: e.color
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
`${o}-${g}`
|
|
89
|
+
))
|
|
90
|
+
) });
|
|
195
91
|
};
|
|
92
|
+
function E(n, p) {
|
|
93
|
+
let i = 0, h = 0;
|
|
94
|
+
for (const s of n.runs) {
|
|
95
|
+
const r = s.text.length, m = s.glyphs.length;
|
|
96
|
+
if (p < i + r) {
|
|
97
|
+
const c = p - i;
|
|
98
|
+
return h + Math.min(c, m - 1);
|
|
99
|
+
}
|
|
100
|
+
i += r, h += m;
|
|
101
|
+
}
|
|
102
|
+
return Math.max(0, h - 1);
|
|
103
|
+
}
|
|
196
104
|
export {
|
|
197
|
-
|
|
105
|
+
Z as TextHighlightLayer
|
|
198
106
|
};
|