@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.
Files changed (80) hide show
  1. package/dist/{ToolbarLayout.module-9594715b.js → ToolbarLayout.module-3f4e0f88.js} +1239 -1245
  2. package/dist/components/RPController.js +15 -14
  3. package/dist/components/RPPages.js +3 -2
  4. package/dist/components/RPProvider.js +33 -22
  5. package/dist/components/layout/LayoutContainer.js +3 -2
  6. package/dist/components/layout/RPDefaultLayout.js +3 -2
  7. package/dist/components/layout/RPLayout.js +4 -3
  8. package/dist/components/layout/SkipLink.js +2 -3
  9. package/dist/components/layout/sidebar/RPSidebar.js +3 -2
  10. package/dist/components/layout/sidebar/Thumbnail.js +3 -2
  11. package/dist/components/layout/sidebar/Thumbnails.js +3 -2
  12. package/dist/components/layout/toolbar/DocumentDialog.js +3 -2
  13. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -2
  14. package/dist/components/layout/toolbar/MostPageTool.js +3 -2
  15. package/dist/components/layout/toolbar/OtherTool.js +3 -2
  16. package/dist/components/layout/toolbar/Paginate.js +3 -2
  17. package/dist/components/layout/toolbar/PrintTool.js +3 -2
  18. package/dist/components/layout/toolbar/RPMoreOptions.js +7 -6
  19. package/dist/components/layout/toolbar/RPToolbar.js +3 -2
  20. package/dist/components/layout/toolbar/RPToolbarEnd.js +3 -2
  21. package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -2
  22. package/dist/components/layout/toolbar/SearchTool.js +3 -2
  23. package/dist/components/layout/toolbar/ThumbnailTool.js +4 -3
  24. package/dist/components/layout/toolbar/ToolbarCustom.js +4 -3
  25. package/dist/components/layout/toolbar/ToolbarDefault.js +4 -3
  26. package/dist/components/layout/toolbar/ToolbarLayout.js +4 -3
  27. package/dist/components/layout/toolbar/ZoomTool.js +3 -2
  28. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +4 -3
  29. package/dist/components/layout/toolbar/tools/DualPageTool.js +4 -3
  30. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +4 -3
  31. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +4 -3
  32. package/dist/components/layout/toolbar/tools/FirstPageTool.js +148 -0
  33. package/dist/components/layout/toolbar/tools/InputPageTool.js +4 -3
  34. package/dist/components/layout/toolbar/tools/LastPageTool.js +148 -0
  35. package/dist/components/layout/toolbar/tools/NextPageTool.js +4 -3
  36. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +4 -3
  37. package/dist/components/layout/toolbar/tools/PrintTool.js +4 -3
  38. package/dist/components/layout/toolbar/tools/SinglePageTool.js +4 -3
  39. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +4 -3
  40. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +3 -2
  41. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +4 -3
  42. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +4 -3
  43. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +4 -3
  44. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +4 -3
  45. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +4 -3
  46. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +12 -11
  47. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +4 -3
  48. package/dist/components/page/AnnotationLayer.js +3 -2
  49. package/dist/components/page/CanvasLayer.js +3 -2
  50. package/dist/components/page/DualPage.js +3 -2
  51. package/dist/components/page/DualPageWithCover.js +3 -2
  52. package/dist/components/page/RPPage.js +3 -2
  53. package/dist/components/page/SinglePage.js +3 -2
  54. package/dist/components/page/TextHighlightLayer.js +3 -2
  55. package/dist/components/page/TextLayer.js +3 -2
  56. package/dist/components/ui/LoadingIndicator.js +3 -2
  57. package/dist/contexts/EventCallbackContext.js +12 -8
  58. package/dist/contexts/PaginationContext.js +5 -4
  59. package/dist/contexts/PrintContext.js +5 -4
  60. package/dist/contexts/RenderQueueProvider.js +5 -4
  61. package/dist/contexts/SearchContext.js +5 -4
  62. package/dist/contexts/ThumbnailsContext.js +5 -4
  63. package/dist/main.js +96 -91
  64. package/dist/types/components/layout/toolbar/tools/FirstPageTool.d.ts +3 -0
  65. package/dist/types/components/layout/toolbar/tools/LastPageTool.d.ts +3 -0
  66. package/dist/types/main.d.ts +3 -1
  67. package/dist/types/utils/hooks/useTextSelection.d.ts +7 -0
  68. package/dist/types/utils/types.d.ts +21 -1
  69. package/dist/utils/highlight.js +139 -139
  70. package/dist/utils/hooks/useFileDownload.js +3 -2
  71. package/dist/utils/hooks/useLicense.js +1 -1
  72. package/dist/utils/hooks/usePaginate.js +3 -2
  73. package/dist/utils/hooks/usePresentPage.js +3 -2
  74. package/dist/utils/hooks/usePrint.js +3 -2
  75. package/dist/utils/hooks/useScrollToPage.js +3 -2
  76. package/dist/utils/hooks/useSearch.js +3 -2
  77. package/dist/utils/hooks/useTextSelection.js +76 -0
  78. package/dist/utils/hooks/useThumbnail.js +3 -2
  79. package/dist/utils/hooks/useVirtualReactWindow.js +3 -2
  80. 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;
