@pdf-viewer/react 1.17.0-rc.4 → 1.18.0-beta.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/{ToolbarLayout.module-9594715b.js → ToolbarLayout.module-3f4e0f88.js} +1239 -1245
- package/dist/components/RPController.js +15 -14
- package/dist/components/RPPages.js +3 -2
- package/dist/components/RPProvider.js +33 -22
- package/dist/components/layout/LayoutContainer.js +3 -2
- package/dist/components/layout/RPDefaultLayout.js +3 -2
- package/dist/components/layout/RPLayout.js +4 -3
- package/dist/components/layout/SkipLink.js +2 -3
- package/dist/components/layout/sidebar/RPSidebar.js +3 -2
- package/dist/components/layout/sidebar/Thumbnail.js +3 -2
- package/dist/components/layout/sidebar/Thumbnails.js +3 -2
- package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
- package/dist/components/layout/toolbar/FileDownloadTool.js +3 -2
- package/dist/components/layout/toolbar/MostPageTool.js +3 -2
- package/dist/components/layout/toolbar/OtherTool.js +3 -2
- package/dist/components/layout/toolbar/Paginate.js +3 -2
- package/dist/components/layout/toolbar/PrintTool.js +3 -2
- package/dist/components/layout/toolbar/RPMoreOptions.js +7 -6
- package/dist/components/layout/toolbar/RPToolbar.js +3 -2
- package/dist/components/layout/toolbar/RPToolbarEnd.js +3 -2
- package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -2
- package/dist/components/layout/toolbar/SearchTool.js +3 -2
- 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 +4 -3
- package/dist/components/layout/toolbar/ToolbarLayout.js +4 -3
- package/dist/components/layout/toolbar/ZoomTool.js +3 -2
- package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -3
- package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +4 -3
- package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -3
- package/dist/components/layout/toolbar/tools/FirstPageTool.js +148 -0
- package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/LastPageTool.js +148 -0
- 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/SinglePageTool.js +4 -3
- package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -3
- package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +3 -2
- package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +4 -3
- package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +4 -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 +12 -11
- package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +4 -3
- package/dist/components/page/AnnotationLayer.js +3 -2
- package/dist/components/page/CanvasLayer.js +3 -2
- package/dist/components/page/DualPage.js +3 -2
- package/dist/components/page/DualPageWithCover.js +3 -2
- package/dist/components/page/RPPage.js +3 -2
- package/dist/components/page/SinglePage.js +3 -2
- package/dist/components/page/TextHighlightLayer.js +3 -2
- package/dist/components/page/TextLayer.js +3 -2
- package/dist/components/ui/LoadingIndicator.js +3 -2
- package/dist/contexts/EventCallbackContext.js +12 -8
- package/dist/contexts/PaginationContext.js +5 -4
- package/dist/contexts/PrintContext.js +5 -4
- package/dist/contexts/RenderQueueProvider.js +5 -4
- package/dist/contexts/SearchContext.js +5 -4
- package/dist/contexts/ThumbnailsContext.js +5 -4
- package/dist/main.js +96 -91
- package/dist/types/components/layout/toolbar/tools/FirstPageTool.d.ts +3 -0
- package/dist/types/components/layout/toolbar/tools/LastPageTool.d.ts +3 -0
- package/dist/types/main.d.ts +3 -1
- package/dist/types/utils/hooks/useTextSelection.d.ts +7 -0
- package/dist/types/utils/types.d.ts +21 -1
- package/dist/utils/highlight.js +139 -139
- package/dist/utils/hooks/useFileDownload.js +3 -2
- package/dist/utils/hooks/useLicense.js +1 -1
- package/dist/utils/hooks/usePaginate.js +3 -2
- package/dist/utils/hooks/usePresentPage.js +3 -2
- package/dist/utils/hooks/usePrint.js +3 -2
- package/dist/utils/hooks/useScrollToPage.js +3 -2
- package/dist/utils/hooks/useSearch.js +3 -2
- package/dist/utils/hooks/useTextSelection.js +76 -0
- package/dist/utils/hooks/useThumbnail.js +3 -2
- package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
- package/package.json +1 -1
|
@@ -64,7 +64,7 @@ export interface OutlineDestinationName {
|
|
|
64
64
|
name: string;
|
|
65
65
|
}
|
|
66
66
|
export type OutlineDestination = [
|
|
67
|
-
OutlineRef | number,
|
|
67
|
+
(OutlineRef | number),
|
|
68
68
|
OutlineDestinationName,
|
|
69
69
|
...any[]
|
|
70
70
|
];
|
|
@@ -469,10 +469,29 @@ export interface CharacterMap {
|
|
|
469
469
|
url: string;
|
|
470
470
|
isCompressed: boolean;
|
|
471
471
|
}
|
|
472
|
+
interface Dimension {
|
|
473
|
+
width: number;
|
|
474
|
+
height: number;
|
|
475
|
+
}
|
|
476
|
+
interface Point {
|
|
477
|
+
x: number;
|
|
478
|
+
y: number;
|
|
479
|
+
}
|
|
480
|
+
export interface PageSelectionRect {
|
|
481
|
+
pageNumber: number;
|
|
482
|
+
pageBasedBoundingRects: Array<Dimension & RectPosition>;
|
|
483
|
+
pageDimension: Dimension;
|
|
484
|
+
pagePositionInWindow: Point;
|
|
485
|
+
}
|
|
486
|
+
export interface TextSelectionData {
|
|
487
|
+
text: string;
|
|
488
|
+
pageSelections: PageSelectionRect[];
|
|
489
|
+
}
|
|
472
490
|
export interface EventCallbackContextType {
|
|
473
491
|
onPageChange?: (page: number) => void;
|
|
474
492
|
onRotate?: (rotation: Record<number, number>) => void;
|
|
475
493
|
onScroll?: (scroll: Event) => void;
|
|
494
|
+
onTextSelect?: (selection: TextSelectionData | null) => void;
|
|
476
495
|
}
|
|
477
496
|
export interface RPProviderProps extends PropsWithChildren, LoadPDFOptions, RPControllerProps, EventCallbackContextType {
|
|
478
497
|
src: RPSrc;
|
|
@@ -581,6 +600,7 @@ export interface Match {
|
|
|
581
600
|
oIndex: number;
|
|
582
601
|
pageIndex: number;
|
|
583
602
|
rect: RectPosition;
|
|
603
|
+
rects?: RectPosition[];
|
|
584
604
|
}
|
|
585
605
|
export interface MatchValue extends Match {
|
|
586
606
|
page: number;
|
package/dist/utils/highlight.js
CHANGED
|
@@ -1,221 +1,221 @@
|
|
|
1
1
|
import { getCharacterType as D } from "./charators.js";
|
|
2
|
-
function
|
|
3
|
-
const
|
|
2
|
+
function _(r, c, m, i) {
|
|
3
|
+
const s = [];
|
|
4
4
|
for (const n of r) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const o = y(c, n, i);
|
|
6
|
+
s.push(...R(o, c, m));
|
|
7
7
|
}
|
|
8
|
-
return
|
|
8
|
+
return s;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
c.matchCase ||
|
|
13
|
-
let
|
|
14
|
-
return new RegExp(
|
|
10
|
+
const L = (r, c) => {
|
|
11
|
+
const m = ["g"];
|
|
12
|
+
c.matchCase || m.push("i");
|
|
13
|
+
let s = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
|
|
14
|
+
return new RegExp(s, m.join(""));
|
|
15
15
|
};
|
|
16
|
-
function y(r, c,
|
|
16
|
+
function y(r, c, m) {
|
|
17
17
|
const i = [];
|
|
18
18
|
for (const t of r.items)
|
|
19
19
|
if (t.hasEOL)
|
|
20
20
|
if (t.str.endsWith("-")) {
|
|
21
|
-
const
|
|
22
|
-
i.push(t.str.substring(0,
|
|
21
|
+
const d = t.str.lastIndexOf("-");
|
|
22
|
+
i.push(t.str.substring(0, d));
|
|
23
23
|
} else
|
|
24
24
|
i.push(t.str, `
|
|
25
25
|
`);
|
|
26
26
|
else
|
|
27
27
|
i.push(t.str);
|
|
28
|
-
const
|
|
28
|
+
const s = 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 =
|
|
31
|
-
const
|
|
30
|
+
c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = L(c, m);
|
|
31
|
+
const o = [];
|
|
32
32
|
let e;
|
|
33
|
-
for (; (e = n.exec(
|
|
34
|
-
|
|
35
|
-
return
|
|
33
|
+
for (; (e = n.exec(s)) !== null; )
|
|
34
|
+
m.wholeWords && !W(s, e.index, e[0].length) || o.push([e.index, e[0].length, e[0]]);
|
|
35
|
+
return o;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
function i(
|
|
39
|
-
return
|
|
37
|
+
function R(r, c, m) {
|
|
38
|
+
function i(d) {
|
|
39
|
+
return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
|
|
40
40
|
}
|
|
41
|
-
let
|
|
42
|
-
const
|
|
43
|
-
for (let
|
|
44
|
-
let
|
|
45
|
-
for (;
|
|
46
|
-
const
|
|
47
|
-
n +=
|
|
41
|
+
let s = 0, n = 0;
|
|
42
|
+
const o = c.items, e = o.length - 1, t = [];
|
|
43
|
+
for (let d = 0; d < r.length; d++) {
|
|
44
|
+
let h = r[d][0];
|
|
45
|
+
for (; s !== e && h >= n + o[s].str.length; ) {
|
|
46
|
+
const x = o[s];
|
|
47
|
+
n += x.str.length + i(x), s++;
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
idx:
|
|
51
|
-
offset:
|
|
49
|
+
const g = {
|
|
50
|
+
idx: s,
|
|
51
|
+
offset: h - n
|
|
52
52
|
};
|
|
53
|
-
for (
|
|
54
|
-
const
|
|
55
|
-
n +=
|
|
53
|
+
for (h += r[d][1]; s !== e && h > n + o[s].str.length; ) {
|
|
54
|
+
const x = o[s];
|
|
55
|
+
n += x.str.length + i(x), s++;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
58
|
-
idx:
|
|
59
|
-
offset:
|
|
57
|
+
const l = {
|
|
58
|
+
idx: s,
|
|
59
|
+
offset: h - n
|
|
60
60
|
};
|
|
61
61
|
t.push({
|
|
62
|
-
start:
|
|
63
|
-
end:
|
|
64
|
-
str: r[
|
|
65
|
-
oIndex: r[
|
|
66
|
-
pageIndex:
|
|
67
|
-
rect: {
|
|
68
|
-
|
|
69
|
-
bottom: 0,
|
|
70
|
-
width: 0,
|
|
71
|
-
height: 0
|
|
72
|
-
}
|
|
62
|
+
start: g,
|
|
63
|
+
end: l,
|
|
64
|
+
str: r[d][2],
|
|
65
|
+
oIndex: r[d][0],
|
|
66
|
+
pageIndex: m,
|
|
67
|
+
rect: { left: 0, bottom: 0, width: 0, height: 0 },
|
|
68
|
+
rects: []
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
|
-
for (const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
for (const d of t) {
|
|
72
|
+
const h = [];
|
|
73
|
+
for (let g = d.start.idx; g <= d.end.idx; g++) {
|
|
74
|
+
const l = o[g], x = l.transform[4], C = l.transform[5], a = l.str.length > 0 ? l.width / l.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : l.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[l.fontName], T = (u == null ? void 0 : u.ascent) ?? 1, v = (u == null ? void 0 : u.descent) != null ? Math.abs(u.descent) : 1 - T, b = C - v * l.height;
|
|
75
|
+
(E > 0 || l.height > 0) && h.push({
|
|
76
|
+
left: f,
|
|
77
|
+
bottom: b,
|
|
78
|
+
width: E,
|
|
79
|
+
height: l.height
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
d.rect = h[0], d.rects = h;
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function W(r, c, m) {
|
|
87
87
|
let i = r.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
|
|
88
88
|
if (i) {
|
|
89
|
-
const
|
|
90
|
-
if (D(
|
|
89
|
+
const s = r.charCodeAt(c), n = i[1].charCodeAt(0);
|
|
90
|
+
if (D(s) === D(n))
|
|
91
91
|
return !1;
|
|
92
92
|
}
|
|
93
|
-
if (i = r.slice(c +
|
|
94
|
-
const
|
|
95
|
-
if (D(
|
|
93
|
+
if (i = r.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
|
|
94
|
+
const s = r.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
|
|
95
|
+
if (D(s) === D(n))
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
return !0;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function I(r, c, m) {
|
|
101
101
|
const i = [];
|
|
102
|
-
function
|
|
103
|
-
const
|
|
104
|
-
let
|
|
102
|
+
function s(n, o, e = -1, t = -1, d = "") {
|
|
103
|
+
const h = c.items[n], g = [];
|
|
104
|
+
let l = "", x = "", C = "", a = m[n];
|
|
105
105
|
if (!a)
|
|
106
106
|
return;
|
|
107
107
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
108
|
-
const
|
|
109
|
-
a.before(
|
|
108
|
+
const f = document.createElement("span");
|
|
109
|
+
a.before(f), f.append(a), m[n] = f, a = f;
|
|
110
110
|
}
|
|
111
|
-
e >= 0 && t >= 0 ?
|
|
112
|
-
const M = document.createTextNode(
|
|
113
|
-
if (N.className = "highlight appended " +
|
|
111
|
+
e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
|
|
112
|
+
const M = document.createTextNode(l), N = document.createElement("span");
|
|
113
|
+
if (N.className = "highlight appended " + d, N.setAttribute("data-match-index", `${o}`), N.append(M), g.push(N), i.push({ element: N, index: o }), e > 0)
|
|
114
114
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
115
|
+
x = h.str.substring(0, e);
|
|
116
|
+
const f = document.createTextNode(x);
|
|
117
|
+
g.unshift(f);
|
|
118
118
|
} else {
|
|
119
|
-
let
|
|
120
|
-
const
|
|
121
|
-
for (const
|
|
122
|
-
const
|
|
123
|
-
|
|
119
|
+
let f = 0;
|
|
120
|
+
const E = [];
|
|
121
|
+
for (const p of a.childNodes) {
|
|
122
|
+
const u = p.nodeType === Node.TEXT_NODE ? p.nodeValue : p.firstChild.nodeValue;
|
|
123
|
+
f += u.length, f <= e ? E.push(p) : e >= f - u.length && t <= f && E.push(
|
|
124
124
|
document.createTextNode(
|
|
125
|
-
|
|
125
|
+
u.substring(0, e - (f - u.length))
|
|
126
126
|
)
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
g.unshift(...E);
|
|
130
130
|
}
|
|
131
131
|
if (t > 0) {
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
132
|
+
C = h.str.substring(t);
|
|
133
|
+
const f = document.createTextNode(C);
|
|
134
|
+
g.push(f);
|
|
135
135
|
}
|
|
136
|
-
a.replaceChildren(...
|
|
136
|
+
a.replaceChildren(...g);
|
|
137
137
|
}
|
|
138
|
-
for (const [n,
|
|
139
|
-
if (
|
|
140
|
-
o
|
|
138
|
+
for (const [n, o] of r.entries())
|
|
139
|
+
if (o.start.idx === o.end.idx)
|
|
140
|
+
s(o.start.idx, n, o.start.offset, o.end.offset);
|
|
141
141
|
else
|
|
142
|
-
for (let e =
|
|
143
|
-
e ===
|
|
142
|
+
for (let e = o.start.idx, t = o.end.idx; e <= t; e++)
|
|
143
|
+
e === o.start.idx ? s(e, n, o.start.offset, -1, "begin") : e === o.end.idx ? s(e, n, -1, o.end.offset, "end") : s(e, n, -1, -1, "middle");
|
|
144
144
|
return i;
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
146
|
+
function V(r, c) {
|
|
147
|
+
const m = r.items.map((i) => i.str);
|
|
148
148
|
for (let i = 0; i < c.length; i++) {
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
const n = document.createTextNode(
|
|
152
|
-
|
|
149
|
+
const s = c[i];
|
|
150
|
+
if (s && s.nodeType !== Node.TEXT_NODE) {
|
|
151
|
+
const n = document.createTextNode(m[i]);
|
|
152
|
+
s.replaceChildren(n);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function H(r = {}) {
|
|
157
157
|
return { matchCase: !1, wholeWords: !1, ...r };
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function S(r, c, m) {
|
|
160
160
|
const i = [];
|
|
161
|
-
function
|
|
162
|
-
var
|
|
163
|
-
const
|
|
164
|
-
let
|
|
161
|
+
function s(n, o, e = -1, t = -1, d) {
|
|
162
|
+
var f, E;
|
|
163
|
+
const h = c.items[n], g = [];
|
|
164
|
+
let l = "", x = "", C = "", a = m[n];
|
|
165
165
|
if (!a)
|
|
166
166
|
return;
|
|
167
|
-
e >= 0 && t >= 0 ?
|
|
168
|
-
const M = document.createTextNode(
|
|
169
|
-
if (N.style.background =
|
|
167
|
+
e >= 0 && t >= 0 ? l = h.str.substring(e, t) : e < 0 && t < 0 ? l = h.str : e >= 0 ? l = h.str.substring(e) : t >= 0 && (l = h.str.substring(0, t));
|
|
168
|
+
const M = document.createTextNode(l), N = document.createElement("span");
|
|
169
|
+
if (N.style.background = d, N.append(M), g.push(N), e > 0)
|
|
170
170
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
171
|
+
x = h.str.substring(0, e);
|
|
172
|
+
const p = document.createTextNode(x);
|
|
173
|
+
g.unshift(p);
|
|
174
174
|
} else {
|
|
175
|
-
let
|
|
176
|
-
const
|
|
175
|
+
let p = 0;
|
|
176
|
+
const u = [];
|
|
177
177
|
for (const T of a.childNodes) {
|
|
178
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
else if (e >=
|
|
182
|
-
const w = v.substring(0, e - (
|
|
183
|
-
|
|
178
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((f = T.firstChild) == null ? void 0 : f.nodeValue) || "", b = v.length;
|
|
179
|
+
if (p += b, p <= e)
|
|
180
|
+
u.push(T);
|
|
181
|
+
else if (e >= p - b && t <= p) {
|
|
182
|
+
const w = v.substring(0, e - (p - b));
|
|
183
|
+
u.push(document.createTextNode(w));
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
g.unshift(...u);
|
|
187
187
|
}
|
|
188
188
|
if (t > 0)
|
|
189
189
|
if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
190
|
+
C = h.str.substring(t);
|
|
191
|
+
const p = document.createTextNode(C);
|
|
192
|
+
g.push(p);
|
|
193
193
|
} else {
|
|
194
|
-
let
|
|
195
|
-
const
|
|
194
|
+
let p = 0;
|
|
195
|
+
const u = [];
|
|
196
196
|
for (const T of a.childNodes) {
|
|
197
|
-
|
|
198
|
-
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((
|
|
199
|
-
if (
|
|
200
|
-
const w = v.substring(t - (
|
|
201
|
-
w &&
|
|
197
|
+
p >= t && u.push(T);
|
|
198
|
+
const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((E = T.firstChild) == null ? void 0 : E.nodeValue) || "", b = v.length;
|
|
199
|
+
if (p += b, p > t) {
|
|
200
|
+
const w = v.substring(t - (p - b));
|
|
201
|
+
w && u.push(document.createTextNode(w));
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
|
|
204
|
+
u.length > 0 && g.push(...u);
|
|
205
205
|
}
|
|
206
|
-
a.replaceChildren(...
|
|
206
|
+
a.replaceChildren(...g), i.push({ element: N, index: o });
|
|
207
207
|
}
|
|
208
|
-
for (const [n,
|
|
209
|
-
const { start: e, end: t, color:
|
|
210
|
-
e.idx === t.idx &&
|
|
208
|
+
for (const [n, o] of r.entries()) {
|
|
209
|
+
const { start: e, end: t, color: d } = o;
|
|
210
|
+
e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
|
|
211
211
|
}
|
|
212
212
|
return i;
|
|
213
213
|
}
|
|
214
214
|
export {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
_ as findMatches,
|
|
216
|
+
H as getHighlightOptionsWithDefaults,
|
|
217
|
+
I as highlightMatches,
|
|
218
|
+
S as highlightMultipleColorMatches,
|
|
219
|
+
W as isMatchEntireWord,
|
|
220
|
+
V as resetDivs
|
|
221
221
|
};
|
|
@@ -2,7 +2,7 @@ import "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
4
|
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
-
import { b as
|
|
5
|
+
import { b as Hr } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
6
6
|
import "../../contexts/DarkModeContext.js";
|
|
7
7
|
import "../../contexts/RotationContext.js";
|
|
8
8
|
import "../../contexts/LayerContext.js";
|
|
@@ -91,6 +91,7 @@ import "./usePinch.js";
|
|
|
91
91
|
import "../../components/ui/PasswordModal.js";
|
|
92
92
|
import "./useLocalization.js";
|
|
93
93
|
import "./useCopyText.js";
|
|
94
|
+
import "./useTextSelection.js";
|
|
94
95
|
import "../getWordPositionInPage.js";
|
|
95
96
|
import "../smoothScrollTo.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Hr as useFileDownload
|
|
141
142
|
};
|
|
@@ -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-02-
|
|
3
|
+
const b = /* @__PURE__ */ new Date("2026-02-02T10:36:09.752Z"), 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,6 +1,6 @@
|
|
|
1
1
|
import "react";
|
|
2
2
|
import "../types.js";
|
|
3
|
-
import { v as
|
|
3
|
+
import { v as Gr } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
4
4
|
import "react/jsx-runtime";
|
|
5
5
|
import "../../contexts/RPDocumentContext.js";
|
|
6
6
|
import "../../contexts/DocumentPasswordContext.js";
|
|
@@ -91,6 +91,7 @@ import "./usePinch.js";
|
|
|
91
91
|
import "../../components/ui/PasswordModal.js";
|
|
92
92
|
import "./useLocalization.js";
|
|
93
93
|
import "./useCopyText.js";
|
|
94
|
+
import "./useTextSelection.js";
|
|
94
95
|
import "../getWordPositionInPage.js";
|
|
95
96
|
import "../smoothScrollTo.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Gr as usePaginate
|
|
141
142
|
};
|
|
@@ -5,7 +5,7 @@ import "../calculatePage.js";
|
|
|
5
5
|
import "react/jsx-runtime";
|
|
6
6
|
import "../../contexts/RPDocumentContext.js";
|
|
7
7
|
import "../../contexts/DocumentPasswordContext.js";
|
|
8
|
-
import { U as
|
|
8
|
+
import { U as Fo } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
9
9
|
import "../../contexts/DarkModeContext.js";
|
|
10
10
|
import "../types.js";
|
|
11
11
|
import "../../contexts/RotationContext.js";
|
|
@@ -91,6 +91,7 @@ import "./usePinch.js";
|
|
|
91
91
|
import "../../components/ui/PasswordModal.js";
|
|
92
92
|
import "./useLocalization.js";
|
|
93
93
|
import "./useCopyText.js";
|
|
94
|
+
import "./useTextSelection.js";
|
|
94
95
|
import "../getWordPositionInPage.js";
|
|
95
96
|
import "../smoothScrollTo.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Fo as usePresentPage
|
|
141
142
|
};
|
|
@@ -2,7 +2,7 @@ import "react";
|
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "../../contexts/RPDocumentContext.js";
|
|
4
4
|
import "../../contexts/DocumentPasswordContext.js";
|
|
5
|
-
import { x as
|
|
5
|
+
import { x as Go } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
6
6
|
import "../../contexts/DarkModeContext.js";
|
|
7
7
|
import "../../contexts/RotationContext.js";
|
|
8
8
|
import "../../contexts/LayerContext.js";
|
|
@@ -91,6 +91,7 @@ import "./usePinch.js";
|
|
|
91
91
|
import "../../components/ui/PasswordModal.js";
|
|
92
92
|
import "./useLocalization.js";
|
|
93
93
|
import "./useCopyText.js";
|
|
94
|
+
import "./useTextSelection.js";
|
|
94
95
|
import "../getWordPositionInPage.js";
|
|
95
96
|
import "../smoothScrollTo.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Go as usePrint
|
|
141
142
|
};
|
|
@@ -3,7 +3,7 @@ import "../../contexts/ScrollModeContext.js";
|
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "../../contexts/RPDocumentContext.js";
|
|
5
5
|
import "../../contexts/DocumentPasswordContext.js";
|
|
6
|
-
import { t as
|
|
6
|
+
import { t as Er } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
7
7
|
import "../../contexts/DarkModeContext.js";
|
|
8
8
|
import "../types.js";
|
|
9
9
|
import "../../contexts/RotationContext.js";
|
|
@@ -92,6 +92,7 @@ import "./usePinch.js";
|
|
|
92
92
|
import "../../components/ui/PasswordModal.js";
|
|
93
93
|
import "./useLocalization.js";
|
|
94
94
|
import "./useCopyText.js";
|
|
95
|
+
import "./useTextSelection.js";
|
|
95
96
|
import "../getWordPositionInPage.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
97
98
|
import "../../components/icons/FileUploadDefaultIcon.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Er as useScrollToPage
|
|
141
142
|
};
|
|
@@ -7,7 +7,7 @@ import "../../contexts/RPDocumentContext.js";
|
|
|
7
7
|
import "../../contexts/ZoomContext.js";
|
|
8
8
|
import "react/jsx-runtime";
|
|
9
9
|
import "../../contexts/DocumentPasswordContext.js";
|
|
10
|
-
import { B as
|
|
10
|
+
import { B as Go } from "../../ToolbarLayout.module-3f4e0f88.js";
|
|
11
11
|
import "../../contexts/DarkModeContext.js";
|
|
12
12
|
import "../../contexts/RotationContext.js";
|
|
13
13
|
import "../../contexts/LayerContext.js";
|
|
@@ -92,6 +92,7 @@ import "./usePinch.js";
|
|
|
92
92
|
import "../../components/ui/PasswordModal.js";
|
|
93
93
|
import "./useLocalization.js";
|
|
94
94
|
import "./useCopyText.js";
|
|
95
|
+
import "./useTextSelection.js";
|
|
95
96
|
import "../smoothScrollTo.js";
|
|
96
97
|
import "../../components/layout/toolbar/FileUploadTool.js";
|
|
97
98
|
import "../../components/icons/FileUploadDefaultIcon.js";
|
|
@@ -137,5 +138,5 @@ import "./useHighlight.js";
|
|
|
137
138
|
import "../../components/icons/LightPdfIcon.js";
|
|
138
139
|
import "../../components/icons/DarkPdfIcon.js";
|
|
139
140
|
export {
|
|
140
|
-
|
|
141
|
+
Go as useSearch
|
|
141
142
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useCallback as p, useEffect as b } from "react";
|
|
2
|
+
const D = ({ onTextSelect: s, pagesRef: n }) => {
|
|
3
|
+
const f = p(() => {
|
|
4
|
+
const e = n == null ? void 0 : n.querySelectorAll('[data-rp$="-textLayer"]');
|
|
5
|
+
return e ? Array.from(e) : [];
|
|
6
|
+
}, [n]), N = p(() => {
|
|
7
|
+
const e = document.getSelection();
|
|
8
|
+
if (!e || e.rangeCount === 0 || e.toString().trim() === "")
|
|
9
|
+
return null;
|
|
10
|
+
const E = e.toString(), a = /* @__PURE__ */ new Map(), O = f();
|
|
11
|
+
for (let i = 0; i < e.rangeCount; i++) {
|
|
12
|
+
const t = e.getRangeAt(i);
|
|
13
|
+
O.forEach((d) => {
|
|
14
|
+
if (t.intersectsNode(d)) {
|
|
15
|
+
const g = d.getAttribute("data-rp"), T = g == null ? void 0 : g.match(/page-(\d+)-textLayer/);
|
|
16
|
+
if (T) {
|
|
17
|
+
const h = parseInt(T[1]), C = d.closest('[data-rp*="page-"]');
|
|
18
|
+
if (!C)
|
|
19
|
+
return;
|
|
20
|
+
const c = C.getBoundingClientRect();
|
|
21
|
+
a.has(h) || a.set(h, {
|
|
22
|
+
rects: [],
|
|
23
|
+
pageRect: c
|
|
24
|
+
});
|
|
25
|
+
const y = a.get(h), _ = document.createTreeWalker(d, NodeFilter.SHOW_TEXT, null);
|
|
26
|
+
let u;
|
|
27
|
+
for (; u = _.nextNode(); )
|
|
28
|
+
if (t.intersectsNode(u) && u.parentElement) {
|
|
29
|
+
const o = document.createRange();
|
|
30
|
+
o.selectNodeContents(u);
|
|
31
|
+
const A = t.compareBoundaryPoints(Range.START_TO_START, o) > 0 ? t.startContainer : o.startContainer, B = t.compareBoundaryPoints(Range.START_TO_START, o) > 0 ? t.startOffset : o.startOffset, R = t.compareBoundaryPoints(Range.END_TO_END, o) < 0 ? t.endContainer : o.endContainer, S = t.compareBoundaryPoints(Range.END_TO_END, o) < 0 ? t.endOffset : o.endOffset, m = document.createRange();
|
|
32
|
+
m.setStart(A, B), m.setEnd(R, S);
|
|
33
|
+
const r = m.getBoundingClientRect();
|
|
34
|
+
if (r.width === 0 || r.height === 0)
|
|
35
|
+
continue;
|
|
36
|
+
const P = {
|
|
37
|
+
left: r.left - c.left,
|
|
38
|
+
top: r.top - c.top,
|
|
39
|
+
right: r.right - c.left,
|
|
40
|
+
bottom: r.bottom - c.top,
|
|
41
|
+
width: r.width,
|
|
42
|
+
height: r.height
|
|
43
|
+
};
|
|
44
|
+
y.rects.push(P);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const w = Array.from(a.entries()).sort(([i], [t]) => i - t).map(([i, t]) => ({
|
|
51
|
+
pageNumber: i,
|
|
52
|
+
pageBasedBoundingRects: t.rects,
|
|
53
|
+
pageDimension: {
|
|
54
|
+
width: t.pageRect.width,
|
|
55
|
+
height: t.pageRect.height
|
|
56
|
+
},
|
|
57
|
+
pagePositionInWindow: {
|
|
58
|
+
x: t.pageRect.left,
|
|
59
|
+
y: t.pageRect.top
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
return {
|
|
63
|
+
text: E,
|
|
64
|
+
pageSelections: w
|
|
65
|
+
};
|
|
66
|
+
}, [f]), l = p(() => {
|
|
67
|
+
const e = N();
|
|
68
|
+
e && (s == null || s(e));
|
|
69
|
+
}, [N, s]);
|
|
70
|
+
b(() => (n == null || n.addEventListener("pointerup", l), () => {
|
|
71
|
+
n == null || n.removeEventListener("pointerup", l);
|
|
72
|
+
}), [n, l]);
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
D as useTextSelection
|
|
76
|
+
};
|