@react-pdf-kit/viewer 0.0.0-experimental.9 → 0.0.0-legacy.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Combination-479e39c6.js → Combination-17ab8af1.js} +184 -187
- package/dist/RPLayout.module-b4b23e29.js +14 -0
- package/dist/assets/style.css +1 -1
- package/dist/assets/style.js +15 -15
- package/dist/components/RPConfig.js +7 -16
- package/dist/components/RPController.js +21 -26
- package/dist/components/RPDropFileZone.js +27 -35
- package/dist/components/RPPages.js +352 -361
- package/dist/components/RPProvider.js +20 -24
- package/dist/components/layout/LayoutContainer.js +1 -1
- package/dist/components/layout/LayoutWrapper.js +1 -1
- package/dist/components/layout/RPDefaultLayout.js +6 -11
- package/dist/components/layout/RPLayout.js +21 -27
- package/dist/components/layout/WrapperLayout.js +9 -10
- package/dist/components/layout/sidebar/RPSidebar.js +3 -4
- package/dist/components/layout/sidebar/Thumbnail.js +3 -4
- package/dist/components/layout/sidebar/Thumbnails.js +3 -4
- package/dist/components/layout/toolbar/DocumentDialog.js +6 -7
- package/dist/components/layout/toolbar/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +5 -6
- package/dist/components/layout/toolbar/FileUploadTool.js +5 -6
- package/dist/components/layout/toolbar/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/MenuItem.js +2 -2
- package/dist/components/layout/toolbar/MenuSeparator.js +2 -2
- package/dist/components/layout/toolbar/MostPageTool.js +5 -6
- package/dist/components/layout/toolbar/OtherTool.js +5 -6
- package/dist/components/layout/toolbar/Paginate.js +3 -4
- package/dist/components/layout/toolbar/PrintTool.js +5 -6
- package/dist/components/layout/toolbar/RPMenuItem.js +2 -2
- package/dist/components/layout/toolbar/RPMoreOptions.js +5 -6
- package/dist/components/layout/toolbar/RPToolbar.js +5 -8
- package/dist/components/layout/toolbar/RPToolbarEnd.js +5 -6
- package/dist/components/layout/toolbar/RotateTool.js +5 -6
- package/dist/components/layout/toolbar/ScrollModeTool.js +2 -2
- package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -6
- package/dist/components/layout/toolbar/SearchTool.js +5 -8
- package/dist/components/layout/toolbar/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/ThumbnailTool.js +3 -4
- package/dist/components/layout/toolbar/ToolbarCustom.js +3 -4
- package/dist/components/layout/toolbar/ToolbarDefault.js +5 -8
- package/dist/components/layout/toolbar/ToolbarLayout.js +5 -8
- package/dist/components/layout/toolbar/ViewModeTool.js +2 -2
- package/dist/components/layout/toolbar/ZoomTool.js +5 -6
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -5
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +7 -13
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +3 -4
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +3 -4
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +7 -13
- package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -4
- package/dist/components/layout/toolbar/tools/LastPageTool.js +7 -13
- package/dist/components/layout/toolbar/tools/NextPageTool.js +3 -4
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +3 -4
- package/dist/components/layout/toolbar/tools/PrintTool.js +3 -4
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +3 -4
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +3 -4
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +3 -4
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +3 -4
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +15 -16
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +3 -4
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +5 -8
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +3 -4
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +5 -6
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +5 -6
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +5 -6
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +5 -6
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +5 -6
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +2 -2
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +2 -2
- package/dist/components/page/AnnotationLayer.js +72 -69
- package/dist/components/page/CanvasLayer.js +3 -4
- package/dist/components/page/CustomElement.js +3 -4
- package/dist/components/page/DualPage.js +5 -11
- package/dist/components/page/DualPageWithCover.js +5 -11
- package/dist/components/page/RPPage.js +6 -12
- package/dist/components/page/SinglePage.js +5 -11
- package/dist/components/page/TextHighlightLayer.js +178 -86
- package/dist/components/page/TextLayer.js +170 -125
- package/dist/components/ui/DropDown.js +2 -2
- package/dist/components/ui/LoadingIndicator.js +7 -8
- package/dist/contexts/ConfigContext.js +4 -5
- package/dist/contexts/DimensionPagesContext.js +5 -6
- package/dist/contexts/DropFileZoneContext.js +4 -5
- package/dist/contexts/ElementPageContext.js +5 -6
- package/dist/contexts/FileInputContext.js +5 -6
- package/dist/contexts/HighlightContext.js +7 -10
- package/dist/contexts/LicenseContext.js +6 -8
- package/dist/contexts/PagesRotateContext.js +5 -6
- package/dist/contexts/PaginationContext.js +5 -6
- package/dist/contexts/PrintContext.js +16 -17
- package/dist/contexts/RPDocumentContext.js +13 -14
- package/dist/contexts/RenderQueueProvider.js +5 -6
- package/dist/contexts/RotationContext.js +8 -9
- package/dist/contexts/SearchContext.js +5 -8
- package/dist/contexts/ThumbnailsContext.js +4 -5
- package/dist/contexts/ZoomContext.js +5 -6
- package/dist/{index-535ad364.js → index-11f3cd64.js} +1 -1
- package/dist/main.js +115 -120
- package/dist/polyfills.js +8166 -0
- 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/main.d.ts +1 -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/useFlickerSelectText.d.ts +1 -0
- 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 +1 -5
- package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
- package/dist/types/utils/hooks/useTextSelection.d.ts +3 -12
- package/dist/types/utils/link_service.d.ts +3 -2
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +8 -9
- package/dist/utils/highlight.js +158 -184
- package/dist/utils/hooks/useCopyText.js +22 -60
- package/dist/utils/hooks/useFileDownload.js +5 -6
- package/dist/utils/hooks/useFlickerSelectText.js +25 -0
- package/dist/utils/hooks/useHighlight.js +33 -35
- package/dist/utils/hooks/useLicense.js +29 -38
- package/dist/utils/hooks/useLoadPdf.js +80 -103
- package/dist/utils/hooks/useLoadWorker.js +14 -4
- package/dist/utils/hooks/usePageRotateContext.js +7 -8
- package/dist/utils/hooks/usePaginate.js +3 -4
- package/dist/utils/hooks/usePinch.js +10 -11
- package/dist/utils/hooks/usePresentPage.js +3 -4
- package/dist/utils/hooks/usePrint.js +78 -74
- package/dist/utils/hooks/useRotate.js +3 -4
- package/dist/utils/hooks/useScrollToPage.js +3 -4
- package/dist/utils/hooks/useSearch.js +15 -18
- package/dist/utils/hooks/useTextSelection.js +73 -2
- package/dist/utils/hooks/useThumbnail.js +17 -18
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
- package/dist/utils/hooks/useWatermark.js +6 -8
- package/dist/utils/link_service.js +19 -18
- package/dist/utils/renderPage.js +1 -1
- package/dist/utils/types.js +3 -3
- package/package.json +14 -3
- package/dist/RPLayout.module-7766e0b4.js +0 -14
- package/dist/contexts/LayoutDropFileZoneContext.js +0 -11
- package/dist/contexts/TextSelectionContext.js +0 -191
- package/dist/types/contexts/LayoutDropFileZoneContext.d.ts +0 -9
- package/dist/types/contexts/TextSelectionContext.d.ts +0 -14
- package/dist/types/utils/geometryCache.d.ts +0 -15
- package/dist/types/utils/glyphHitTest.d.ts +0 -12
- package/dist/types/utils/hooks/useDropFileZone.d.ts +0 -5
- package/dist/types/utils/selectionUtils.d.ts +0 -30
- package/dist/utils/geometryCache.js +0 -32
- package/dist/utils/glyphHitTest.js +0 -29
- package/dist/utils/hooks/useDropFileZone.js +0 -12
- package/dist/utils/selectionUtils.js +0 -96
|
@@ -7,8 +7,7 @@ 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 "
|
|
11
|
-
import "@pdf-viewer/pdfium/compat";
|
|
10
|
+
import "pdfjs-dist";
|
|
12
11
|
import "../../utils/getThumbnailViewport.js";
|
|
13
12
|
import "../../contexts/ConfigContext.js";
|
|
14
13
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -42,7 +41,7 @@ const a = ({ child: t }) => {
|
|
|
42
41
|
(o = r.current) == null || o.removeChild(t);
|
|
43
42
|
};
|
|
44
43
|
}, [t]), /* @__PURE__ */ m("div", { ref: r });
|
|
45
|
-
},
|
|
44
|
+
}, X = ({ pageNumber: t }) => {
|
|
46
45
|
const { elementList: r } = f(), i = u(null), o = l(() => {
|
|
47
46
|
var e;
|
|
48
47
|
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));
|
|
@@ -50,5 +49,5 @@ const a = ({ child: t }) => {
|
|
|
50
49
|
return o ? /* @__PURE__ */ m(s, { children: /* @__PURE__ */ m("div", { ref: i, "data-rp": `page-${t}-customElement`, children: o.map((e) => e) }) }) : null;
|
|
51
50
|
};
|
|
52
51
|
export {
|
|
53
|
-
|
|
52
|
+
X as CustomElement
|
|
54
53
|
};
|
|
@@ -9,8 +9,7 @@ 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 "
|
|
13
|
-
import "@pdf-viewer/pdfium/compat";
|
|
12
|
+
import "pdfjs-dist";
|
|
14
13
|
import "../../utils/getThumbnailViewport.js";
|
|
15
14
|
import "../../contexts/ConfigContext.js";
|
|
16
15
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -39,16 +38,11 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
39
38
|
import "../../utils/Queue.js";
|
|
40
39
|
import "../../utils/renderPage.js";
|
|
41
40
|
import "./TextLayer.js";
|
|
42
|
-
import "../../contexts/SearchContext.js";
|
|
43
|
-
import "../../utils/hooks/useSearch.js";
|
|
44
41
|
import "../../utils/highlight.js";
|
|
45
42
|
import "../../utils/charators.js";
|
|
46
|
-
import "../../
|
|
47
|
-
import "../../utils/
|
|
43
|
+
import "../../contexts/SearchContext.js";
|
|
44
|
+
import "../../utils/hooks/useSearch.js";
|
|
48
45
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
-
import "../../contexts/TextSelectionContext.js";
|
|
50
|
-
import "../../utils/glyphHitTest.js";
|
|
51
|
-
import "../../contexts/SelectionModeContext.js";
|
|
52
46
|
import "./AnnotationLayer.js";
|
|
53
47
|
import "../../contexts/PrintContext.js";
|
|
54
48
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -73,7 +67,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
73
67
|
import "../../utils/hooks/useLicense.js";
|
|
74
68
|
import "../../utils/getElementPositionInPage.js";
|
|
75
69
|
import "../../utils/withRef.js";
|
|
76
|
-
const
|
|
70
|
+
const Rt = h(({ widths: m, heights: s }) => {
|
|
77
71
|
const { focusedPage: r, totalPages: n } = l(), a = e(() => {
|
|
78
72
|
const t = [], o = Math.ceil(r / 2) * 2 - 1;
|
|
79
73
|
if (t.push(o), o + 1 <= n) {
|
|
@@ -101,5 +95,5 @@ const Et = h(({ widths: m, heights: s }) => {
|
|
|
101
95
|
return /* @__PURE__ */ u("div", { style: { width: g, position: "relative" }, children: a.map((t, o) => /* @__PURE__ */ u(f, { style: p[o], pageNumber: t }, t)) });
|
|
102
96
|
});
|
|
103
97
|
export {
|
|
104
|
-
|
|
98
|
+
Rt as DualPage
|
|
105
99
|
};
|
|
@@ -9,8 +9,7 @@ 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 "
|
|
13
|
-
import "@pdf-viewer/pdfium/compat";
|
|
12
|
+
import "pdfjs-dist";
|
|
14
13
|
import "../../utils/getThumbnailViewport.js";
|
|
15
14
|
import "../../contexts/ConfigContext.js";
|
|
16
15
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -39,16 +38,11 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
39
38
|
import "../../utils/Queue.js";
|
|
40
39
|
import "../../utils/renderPage.js";
|
|
41
40
|
import "./TextLayer.js";
|
|
42
|
-
import "../../contexts/SearchContext.js";
|
|
43
|
-
import "../../utils/hooks/useSearch.js";
|
|
44
41
|
import "../../utils/highlight.js";
|
|
45
42
|
import "../../utils/charators.js";
|
|
46
|
-
import "../../
|
|
47
|
-
import "../../utils/
|
|
43
|
+
import "../../contexts/SearchContext.js";
|
|
44
|
+
import "../../utils/hooks/useSearch.js";
|
|
48
45
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
-
import "../../contexts/TextSelectionContext.js";
|
|
50
|
-
import "../../utils/glyphHitTest.js";
|
|
51
|
-
import "../../contexts/SelectionModeContext.js";
|
|
52
46
|
import "./AnnotationLayer.js";
|
|
53
47
|
import "../../contexts/PrintContext.js";
|
|
54
48
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -73,7 +67,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
73
67
|
import "../../utils/hooks/useLicense.js";
|
|
74
68
|
import "../../utils/getElementPositionInPage.js";
|
|
75
69
|
import "../../utils/withRef.js";
|
|
76
|
-
const
|
|
70
|
+
const Et = b(({ widths: o, heights: a }) => {
|
|
77
71
|
const { focusedPage: l, totalPages: m } = y(), i = f(() => {
|
|
78
72
|
const t = [];
|
|
79
73
|
if (l === 1)
|
|
@@ -133,5 +127,5 @@ const Qt = b(({ widths: o, heights: a }) => {
|
|
|
133
127
|
return /* @__PURE__ */ h("div", { style: W, children: i.map((t, r) => /* @__PURE__ */ h(I, { style: x[r], pageNumber: t }, t)) });
|
|
134
128
|
});
|
|
135
129
|
export {
|
|
136
|
-
|
|
130
|
+
Et as DualPageWithCover
|
|
137
131
|
};
|
|
@@ -12,8 +12,7 @@ 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 "
|
|
16
|
-
import "@pdf-viewer/pdfium/compat";
|
|
15
|
+
import "pdfjs-dist";
|
|
17
16
|
import "../../utils/types.js";
|
|
18
17
|
import "../../de_DE-a553b162.js";
|
|
19
18
|
import "../../utils/getThumbnailViewport.js";
|
|
@@ -44,16 +43,11 @@ import "../../utils/hooks/useDebounce.js";
|
|
|
44
43
|
import "../../contexts/SmoothScrollContext.js";
|
|
45
44
|
import "../../utils/getScrollDistance.js";
|
|
46
45
|
import "../../utils/calculatePage.js";
|
|
47
|
-
import "../../contexts/SearchContext.js";
|
|
48
|
-
import "../../utils/hooks/useSearch.js";
|
|
49
46
|
import "../../utils/highlight.js";
|
|
50
47
|
import "../../utils/charators.js";
|
|
51
|
-
import "../../
|
|
52
|
-
import "../../utils/
|
|
48
|
+
import "../../contexts/SearchContext.js";
|
|
49
|
+
import "../../utils/hooks/useSearch.js";
|
|
53
50
|
import "../../utils/getWordPositionInPage.js";
|
|
54
|
-
import "../../contexts/TextSelectionContext.js";
|
|
55
|
-
import "../../utils/glyphHitTest.js";
|
|
56
|
-
import "../../contexts/SelectionModeContext.js";
|
|
57
51
|
import "../../contexts/PrintContext.js";
|
|
58
52
|
import "../../utils/hooks/usePrint.js";
|
|
59
53
|
import "../../utils/link_service.js";
|
|
@@ -76,7 +70,7 @@ const a = {
|
|
|
76
70
|
"rp-page-wrapper": "_rp-page-wrapper_ii91u_1",
|
|
77
71
|
"rp-page": "_rp-page_ii91u_1",
|
|
78
72
|
"rp-loader-wrapper": "_rp-loader-wrapper_ii91u_15"
|
|
79
|
-
},
|
|
73
|
+
}, rr = O((h, w) => {
|
|
80
74
|
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({
|
|
81
75
|
width: 0,
|
|
82
76
|
height: 0
|
|
@@ -118,7 +112,7 @@ const a = {
|
|
|
118
112
|
...x,
|
|
119
113
|
"--rp-rotate": `${e}deg`,
|
|
120
114
|
"--rp-page-rotate-translate": `${C}`,
|
|
121
|
-
"--user-unit": 1,
|
|
115
|
+
"--user-unit": r.userUnit || 1,
|
|
122
116
|
"--scale-factor": m,
|
|
123
117
|
"--total-scale-factor": "calc(var(--scale-factor) * var(--user-unit))"
|
|
124
118
|
},
|
|
@@ -145,5 +139,5 @@ const a = {
|
|
|
145
139
|
);
|
|
146
140
|
});
|
|
147
141
|
export {
|
|
148
|
-
|
|
142
|
+
rr as RPPage
|
|
149
143
|
};
|
|
@@ -9,8 +9,7 @@ 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 "
|
|
13
|
-
import "@pdf-viewer/pdfium/compat";
|
|
12
|
+
import "pdfjs-dist";
|
|
14
13
|
import "../../utils/getThumbnailViewport.js";
|
|
15
14
|
import "../../contexts/ConfigContext.js";
|
|
16
15
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -39,16 +38,11 @@ import "../../contexts/RenderQueueProvider.js";
|
|
|
39
38
|
import "../../utils/Queue.js";
|
|
40
39
|
import "../../utils/renderPage.js";
|
|
41
40
|
import "./TextLayer.js";
|
|
42
|
-
import "../../contexts/SearchContext.js";
|
|
43
|
-
import "../../utils/hooks/useSearch.js";
|
|
44
41
|
import "../../utils/highlight.js";
|
|
45
42
|
import "../../utils/charators.js";
|
|
46
|
-
import "../../
|
|
47
|
-
import "../../utils/
|
|
43
|
+
import "../../contexts/SearchContext.js";
|
|
44
|
+
import "../../utils/hooks/useSearch.js";
|
|
48
45
|
import "../../utils/getWordPositionInPage.js";
|
|
49
|
-
import "../../contexts/TextSelectionContext.js";
|
|
50
|
-
import "../../utils/glyphHitTest.js";
|
|
51
|
-
import "../../contexts/SelectionModeContext.js";
|
|
52
46
|
import "./AnnotationLayer.js";
|
|
53
47
|
import "../../contexts/PrintContext.js";
|
|
54
48
|
import "../../utils/hooks/usePrint.js";
|
|
@@ -73,7 +67,7 @@ import "../../contexts/LicenseContext.js";
|
|
|
73
67
|
import "../../utils/hooks/useLicense.js";
|
|
74
68
|
import "../../utils/getElementPositionInPage.js";
|
|
75
69
|
import "../../utils/withRef.js";
|
|
76
|
-
const
|
|
70
|
+
const Ro = ({ widths: t, heights: r }) => {
|
|
77
71
|
const { focusedPage: o } = n(), p = m(() => ({
|
|
78
72
|
position: "absolute",
|
|
79
73
|
width: t(o - 1),
|
|
@@ -91,5 +85,5 @@ const Ao = ({ widths: t, heights: r }) => {
|
|
|
91
85
|
);
|
|
92
86
|
};
|
|
93
87
|
export {
|
|
94
|
-
|
|
88
|
+
Ro as SinglePage
|
|
95
89
|
};
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useDocumentContext as
|
|
4
|
-
import { useHighlightContext as
|
|
5
|
-
import { normalizeSingleKeyword as
|
|
6
|
-
import { isMatchEntireWord as
|
|
7
|
-
import { geometryCache as w } from "../../utils/geometryCache.js";
|
|
8
|
-
import { rectsForRange as G } from "../../utils/selectionUtils.js";
|
|
1
|
+
import { jsx as k, Fragment as J } from "react/jsx-runtime";
|
|
2
|
+
import { useState as A, useRef as N, useEffect as H, useMemo as Q } from "react";
|
|
3
|
+
import { useDocumentContext as U } from "../../contexts/RPDocumentContext.js";
|
|
4
|
+
import { useHighlightContext as V } from "../../contexts/HighlightContext.js";
|
|
5
|
+
import { normalizeSingleKeyword as Y, sortHighlightPosition as Z, unwrap as tt } from "./searchHighlight.js";
|
|
6
|
+
import { isMatchEntireWord as et } from "../../utils/highlight.js";
|
|
9
7
|
import "../../utils/hooks/useLoadPdf.js";
|
|
10
|
-
import "
|
|
11
|
-
import "@pdf-viewer/pdfium/compat";
|
|
8
|
+
import "pdfjs-dist";
|
|
12
9
|
import "../../utils/types.js";
|
|
13
10
|
import "../../de_DE-a553b162.js";
|
|
14
11
|
import "../../utils/getThumbnailViewport.js";
|
|
@@ -21,86 +18,181 @@ import "../../utils/formatFileSize.js";
|
|
|
21
18
|
import "../../utils/hooks/useHighlight.js";
|
|
22
19
|
import "../../utils/charators.js";
|
|
23
20
|
import "../../utils/const.js";
|
|
24
|
-
const
|
|
25
|
-
"rp-text-highlight
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const c = y(() => s ? s.map((e) => {
|
|
42
|
-
var o, t;
|
|
21
|
+
const nt = {
|
|
22
|
+
"rp-text-highlight": "_rp-text-highlight_jdkf8_1"
|
|
23
|
+
}, Tt = ({ pageNumber: w, viewport: O }) => {
|
|
24
|
+
const [$, v] = A(), { pages: R } = U(), { highlightKeywords: d } = V(), M = !0, C = N(null), [P, q] = A(null), [_, b] = A([]);
|
|
25
|
+
H(() => {
|
|
26
|
+
C.current && q(C.current.parentElement);
|
|
27
|
+
}, [C]), H(() => {
|
|
28
|
+
(async () => {
|
|
29
|
+
const e = R.get(w);
|
|
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;
|
|
43
38
|
return {
|
|
44
|
-
...
|
|
45
|
-
color:
|
|
39
|
+
...Y(t.keyword, (e = t.options) == null ? void 0 : e.matchCase, (n = t.options) == null ? void 0 : n.wholeWords),
|
|
40
|
+
color: t.highlightColor
|
|
46
41
|
};
|
|
47
|
-
}) : [], [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
}
|
|
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;
|
|
70
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)
|
|
101
|
+
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);
|
|
71
121
|
}
|
|
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
|
-
) });
|
|
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
122
|
}
|
|
102
|
-
|
|
103
|
-
|
|
123
|
+
const B = (t, e, n, r) => {
|
|
124
|
+
const s = e.length;
|
|
125
|
+
if (!r.length || !s)
|
|
126
|
+
return [];
|
|
127
|
+
const o = [], i = r.map((c) => c.char).join("");
|
|
128
|
+
return j.forEach((c) => {
|
|
129
|
+
const { keyword: l, regExp: h, wholeWords: a, color: f } = c, m = l;
|
|
130
|
+
if (!m.trim())
|
|
131
|
+
return;
|
|
132
|
+
const p = h.flags.indexOf("g") === -1 ? new RegExp(h, `${h.flags}g`) : h;
|
|
133
|
+
let x;
|
|
134
|
+
const E = [];
|
|
135
|
+
for (; (x = p.exec(i)) !== null; )
|
|
136
|
+
a && !et(i, x.index, x[0].length) || E.push({
|
|
137
|
+
keyword: p,
|
|
138
|
+
startIndex: x.index,
|
|
139
|
+
endIndex: p.lastIndex
|
|
140
|
+
});
|
|
141
|
+
const S = E.map((g) => ({
|
|
142
|
+
keyword: g.keyword,
|
|
143
|
+
indexes: r.slice(g.startIndex, g.endIndex),
|
|
144
|
+
color: f
|
|
145
|
+
}));
|
|
146
|
+
for (const g of S) {
|
|
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
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
e
|
|
194
|
+
)) }) });
|
|
195
|
+
};
|
|
104
196
|
export {
|
|
105
|
-
|
|
197
|
+
Tt as TextHighlightLayer
|
|
106
198
|
};
|