@react-pdf-kit/viewer 0.0.0-experimental.4 → 0.0.0-experimental.6

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 (138) hide show
  1. package/dist/RPLayout.module-b4b23e29.js +14 -0
  2. package/dist/assets/style.css +1 -1
  3. package/dist/assets/style.js +15 -15
  4. package/dist/components/RPConfig.js +18 -6
  5. package/dist/components/RPController.js +21 -26
  6. package/dist/components/RPDropFileZone.js +34 -28
  7. package/dist/components/RPPages.js +352 -361
  8. package/dist/components/RPProvider.js +20 -24
  9. package/dist/components/layout/LayoutContainer.js +1 -1
  10. package/dist/components/layout/LayoutWrapper.js +1 -1
  11. package/dist/components/layout/RPDefaultLayout.js +6 -7
  12. package/dist/components/layout/RPLayout.js +22 -22
  13. package/dist/components/layout/WrapperLayout.js +10 -11
  14. package/dist/components/layout/sidebar/RPSidebar.js +3 -4
  15. package/dist/components/layout/sidebar/Thumbnail.js +3 -4
  16. package/dist/components/layout/sidebar/Thumbnails.js +3 -4
  17. package/dist/components/layout/toolbar/DocumentDialog.js +5 -6
  18. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -4
  19. package/dist/components/layout/toolbar/FileUploadTool.js +3 -4
  20. package/dist/components/layout/toolbar/MostPageTool.js +3 -4
  21. package/dist/components/layout/toolbar/OtherTool.js +3 -4
  22. package/dist/components/layout/toolbar/Paginate.js +3 -4
  23. package/dist/components/layout/toolbar/PrintTool.js +3 -4
  24. package/dist/components/layout/toolbar/RPMoreOptions.js +3 -4
  25. package/dist/components/layout/toolbar/RPToolbar.js +3 -6
  26. package/dist/components/layout/toolbar/RPToolbarEnd.js +3 -4
  27. package/dist/components/layout/toolbar/RotateTool.js +3 -4
  28. package/dist/components/layout/toolbar/SearchResultNavigator.js +3 -6
  29. package/dist/components/layout/toolbar/SearchTool.js +5 -8
  30. package/dist/components/layout/toolbar/ThumbnailTool.js +3 -4
  31. package/dist/components/layout/toolbar/ToolbarCustom.js +3 -4
  32. package/dist/components/layout/toolbar/ToolbarDefault.js +3 -6
  33. package/dist/components/layout/toolbar/ToolbarLayout.js +3 -6
  34. package/dist/components/layout/toolbar/ZoomTool.js +3 -4
  35. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -4
  36. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +7 -9
  37. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +3 -4
  38. package/dist/components/layout/toolbar/tools/FileUploadTool.js +3 -4
  39. package/dist/components/layout/toolbar/tools/FirstPageTool.js +7 -9
  40. package/dist/components/layout/toolbar/tools/InputPageTool.js +3 -4
  41. package/dist/components/layout/toolbar/tools/LastPageTool.js +7 -9
  42. package/dist/components/layout/toolbar/tools/NextPageTool.js +3 -4
  43. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +3 -4
  44. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -4
  45. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +3 -4
  46. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +3 -4
  47. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +3 -4
  48. package/dist/components/layout/toolbar/tools/ZoomInTool.js +3 -4
  49. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +13 -14
  50. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +3 -4
  51. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +3 -6
  52. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +3 -4
  53. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +3 -4
  54. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +3 -4
  55. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +3 -4
  56. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +3 -4
  57. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +3 -4
  58. package/dist/components/page/AnnotationLayer.js +65 -66
  59. package/dist/components/page/CanvasLayer.js +3 -4
  60. package/dist/components/page/CustomElement.js +3 -4
  61. package/dist/components/page/DualPage.js +5 -11
  62. package/dist/components/page/DualPageWithCover.js +5 -11
  63. package/dist/components/page/RPPage.js +6 -12
  64. package/dist/components/page/SinglePage.js +5 -11
  65. package/dist/components/page/TextHighlightLayer.js +178 -86
  66. package/dist/components/page/TextLayer.js +170 -125
  67. package/dist/components/ui/LoadingIndicator.js +7 -8
  68. package/dist/contexts/ConfigContext.js +5 -4
  69. package/dist/contexts/DimensionPagesContext.js +5 -6
  70. package/dist/contexts/DropFileZoneContext.js +4 -5
  71. package/dist/contexts/ElementPageContext.js +5 -6
  72. package/dist/contexts/FileInputContext.js +5 -6
  73. package/dist/contexts/HighlightContext.js +7 -10
  74. package/dist/contexts/LayoutDropFileZoneContext.js +11 -0
  75. package/dist/contexts/LicenseContext.js +8 -6
  76. package/dist/contexts/PagesRotateContext.js +5 -6
  77. package/dist/contexts/PaginationContext.js +5 -6
  78. package/dist/contexts/PrintContext.js +16 -17
  79. package/dist/contexts/RPDocumentContext.js +13 -14
  80. package/dist/contexts/RenderQueueProvider.js +5 -6
  81. package/dist/contexts/RotationContext.js +8 -9
  82. package/dist/contexts/SearchContext.js +5 -8
  83. package/dist/contexts/ThumbnailsContext.js +4 -5
  84. package/dist/contexts/ZoomContext.js +5 -6
  85. package/dist/main.js +9 -9
  86. package/dist/types/components/layout/sidebar/Thumbnail.d.ts +2 -2
  87. package/dist/types/contexts/LayoutDropFileZoneContext.d.ts +9 -0
  88. package/dist/types/contexts/RPDocumentContext.d.ts +1 -1
  89. package/dist/types/contexts/RenderQueueProvider.d.ts +1 -1
  90. package/dist/types/contexts/RenderedPagesCache.d.ts +2 -2
  91. package/dist/types/main.d.ts +1 -1
  92. package/dist/types/utils/annotations.d.ts +2 -2
  93. package/dist/types/utils/getThumbnailViewport.d.ts +2 -2
  94. package/dist/types/utils/highlight.d.ts +5 -5
  95. package/dist/types/utils/hooks/useDropFileZone.d.ts +5 -0
  96. package/dist/types/utils/hooks/useFlickerSelectText.d.ts +1 -0
  97. package/dist/types/utils/hooks/useHighlight.d.ts +1 -1
  98. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  99. package/dist/types/utils/hooks/useLoadWorker.d.ts +1 -5
  100. package/dist/types/utils/hooks/usePdfProperties.d.ts +1 -1
  101. package/dist/types/utils/hooks/useTextSelection.d.ts +3 -12
  102. package/dist/types/utils/link_service.d.ts +3 -2
  103. package/dist/types/utils/renderPage.d.ts +2 -2
  104. package/dist/types/utils/types.d.ts +10 -6
  105. package/dist/utils/highlight.js +158 -184
  106. package/dist/utils/hooks/useCopyText.js +22 -60
  107. package/dist/utils/hooks/useDropFileZone.js +12 -0
  108. package/dist/utils/hooks/useFileDownload.js +5 -6
  109. package/dist/utils/hooks/useFlickerSelectText.js +25 -0
  110. package/dist/utils/hooks/useHighlight.js +33 -35
  111. package/dist/utils/hooks/useLicense.js +22 -28
  112. package/dist/utils/hooks/useLoadPdf.js +70 -95
  113. package/dist/utils/hooks/useLoadWorker.js +14 -4
  114. package/dist/utils/hooks/usePageRotateContext.js +7 -8
  115. package/dist/utils/hooks/usePaginate.js +3 -4
  116. package/dist/utils/hooks/usePinch.js +10 -11
  117. package/dist/utils/hooks/usePresentPage.js +3 -4
  118. package/dist/utils/hooks/usePrint.js +55 -54
  119. package/dist/utils/hooks/useRotate.js +3 -4
  120. package/dist/utils/hooks/useScrollToPage.js +3 -4
  121. package/dist/utils/hooks/useSearch.js +15 -18
  122. package/dist/utils/hooks/useTextSelection.js +73 -2
  123. package/dist/utils/hooks/useThumbnail.js +17 -18
  124. package/dist/utils/hooks/useVirtualReactWindow.js +3 -4
  125. package/dist/utils/hooks/useWatermark.js +8 -6
  126. package/dist/utils/link_service.js +19 -18
  127. package/dist/utils/renderPage.js +1 -1
  128. package/dist/utils/types.js +3 -3
  129. package/package.json +6 -7
  130. package/dist/RPLayout.module-7766e0b4.js +0 -14
  131. package/dist/contexts/TextSelectionContext.js +0 -191
  132. package/dist/types/contexts/TextSelectionContext.d.ts +0 -14
  133. package/dist/types/utils/geometryCache.d.ts +0 -15
  134. package/dist/types/utils/glyphHitTest.d.ts +0 -12
  135. package/dist/types/utils/selectionUtils.d.ts +0 -30
  136. package/dist/utils/geometryCache.js +0 -32
  137. package/dist/utils/glyphHitTest.js +0 -29
  138. package/dist/utils/selectionUtils.js +0 -96
