@pdf-viewer/react 1.14.0-beta.3 → 1.14.0-beta.4

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.
@@ -1,5 +1,5 @@
1
- import { RectPosition } from './types';
1
+ import { ElementPosition } from './types';
2
2
  export declare const getElementPagePosition: (pageDimension: {
3
3
  width: number;
4
4
  height: number;
5
- }, pagesRef: HTMLDivElement, element: HTMLElement | JSX.Element, rotation: number, scale: number) => RectPosition;
5
+ }, pagesRef: HTMLDivElement, element: HTMLElement | JSX.Element, rotation: number, scale: number) => ElementPosition;
@@ -546,6 +546,12 @@ export interface ScrollModeInitialProps {
546
546
  initialScrollMode?: ScrollMode;
547
547
  }
548
548
  export interface RectPosition {
549
+ left: number;
550
+ bottom: number;
551
+ width: number;
552
+ height: number;
553
+ }
554
+ export interface ElementPosition {
549
555
  left: number;
550
556
  top: number;
551
557
  width: number;
@@ -1,5 +1,5 @@
1
1
  const a = (i, h, l, o, n) => {
2
- const c = l.height * o, s = l.width * o, y = l.top * o, w = l.left * o, d = {
2
+ const c = l.height * o, s = l.width * o, y = l.bottom * o, m = l.left * o, d = {
3
3
  width: n % 180 === 90 ? i.height : i.width,
4
4
  height: n % 180 === 90 ? i.width : i.height
5
5
  }, r = {
@@ -8,16 +8,16 @@ const a = (i, h, l, o, n) => {
8
8
  }, t = document.createElement("div");
9
9
  t.style.width = `${d.width}px`, t.style.height = `${d.height}px`, t.style.position = "absolute", t.style.transform = `rotate(${n}deg)`, t.style.transformOrigin = "center center", t.style.visibility = "hidden", t.style.left = "-99999px";
10
10
  const e = document.createElement("div");
11
- e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${w}px`, t.appendChild(e), h.appendChild(t);
12
- const p = t.getBoundingClientRect(), g = e.getBoundingClientRect();
11
+ e.style.position = "absolute", e.style.width = `${s}px`, e.style.height = `${c}px`, e.style.position = "absolute", e.style.bottom = `${y}px`, e.style.left = `${m}px`, t.appendChild(e), h.appendChild(t);
12
+ const g = t.getBoundingClientRect(), p = e.getBoundingClientRect();
13
13
  h.removeChild(t);
14
14
  const u = {
15
15
  top: h.clientHeight / 2,
16
16
  left: h.clientWidth / 2
17
17
  };
18
18
  return {
19
- leftInPage: g.left - p.left - u.left + r.width / 2,
20
- topInPage: g.top - p.top - u.top + r.height / 2
19
+ leftInPage: p.left - g.left - u.left + r.width / 2,
20
+ topInPage: p.top - g.top - u.top + r.height / 2
21
21
  };
22
22
  };
23
23
  export {
@@ -1,19 +1,19 @@
1
- import { getCharacterType as X } from "./charators.js";
2
- function V(r, c, a, i) {
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, a));
6
+ o.push(...I(s, c, u));
7
7
  }
8
8
  return o;
9
9
  }
10
- const D = (r, c) => {
11
- const a = ["g"];
12
- c.matchCase || a.push("i");
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, a.join(""));
14
+ return new RegExp(o, u.join(""));
15
15
  };
16
- function y(r, c, a) {
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 = D(c, a);
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
- a.wholeWords && !L(o, e.index, e[0].length) || s.push([e.index, e[0].length, e[0]]);
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, a) {
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 p = {
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: p,
62
+ start: h,
63
63
  end: m,
64
64
  str: r[l][2],
65
65
  oIndex: r[l][0],
66
- pageIndex: a,
66
+ pageIndex: u,
67
67
  rect: {
68
68
  left: 0,
69
- top: 0,
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], p = s[l.end.idx], m = d.transform[4], f = d.transform[5], E = m + d.width * l.start.offset / d.str.length, h = f, b = m + p.width * l.end.offset / p.str.length, N = f, u = {
77
- left: Math.min(E, b),
78
- top: Math.min(h, N),
79
- width: Math.abs(b - E),
80
- height: Math.max(d.height, p.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 = u;
82
+ l.rect = M;
83
83
  }
84
84
  return t;
85
85
  }
86
- function L(r, c, a) {
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 (X(o) === X(n))
90
+ if (D(o) === D(n))
91
91
  return !1;
92
92
  }
93
- if (i = r.slice(c + a).match(/^\p{M}*([^\p{M}])/u), i) {
94
- const o = r.charCodeAt(c + a - 1), n = i[1].charCodeAt(0);
95
- if (X(o) === X(n))
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, a) {
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], p = [];
104
- let m = "", f = "", E = "", h = a[n];
105
- if (!h)
103
+ const d = c.items[n], h = [];
104
+ let m = "", f = "", E = "", a = u[n];
105
+ if (!a)
106
106
  return;
107
- if (h.nodeType === Node.TEXT_NODE) {
108
- const u = document.createElement("span");
109
- h.before(u), u.append(h), a[n] = u, h = u;
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 b = document.createTextNode(m), N = document.createElement("span");
113
- if (N.className = "highlight appended " + l, N.setAttribute("data-match-index", `${s}`), N.append(b), p.push(N), i.push({ element: N, index: s }), e > 0)
114
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
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 u = document.createTextNode(f);
117
- p.unshift(u);
116
+ const p = document.createTextNode(f);
117
+ h.unshift(p);
118
118
  } else {
119
- let u = 0;
120
- const C = [];
121
- for (const g of h.childNodes) {
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
- u += x.length, u <= e ? C.push(g) : e >= u - x.length && t <= u && C.push(
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 - (u - x.length))
125
+ x.substring(0, e - (p - x.length))
126
126
  )
127
127
  );
128
128
  }
129
- p.unshift(...C);
129
+ h.unshift(...b);
130
130
  }
131
131
  if (t > 0) {
132
132
  E = d.str.substring(t);
133
- const u = document.createTextNode(E);
134
- p.push(u);
133
+ const p = document.createTextNode(E);
134
+ h.push(p);
135
135
  }
136
- h.replaceChildren(...p);
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 a = r.items.map((i) => i.str);
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(a[i]);
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, a) {
159
+ function A(r, c, u) {
160
160
  const i = [];
161
161
  function o(n, s, e = -1, t = -1, l) {
162
- var u, C;
163
- const d = c.items[n], p = [];
164
- let m = "", f = "", E = "", h = a[n];
165
- if (!h)
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 b = document.createTextNode(m), N = document.createElement("span");
169
- if (N.style.background = l, N.append(b), p.push(N), e > 0)
170
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
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
- p.unshift(g);
173
+ h.unshift(g);
174
174
  } else {
175
175
  let g = 0;
176
176
  const x = [];
177
- for (const T of h.childNodes) {
178
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((u = T.firstChild) == null ? void 0 : u.nodeValue) || "", M = v.length;
179
- if (g += M, g <= e)
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 - M && t <= g) {
182
- const w = v.substring(0, e - (g - M));
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
- p.unshift(...x);
186
+ h.unshift(...x);
187
187
  }
188
188
  if (t > 0)
189
- if (h.childNodes.length === 1 && h.childNodes[0].nodeType === Node.TEXT_NODE) {
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
- p.push(g);
192
+ h.push(g);
193
193
  } else {
194
194
  let g = 0;
195
195
  const x = [];
196
- for (const T of h.childNodes) {
196
+ for (const T of a.childNodes) {
197
197
  g >= t && x.push(T);
198
- const v = T.nodeType === Node.TEXT_NODE ? T.nodeValue || "" : ((C = T.firstChild) == null ? void 0 : C.nodeValue) || "", M = v.length;
199
- if (g += M, g > t) {
200
- const w = v.substring(t - (g - M));
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 && p.push(...x);
204
+ x.length > 0 && h.push(...x);
205
205
  }
206
- h.replaceChildren(...p), i.push({ element: N, index: s });
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;
@@ -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("2025-12-01T06:37:11.550Z"), d = "Please visit https://www.react-pdf.dev/manage-license/ to generate a new license key.", s = {
3
+ const b = /* @__PURE__ */ new Date("2025-12-02T02:55:04.012Z"), 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}`,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@pdf-viewer/react",
3
3
  "private": false,
4
4
  "description": "A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.",
5
- "version": "1.14.0-beta.3",
5
+ "version": "1.14.0-beta.4",
6
6
  "keywords": [
7
7
  "react-pdf",
8
8
  "react-pdf-viewer",