@@ -1,221 +1,221 @@
1
1
  import { getCharacterType as D } from "./charators.js";
2
- function V(r, c, u, i) {
3
- const o = [];
2
+ function _(r, c, m, i) {
3
+ const s = [];
4
4
  for (const n of r) {
5
- const s = y(c, n, i);
6
- o.push(...I(s, c, u));
5
+ const o = y(c, n, i);
6
+ s.push(...R(o, c, m));
7
7
  }
8
- return o;
8
+ return s;
9
9
  }
10
- const X = (r, c) => {
11
- const u = ["g"];
12
- c.matchCase || u.push("i");
13
- let o = r.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
- return new RegExp(o, u.join(""));
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, u) {
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 l = t.str.lastIndexOf("-");
22
- i.push(t.str.substring(0, l));
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 o = i.join("").replace(/\n/g, " ");
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 = X(c, u);
31
- const s = [];
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(o)) !== null; )
34
- u.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
35
- return s;
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 I(r, c, u) {
38
- function i(l) {
39
- return l.hasEOL ? l.str.endsWith("-") ? -1 : 1 : 0;
37
+ function R(r, c, m) {
38
+ function i(d) {
39
+ return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
40
40
  }
41
- let o = 0, n = 0;
42
- const s = c.items, e = s.length - 1, t = [];
43
- for (let l = 0; l < r.length; l++) {
44
- let d = r[l][0];
45
- for (; o !== e && d >= n + s[o].str.length; ) {
46
- const f = s[o];
47
- n += f.str.length + i(f), o++;
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 h = {
50
- idx: o,
51
- offset: d - n
49
+ const g = {
50
+ idx: s,
51
+ offset: h - n
52
52
  };
53
- for (d += r[l][1]; o !== e && d > n + s[o].str.length; ) {
54
- const f = s[o];
55
- n += f.str.length + i(f), o++;
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 m = {
58
- idx: o,
59
- offset: d - n
57
+ const l = {
58
+ idx: s,
59
+ offset: h - n
60
60
  };
61
61
  t.push({
62
- start: h,
63
- end: m,
64
- str: r[l][2],
65
- oIndex: r[l][0],
66
- pageIndex: u,
67
- rect: {
68
- left: 0,
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 l of t) {
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
- };
82
- l.rect = M;
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 L(r, c, u) {
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 o = r.charCodeAt(c), n = i[1].charCodeAt(0);
90
- if (D(o) === D(n))
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 + 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))
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 H(r, c, u) {
100
+ function I(r, c, m) {
101
101
  const i = [];
102
- function o(n, s, e = -1, t = -1, l = "") {
103
- const d = c.items[n], h = [];
104
- let m = "", f = "", E = "", a = u[n];
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 p = document.createElement("span");
109
- a.before(p), p.append(a), u[n] = p, a = p;
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 ? 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 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)
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
- f = d.str.substring(0, e);
116
- const p = document.createTextNode(f);
117
- h.unshift(p);
115
+ x = h.str.substring(0, e);
116
+ const f = document.createTextNode(x);
117
+ g.unshift(f);
118
118
  } else {
119
- let p = 0;
120
- const b = [];
121
- for (const g of a.childNodes) {
122
- const x = g.nodeType === Node.TEXT_NODE ? g.nodeValue : g.firstChild.nodeValue;
123
- p += x.length, p <= e ? b.push(g) : e >= p - x.length && t <= p && b.push(
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
- x.substring(0, e - (p - x.length))
125
+ u.substring(0, e - (f - u.length))
126
126
  )
127
127
  );
128
128
  }
129
- h.unshift(...b);
129
+ g.unshift(...E);
130
130
  }
131
131
  if (t > 0) {
132
- E = d.str.substring(t);
133
- const p = document.createTextNode(E);
134
- h.push(p);
132
+ C = h.str.substring(t);
133
+ const f = document.createTextNode(C);
134
+ g.push(f);
135
135
  }
136
- a.replaceChildren(...h);
136
+ a.replaceChildren(...g);
137
137
  }
138
- for (const [n, s] of r.entries())
139
- if (s.start.idx === s.end.idx)
140
- o(s.start.idx, n, s.start.offset, s.end.offset);
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 = s.start.idx, t = s.end.idx; e <= t; e++)
143
- e === s.start.idx ? o(e, n, s.start.offset, -1, "begin") : e === s.end.idx ? o(e, n, -1, s.end.offset, "end") : o(e, n, -1, -1, "middle");
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 R(r, c) {
147
- const u = r.items.map((i) => i.str);
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 o = c[i];
150
- if (o && o.nodeType !== Node.TEXT_NODE) {
151
- const n = document.createTextNode(u[i]);
152
- o.replaceChildren(n);
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 W(r = {}) {
156
+ function H(r = {}) {
157
157
  return { matchCase: !1, wholeWords: !1, ...r };
158
158
  }
159
- function A(r, c, u) {
159
+ function S(r, c, m) {
160
160
  const i = [];
161
- function o(n, s, e = -1, t = -1, l) {
162
- var p, b;
163
- const d = c.items[n], h = [];
164
- let m = "", f = "", E = "", a = u[n];
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 ? 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 M = document.createTextNode(m), N = document.createElement("span");
169
- if (N.style.background = l, N.append(M), h.push(N), e > 0)
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
- f = d.str.substring(0, e);
172
- const g = document.createTextNode(f);
173
- h.unshift(g);
171
+ x = h.str.substring(0, e);
172
+ const p = document.createTextNode(x);
173
+ g.unshift(p);
174
174
  } else {
175
- let g = 0;
176
- const x = [];
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 || "" : ((p = T.firstChild) == null ? void 0 : p.nodeValue) || "", C = v.length;
179
- if (g += C, g <= e)
180
- x.push(T);
181
- else if (e >= g - C && t <= g) {
182
- const w = v.substring(0, e - (g - C));
183
- x.push(document.createTextNode(w));
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
- h.unshift(...x);
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
- E = d.str.substring(t);
191
- const g = document.createTextNode(E);
192
- h.push(g);
190
+ C = h.str.substring(t);
191
+ const p = document.createTextNode(C);
192
+ g.push(p);
193
193
  } else {
194
- let g = 0;
195
- const x = [];
194
+ let p = 0;
195
+ const u = [];
196
196
  for (const T of a.childNodes) {
197
- g >= t && x.push(T);
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
- w && x.push(document.createTextNode(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
- x.length > 0 && h.push(...x);
204
+ u.length > 0 && g.push(...u);
205
205
  }
206
- a.replaceChildren(...h), i.push({ element: N, index: s });
206
+ a.replaceChildren(...g), i.push({ element: N, index: o });
207
207
  }
208
- for (const [n, s] of r.entries()) {
209
- const { start: e, end: t, color: l } = s;
210
- e.idx === t.idx && o(e.idx, n, e.offset, t.offset, l);
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
- V as findMatches,
216
- W as getHighlightOptionsWithDefaults,
217
- H as highlightMatches,
218
- A as highlightMultipleColorMatches,
219
- L as isMatchEntireWord,
220
- R as resetDivs
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 Gr } from "../../ToolbarLayout.module-9594715b.js";
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
- Gr as useFileDownload
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-03T03:12:21.009Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
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 Fr } from "../../ToolbarLayout.module-9594715b.js";
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
- Fr as usePaginate
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 Eo } from "../../ToolbarLayout.module-9594715b.js";
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
- Eo as usePresentPage
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 Fo } from "../../ToolbarLayout.module-9594715b.js";
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
- Fo as usePrint
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 Dr } from "../../ToolbarLayout.module-9594715b.js";
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
- Dr as useScrollToPage
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 Fo } from "../../ToolbarLayout.module-9594715b.js";
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
- Fo as useSearch
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
+ };