@react-pdf-kit/viewer 2.0.0-beta.0 → 2.0.0-beta.10
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-54a77a7a.js +701 -0
- package/dist/MostPageTool.module-13578ad6.js +6 -0
- package/dist/OtherTool.module-a4be5f1f.js +6 -0
- package/dist/Paginate.module-206a7d7d.js +8 -0
- package/dist/PaginationContext-9217cab4.js +201 -0
- package/dist/{LayoutWrapper-a871c161.js → RPLayout.module-967bf4bc.js} +3 -9
- package/dist/RPToolbar.module-27d7fe77.js +10 -0
- package/dist/{RotateTool.module-03987eba.js → RotateTool.module-67946714.js} +1 -1
- package/dist/SearchTool.module-99f60dc7.js +16 -0
- package/dist/ToolbarLayout.module-1fee0a18.js +11 -0
- package/dist/{ZoomTool.module-6c5eabbb.js → ZoomTool.module-7082af8c.js} +1 -1
- package/dist/assets/style.css +1 -0
- package/dist/assets/style.js +75 -0
- package/dist/components/RPConfig.js +14 -1489
- package/dist/components/RPController.js +109 -66
- package/dist/components/RPDropFileZone.js +26 -12
- package/dist/components/RPPages.js +991 -58
- package/dist/components/RPProvider.js +107 -19
- package/dist/components/RPTheme.js +6 -5
- package/dist/components/icons/DualPageIcon.js +6 -6
- package/dist/components/icons/LoaderIcon.js +1 -1
- package/dist/components/icons/SinglePageIcon.js +6 -6
- package/dist/components/layout/Container.js +1 -1
- package/dist/components/layout/LayoutContainer.js +32 -57
- package/dist/components/layout/LayoutWrapper.js +9 -4
- package/dist/components/layout/RPDefaultLayout.js +214 -14
- package/dist/components/layout/RPLayout.js +143 -41
- package/dist/components/layout/WrapperLayout.js +22 -9
- package/dist/components/layout/sidebar/RPSidebar.js +110 -13
- package/dist/components/layout/sidebar/RPSplitter.js +1 -1
- package/dist/components/layout/sidebar/Thumbnail.js +129 -52
- package/dist/components/layout/sidebar/Thumbnails.js +75 -6
- package/dist/components/layout/toolbar/DarkModeTool.js +24 -13
- package/dist/components/layout/toolbar/DocumentDialog.js +311 -56
- package/dist/components/layout/toolbar/DocumentProperties.js +21 -8
- package/dist/components/layout/toolbar/FileDownloadTool.js +48 -13
- package/dist/components/layout/toolbar/FileUploadTool.js +34 -10
- package/dist/components/layout/toolbar/FullScreenTool.js +43 -28
- package/dist/components/layout/toolbar/MenuItem.js +15 -8
- package/dist/components/layout/toolbar/MenuSeparator.js +11 -4
- package/dist/components/layout/toolbar/MostPageTool.js +72 -51
- package/dist/components/layout/toolbar/OtherTool.js +188 -22
- package/dist/components/layout/toolbar/Paginate.js +136 -17
- package/dist/components/layout/toolbar/PrintTool.js +70 -13
- package/dist/components/layout/toolbar/PropertyItem.js +1 -1
- package/dist/components/layout/toolbar/RPMenuItem.js +23 -13
- package/dist/components/layout/toolbar/RPMoreOptions.js +119 -47
- package/dist/components/layout/toolbar/RPToolbar.js +148 -8
- package/dist/components/layout/toolbar/RPToolbarEnd.js +118 -7
- package/dist/components/layout/toolbar/RotateTool.js +42 -18
- package/dist/components/layout/toolbar/ScrollModeTool.js +33 -21
- package/dist/components/layout/toolbar/SearchCloseButton.js +30 -7
- package/dist/components/layout/toolbar/SearchResultNavigator.js +87 -8
- package/dist/components/layout/toolbar/SearchTool.js +236 -54
- package/dist/components/layout/toolbar/SelectionModeTool.js +22 -10
- package/dist/components/layout/toolbar/ThumbnailTool.js +32 -10
- package/dist/components/layout/toolbar/ToolbarCustom.js +52 -55
- package/dist/components/layout/toolbar/ToolbarDefault.js +144 -58
- package/dist/components/layout/toolbar/ToolbarLayout.js +149 -6
- package/dist/components/layout/toolbar/ViewModeTool.js +31 -19
- package/dist/components/layout/toolbar/ZoomTool.js +104 -84
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +38 -12
- package/dist/components/layout/toolbar/tools/DualPageTool.js +26 -0
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +31 -9
- package/dist/components/layout/toolbar/tools/FileUploadTool.js +29 -8
- package/dist/components/layout/toolbar/tools/FullScreenTool.js +25 -13
- package/dist/components/layout/toolbar/tools/InputPageTool.js +66 -26
- package/dist/components/layout/toolbar/tools/NextPageTool.js +36 -47
- package/dist/components/layout/toolbar/tools/PreviousPageTool.js +51 -11
- package/dist/components/layout/toolbar/tools/PrintTool.js +29 -7
- package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +31 -8
- package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +34 -11
- package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +31 -0
- package/dist/components/layout/toolbar/tools/SinglePageTool.js +26 -0
- package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +17 -6
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +35 -13
- package/dist/components/layout/toolbar/tools/ZoomInTool.js +49 -20
- package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +27 -0
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +57 -23
- package/dist/components/layout/toolbar/tools/ZoomOutTool.js +47 -18
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +122 -45
- package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +37 -11
- package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +18 -5
- package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +36 -11
- package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +25 -50
- package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +24 -9
- package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +47 -54
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +32 -7
- package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +36 -12
- package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +26 -14
- package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +27 -15
- package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +30 -18
- package/dist/components/page/AnnotationLayer.js +130 -54
- package/dist/components/page/CanvasLayer.js +62 -49
- package/dist/components/page/CustomElement.js +49 -18
- package/dist/components/page/DualPage.js +97 -4
- package/dist/components/page/RPPage.js +134 -51
- package/dist/components/page/SinglePage.js +87 -4
- package/dist/components/page/TextHighlightLayer.js +195 -57
- package/dist/components/page/TextLayer.js +193 -52
- package/dist/components/ui/Button.js +9 -8
- package/dist/components/ui/Checkbox.js +27 -25
- package/dist/components/ui/DropDown.js +21 -14
- package/dist/components/ui/Input.js +10 -9
- package/dist/components/ui/LoadingIndicator.js +45 -5
- package/dist/components/ui/PasswordModal.js +18 -15
- package/dist/components/ui/RPTooltip.js +98 -95
- package/dist/contexts/DimensionPagesContext.js +35 -17
- package/dist/contexts/DropFileZoneContext.js +32 -22
- package/dist/contexts/ElementPageContext.js +114 -51
- package/dist/contexts/EventCallbackContext.js +30 -0
- package/dist/contexts/FileInputContext.js +32 -22
- package/dist/contexts/FullScreenContext.js +17 -10
- package/dist/contexts/GlobalCurrentPage.js +13 -10
- package/dist/contexts/HighlightContext.js +24 -11
- package/dist/contexts/LicenseContext.js +1 -0
- package/dist/contexts/LoaderContext.js +10 -9
- package/dist/contexts/LocalizationContext.js +25 -29
- package/dist/contexts/PagesRotateContext.js +36 -18
- package/dist/contexts/PaginationContext.js +32 -4
- package/dist/contexts/PrintContext.js +76 -6
- package/dist/contexts/RPDocumentContext.js +48 -30
- package/dist/contexts/RenderQueueProvider.js +70 -8
- package/dist/contexts/RotationContext.js +25 -15
- package/dist/contexts/ScrollModeContext.js +7 -6
- package/dist/contexts/SearchContext.js +94 -6
- package/dist/contexts/SelectionModeContext.js +5 -4
- package/dist/contexts/ThumbnailsContext.js +41 -6
- package/dist/contexts/ViewModeContext.js +10 -9
- package/dist/contexts/ZoomContext.js +48 -38
- package/dist/floating-ui.react-dom-5ec29bd6.js +1327 -0
- package/dist/index-4baea9b5.js +1198 -0
- package/dist/index-655864a7.js +27 -0
- package/dist/{index-35c7f4a2.js → index-c0faa594.js} +63 -86
- package/dist/index-e3ee9457.js +150 -0
- package/dist/libInjectCss.js +9 -0
- package/dist/main.js +269 -84
- package/dist/types/assets/style.d.ts +1 -0
- package/dist/types/components/icons/DualPageIcon.d.ts +1 -1
- package/dist/types/components/icons/SinglePageIcon.d.ts +1 -1
- package/dist/types/components/layout/toolbar/tools/DualPageTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/SelectionModeSwitcherTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/SinglePageTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/ZoomLevelDisplay.d.ts +7 -0
- package/dist/types/contexts/EventCallbackContext.d.ts +5 -0
- package/dist/types/contexts/RenderQueueProvider.d.ts +2 -2
- package/dist/types/libInjectCss.d.ts +1 -0
- package/dist/types/main.d.ts +6 -6
- package/dist/types/utils/annotations.d.ts +3 -3
- package/dist/types/utils/approximateFragtion.d.ts +9 -0
- package/dist/types/utils/getElementPositionInPage.d.ts +5 -0
- package/dist/types/utils/hooks/useCopyText.d.ts +1 -0
- package/dist/types/utils/hooks/usePrint.d.ts +3 -2
- package/dist/types/utils/hooks/useSearch.d.ts +1 -2
- package/dist/types/utils/injectPrintCSS.d.ts +1 -0
- package/dist/types/utils/link_service.d.ts +11 -1
- package/dist/types/utils/renderPage.d.ts +2 -2
- package/dist/types/utils/types.d.ts +38 -5
- package/dist/types/utils/zoom.d.ts +2 -0
- package/dist/utils/annotations.js +125 -149
- package/dist/utils/approximateFragtion.js +22 -0
- package/dist/utils/getElementPositionInPage.js +84 -0
- package/dist/utils/getWordPositionInPage.js +5 -5
- package/dist/utils/getZoomLevel.js +9 -8
- package/dist/utils/highlight.js +72 -72
- package/dist/utils/hooks/useCopyText.js +36 -0
- package/dist/utils/hooks/useDarkModeProps.js +3 -2
- package/dist/utils/hooks/useFileDownload.js +29 -54
- package/dist/utils/hooks/useHighlight.js +34 -33
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/useLoadPdf.js +44 -36
- package/dist/utils/hooks/useLoadWorker.js +11 -8
- package/dist/utils/hooks/useLocalization.js +13 -13
- package/dist/utils/hooks/usePageRotateContext.js +33 -17
- package/dist/utils/hooks/usePaginate.js +26 -49
- package/dist/utils/hooks/usePinch.js +62 -41
- package/dist/utils/hooks/usePresentPage.js +80 -50
- package/dist/utils/hooks/usePrint.js +181 -55
- package/dist/utils/hooks/useRotate.js +21 -7
- package/dist/utils/hooks/useScrollToPage.js +26 -51
- package/dist/utils/hooks/useSearch.js +141 -55
- package/dist/utils/hooks/useThumbnail.js +55 -55
- package/dist/utils/hooks/useVirtualReactWindow.js +70 -52
- package/dist/utils/hooks/useWatermark.js +18 -15
- package/dist/utils/injectPrintCSS.js +22 -0
- package/dist/utils/link_service.js +49 -9
- package/dist/utils/renderPage.js +13 -10
- package/dist/utils/zoom.js +6 -0
- package/package.json +6 -8
- package/dist/SearchCloseButton-cbf182aa.js +0 -33
- package/dist/ToolbarLayout.module-c588d36b.js +0 -3411
- package/dist/assets/Button.css +0 -1
- package/dist/assets/Checkbox.css +0 -1
- package/dist/assets/Container.css +0 -1
- package/dist/assets/DropDown.css +0 -1
- package/dist/assets/Input.css +0 -1
- package/dist/assets/LayoutWrapper.css +0 -1
- package/dist/assets/LoaderIcon.css +0 -1
- package/dist/assets/MenuItem.css +0 -1
- package/dist/assets/MenuSeparator.css +0 -1
- package/dist/assets/PasswordModal.css +0 -1
- package/dist/assets/PropertyItem.css +0 -1
- package/dist/assets/RPDropFileZone.css +0 -1
- package/dist/assets/RPSplitter.css +0 -1
- package/dist/assets/RPTooltip.css +0 -1
- package/dist/assets/RotateTool.css +0 -1
- package/dist/assets/SearchCloseButton.css +0 -1
- package/dist/assets/ToolbarLayout.css +0 -1
- package/dist/assets/WrapperLayout.css +0 -1
- package/dist/assets/ZoomTool.css +0 -1
- package/dist/floating-ui.react-dom-6b2fe0df.js +0 -1474
- package/dist/index-f563c6f0.js +0 -1889
package/dist/utils/highlight.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { getCharacterType as
|
|
2
|
-
function V(r, c,
|
|
1
|
+
import { getCharacterType as D } from "./charators.js";
|
|
2
|
+
function V(r, c, u, i) {
|
|
3
3
|
const o = [];
|
|
4
4
|
for (const n of r) {
|
|
5
5
|
const s = y(c, n, i);
|
|
6
|
-
o.push(...I(s, c,
|
|
6
|
+
o.push(...I(s, c, u));
|
|
7
7
|
}
|
|
8
8
|
return o;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
c.matchCase ||
|
|
10
|
+
const X = (r, c) => {
|
|
11
|
+
const u = ["g"];
|
|
12
|
+
c.matchCase || u.push("i");
|
|
13
13
|
let o = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
|
-
return new RegExp(o,
|
|
14
|
+
return new RegExp(o, u.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(r, c,
|
|
16
|
+
function y(r, c, u) {
|
|
17
17
|
const i = [];
|
|
18
18
|
for (const t of r.items)
|
|
19
19
|
if (t.hasEOL)
|
|
@@ -27,14 +27,14 @@ function y(r, c, a) {
|
|
|
27
27
|
i.push(t.str);
|
|
28
28
|
const o = i.join("").replace(/\n/g, " ");
|
|
29
29
|
let n;
|
|
30
|
-
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n =
|
|
30
|
+
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = X(c, u);
|
|
31
31
|
const s = [];
|
|
32
32
|
let e;
|
|
33
33
|
for (; (e = n.exec(o)) !== null; )
|
|
34
|
-
|
|
34
|
+
u.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
|
|
35
35
|
return s;
|
|
36
36
|
}
|
|
37
|
-
function I(r, c,
|
|
37
|
+
function I(r, c, u) {
|
|
38
38
|
function i(l) {
|
|
39
39
|
return l.hasEOL ? l.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
@@ -46,7 +46,7 @@ function I(r, c, a) {
|
|
|
46
46
|
const f = s[o];
|
|
47
47
|
n += f.str.length + i(f), o++;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const h = {
|
|
50
50
|
idx: o,
|
|
51
51
|
offset: d - n
|
|
52
52
|
};
|
|
@@ -59,81 +59,81 @@ function I(r, c, a) {
|
|
|
59
59
|
offset: d - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
|
-
start:
|
|
62
|
+
start: h,
|
|
63
63
|
end: m,
|
|
64
64
|
str: r[l][2],
|
|
65
65
|
oIndex: r[l][0],
|
|
66
|
-
pageIndex:
|
|
66
|
+
pageIndex: u,
|
|
67
67
|
rect: {
|
|
68
68
|
left: 0,
|
|
69
|
-
|
|
69
|
+
bottom: 0,
|
|
70
70
|
width: 0,
|
|
71
71
|
height: 0
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
for (const l of t) {
|
|
76
|
-
const d = s[l.start.idx],
|
|
77
|
-
left: Math.min(
|
|
78
|
-
|
|
79
|
-
width: Math.abs(
|
|
80
|
-
height: Math.max(d.height,
|
|
76
|
+
const d = s[l.start.idx], h = s[l.end.idx], m = d.transform[4] + l.start.offset * (d.width / d.str.length), f = d.transform[5], E = h.transform[4] + l.end.offset * (h.width / h.str.length), a = h.transform[5], M = {
|
|
77
|
+
left: Math.min(m, E),
|
|
78
|
+
bottom: Math.min(f, a),
|
|
79
|
+
width: Math.abs(E - m),
|
|
80
|
+
height: Math.max(d.height, h.height)
|
|
81
81
|
};
|
|
82
|
-
l.rect =
|
|
82
|
+
l.rect = M;
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function L(r, c,
|
|
86
|
+
function L(r, c, u) {
|
|
87
87
|
let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
89
|
const o = r.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
|
-
if (
|
|
90
|
+
if (D(o) === D(n))
|
|
91
91
|
return !1;
|
|
92
92
|
}
|
|
93
|
-
if (i = r.slice(c +
|
|
94
|
-
const o = r.charCodeAt(c +
|
|
95
|
-
if (
|
|
93
|
+
if (i = r.slice(c + u).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const o = r.charCodeAt(c + u - 1), n = i[1].charCodeAt(0);
|
|
95
|
+
if (D(o) === D(n))
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
|
-
function H(r, c,
|
|
100
|
+
function H(r, c, u) {
|
|
101
101
|
const i = [];
|
|
102
102
|
function o(n, s, e = -1, t = -1, l = "") {
|
|
103
|
-
const d = c.items[n],
|
|
104
|
-
let m = "", f = "", E = "",
|
|
105
|
-
if (!
|
|
103
|
+
const d = c.items[n], h = [];
|
|
104
|
+
let m = "", f = "", E = "", a = u[n];
|
|
105
|
+
if (!a)
|
|
106
106
|
return;
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
|
|
107
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
|
+
const p = document.createElement("span");
|
|
109
|
+
a.before(p), p.append(a), u[n] = p, a = p;
|
|
110
110
|
}
|
|
111
111
|
e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
|
|
112
|
-
const
|
|
113
|
-
if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(
|
|
114
|
-
if (
|
|
112
|
+
const M = document.createTextNode(m), N = document.createElement("span");
|
|
113
|
+
if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(M), h.push(N), i.push({ element: N, index: s }), e > 0)
|
|
114
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
115
|
f = d.str.substring(0, e);
|
|
116
|
-
const
|
|
117
|
-
|
|
116
|
+
const p = document.createTextNode(f);
|
|
117
|
+
h.unshift(p);
|
|
118
118
|
} else {
|
|
119
|
-
let
|
|
120
|
-
const
|
|
121
|
-
for (const g of
|
|
119
|
+
let p = 0;
|
|
120
|
+
const b = [];
|
|
121
|
+
for (const g of a.childNodes) {
|
|
122
122
|
const x = g.nodeType === Node.TEXT_NODE ? g.nodeValue : g.firstChild.nodeValue;
|
|
123
|
-
|
|
123
|
+
p += x.length, p <= e ? b.push(g) : e >= p - x.length && t <= p && b.push(
|
|
124
124
|
document.createTextNode(
|
|
125
|
-
x.substring(0, e - (
|
|
125
|
+
x.substring(0, e - (p - x.length))
|
|
126
126
|
)
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
h.unshift(...b);
|
|
130
130
|
}
|
|
131
131
|
if (t > 0) {
|
|
132
132
|
E = d.str.substring(t);
|
|
133
|
-
const
|
|
134
|
-
|
|
133
|
+
const p = document.createTextNode(E);
|
|
134
|
+
h.push(p);
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
a.replaceChildren(...h);
|
|
137
137
|
}
|
|
138
138
|
for (const [n, s] of r.entries())
|
|
139
139
|
if (s.start.idx === s.end.idx)
|
|
@@ -144,11 +144,11 @@ function H(r, c, a) {
|
|
|
144
144
|
return i;
|
|
145
145
|
}
|
|
146
146
|
function R(r, c) {
|
|
147
|
-
const
|
|
147
|
+
const u = r.items.map((i) => i.str);
|
|
148
148
|
for (let i = 0; i < c.length; i++) {
|
|
149
149
|
const o = c[i];
|
|
150
150
|
if (o && o.nodeType !== Node.TEXT_NODE) {
|
|
151
|
-
const n = document.createTextNode(
|
|
151
|
+
const n = document.createTextNode(u[i]);
|
|
152
152
|
o.replaceChildren(n);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -156,54 +156,54 @@ function R(r, c) {
|
|
|
156
156
|
function W(r = {}) {
|
|
157
157
|
return { matchCase: !1, wholeWords: !1, ...r };
|
|
158
158
|
}
|
|
159
|
-
function A(r, c,
|
|
159
|
+
function A(r, c, u) {
|
|
160
160
|
const i = [];
|
|
161
161
|
function o(n, s, e = -1, t = -1, l) {
|
|
162
|
-
var
|
|
163
|
-
const d = c.items[n],
|
|
164
|
-
let m = "", f = "", E = "",
|
|
165
|
-
if (!
|
|
162
|
+
var p, b;
|
|
163
|
+
const d = c.items[n], h = [];
|
|
164
|
+
let m = "", f = "", E = "", a = u[n];
|
|
165
|
+
if (!a)
|
|
166
166
|
return;
|
|
167
167
|
e >= 0 && t >= 0 ? m = d.str.substring(e, t) : e < 0 && t < 0 ? m = d.str : e >= 0 ? m = d.str.substring(e) : t >= 0 && (m = d.str.substring(0, t));
|
|
168
|
-
const
|
|
169
|
-
if (N.style.background = l, N.append(
|
|
170
|
-
if (
|
|
168
|
+
const M = document.createTextNode(m), N = document.createElement("span");
|
|
169
|
+
if (N.style.background = l, N.append(M), h.push(N), e > 0)
|
|
170
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
171
|
f = d.str.substring(0, e);
|
|
172
172
|
const g = document.createTextNode(f);
|
|
173
|
-
|
|
173
|
+
h.unshift(g);
|
|
174
174
|
} else {
|
|
175
175
|
let g = 0;
|
|
176
176
|
const x = [];
|
|
177
|
-
for (const T of
|
|
178
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
179
|
-
if (g +=
|
|
177
|
+
for (const T of a.childNodes) {
|
|
178
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((p = T.firstChild) == null ? void 0 : p.nodeValue) || "", C = v.length;
|
|
179
|
+
if (g += C, g <= e)
|
|
180
180
|
x.push(T);
|
|
181
|
-
else if (e >= g -
|
|
182
|
-
const w = v.substring(0, e - (g -
|
|
181
|
+
else if (e >= g - C && t <= g) {
|
|
182
|
+
const w = v.substring(0, e - (g - C));
|
|
183
183
|
x.push(document.createTextNode(w));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
h.unshift(...x);
|
|
187
187
|
}
|
|
188
188
|
if (t > 0)
|
|
189
|
-
if (
|
|
189
|
+
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
190
190
|
E = d.str.substring(t);
|
|
191
191
|
const g = document.createTextNode(E);
|
|
192
|
-
|
|
192
|
+
h.push(g);
|
|
193
193
|
} else {
|
|
194
194
|
let g = 0;
|
|
195
195
|
const x = [];
|
|
196
|
-
for (const T of
|
|
196
|
+
for (const T of a.childNodes) {
|
|
197
197
|
g >= t && x.push(T);
|
|
198
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
199
|
-
if (g +=
|
|
200
|
-
const w = v.substring(t - (g -
|
|
198
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((b = T.firstChild) == null ? void 0 : b.nodeValue) || "", C = v.length;
|
|
199
|
+
if (g += C, g > t) {
|
|
200
|
+
const w = v.substring(t - (g - C));
|
|
201
201
|
w && x.push(document.createTextNode(w));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
x.length > 0 &&
|
|
204
|
+
x.length > 0 && h.push(...x);
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
a.replaceChildren(...h), i.push({ element: N, index: s });
|
|
207
207
|
}
|
|
208
208
|
for (const [n, s] of r.entries()) {
|
|
209
209
|
const { start: e, end: t, color: l } = s;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRef as o, useEffect as i } from "react";
|
|
2
|
+
const s = /[\x00-\x1F]/g;
|
|
3
|
+
let c = null, r = null;
|
|
4
|
+
function d(e) {
|
|
5
|
+
return c || (c = /([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu, r = /* @__PURE__ */ new Map([["ſt", "ſt"]])), e.replace(
|
|
6
|
+
c,
|
|
7
|
+
(f, u, t) => u ? u.normalize("NFKC") : (r == null ? void 0 : r.get(t)) || ""
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
function p(e, f = !1) {
|
|
11
|
+
return s.test(e) ? f ? e.replace(s, (u) => u === "\0" ? "" : " ") : e.replace(/\x00/g, "") : e;
|
|
12
|
+
}
|
|
13
|
+
const x = (e) => {
|
|
14
|
+
const f = o(!1), u = o(null);
|
|
15
|
+
i(() => {
|
|
16
|
+
if (!e || f.current)
|
|
17
|
+
return;
|
|
18
|
+
const t = (n) => {
|
|
19
|
+
var l;
|
|
20
|
+
const b = document.getSelection();
|
|
21
|
+
if (!b)
|
|
22
|
+
return;
|
|
23
|
+
const a = b.toString();
|
|
24
|
+
a && ((l = n.clipboardData) == null || l.setData(
|
|
25
|
+
"text/plain",
|
|
26
|
+
p(d(a))
|
|
27
|
+
), n.preventDefault(), n.stopPropagation());
|
|
28
|
+
};
|
|
29
|
+
return e.addEventListener("copy", t), u.current = e, f.current = !0, () => {
|
|
30
|
+
u.current && (u.current.removeEventListener("copy", t), f.current = !1);
|
|
31
|
+
};
|
|
32
|
+
}, [e]);
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
x as useCopyText
|
|
36
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useDarkMode as e } from "./useDarkMode.js";
|
|
2
|
-
|
|
2
|
+
import "react";
|
|
3
|
+
const d = () => {
|
|
3
4
|
const { darkMode: o, setDarkMode: r } = e();
|
|
4
5
|
return {
|
|
5
6
|
darkMode: o,
|
|
@@ -7,5 +8,5 @@ const t = () => {
|
|
|
7
8
|
};
|
|
8
9
|
};
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
d as useDarkModeProps
|
|
11
12
|
};
|
|
@@ -1,58 +1,33 @@
|
|
|
1
|
+
import { useDocumentContext as c } from "../../contexts/RPDocumentContext.js";
|
|
2
|
+
import { useCallback as a } from "react";
|
|
3
|
+
import { useDownloadContext as s } from "../../contexts/DownloadContext.js";
|
|
1
4
|
import "react/jsx-runtime";
|
|
2
|
-
import "
|
|
3
|
-
import "
|
|
5
|
+
import "./useLoadPdf.js";
|
|
6
|
+
import "pdfjs-dist";
|
|
7
|
+
import "../types.js";
|
|
8
|
+
import "../../th_TH-d627cd51.js";
|
|
9
|
+
import "../getThumbnailViewport.js";
|
|
10
|
+
import "../../contexts/ConfigContext.js";
|
|
4
11
|
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
-
import
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
import "../../contexts/DownloadContext.js";
|
|
25
|
-
import "../../contexts/SmoothScrollContext.js";
|
|
26
|
-
import "../../contexts/ElementPageContext.js";
|
|
27
|
-
import "../../contexts/PagesRotateContext.js";
|
|
28
|
-
import "../../contexts/GlobalCurrentPage.js";
|
|
29
|
-
import "../../contexts/LoaderContext.js";
|
|
30
|
-
import "../../contexts/ToolComponentContext.js";
|
|
31
|
-
import "../../contexts/IconToolContext.js";
|
|
32
|
-
import "../../contexts/OtherToolContext.js";
|
|
33
|
-
import "../../components/RPConfig.js";
|
|
34
|
-
import "../../components/layout/Container.js";
|
|
35
|
-
import "../../contexts/ViewportContext.js";
|
|
36
|
-
import "../../contexts/ToolbarComponentContext.js";
|
|
37
|
-
import "../../components/layout/sidebar/RPSplitter.js";
|
|
38
|
-
import "../../components/layout/WrapperLayout.js";
|
|
39
|
-
import "../../LayoutWrapper-a871c161.js";
|
|
40
|
-
import "../../contexts/ThemeContext.js";
|
|
41
|
-
import "../../components/RPDropFileZone.js";
|
|
42
|
-
import "../../components/ui/Button.js";
|
|
43
|
-
import "../../SearchCloseButton-cbf182aa.js";
|
|
44
|
-
import "../../components/ui/Input.js";
|
|
45
|
-
import "../../components/ui/Checkbox.js";
|
|
46
|
-
import "../../components/icons/LoaderIcon.js";
|
|
47
|
-
import "../../contexts/IconContext.js";
|
|
48
|
-
import "../../components/ui/RPTooltip.js";
|
|
49
|
-
import "../../components/ui/DropDown.js";
|
|
50
|
-
import "../../ZoomTool.module-6c5eabbb.js";
|
|
51
|
-
import "../../components/layout/toolbar/MenuItem.js";
|
|
52
|
-
import "../../components/layout/toolbar/MenuSeparator.js";
|
|
53
|
-
import "../dateFormatter.js";
|
|
54
|
-
import "../../components/layout/toolbar/PropertyItem.js";
|
|
55
|
-
import "../../RotateTool.module-03987eba.js";
|
|
12
|
+
import "../appConsole.js";
|
|
13
|
+
import "./usePdfProperties.js";
|
|
14
|
+
import "../convertPdfDate.js";
|
|
15
|
+
import "../formatFileSize.js";
|
|
16
|
+
const i = ".pdf", d = (o) => URL.createObjectURL(o), l = async (o) => {
|
|
17
|
+
const r = await (await fetch(o)).blob();
|
|
18
|
+
return d(r);
|
|
19
|
+
}, k = () => {
|
|
20
|
+
const { filename: o, pdfSrc: e } = c(), { downloadFilename: r } = s(), m = (t) => {
|
|
21
|
+
const n = r || t;
|
|
22
|
+
return n.endsWith(i) ? n : `${n}${i}`;
|
|
23
|
+
};
|
|
24
|
+
return { download: a(async () => {
|
|
25
|
+
if (!o || !e)
|
|
26
|
+
throw new Error("There is no PDF source to download");
|
|
27
|
+
const t = document.createElement("a");
|
|
28
|
+
t.href = await l(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
29
|
+
}, [o, e]) };
|
|
30
|
+
};
|
|
56
31
|
export {
|
|
57
|
-
|
|
32
|
+
k as useFileDownload
|
|
58
33
|
};
|
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as m, useCallback as r, useEffect as C } from "react";
|
|
2
2
|
import { getHighlightOptionsWithDefaults as H, findMatches as M } from "../highlight.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import "../charators.js";
|
|
4
|
+
const k = (s) => {
|
|
5
|
+
const [n, c] = m(void 0), [f, l] = m([]), u = r(async (t) => {
|
|
5
6
|
if (!t)
|
|
6
7
|
return {};
|
|
7
|
-
const
|
|
8
|
-
for (let o = 1; o <=
|
|
9
|
-
const
|
|
10
|
-
e[o.toString()] = await
|
|
8
|
+
const i = t.numPages, e = {};
|
|
9
|
+
for (let o = 1; o <= i; o++) {
|
|
10
|
+
const h = await t.getPage(o);
|
|
11
|
+
e[o.toString()] = await h.getTextContent();
|
|
11
12
|
}
|
|
12
13
|
return e;
|
|
13
|
-
}, []),
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
};
|
|
14
|
+
}, []), p = r(async (t) => {
|
|
15
|
+
c(t);
|
|
16
|
+
}, []), g = r(() => {
|
|
17
|
+
l([]), c(void 0);
|
|
18
|
+
}, []);
|
|
18
19
|
return C(() => {
|
|
19
|
-
|
|
20
|
-
let
|
|
21
|
-
for (const { keyword: e, highlightColor: o, options:
|
|
20
|
+
s && u(s).then((t) => {
|
|
21
|
+
let i = [];
|
|
22
|
+
for (const { keyword: e, highlightColor: o, options: h } of n) {
|
|
22
23
|
if (!e)
|
|
23
24
|
continue;
|
|
24
|
-
const
|
|
25
|
-
for (const
|
|
26
|
-
const
|
|
25
|
+
const y = H(h);
|
|
26
|
+
for (const a of Object.keys(t)) {
|
|
27
|
+
const b = M(
|
|
27
28
|
[e],
|
|
28
|
-
t[
|
|
29
|
-
Number(
|
|
30
|
-
|
|
31
|
-
).map((
|
|
32
|
-
...
|
|
33
|
-
page: Number(
|
|
34
|
-
pageMatchIdx:
|
|
29
|
+
t[a],
|
|
30
|
+
Number(a) - 1,
|
|
31
|
+
y
|
|
32
|
+
).map((w, x) => ({
|
|
33
|
+
...w,
|
|
34
|
+
page: Number(a),
|
|
35
|
+
pageMatchIdx: x,
|
|
35
36
|
color: o,
|
|
36
37
|
keyword: e
|
|
37
38
|
}));
|
|
38
|
-
|
|
39
|
+
i = [...i, ...b];
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
l(i);
|
|
42
43
|
}).catch(() => {
|
|
43
|
-
|
|
44
|
+
g();
|
|
44
45
|
});
|
|
45
|
-
}, [n,
|
|
46
|
-
highlight:
|
|
47
|
-
clear:
|
|
48
|
-
highlightMatches:
|
|
46
|
+
}, [n, s, g, u]), {
|
|
47
|
+
highlight: p,
|
|
48
|
+
clear: g,
|
|
49
|
+
highlightMatches: f,
|
|
49
50
|
highlightKeywords: n
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
export {
|
|
53
|
-
|
|
54
|
+
k as useHighlight
|
|
54
55
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as E, useCallback as h, useEffect as A } from "react";
|
|
2
2
|
import { appConsole as l } from "../appConsole.js";
|
|
3
|
-
const b = /* @__PURE__ */ new Date("2026-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2026-02-11T04:45:54.847Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
|
|
4
4
|
invalidLicense: `You are currently using without a valid license. ${d}`,
|
|
5
5
|
mismatchedDomain: `Your license key is not valid for the current domain / IP. ${d}`,
|
|
6
6
|
expired: `Your license key has expired. ${d}`,
|
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import * as
|
|
3
|
-
import { ErrorType as
|
|
4
|
-
import { getThumbnailViewport as
|
|
5
|
-
import { useConfigContext as
|
|
6
|
-
import { useDocumentPasswordContext as
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useState as d, useRef as A, useEffect as k } from "react";
|
|
2
|
+
import * as I from "pdfjs-dist";
|
|
3
|
+
import { ErrorType as F } from "../types.js";
|
|
4
|
+
import { getThumbnailViewport as j } from "../getThumbnailViewport.js";
|
|
5
|
+
import { useConfigContext as z } from "../../contexts/ConfigContext.js";
|
|
6
|
+
import { useDocumentPasswordContext as _ } from "../../contexts/DocumentPasswordContext.js";
|
|
7
|
+
import "../../th_TH-d627cd51.js";
|
|
8
|
+
import "react/jsx-runtime";
|
|
9
|
+
import "../appConsole.js";
|
|
10
|
+
const Y = (m, s, h = {}) => {
|
|
11
|
+
const [n, q] = d(), { workerUrlAdded: v } = z(), [D, S] = d(/* @__PURE__ */ new Map()), a = A(), [f, g] = d(0), [P, T] = d(!1), [N, O] = d(), { password: u, passwordError: U, setPasswordError: c, passwordRequired: p, setPasswordRequired: w } = _(), { onLoadError: i, onLoaded: E, onLoadProgress: b, disableAutoFetch: x, disableStream: C, rangeChunkSize: V } = h;
|
|
9
12
|
return k(() => {
|
|
10
|
-
|
|
13
|
+
b && b(f);
|
|
14
|
+
}, [f, b]), k(() => {
|
|
15
|
+
if (!v || !m)
|
|
11
16
|
return;
|
|
12
|
-
|
|
13
|
-
const r =
|
|
14
|
-
url:
|
|
17
|
+
g(0), a.current = Date.now();
|
|
18
|
+
const r = a.current, R = {
|
|
19
|
+
url: m,
|
|
15
20
|
cMapPacked: (s == null ? void 0 : s.isCompressed) ?? !0,
|
|
16
21
|
...(s == null ? void 0 : s.url) && { cMapUrl: s.url },
|
|
17
22
|
...u && { password: u },
|
|
18
|
-
|
|
23
|
+
...x !== void 0 && { disableAutoFetch: x },
|
|
24
|
+
...C !== void 0 && { disableStream: C },
|
|
25
|
+
...V !== void 0 && { rangeChunkSize: V },
|
|
26
|
+
verbosity: I.VerbosityLevel.ERRORS
|
|
19
27
|
};
|
|
20
28
|
try {
|
|
21
|
-
const e =
|
|
29
|
+
const e = I.getDocument(R);
|
|
22
30
|
e.onProgress = (o) => {
|
|
23
|
-
if (r ===
|
|
24
|
-
const { loaded:
|
|
25
|
-
|
|
31
|
+
if (r === a.current) {
|
|
32
|
+
const { loaded: y, total: l } = o, L = l ? Math.min(100, Math.round(y / l * 100)) : 0;
|
|
33
|
+
g(L);
|
|
26
34
|
}
|
|
27
35
|
}, T(!0);
|
|
28
|
-
const t = e.promise.then((o) => (r ===
|
|
29
|
-
o instanceof Error && o.name === "PasswordException" ? (
|
|
36
|
+
const t = e.promise.then((o) => (r === a.current && (q(o), g(100)), E && E(o), w(!1), c(""), o)).catch((o) => {
|
|
37
|
+
o instanceof Error && o.name === "PasswordException" ? (w(!0), c(o.message || "Password required")) : o instanceof Error && o.name === "InvalidPDFException" && u ? (w(!0), c("Incorrect password")) : i && i(o);
|
|
30
38
|
}).finally(() => {
|
|
31
39
|
T(!1);
|
|
32
40
|
});
|
|
@@ -36,42 +44,42 @@ const G = (f, s, V = {}) => {
|
|
|
36
44
|
});
|
|
37
45
|
};
|
|
38
46
|
} catch (e) {
|
|
39
|
-
|
|
47
|
+
O(F.NOT_SUPPORTED), i && i(e);
|
|
40
48
|
}
|
|
41
|
-
}, [
|
|
42
|
-
if (
|
|
49
|
+
}, [m, v, u, i, E]), k(() => {
|
|
50
|
+
if (p)
|
|
43
51
|
return;
|
|
44
52
|
const r = /* @__PURE__ */ new Map();
|
|
45
53
|
if (!n || P) {
|
|
46
|
-
|
|
54
|
+
S(r);
|
|
47
55
|
return;
|
|
48
56
|
}
|
|
49
|
-
const
|
|
50
|
-
for (let t = 1; t <=
|
|
57
|
+
const R = n.numPages, e = [];
|
|
58
|
+
for (let t = 1; t <= R; t++) {
|
|
51
59
|
const o = n.getPage(t);
|
|
52
60
|
e.push(o);
|
|
53
61
|
}
|
|
54
62
|
Promise.all(e).then((t) => {
|
|
55
63
|
t.map((o) => {
|
|
56
|
-
const { thumbnailViewport:
|
|
64
|
+
const { thumbnailViewport: y, scale: l } = j(o), L = o.getViewport();
|
|
57
65
|
r.set(o.pageNumber, {
|
|
58
66
|
page: o,
|
|
59
|
-
thumbnailViewport:
|
|
67
|
+
thumbnailViewport: y,
|
|
60
68
|
thumbnailScale: l,
|
|
61
|
-
defaultRotation:
|
|
69
|
+
defaultRotation: L.rotation
|
|
62
70
|
});
|
|
63
|
-
}),
|
|
71
|
+
}), S(r);
|
|
64
72
|
});
|
|
65
|
-
}, [n, P,
|
|
73
|
+
}, [n, P, p]), {
|
|
66
74
|
pdf: n,
|
|
67
|
-
pages:
|
|
75
|
+
pages: D,
|
|
68
76
|
loading: P,
|
|
69
|
-
error:
|
|
70
|
-
loadingProgress:
|
|
71
|
-
passwordRequired:
|
|
72
|
-
passwordError:
|
|
77
|
+
error: N,
|
|
78
|
+
loadingProgress: f,
|
|
79
|
+
passwordRequired: p,
|
|
80
|
+
passwordError: U
|
|
73
81
|
};
|
|
74
82
|
};
|
|
75
83
|
export {
|
|
76
|
-
|
|
84
|
+
Y as useLoadPdf
|
|
77
85
|
};
|