@@ -1,247 +1,221 @@
1
- import { getCharacterType as y } from "./charators.js";
2
- import { rectsForRange as L } from "./selectionUtils.js";
3
- import { geometryCache as R } from "./geometryCache.js";
4
- function A(r, d, a, i) {
5
- const t = [];
6
- for (const s of r) {
7
- const c = X(d, s, i);
8
- t.push(..._(c, d, a));
1
+ import { getCharacterType as D } from "./charators.js";
2
+ function _(l, c, m, i) {
3
+ const s = [];
4
+ for (const n of l) {
5
+ const o = y(c, n, i);
6
+ s.push(...R(o, c, m));
9
7
  }
10
- return t;
8
+ return s;
11
9
  }
12
- const W = (r, d) => {
13
- const a = ["g"];
14
- d.matchCase || a.push("i");
15
- let t = r.replace(/[.^$*+?()[{|\\]/g, (s) => `\\${s}`).trim();
16
- return new RegExp(t, a.join(""));
10
+ const L = (l, c) => {
11
+ const m = ["g"];
12
+ c.matchCase || m.push("i");
13
+ let s = l.replace(/[.^$*+?()[{|\\]/g, (n) => `\\${n}`).trim();
14
+ return new RegExp(s, m.join(""));
17
15
  };
18
- function X(r, d, a) {
16
+ function y(l, c, m) {
19
17
  const i = [];
20
- for (const n of r.items)
21
- if (n.hasEOL)
22
- if (n.str.endsWith("-")) {
23
- const T = n.str.lastIndexOf("-");
24
- i.push(n.str.substring(0, T));
18
+ for (const t of l.items)
19
+ if (t.hasEOL)
20
+ if (t.str.endsWith("-")) {
21
+ const d = t.str.lastIndexOf("-");
22
+ i.push(t.str.substring(0, d));
25
23
  } else
26
- i.push(n.str, `
24
+ i.push(t.str, `
27
25
  `);
28
26
  else
29
- i.push(n.str);
30
- const t = i.join("").replace(/\n/g, " ");
31
- let s;
32
- d instanceof RegExp ? s = d.flags.indexOf("g") === -1 ? new RegExp(d, `${d.flags}g`) : d : s = W(d, a);
33
- const c = [];
27
+ i.push(t.str);
28
+ const s = i.join("").replace(/\n/g, " ");
29
+ let n;
30
+ c instanceof RegExp ? n = c.flags.indexOf("g") === -1 ? new RegExp(c, `${c.flags}g`) : c : n = L(c, m);
31
+ const o = [];
34
32
  let e;
35
- for (; (e = s.exec(t)) !== null; )
36
- a.wholeWords && !V(t, e.index, e[0].length) || c.push([e.index, e[0].length, e[0]]);
37
- return c;
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;
38
36
  }
39
- function _(r, d, a) {
40
- function i(o) {
41
- return o.hasEOL ? o.str.endsWith("-") ? -1 : 1 : 0;
37
+ function R(l, c, m) {
38
+ function i(d) {
39
+ return d.hasEOL ? d.str.endsWith("-") ? -1 : 1 : 0;
42
40
  }
43
- let t = 0, s = 0;
44
- const c = d.items, e = c.length - 1, n = [];
45
- for (let o = 0; o < r.length; o++) {
46
- let l = r[o][0];
47
- for (; t !== e && l >= s + c[t].str.length; ) {
48
- const x = c[t];
49
- s += x.str.length + i(x), t++;
41
+ let s = 0, n = 0;
42
+ const o = c.items, e = o.length - 1, t = [];
43
+ for (let d = 0; d < l.length; d++) {
44
+ let h = l[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++;
50
48
  }
51
- const u = {
52
- idx: t,
53
- offset: l - s
49
+ const g = {
50
+ idx: s,
51
+ offset: h - n
54
52
  };
55
- for (l += r[o][1]; t !== e && l > s + c[t].str.length; ) {
56
- const x = c[t];
57
- s += x.str.length + i(x), t++;
53
+ for (h += l[d][1]; s !== e && h > n + o[s].str.length; ) {
54
+ const x = o[s];
55
+ n += x.str.length + i(x), s++;
58
56
  }
59
- const g = {
60
- idx: t,
61
- offset: l - s
57
+ const r = {
58
+ idx: s,
59
+ offset: h - n
62
60
  };
63
- n.push({
64
- start: u,
65
- end: g,
66
- str: r[o][2],
67
- oIndex: r[o][0],
68
- pageIndex: a,
61
+ t.push({
62
+ start: g,
63
+ end: r,
64
+ str: l[d][2],
65
+ oIndex: l[d][0],
66
+ pageIndex: m,
69
67
  rect: { left: 0, bottom: 0, width: 0, height: 0 },
70
68
  rects: []
71
69
  });
72
70
  }
73
- const T = R.get(a);
74
- for (const o of n) {
75
- const l = [];
76
- if (T && T.runs.length > 0) {
77
- const u = D(T, o.start.idx, o.start.offset), g = D(T, o.end.idx, o.end.offset - 1);
78
- if (u >= 0 && g >= 0) {
79
- const x = L(T, u, g);
80
- for (const h of x)
81
- l.push({
82
- left: h.x,
83
- bottom: h.y + h.height,
84
- width: h.width,
85
- height: h.height
86
- });
87
- }
71
+ for (const d of t) {
72
+ const h = [];
73
+ for (let g = d.start.idx; g <= d.end.idx; g++) {
74
+ const r = o[g], x = r.transform[4], C = r.transform[5], a = r.str.length > 0 ? r.width / r.str.length : 0, M = g === d.start.idx ? d.start.offset : 0, N = g === d.end.idx ? d.end.offset : r.str.length, f = x + M * a, E = (N - M) * a, u = (c.styles ?? {})[r.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 * r.height;
75
+ r.height > 0 && r.width > 0 && h.push({
76
+ left: f,
77
+ bottom: b,
78
+ width: E,
79
+ height: r.height
80
+ });
88
81
  }
89
- if (l.length === 0)
90
- for (let u = o.start.idx; u <= o.end.idx; u++) {
91
- const g = c[u], x = g.transform[4], h = g.transform[5], v = g.str.length > 0 ? g.width / g.str.length : 0, b = u === o.start.idx ? o.start.offset : 0, p = u === o.end.idx ? o.end.offset : g.str.length, E = x + b * v, f = (p - b) * v, m = (d.styles ?? {})[g.fontName], M = (m == null ? void 0 : m.ascent) ?? 1, C = (m == null ? void 0 : m.descent) != null ? Math.abs(m.descent) : 1 - M, w = h - C * g.height;
92
- g.height > 0 && g.width > 0 && l.push({
93
- left: E,
94
- bottom: w,
95
- width: f,
96
- height: g.height
97
- });
98
- }
99
- o.rect = l[0] ?? { left: 0, bottom: 0, width: 0, height: 0 }, o.rects = l;
82
+ d.rect = h[0], d.rects = h;
100
83
  }
101
- return n;
84
+ return t;
102
85
  }
103
- function V(r, d, a) {
104
- let i = r.slice(0, d).match(/([^\p{M}])\p{M}*$/u);
86
+ function W(l, c, m) {
87
+ let i = l.slice(0, c).match(/([^\p{M}])\p{M}*$/u);
105
88
  if (i) {
106
- const t = r.charCodeAt(d), s = i[1].charCodeAt(0);
107
- if (y(t) === y(s))
89
+ const s = l.charCodeAt(c), n = i[1].charCodeAt(0);
90
+ if (D(s) === D(n))
108
91
  return !1;
109
92
  }
110
- if (i = r.slice(d + a).match(/^\p{M}*([^\p{M}])/u), i) {
111
- const t = r.charCodeAt(d + a - 1), s = i[1].charCodeAt(0);
112
- if (y(t) === y(s))
93
+ if (i = l.slice(c + m).match(/^\p{M}*([^\p{M}])/u), i) {
94
+ const s = l.charCodeAt(c + m - 1), n = i[1].charCodeAt(0);
95
+ if (D(s) === D(n))
113
96
  return !1;
114
97
  }
115
98
  return !0;
116
99
  }
117
- function $(r, d, a) {
100
+ function I(l, c, m) {
118
101
  const i = [];
119
- function t(s, c, e = -1, n = -1, T = "") {
120
- const o = d.items[s], l = [];
121
- let u = "", g = "", x = "", h = a[s];
122
- if (!h)
102
+ function s(n, o, e = -1, t = -1, d = "") {
103
+ const h = c.items[n], g = [];
104
+ let r = "", x = "", C = "", a = m[n];
105
+ if (!a)
123
106
  return;
124
- if (h.nodeType === Node.TEXT_NODE) {
125
- const p = document.createElement("span");
126
- h.before(p), p.append(h), a[s] = p, h = p;
107
+ if (a.nodeType === Node.TEXT_NODE) {
108
+ const f = document.createElement("span");
109
+ a.before(f), f.append(a), m[n] = f, a = f;
127
110
  }
128
- e >= 0 && n >= 0 ? u = o.str.substring(e, n) : e < 0 && n < 0 ? u = o.str : e >= 0 ? u = o.str.substring(e) : n >= 0 && (u = o.str.substring(0, n));
129
- const v = document.createTextNode(u), b = document.createElement("span");
130
- if (b.className = "highlight appended " + T, b.setAttribute("data-match-index", `${c}`), b.append(v), l.push(b), i.push({ element: b, index: c }), e > 0)
131
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
132
- g = o.str.substring(0, e);
133
- const p = document.createTextNode(g);
134
- l.unshift(p);
111
+ e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
112
+ const M = document.createTextNode(r), 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
+ if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
115
+ x = h.str.substring(0, e);
116
+ const f = document.createTextNode(x);
117
+ g.unshift(f);
135
118
  } else {
136
- let p = 0;
119
+ let f = 0;
137
120
  const E = [];
138
- for (const f of h.childNodes) {
139
- const N = f.nodeType === Node.TEXT_NODE ? f.nodeValue : f.firstChild.nodeValue;
140
- p += N.length, p <= e ? E.push(f) : e >= p - N.length && n <= p && E.push(
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(
141
124
  document.createTextNode(
142
- N.substring(0, e - (p - N.length))
125
+ u.substring(0, e - (f - u.length))
143
126
  )
144
127
  );
145
128
  }
146
- l.unshift(...E);
129
+ g.unshift(...E);
147
130
  }
148
- if (n > 0) {
149
- x = o.str.substring(n);
150
- const p = document.createTextNode(x);
151
- l.push(p);
131
+ if (t > 0) {
132
+ C = h.str.substring(t);
133
+ const f = document.createTextNode(C);
134
+ g.push(f);
152
135
  }
153
- h.replaceChildren(...l);
136
+ a.replaceChildren(...g);
154
137
  }
155
- for (const [s, c] of r.entries())
156
- if (c.start.idx === c.end.idx)
157
- t(c.start.idx, s, c.start.offset, c.end.offset);
138
+ for (const [n, o] of l.entries())
139
+ if (o.start.idx === o.end.idx)
140
+ s(o.start.idx, n, o.start.offset, o.end.offset);
158
141
  else
159
- for (let e = c.start.idx, n = c.end.idx; e <= n; e++)
160
- e === c.start.idx ? t(e, s, c.start.offset, -1, "begin") : e === c.end.idx ? t(e, s, -1, c.end.offset, "end") : t(e, s, -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");
161
144
  return i;
162
145
  }
163
- function F(r, d) {
164
- const a = r.items.map((i) => i.str);
165
- for (let i = 0; i < d.length; i++) {
166
- const t = d[i];
167
- if (t && t.nodeType !== Node.TEXT_NODE) {
168
- const s = document.createTextNode(a[i]);
169
- t.replaceChildren(s);
146
+ function V(l, c) {
147
+ const m = l.items.map((i) => i.str);
148
+ for (let i = 0; i < c.length; i++) {
149
+ const s = c[i];
150
+ if (s && s.nodeType !== Node.TEXT_NODE) {
151
+ const n = document.createTextNode(m[i]);
152
+ s.replaceChildren(n);
170
153
  }
171
154
  }
172
155
  }
173
- function G(r = {}) {
174
- return { matchCase: !1, wholeWords: !1, ...r };
156
+ function H(l = {}) {
157
+ return { matchCase: !1, wholeWords: !1, ...l };
175
158
  }
176
- function j(r, d, a) {
159
+ function S(l, c, m) {
177
160
  const i = [];
178
- function t(s, c, e = -1, n = -1, T) {
179
- var p, E;
180
- const o = d.items[s], l = [];
181
- let u = "", g = "", x = "", h = a[s];
182
- if (!h)
161
+ function s(n, o, e = -1, t = -1, d) {
162
+ var f, E;
163
+ const h = c.items[n], g = [];
164
+ let r = "", x = "", C = "", a = m[n];
165
+ if (!a)
183
166
  return;
184
- e >= 0 && n >= 0 ? u = o.str.substring(e, n) : e < 0 && n < 0 ? u = o.str : e >= 0 ? u = o.str.substring(e) : n >= 0 && (u = o.str.substring(0, n));
185
- const v = document.createTextNode(u), b = document.createElement("span");
186
- if (b.style.background = T, b.append(v), l.push(b), e > 0)
187
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
188
- g = o.str.substring(0, e);
189
- const f = document.createTextNode(g);
190
- l.unshift(f);
167
+ e >= 0 && t >= 0 ? r = h.str.substring(e, t) : e < 0 && t < 0 ? r = h.str : e >= 0 ? r = h.str.substring(e) : t >= 0 && (r = h.str.substring(0, t));
168
+ const M = document.createTextNode(r), N = document.createElement("span");
169
+ if (N.style.background = d, N.append(M), g.push(N), e > 0)
170
+ if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
171
+ x = h.str.substring(0, e);
172
+ const p = document.createTextNode(x);
173
+ g.unshift(p);
191
174
  } else {
192
- let f = 0;
193
- const N = [];
194
- for (const m of h.childNodes) {
195
- const M = m.nodeType === Node.TEXT_NODE ? m.nodeValue || "" : ((p = m.firstChild) == null ? void 0 : p.nodeValue) || "", C = M.length;
196
- if (f += C, f <= e)
197
- N.push(m);
198
- else if (e >= f - C && n <= f) {
199
- const w = M.substring(0, e - (f - C));
200
- N.push(document.createTextNode(w));
175
+ let p = 0;
176
+ const u = [];
177
+ for (const T of a.childNodes) {
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));
201
184
  }
202
185
  }
203
- l.unshift(...N);
186
+ g.unshift(...u);
204
187
  }
205
- if (n > 0)
206
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
207
- x = o.str.substring(n);
208
- const f = document.createTextNode(x);
209
- l.push(f);
188
+ if (t > 0)
189
+ if (a.childNodes.length === 1 && a.childNodes[0].nodeType === Node.TEXT_NODE) {
190
+ C = h.str.substring(t);
191
+ const p = document.createTextNode(C);
192
+ g.push(p);
210
193
  } else {
211
- let f = 0;
212
- const N = [];
213
- for (const m of h.childNodes) {
214
- f >= n && N.push(m);
215
- const M = m.nodeType === Node.TEXT_NODE ? m.nodeValue || "" : ((E = m.firstChild) == null ? void 0 : E.nodeValue) || "", C = M.length;
216
- if (f += C, f > n) {
217
- const w = M.substring(n - (f - C));
218
- w && N.push(document.createTextNode(w));
194
+ let p = 0;
195
+ const u = [];
196
+ for (const T of a.childNodes) {
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));
219
202
  }
220
203
  }
221
- N.length > 0 && l.push(...N);
204
+ u.length > 0 && g.push(...u);
222
205
  }
223
- h.replaceChildren(...l), i.push({ element: b, index: c });
206
+ a.replaceChildren(...g), i.push({ element: N, index: o });
224
207
  }
225
- for (const [s, c] of r.entries()) {
226
- const { start: e, end: n, color: T } = c;
227
- e.idx === n.idx && t(e.idx, s, e.offset, n.offset, T);
208
+ for (const [n, o] of l.entries()) {
209
+ const { start: e, end: t, color: d } = o;
210
+ e.idx === t.idx && s(e.idx, n, e.offset, t.offset, d);
228
211
  }
229
212
  return i;
230
213
  }
231
- function D(r, d, a) {
232
- let i = 0;
233
- for (let t = 0; t < r.runs.length; t++) {
234
- if (t === d)
235
- return i + Math.min(a, r.runs[t].glyphs.length - 1);
236
- i += r.runs[t].glyphs.length;
237
- }
238
- return Math.max(0, i - 1);
239
- }
240
214
  export {
241
- A as findMatches,
242
- G as getHighlightOptionsWithDefaults,
243
- $ as highlightMatches,
244
- j as highlightMultipleColorMatches,
245
- V as isMatchEntireWord,
246
- F 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
247
221
  };
@@ -1,74 +1,36 @@
1
- import { useRef as p, useEffect as x } from "react";
2
- import { useTextSelectionContext as R } from "../../contexts/TextSelectionContext.js";
3
- import "react/jsx-runtime";
4
- import "../glyphHitTest.js";
5
- import "../selectionUtils.js";
6
- import "../geometryCache.js";
7
- import "../../contexts/EventCallbackContext.js";
8
- import "../../contexts/ZoomContext.js";
9
- import "../types.js";
10
- import "../../de_DE-a553b162.js";
11
- import "../appConsole.js";
12
- import "../../contexts/InitialStateContext.js";
13
- import "../../contexts/RPDocumentContext.js";
14
- import "./useLoadPdf.js";
15
- import "@pdf-viewer/pdfium";
16
- import "@pdf-viewer/pdfium/compat";
17
- import "../getThumbnailViewport.js";
18
- import "../../contexts/ConfigContext.js";
19
- import "../../contexts/DocumentPasswordContext.js";
20
- import "./usePdfProperties.js";
21
- import "../convertPdfDate.js";
22
- import "../formatFileSize.js";
23
- import "../constants.js";
24
- import "../getZoomLevel.js";
25
- import "../../contexts/LayoutContainerContext.js";
26
- import "../../contexts/ViewModeContext.js";
27
- import "../../contexts/RotationContext.js";
28
- import "../../contexts/GlobalCurrentPage.js";
29
- import "./useDebounce.js";
30
- const g = /[\x00-\x1F]/g;
31
- let c = null, o = null;
32
- function C(t) {
33
- 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, o = /* @__PURE__ */ new Map([["ſt", "ſt"]])), t.replace(
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(
34
6
  c,
35
- (e, r, f) => r ? r.normalize("NFKC") : (o == null ? void 0 : o.get(f)) || ""
7
+ (f, u, t) => u ? u.normalize("NFKC") : (r == null ? void 0 : r.get(t)) || ""
36
8
  );
37
9
  }
38
- function D(t, e = !1) {
39
- return g.test(t) ? e ? t.replace(g, (r) => r === "\0" ? "" : " ") : t.replace(/\x00/g, "") : t;
10
+ function p(e, f = !1) {
11
+ return s.test(e) ? f ? e.replace(s, (u) => u === "\0" ? "" : " ") : e.replace(/\x00/g, "") : e;
40
12
  }
41
- const X = (t) => {
42
- const { selectedText: e, selectionVersion: r } = R(), f = p(e), i = p(!1), n = p(null);
43
- x(() => {
44
- f.current = e;
45
- }, [e, r]), x(() => {
46
- if (!t || i.current)
13
+ const x = (e) => {
14
+ const f = o(!1), u = o(null);
15
+ i(() => {
16
+ if (!e || f.current)
47
17
  return;
48
- const a = (u) => {
49
- var s, d;
50
- const m = f.current;
51
- if (m) {
52
- (s = u.clipboardData) == null || s.setData(
53
- "text/plain",
54
- D(C(m))
55
- ), u.preventDefault(), u.stopPropagation();
56
- return;
57
- }
18
+ const t = (n) => {
19
+ var l;
58
20
  const b = document.getSelection();
59
21
  if (!b)
60
22
  return;
61
- const l = b.toString();
62
- l && ((d = u.clipboardData) == null || d.setData(
23
+ const a = b.toString();
24
+ a && ((l = n.clipboardData) == null || l.setData(
63
25
  "text/plain",
64
- D(C(l))
65
- ), u.preventDefault(), u.stopPropagation());
26
+ p(d(a))
27
+ ), n.preventDefault(), n.stopPropagation());
66
28
  };
67
- return t.addEventListener("copy", a), n.current = t, i.current = !0, () => {
68
- n.current && (n.current.removeEventListener("copy", a), i.current = !1);
29
+ return e.addEventListener("copy", t), u.current = e, f.current = !0, () => {
30
+ u.current && (u.current.removeEventListener("copy", t), f.current = !1);
69
31
  };
70
- }, [t]);
32
+ }, [e]);
71
33
  };
72
34
  export {
73
- X as useCopyText
35
+ x as useCopyText
74
36
  };
@@ -0,0 +1,12 @@
1
+ import { useLayoutDropFileZoneContext as r } from "../../contexts/LayoutDropFileZoneContext.js";
2
+ import { useToolComponentContext as n } from "../../contexts/ToolComponentContext.js";
3
+ import { useToolbarComponentContext as p } from "../../contexts/ToolbarComponentContext.js";
4
+ import "react/jsx-runtime";
5
+ import "react";
6
+ const F = () => {
7
+ const o = r(), { dropFileZone: e } = n(), { dropFileZone: t } = p();
8
+ return { DropFileZoneLayout: o, DropFileZoneTool: e, DropFileZoneToolbar: t };
9
+ };
10
+ export {
11
+ F as useDropFileZone
12
+ };
@@ -3,8 +3,7 @@ import { useCallback as a } from "react";
3
3
  import { useDownloadContext as s } from "../../contexts/DownloadContext.js";
4
4
  import "react/jsx-runtime";
5
5
  import "./useLoadPdf.js";
6
- import "@pdf-viewer/pdfium";
7
- import "@pdf-viewer/pdfium/compat";
6
+ import "pdfjs-dist";
8
7
  import "../types.js";
9
8
  import "../../de_DE-a553b162.js";
10
9
  import "../getThumbnailViewport.js";
@@ -14,10 +13,10 @@ import "../appConsole.js";
14
13
  import "./usePdfProperties.js";
15
14
  import "../convertPdfDate.js";
16
15
  import "../formatFileSize.js";
17
- const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
16
+ const i = ".pdf", d = (o) => URL.createObjectURL(o), l = async (o) => {
18
17
  const r = await (await fetch(o)).blob();
19
18
  return d(r);
20
- }, B = () => {
19
+ }, k = () => {
21
20
  const { filename: o, pdfSrc: e } = c(), { downloadFilename: r } = s(), m = (t) => {
22
21
  const n = r || t;
23
22
  return n.endsWith(i) ? n : `${n}${i}`;
@@ -26,9 +25,9 @@ const i = ".pdf", d = (o) => URL.createObjectURL(o), p = async (o) => {
26
25
  if (!o || !e)
27
26
  throw new Error("There is no PDF source to download");
28
27
  const t = document.createElement("a");
29
- t.href = await p(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
28
+ t.href = await l(e), t.download = m(o), document.body.appendChild(t), t.click(), document.body.removeChild(t);
30
29
  }, [o, e]) };
31
30
  };
32
31
  export {
33
- B as useFileDownload
32
+ k as useFileDownload
34
33
  };
@@ -0,0 +1,25 @@
1
+ import { useRef as u, useCallback as g, useEffect as f } from "react";
2
+ const m = () => {
3
+ const i = u(null), a = u(/firefox/i.test(navigator.userAgent)), o = g(() => {
4
+ var c, d;
5
+ const s = document.getSelection();
6
+ if (!s || s.rangeCount === 0 || a.current)
7
+ return;
8
+ const t = s.getRangeAt(0), l = i.current && (t.compareBoundaryPoints(Range.END_TO_END, i.current) === 0 || t.compareBoundaryPoints(Range.START_TO_END, i.current) === 0);
9
+ let e = l ? t.startContainer : t.endContainer;
10
+ if ((e == null ? void 0 : e.nodeType) === Node.TEXT_NODE && (e = e.parentNode), !l && t.endOffset === 0)
11
+ do {
12
+ for (; !(e != null && e.previousSibling); )
13
+ e = e == null ? void 0 : e.parentNode;
14
+ e = e.previousSibling;
15
+ } while (!e.childNodes.length);
16
+ const n = (c = e == null ? void 0 : e.parentElement) == null ? void 0 : c.closest("[data-rp-text-layer]"), r = n == null ? void 0 : n.querySelector(".endOfContent");
17
+ r && (r.style.width = n.style.width, r.style.height = n.style.height, (d = e == null ? void 0 : e.parentElement) == null || d.insertBefore(r, l ? e : e.nextSibling)), i.current = t.cloneRange();
18
+ }, []);
19
+ f(() => (document == null || document.addEventListener("selectionchange", o), () => {
20
+ document == null || document.removeEventListener("selectionchange", o);
21
+ }), [o]);
22
+ };
23
+ export {
24
+ m as useFlickerSelectText
25
+ };