pdfjs-reader-core 0.2.15 → 0.2.17
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/LICENSE +21 -0
- package/dist/index.cjs +904 -519
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +719 -335
- package/dist/index.js.map +1 -1
- package/package.json +20 -18
- package/runkit-example.js +91 -0
package/dist/index.cjs
CHANGED
|
@@ -200,6 +200,122 @@ function clearDocumentCache(url) {
|
|
|
200
200
|
documentCache.clear();
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
function loadDocumentWithCallbacks(options) {
|
|
204
|
+
const {
|
|
205
|
+
src,
|
|
206
|
+
workerSrc,
|
|
207
|
+
password,
|
|
208
|
+
onProgress,
|
|
209
|
+
onDocumentReady,
|
|
210
|
+
onFirstPageReady,
|
|
211
|
+
enableRangeRequests = true,
|
|
212
|
+
enableStreaming = true,
|
|
213
|
+
cacheDocument = true,
|
|
214
|
+
signal
|
|
215
|
+
} = options;
|
|
216
|
+
const abortController = new AbortController();
|
|
217
|
+
if (signal) {
|
|
218
|
+
signal.addEventListener("abort", () => abortController.abort());
|
|
219
|
+
}
|
|
220
|
+
const promise = (async () => {
|
|
221
|
+
if (abortController.signal.aborted) {
|
|
222
|
+
throw new DOMException("Aborted", "AbortError");
|
|
223
|
+
}
|
|
224
|
+
await initializePDFJS({ workerSrc });
|
|
225
|
+
if (abortController.signal.aborted) {
|
|
226
|
+
throw new DOMException("Aborted", "AbortError");
|
|
227
|
+
}
|
|
228
|
+
const cacheKey = typeof src === "string" ? src : null;
|
|
229
|
+
if (cacheKey && cacheDocument && documentCache.has(cacheKey)) {
|
|
230
|
+
const cachedDoc = documentCache.get(cacheKey);
|
|
231
|
+
try {
|
|
232
|
+
const numPages2 = cachedDoc.numPages;
|
|
233
|
+
const isDestroyed = cachedDoc._transport?.destroyed || cachedDoc.destroyed;
|
|
234
|
+
if (numPages2 > 0 && !isDestroyed) {
|
|
235
|
+
onDocumentReady?.(cachedDoc, numPages2);
|
|
236
|
+
if (onFirstPageReady && numPages2 > 0) {
|
|
237
|
+
try {
|
|
238
|
+
const firstPage = await cachedDoc.getPage(1);
|
|
239
|
+
if (!abortController.signal.aborted) {
|
|
240
|
+
onFirstPageReady(firstPage);
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
document: cachedDoc,
|
|
247
|
+
numPages: numPages2
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
documentCache.delete(cacheKey);
|
|
251
|
+
} catch {
|
|
252
|
+
documentCache.delete(cacheKey);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const loadingParams = {
|
|
256
|
+
password,
|
|
257
|
+
isEvalSupported: false,
|
|
258
|
+
useSystemFonts: true,
|
|
259
|
+
disableRange: !enableRangeRequests,
|
|
260
|
+
disableStream: !enableStreaming,
|
|
261
|
+
disableAutoFetch: true
|
|
262
|
+
};
|
|
263
|
+
if (typeof src === "string") {
|
|
264
|
+
loadingParams.url = src;
|
|
265
|
+
} else {
|
|
266
|
+
loadingParams.data = src;
|
|
267
|
+
}
|
|
268
|
+
const loadingTask = pdfjsLib.getDocument(loadingParams);
|
|
269
|
+
const abortHandler = () => {
|
|
270
|
+
loadingTask.destroy();
|
|
271
|
+
};
|
|
272
|
+
abortController.signal.addEventListener("abort", abortHandler);
|
|
273
|
+
if (onProgress) {
|
|
274
|
+
loadingTask.onProgress = ({ loaded, total }) => {
|
|
275
|
+
if (!abortController.signal.aborted) {
|
|
276
|
+
onProgress({ loaded, total });
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
let document2;
|
|
281
|
+
try {
|
|
282
|
+
document2 = await loadingTask.promise;
|
|
283
|
+
} catch (error) {
|
|
284
|
+
abortController.signal.removeEventListener("abort", abortHandler);
|
|
285
|
+
if (abortController.signal.aborted) {
|
|
286
|
+
throw new DOMException("Aborted", "AbortError");
|
|
287
|
+
}
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
290
|
+
abortController.signal.removeEventListener("abort", abortHandler);
|
|
291
|
+
if (abortController.signal.aborted) {
|
|
292
|
+
document2.destroy();
|
|
293
|
+
throw new DOMException("Aborted", "AbortError");
|
|
294
|
+
}
|
|
295
|
+
const numPages = document2.numPages;
|
|
296
|
+
onDocumentReady?.(document2, numPages);
|
|
297
|
+
if (onFirstPageReady && numPages > 0) {
|
|
298
|
+
try {
|
|
299
|
+
const firstPage = await document2.getPage(1);
|
|
300
|
+
if (!abortController.signal.aborted) {
|
|
301
|
+
onFirstPageReady(firstPage);
|
|
302
|
+
}
|
|
303
|
+
} catch {
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (cacheKey && cacheDocument) {
|
|
307
|
+
documentCache.set(cacheKey, document2);
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
document: document2,
|
|
311
|
+
numPages
|
|
312
|
+
};
|
|
313
|
+
})();
|
|
314
|
+
return {
|
|
315
|
+
promise,
|
|
316
|
+
cancel: () => abortController.abort()
|
|
317
|
+
};
|
|
318
|
+
}
|
|
203
319
|
var documentCache;
|
|
204
320
|
var init_document_loader = __esm({
|
|
205
321
|
"src/utils/document-loader.ts"() {
|
|
@@ -403,14 +519,18 @@ function createViewerStore(initialOverrides = {}) {
|
|
|
403
519
|
isLoading: false,
|
|
404
520
|
loadingProgress: null,
|
|
405
521
|
error: null,
|
|
406
|
-
currentPage: 1
|
|
522
|
+
currentPage: 1,
|
|
523
|
+
documentLoadingState: "ready"
|
|
407
524
|
});
|
|
408
525
|
} else {
|
|
409
526
|
set({
|
|
410
527
|
document: null,
|
|
411
528
|
numPages: 0,
|
|
412
529
|
isLoading: false,
|
|
413
|
-
loadingProgress: null
|
|
530
|
+
loadingProgress: null,
|
|
531
|
+
documentLoadingState: "idle",
|
|
532
|
+
firstPageReady: false,
|
|
533
|
+
streamingProgress: null
|
|
414
534
|
});
|
|
415
535
|
}
|
|
416
536
|
},
|
|
@@ -424,7 +544,17 @@ function createViewerStore(initialOverrides = {}) {
|
|
|
424
544
|
set({ loadingProgress: progress });
|
|
425
545
|
},
|
|
426
546
|
setError: (error) => {
|
|
427
|
-
set({ error, isLoading: false, loadingProgress: null });
|
|
547
|
+
set({ error, isLoading: false, loadingProgress: null, documentLoadingState: error ? "error" : "idle" });
|
|
548
|
+
},
|
|
549
|
+
// Progressive loading actions
|
|
550
|
+
setDocumentLoadingState: (documentLoadingState) => {
|
|
551
|
+
set({ documentLoadingState });
|
|
552
|
+
},
|
|
553
|
+
setFirstPageReady: (firstPageReady) => {
|
|
554
|
+
set({ firstPageReady });
|
|
555
|
+
},
|
|
556
|
+
setStreamingProgress: (streamingProgress) => {
|
|
557
|
+
set({ streamingProgress });
|
|
428
558
|
},
|
|
429
559
|
// Navigation actions
|
|
430
560
|
setCurrentPage: (page) => {
|
|
@@ -574,6 +704,10 @@ var init_viewer_store = __esm({
|
|
|
574
704
|
isLoading: false,
|
|
575
705
|
loadingProgress: null,
|
|
576
706
|
error: null,
|
|
707
|
+
// Progressive loading state
|
|
708
|
+
documentLoadingState: "idle",
|
|
709
|
+
firstPageReady: false,
|
|
710
|
+
streamingProgress: null,
|
|
577
711
|
// Navigation state
|
|
578
712
|
currentPage: 1,
|
|
579
713
|
scale: 1,
|
|
@@ -7808,10 +7942,57 @@ var init_PDFLoadingScreen = __esm({
|
|
|
7808
7942
|
totalBytes,
|
|
7809
7943
|
phase = "fetching",
|
|
7810
7944
|
documentName,
|
|
7811
|
-
className
|
|
7945
|
+
className,
|
|
7946
|
+
compact = false,
|
|
7947
|
+
showStreamingProgress = false
|
|
7812
7948
|
}) {
|
|
7813
7949
|
const hasProgress = progress !== void 0 && progress >= 0;
|
|
7814
7950
|
const hasBytes = bytesLoaded !== void 0 && totalBytes !== void 0 && totalBytes > 0;
|
|
7951
|
+
if (compact || showStreamingProgress) {
|
|
7952
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
7953
|
+
"div",
|
|
7954
|
+
{
|
|
7955
|
+
className: cn(
|
|
7956
|
+
"pdf-loading-compact",
|
|
7957
|
+
"flex items-center gap-3 px-4 py-3 bg-gray-800 text-white rounded-lg shadow-lg",
|
|
7958
|
+
className
|
|
7959
|
+
),
|
|
7960
|
+
role: "status",
|
|
7961
|
+
"aria-live": "polite",
|
|
7962
|
+
children: [
|
|
7963
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7964
|
+
"div",
|
|
7965
|
+
{
|
|
7966
|
+
style: {
|
|
7967
|
+
width: 20,
|
|
7968
|
+
height: 20,
|
|
7969
|
+
border: "2px solid rgba(255,255,255,0.3)",
|
|
7970
|
+
borderTopColor: "#fff",
|
|
7971
|
+
borderRadius: "50%",
|
|
7972
|
+
animation: "spin 0.8s linear infinite"
|
|
7973
|
+
}
|
|
7974
|
+
}
|
|
7975
|
+
),
|
|
7976
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-sm font-medium", children: phaseMessages[phase] }),
|
|
7977
|
+
hasProgress && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-sm text-white/70", children: [
|
|
7978
|
+
Math.round(progress),
|
|
7979
|
+
"%"
|
|
7980
|
+
] }),
|
|
7981
|
+
hasBytes && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "text-xs text-white/50 font-mono", children: [
|
|
7982
|
+
formatBytes(bytesLoaded),
|
|
7983
|
+
" / ",
|
|
7984
|
+
formatBytes(totalBytes)
|
|
7985
|
+
] }),
|
|
7986
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("style", { children: `
|
|
7987
|
+
@keyframes spin {
|
|
7988
|
+
0% { transform: rotate(0deg); }
|
|
7989
|
+
100% { transform: rotate(360deg); }
|
|
7990
|
+
}
|
|
7991
|
+
` })
|
|
7992
|
+
]
|
|
7993
|
+
}
|
|
7994
|
+
);
|
|
7995
|
+
}
|
|
7815
7996
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
7816
7997
|
"div",
|
|
7817
7998
|
{
|
|
@@ -8044,6 +8225,114 @@ var init_PDFLoadingScreen2 = __esm({
|
|
|
8044
8225
|
}
|
|
8045
8226
|
});
|
|
8046
8227
|
|
|
8228
|
+
// src/components/PDFViewer/PageSkeleton.tsx
|
|
8229
|
+
var import_react34, import_jsx_runtime20, PageSkeleton, DEFAULT_PAGE_WIDTH, DEFAULT_PAGE_HEIGHT;
|
|
8230
|
+
var init_PageSkeleton = __esm({
|
|
8231
|
+
"src/components/PDFViewer/PageSkeleton.tsx"() {
|
|
8232
|
+
"use strict";
|
|
8233
|
+
import_react34 = require("react");
|
|
8234
|
+
init_utils();
|
|
8235
|
+
import_jsx_runtime20 = require("react/jsx-runtime");
|
|
8236
|
+
PageSkeleton = (0, import_react34.memo)(function PageSkeleton2({
|
|
8237
|
+
pageNumber,
|
|
8238
|
+
width,
|
|
8239
|
+
height,
|
|
8240
|
+
className,
|
|
8241
|
+
isFirstPage = false
|
|
8242
|
+
}) {
|
|
8243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
8244
|
+
"div",
|
|
8245
|
+
{
|
|
8246
|
+
className: cn(
|
|
8247
|
+
"pdf-page-skeleton",
|
|
8248
|
+
"relative bg-white shadow-lg overflow-hidden",
|
|
8249
|
+
"flex items-center justify-center",
|
|
8250
|
+
className
|
|
8251
|
+
),
|
|
8252
|
+
style: {
|
|
8253
|
+
width,
|
|
8254
|
+
height,
|
|
8255
|
+
minWidth: width,
|
|
8256
|
+
minHeight: height
|
|
8257
|
+
},
|
|
8258
|
+
"data-page-number": pageNumber,
|
|
8259
|
+
role: "img",
|
|
8260
|
+
"aria-label": `Loading page ${pageNumber}`,
|
|
8261
|
+
children: [
|
|
8262
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
8263
|
+
"div",
|
|
8264
|
+
{
|
|
8265
|
+
className: "absolute inset-0 pdf-skeleton-shimmer",
|
|
8266
|
+
style: {
|
|
8267
|
+
background: "linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%)",
|
|
8268
|
+
backgroundSize: "200% 100%",
|
|
8269
|
+
animation: "shimmer 1.5s infinite linear"
|
|
8270
|
+
}
|
|
8271
|
+
}
|
|
8272
|
+
),
|
|
8273
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "absolute inset-0 p-6 flex flex-col", style: { opacity: 0.4 }, children: [
|
|
8274
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
8275
|
+
"div",
|
|
8276
|
+
{
|
|
8277
|
+
className: "rounded",
|
|
8278
|
+
style: {
|
|
8279
|
+
width: "60%",
|
|
8280
|
+
height: 12,
|
|
8281
|
+
background: "#e0e0e0",
|
|
8282
|
+
marginBottom: 16
|
|
8283
|
+
}
|
|
8284
|
+
}
|
|
8285
|
+
),
|
|
8286
|
+
[...Array(Math.min(12, Math.floor(height / 40)))].map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
8287
|
+
"div",
|
|
8288
|
+
{
|
|
8289
|
+
className: "rounded",
|
|
8290
|
+
style: {
|
|
8291
|
+
width: `${75 + Math.sin(i * 0.7) * 20}%`,
|
|
8292
|
+
height: 8,
|
|
8293
|
+
background: "#e0e0e0",
|
|
8294
|
+
marginBottom: 12
|
|
8295
|
+
}
|
|
8296
|
+
},
|
|
8297
|
+
i
|
|
8298
|
+
))
|
|
8299
|
+
] }),
|
|
8300
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "relative z-10 flex flex-col items-center gap-3 p-6 rounded-lg bg-white/90 shadow-sm", children: [
|
|
8301
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
8302
|
+
"div",
|
|
8303
|
+
{
|
|
8304
|
+
className: "pdf-skeleton-spinner",
|
|
8305
|
+
style: {
|
|
8306
|
+
width: 32,
|
|
8307
|
+
height: 32,
|
|
8308
|
+
border: "3px solid #e5e7eb",
|
|
8309
|
+
borderTopColor: "#3b82f6",
|
|
8310
|
+
borderRadius: "50%",
|
|
8311
|
+
animation: "spin 0.8s linear infinite"
|
|
8312
|
+
}
|
|
8313
|
+
}
|
|
8314
|
+
),
|
|
8315
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "text-sm text-gray-500 font-medium", children: isFirstPage ? "Loading document..." : `Loading page ${pageNumber}` })
|
|
8316
|
+
] }),
|
|
8317
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("style", { children: `
|
|
8318
|
+
@keyframes shimmer {
|
|
8319
|
+
0% { background-position: 200% 0; }
|
|
8320
|
+
100% { background-position: -200% 0; }
|
|
8321
|
+
}
|
|
8322
|
+
@keyframes spin {
|
|
8323
|
+
0% { transform: rotate(0deg); }
|
|
8324
|
+
100% { transform: rotate(360deg); }
|
|
8325
|
+
}
|
|
8326
|
+
` })
|
|
8327
|
+
]
|
|
8328
|
+
}
|
|
8329
|
+
);
|
|
8330
|
+
});
|
|
8331
|
+
DEFAULT_PAGE_WIDTH = 612;
|
|
8332
|
+
DEFAULT_PAGE_HEIGHT = 792;
|
|
8333
|
+
}
|
|
8334
|
+
});
|
|
8335
|
+
|
|
8047
8336
|
// src/components/SelectionToolbar/SelectionToolbar.tsx
|
|
8048
8337
|
function calculatePosition(selection) {
|
|
8049
8338
|
if (!selection || selection.rects.length === 0) {
|
|
@@ -8059,13 +8348,13 @@ function calculatePosition(selection) {
|
|
|
8059
8348
|
const left = firstRect.left + firstRect.width / 2;
|
|
8060
8349
|
return { top, left, visible: true };
|
|
8061
8350
|
}
|
|
8062
|
-
var
|
|
8351
|
+
var import_react35, import_jsx_runtime21, HIGHLIGHT_COLOR_BUTTONS, SelectionToolbar;
|
|
8063
8352
|
var init_SelectionToolbar = __esm({
|
|
8064
8353
|
"src/components/SelectionToolbar/SelectionToolbar.tsx"() {
|
|
8065
8354
|
"use strict";
|
|
8066
|
-
|
|
8355
|
+
import_react35 = require("react");
|
|
8067
8356
|
init_utils();
|
|
8068
|
-
|
|
8357
|
+
import_jsx_runtime21 = require("react/jsx-runtime");
|
|
8069
8358
|
HIGHLIGHT_COLOR_BUTTONS = [
|
|
8070
8359
|
{ color: "yellow", bg: "bg-yellow-300", hoverBg: "hover:bg-yellow-400", ringColor: "ring-yellow-400" },
|
|
8071
8360
|
{ color: "green", bg: "bg-green-300", hoverBg: "hover:bg-green-400", ringColor: "ring-green-400" },
|
|
@@ -8073,16 +8362,16 @@ var init_SelectionToolbar = __esm({
|
|
|
8073
8362
|
{ color: "pink", bg: "bg-pink-300", hoverBg: "hover:bg-pink-400", ringColor: "ring-pink-400" },
|
|
8074
8363
|
{ color: "orange", bg: "bg-orange-300", hoverBg: "hover:bg-orange-400", ringColor: "ring-orange-400" }
|
|
8075
8364
|
];
|
|
8076
|
-
SelectionToolbar = (0,
|
|
8365
|
+
SelectionToolbar = (0, import_react35.memo)(function SelectionToolbar2({
|
|
8077
8366
|
selection,
|
|
8078
8367
|
onCreateHighlight,
|
|
8079
8368
|
onCopy,
|
|
8080
8369
|
activeColor = "yellow",
|
|
8081
8370
|
className
|
|
8082
8371
|
}) {
|
|
8083
|
-
const [position, setPosition] = (0,
|
|
8084
|
-
const toolbarRef = (0,
|
|
8085
|
-
(0,
|
|
8372
|
+
const [position, setPosition] = (0, import_react35.useState)({ top: 0, left: 0, visible: false });
|
|
8373
|
+
const toolbarRef = (0, import_react35.useRef)(null);
|
|
8374
|
+
(0, import_react35.useEffect)(() => {
|
|
8086
8375
|
if (selection && selection.text && selection.rects.length > 0) {
|
|
8087
8376
|
const newPosition = calculatePosition(selection);
|
|
8088
8377
|
if (toolbarRef.current && newPosition.visible) {
|
|
@@ -8110,19 +8399,19 @@ var init_SelectionToolbar = __esm({
|
|
|
8110
8399
|
setPosition({ top: 0, left: 0, visible: false });
|
|
8111
8400
|
}
|
|
8112
8401
|
}, [selection]);
|
|
8113
|
-
const handleColorClick = (0,
|
|
8402
|
+
const handleColorClick = (0, import_react35.useCallback)(
|
|
8114
8403
|
(color) => {
|
|
8115
8404
|
onCreateHighlight(color);
|
|
8116
8405
|
},
|
|
8117
8406
|
[onCreateHighlight]
|
|
8118
8407
|
);
|
|
8119
|
-
const handleCopy = (0,
|
|
8408
|
+
const handleCopy = (0, import_react35.useCallback)(() => {
|
|
8120
8409
|
onCopy?.();
|
|
8121
8410
|
}, [onCopy]);
|
|
8122
8411
|
if (!position.visible || !selection?.text) {
|
|
8123
8412
|
return null;
|
|
8124
8413
|
}
|
|
8125
|
-
return /* @__PURE__ */ (0,
|
|
8414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
8126
8415
|
"div",
|
|
8127
8416
|
{
|
|
8128
8417
|
ref: toolbarRef,
|
|
@@ -8146,7 +8435,7 @@ var init_SelectionToolbar = __esm({
|
|
|
8146
8435
|
e.stopPropagation();
|
|
8147
8436
|
},
|
|
8148
8437
|
children: [
|
|
8149
|
-
HIGHLIGHT_COLOR_BUTTONS.map((btn) => /* @__PURE__ */ (0,
|
|
8438
|
+
HIGHLIGHT_COLOR_BUTTONS.map((btn) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8150
8439
|
"button",
|
|
8151
8440
|
{
|
|
8152
8441
|
onClick: () => handleColorClick(btn.color),
|
|
@@ -8163,7 +8452,7 @@ var init_SelectionToolbar = __esm({
|
|
|
8163
8452
|
),
|
|
8164
8453
|
title: `Highlight ${btn.color}`,
|
|
8165
8454
|
"aria-label": `Highlight with ${btn.color}`,
|
|
8166
|
-
children: /* @__PURE__ */ (0,
|
|
8455
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { className: "w-4 h-4 text-gray-700", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8167
8456
|
"path",
|
|
8168
8457
|
{
|
|
8169
8458
|
strokeLinecap: "round",
|
|
@@ -8175,8 +8464,8 @@ var init_SelectionToolbar = __esm({
|
|
|
8175
8464
|
},
|
|
8176
8465
|
btn.color
|
|
8177
8466
|
)),
|
|
8178
|
-
/* @__PURE__ */ (0,
|
|
8179
|
-
/* @__PURE__ */ (0,
|
|
8467
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "w-px h-6 bg-gray-300 dark:bg-gray-600 mx-1" }),
|
|
8468
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8180
8469
|
"button",
|
|
8181
8470
|
{
|
|
8182
8471
|
onClick: handleCopy,
|
|
@@ -8188,7 +8477,7 @@ var init_SelectionToolbar = __esm({
|
|
|
8188
8477
|
),
|
|
8189
8478
|
title: "Copy text",
|
|
8190
8479
|
"aria-label": "Copy selected text",
|
|
8191
|
-
children: /* @__PURE__ */ (0,
|
|
8480
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
8192
8481
|
"path",
|
|
8193
8482
|
{
|
|
8194
8483
|
strokeLinecap: "round",
|
|
@@ -8228,13 +8517,13 @@ function calculatePopoverPosition(highlight, scale, pageElement) {
|
|
|
8228
8517
|
const left = scaledLeft + scaledWidth / 2;
|
|
8229
8518
|
return { top, left, visible: true };
|
|
8230
8519
|
}
|
|
8231
|
-
var
|
|
8520
|
+
var import_react36, import_jsx_runtime22, HIGHLIGHT_COLOR_OPTIONS, HighlightPopover;
|
|
8232
8521
|
var init_HighlightPopover = __esm({
|
|
8233
8522
|
"src/components/HighlightPopover/HighlightPopover.tsx"() {
|
|
8234
8523
|
"use strict";
|
|
8235
|
-
|
|
8524
|
+
import_react36 = require("react");
|
|
8236
8525
|
init_utils();
|
|
8237
|
-
|
|
8526
|
+
import_jsx_runtime22 = require("react/jsx-runtime");
|
|
8238
8527
|
HIGHLIGHT_COLOR_OPTIONS = [
|
|
8239
8528
|
{ color: "yellow", bg: "bg-yellow-300", hoverBg: "hover:bg-yellow-400", borderColor: "border-yellow-400" },
|
|
8240
8529
|
{ color: "green", bg: "bg-green-300", hoverBg: "hover:bg-green-400", borderColor: "border-green-400" },
|
|
@@ -8242,7 +8531,7 @@ var init_HighlightPopover = __esm({
|
|
|
8242
8531
|
{ color: "pink", bg: "bg-pink-300", hoverBg: "hover:bg-pink-400", borderColor: "border-pink-400" },
|
|
8243
8532
|
{ color: "orange", bg: "bg-orange-300", hoverBg: "hover:bg-orange-400", borderColor: "border-orange-400" }
|
|
8244
8533
|
];
|
|
8245
|
-
HighlightPopover = (0,
|
|
8534
|
+
HighlightPopover = (0, import_react36.memo)(function HighlightPopover2({
|
|
8246
8535
|
highlight,
|
|
8247
8536
|
scale,
|
|
8248
8537
|
pageElement,
|
|
@@ -8253,16 +8542,16 @@ var init_HighlightPopover = __esm({
|
|
|
8253
8542
|
onClose,
|
|
8254
8543
|
className
|
|
8255
8544
|
}) {
|
|
8256
|
-
const [isEditingComment, setIsEditingComment] = (0,
|
|
8257
|
-
const [comment, setComment] = (0,
|
|
8258
|
-
const [position, setPosition] = (0,
|
|
8259
|
-
const popoverRef = (0,
|
|
8260
|
-
const textareaRef = (0,
|
|
8261
|
-
(0,
|
|
8545
|
+
const [isEditingComment, setIsEditingComment] = (0, import_react36.useState)(false);
|
|
8546
|
+
const [comment, setComment] = (0, import_react36.useState)(highlight?.comment ?? "");
|
|
8547
|
+
const [position, setPosition] = (0, import_react36.useState)({ top: 0, left: 0, visible: false });
|
|
8548
|
+
const popoverRef = (0, import_react36.useRef)(null);
|
|
8549
|
+
const textareaRef = (0, import_react36.useRef)(null);
|
|
8550
|
+
(0, import_react36.useEffect)(() => {
|
|
8262
8551
|
setComment(highlight?.comment ?? "");
|
|
8263
8552
|
setIsEditingComment(false);
|
|
8264
8553
|
}, [highlight?.id, highlight?.comment]);
|
|
8265
|
-
(0,
|
|
8554
|
+
(0, import_react36.useEffect)(() => {
|
|
8266
8555
|
if (highlight && pageElement) {
|
|
8267
8556
|
const newPosition = calculatePopoverPosition(highlight, scale, pageElement);
|
|
8268
8557
|
if (newPosition.visible && popoverRef.current) {
|
|
@@ -8292,12 +8581,12 @@ var init_HighlightPopover = __esm({
|
|
|
8292
8581
|
setPosition({ top: 0, left: 0, visible: false });
|
|
8293
8582
|
}
|
|
8294
8583
|
}, [highlight, pageElement, scale, isEditingComment]);
|
|
8295
|
-
(0,
|
|
8584
|
+
(0, import_react36.useEffect)(() => {
|
|
8296
8585
|
if (isEditingComment && textareaRef.current) {
|
|
8297
8586
|
textareaRef.current.focus();
|
|
8298
8587
|
}
|
|
8299
8588
|
}, [isEditingComment]);
|
|
8300
|
-
(0,
|
|
8589
|
+
(0, import_react36.useEffect)(() => {
|
|
8301
8590
|
function handleClickOutside(event) {
|
|
8302
8591
|
if (popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
8303
8592
|
onClose();
|
|
@@ -8308,7 +8597,7 @@ var init_HighlightPopover = __esm({
|
|
|
8308
8597
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
8309
8598
|
}
|
|
8310
8599
|
}, [position.visible, onClose]);
|
|
8311
|
-
(0,
|
|
8600
|
+
(0, import_react36.useEffect)(() => {
|
|
8312
8601
|
function handleKeyDown(event) {
|
|
8313
8602
|
if (event.key === "Escape") {
|
|
8314
8603
|
if (isEditingComment) {
|
|
@@ -8324,7 +8613,7 @@ var init_HighlightPopover = __esm({
|
|
|
8324
8613
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
8325
8614
|
}
|
|
8326
8615
|
}, [position.visible, isEditingComment, highlight?.comment, onClose]);
|
|
8327
|
-
const handleColorClick = (0,
|
|
8616
|
+
const handleColorClick = (0, import_react36.useCallback)(
|
|
8328
8617
|
(color) => {
|
|
8329
8618
|
if (highlight) {
|
|
8330
8619
|
onColorChange(highlight.id, color);
|
|
@@ -8332,19 +8621,19 @@ var init_HighlightPopover = __esm({
|
|
|
8332
8621
|
},
|
|
8333
8622
|
[highlight, onColorChange]
|
|
8334
8623
|
);
|
|
8335
|
-
const handleSaveComment = (0,
|
|
8624
|
+
const handleSaveComment = (0, import_react36.useCallback)(() => {
|
|
8336
8625
|
if (highlight) {
|
|
8337
8626
|
onCommentChange(highlight.id, comment.trim());
|
|
8338
8627
|
setIsEditingComment(false);
|
|
8339
8628
|
}
|
|
8340
8629
|
}, [highlight, comment, onCommentChange]);
|
|
8341
|
-
const handleDeleteClick = (0,
|
|
8630
|
+
const handleDeleteClick = (0, import_react36.useCallback)(() => {
|
|
8342
8631
|
if (highlight) {
|
|
8343
8632
|
onDelete(highlight.id);
|
|
8344
8633
|
onClose();
|
|
8345
8634
|
}
|
|
8346
8635
|
}, [highlight, onDelete, onClose]);
|
|
8347
|
-
const handleCopyClick = (0,
|
|
8636
|
+
const handleCopyClick = (0, import_react36.useCallback)(() => {
|
|
8348
8637
|
if (highlight?.text) {
|
|
8349
8638
|
navigator.clipboard.writeText(highlight.text);
|
|
8350
8639
|
onCopy?.(highlight.text);
|
|
@@ -8353,7 +8642,7 @@ var init_HighlightPopover = __esm({
|
|
|
8353
8642
|
if (!highlight || !position.visible) {
|
|
8354
8643
|
return null;
|
|
8355
8644
|
}
|
|
8356
|
-
return /* @__PURE__ */ (0,
|
|
8645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
8357
8646
|
"div",
|
|
8358
8647
|
{
|
|
8359
8648
|
ref: popoverRef,
|
|
@@ -8373,8 +8662,8 @@ var init_HighlightPopover = __esm({
|
|
|
8373
8662
|
width: 280
|
|
8374
8663
|
},
|
|
8375
8664
|
children: [
|
|
8376
|
-
/* @__PURE__ */ (0,
|
|
8377
|
-
/* @__PURE__ */ (0,
|
|
8665
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center justify-between p-2 border-b border-gray-200 dark:border-gray-700", children: [
|
|
8666
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex items-center gap-1", children: HIGHLIGHT_COLOR_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8378
8667
|
"button",
|
|
8379
8668
|
{
|
|
8380
8669
|
onClick: () => handleColorClick(opt.color),
|
|
@@ -8392,7 +8681,7 @@ var init_HighlightPopover = __esm({
|
|
|
8392
8681
|
},
|
|
8393
8682
|
opt.color
|
|
8394
8683
|
)) }),
|
|
8395
|
-
/* @__PURE__ */ (0,
|
|
8684
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8396
8685
|
"button",
|
|
8397
8686
|
{
|
|
8398
8687
|
onClick: handleDeleteClick,
|
|
@@ -8404,7 +8693,7 @@ var init_HighlightPopover = __esm({
|
|
|
8404
8693
|
),
|
|
8405
8694
|
title: "Delete highlight",
|
|
8406
8695
|
"aria-label": "Delete highlight",
|
|
8407
|
-
children: /* @__PURE__ */ (0,
|
|
8696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8408
8697
|
"path",
|
|
8409
8698
|
{
|
|
8410
8699
|
strokeLinecap: "round",
|
|
@@ -8416,8 +8705,8 @@ var init_HighlightPopover = __esm({
|
|
|
8416
8705
|
}
|
|
8417
8706
|
)
|
|
8418
8707
|
] }),
|
|
8419
|
-
/* @__PURE__ */ (0,
|
|
8420
|
-
/* @__PURE__ */ (0,
|
|
8708
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "p-2", children: isEditingComment ? /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "space-y-2", children: [
|
|
8709
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8421
8710
|
"textarea",
|
|
8422
8711
|
{
|
|
8423
8712
|
ref: textareaRef,
|
|
@@ -8436,8 +8725,8 @@ var init_HighlightPopover = __esm({
|
|
|
8436
8725
|
rows: 3
|
|
8437
8726
|
}
|
|
8438
8727
|
),
|
|
8439
|
-
/* @__PURE__ */ (0,
|
|
8440
|
-
/* @__PURE__ */ (0,
|
|
8728
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
8729
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8441
8730
|
"button",
|
|
8442
8731
|
{
|
|
8443
8732
|
onClick: () => {
|
|
@@ -8453,7 +8742,7 @@ var init_HighlightPopover = __esm({
|
|
|
8453
8742
|
children: "Cancel"
|
|
8454
8743
|
}
|
|
8455
8744
|
),
|
|
8456
|
-
/* @__PURE__ */ (0,
|
|
8745
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8457
8746
|
"button",
|
|
8458
8747
|
{
|
|
8459
8748
|
onClick: handleSaveComment,
|
|
@@ -8467,14 +8756,14 @@ var init_HighlightPopover = __esm({
|
|
|
8467
8756
|
}
|
|
8468
8757
|
)
|
|
8469
8758
|
] })
|
|
8470
|
-
] }) : /* @__PURE__ */ (0,
|
|
8471
|
-
/* @__PURE__ */ (0,
|
|
8759
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "space-y-2", children: [
|
|
8760
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("p", { className: "text-xs text-gray-500 dark:text-gray-400 line-clamp-2", children: [
|
|
8472
8761
|
"\u201C",
|
|
8473
8762
|
highlight.text.slice(0, 100),
|
|
8474
8763
|
highlight.text.length > 100 ? "..." : "",
|
|
8475
8764
|
"\u201D"
|
|
8476
8765
|
] }),
|
|
8477
|
-
highlight.comment ? /* @__PURE__ */ (0,
|
|
8766
|
+
highlight.comment ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8478
8767
|
"button",
|
|
8479
8768
|
{
|
|
8480
8769
|
onClick: () => setIsEditingComment(true),
|
|
@@ -8487,7 +8776,7 @@ var init_HighlightPopover = __esm({
|
|
|
8487
8776
|
),
|
|
8488
8777
|
children: highlight.comment
|
|
8489
8778
|
}
|
|
8490
|
-
) : /* @__PURE__ */ (0,
|
|
8779
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8491
8780
|
"button",
|
|
8492
8781
|
{
|
|
8493
8782
|
onClick: () => setIsEditingComment(true),
|
|
@@ -8500,7 +8789,7 @@ var init_HighlightPopover = __esm({
|
|
|
8500
8789
|
children: "+ Add a note..."
|
|
8501
8790
|
}
|
|
8502
8791
|
),
|
|
8503
|
-
/* @__PURE__ */ (0,
|
|
8792
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
8504
8793
|
"button",
|
|
8505
8794
|
{
|
|
8506
8795
|
onClick: handleCopyClick,
|
|
@@ -8511,7 +8800,7 @@ var init_HighlightPopover = __esm({
|
|
|
8511
8800
|
"focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
8512
8801
|
),
|
|
8513
8802
|
children: [
|
|
8514
|
-
/* @__PURE__ */ (0,
|
|
8803
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
8515
8804
|
"path",
|
|
8516
8805
|
{
|
|
8517
8806
|
strokeLinecap: "round",
|
|
@@ -8541,20 +8830,21 @@ var init_HighlightPopover2 = __esm({
|
|
|
8541
8830
|
});
|
|
8542
8831
|
|
|
8543
8832
|
// src/components/PDFViewer/DocumentContainer.tsx
|
|
8544
|
-
var
|
|
8833
|
+
var import_react37, import_jsx_runtime23, DocumentContainer;
|
|
8545
8834
|
var init_DocumentContainer = __esm({
|
|
8546
8835
|
"src/components/PDFViewer/DocumentContainer.tsx"() {
|
|
8547
8836
|
"use strict";
|
|
8548
|
-
|
|
8837
|
+
import_react37 = require("react");
|
|
8549
8838
|
init_PDFPage2();
|
|
8550
8839
|
init_PDFLoadingScreen2();
|
|
8840
|
+
init_PageSkeleton();
|
|
8551
8841
|
init_hooks();
|
|
8552
8842
|
init_useHighlights();
|
|
8553
8843
|
init_SelectionToolbar2();
|
|
8554
8844
|
init_HighlightPopover2();
|
|
8555
8845
|
init_utils();
|
|
8556
|
-
|
|
8557
|
-
DocumentContainer = (0,
|
|
8846
|
+
import_jsx_runtime23 = require("react/jsx-runtime");
|
|
8847
|
+
DocumentContainer = (0, import_react37.memo)(function DocumentContainer2({
|
|
8558
8848
|
className,
|
|
8559
8849
|
enableTouchGestures = true
|
|
8560
8850
|
}) {
|
|
@@ -8571,34 +8861,36 @@ var init_DocumentContainer = __esm({
|
|
|
8571
8861
|
} = usePDFViewer();
|
|
8572
8862
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
8573
8863
|
const { viewerStore } = usePDFViewerStores();
|
|
8574
|
-
const [currentPageObj, setCurrentPageObj] = (0,
|
|
8575
|
-
const [isLoadingPage, setIsLoadingPage] = (0,
|
|
8576
|
-
const
|
|
8577
|
-
const
|
|
8578
|
-
const
|
|
8864
|
+
const [currentPageObj, setCurrentPageObj] = (0, import_react37.useState)(null);
|
|
8865
|
+
const [isLoadingPage, setIsLoadingPage] = (0, import_react37.useState)(false);
|
|
8866
|
+
const [pageLoadError, setPageLoadError] = (0, import_react37.useState)(null);
|
|
8867
|
+
const containerRef = (0, import_react37.useRef)(null);
|
|
8868
|
+
const documentRef = (0, import_react37.useRef)(null);
|
|
8869
|
+
const baseScaleRef = (0, import_react37.useRef)(scale);
|
|
8579
8870
|
const isTouchDevice = useIsTouchDevice();
|
|
8871
|
+
const documentLoadingState = useViewerStore((s) => s.documentLoadingState);
|
|
8580
8872
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
8581
|
-
const handlePinchZoom = (0,
|
|
8873
|
+
const handlePinchZoom = (0, import_react37.useCallback)(
|
|
8582
8874
|
(pinchScale) => {
|
|
8583
8875
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
8584
8876
|
setScale(newScale);
|
|
8585
8877
|
},
|
|
8586
8878
|
[setScale]
|
|
8587
8879
|
);
|
|
8588
|
-
const handleSwipeLeft = (0,
|
|
8880
|
+
const handleSwipeLeft = (0, import_react37.useCallback)(() => {
|
|
8589
8881
|
nextPage();
|
|
8590
8882
|
}, [nextPage]);
|
|
8591
|
-
const handleSwipeRight = (0,
|
|
8883
|
+
const handleSwipeRight = (0, import_react37.useCallback)(() => {
|
|
8592
8884
|
previousPage();
|
|
8593
8885
|
}, [previousPage]);
|
|
8594
|
-
const handleDoubleTap = (0,
|
|
8886
|
+
const handleDoubleTap = (0, import_react37.useCallback)(
|
|
8595
8887
|
(_position) => {
|
|
8596
8888
|
const newScale = scale < 1.5 ? 2 : 1;
|
|
8597
8889
|
setScale(newScale);
|
|
8598
8890
|
},
|
|
8599
8891
|
[scale, setScale]
|
|
8600
8892
|
);
|
|
8601
|
-
(0,
|
|
8893
|
+
(0, import_react37.useEffect)(() => {
|
|
8602
8894
|
baseScaleRef.current = scale;
|
|
8603
8895
|
}, [scale]);
|
|
8604
8896
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -8618,20 +8910,23 @@ var init_DocumentContainer = __esm({
|
|
|
8618
8910
|
selectHighlight,
|
|
8619
8911
|
activeColor
|
|
8620
8912
|
} = useHighlights();
|
|
8621
|
-
(0,
|
|
8913
|
+
(0, import_react37.useEffect)(() => {
|
|
8622
8914
|
if (document2 !== documentRef.current) {
|
|
8623
8915
|
documentRef.current = document2;
|
|
8624
8916
|
setCurrentPageObj(null);
|
|
8917
|
+
setPageLoadError(null);
|
|
8625
8918
|
}
|
|
8626
8919
|
}, [document2]);
|
|
8627
|
-
(0,
|
|
8920
|
+
(0, import_react37.useEffect)(() => {
|
|
8628
8921
|
if (!document2) {
|
|
8629
8922
|
setCurrentPageObj(null);
|
|
8923
|
+
setPageLoadError(null);
|
|
8630
8924
|
return;
|
|
8631
8925
|
}
|
|
8632
8926
|
let cancelled = false;
|
|
8633
8927
|
const loadPage = async () => {
|
|
8634
8928
|
setIsLoadingPage(true);
|
|
8929
|
+
setPageLoadError(null);
|
|
8635
8930
|
try {
|
|
8636
8931
|
const page = await document2.getPage(currentPage);
|
|
8637
8932
|
if (!cancelled && document2 === documentRef.current) {
|
|
@@ -8648,6 +8943,7 @@ var init_DocumentContainer = __esm({
|
|
|
8648
8943
|
const isDocumentDestroyed = errorMessage.includes("destroyed") || errorMessage.includes("sendWithStream") || errorMessage.includes("sendWithPromise") || errorMessage.includes("Cannot read properties of null");
|
|
8649
8944
|
if (!isDocumentDestroyed) {
|
|
8650
8945
|
console.error("Error loading page:", error);
|
|
8946
|
+
setPageLoadError(error instanceof Error ? error : new Error(errorMessage));
|
|
8651
8947
|
}
|
|
8652
8948
|
}
|
|
8653
8949
|
} finally {
|
|
@@ -8661,10 +8957,10 @@ var init_DocumentContainer = __esm({
|
|
|
8661
8957
|
cancelled = true;
|
|
8662
8958
|
};
|
|
8663
8959
|
}, [document2, currentPage, scrollToPageRequest, viewerStore]);
|
|
8664
|
-
const getPageElement = (0,
|
|
8960
|
+
const getPageElement = (0, import_react37.useCallback)(() => {
|
|
8665
8961
|
return containerRef.current?.querySelector(`[data-page-number="${currentPage}"]`);
|
|
8666
8962
|
}, [currentPage]);
|
|
8667
|
-
const handleCreateHighlight = (0,
|
|
8963
|
+
const handleCreateHighlight = (0, import_react37.useCallback)(
|
|
8668
8964
|
(color) => {
|
|
8669
8965
|
if (!selection) return;
|
|
8670
8966
|
const pageElement = getPageElement();
|
|
@@ -8674,25 +8970,25 @@ var init_DocumentContainer = __esm({
|
|
|
8674
8970
|
},
|
|
8675
8971
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
8676
8972
|
);
|
|
8677
|
-
const handleCopySelection = (0,
|
|
8973
|
+
const handleCopySelection = (0, import_react37.useCallback)(() => {
|
|
8678
8974
|
copySelection();
|
|
8679
8975
|
}, [copySelection]);
|
|
8680
|
-
const handleColorChange = (0,
|
|
8976
|
+
const handleColorChange = (0, import_react37.useCallback)(
|
|
8681
8977
|
(id, color) => {
|
|
8682
8978
|
updateHighlight(id, { color });
|
|
8683
8979
|
},
|
|
8684
8980
|
[updateHighlight]
|
|
8685
8981
|
);
|
|
8686
|
-
const handleCommentChange = (0,
|
|
8982
|
+
const handleCommentChange = (0, import_react37.useCallback)(
|
|
8687
8983
|
(id, comment) => {
|
|
8688
8984
|
updateHighlight(id, { comment: comment || void 0 });
|
|
8689
8985
|
},
|
|
8690
8986
|
[updateHighlight]
|
|
8691
8987
|
);
|
|
8692
|
-
const handleClosePopover = (0,
|
|
8988
|
+
const handleClosePopover = (0, import_react37.useCallback)(() => {
|
|
8693
8989
|
selectHighlight(null);
|
|
8694
8990
|
}, [selectHighlight]);
|
|
8695
|
-
const setContainerRef = (0,
|
|
8991
|
+
const setContainerRef = (0, import_react37.useCallback)(
|
|
8696
8992
|
(element) => {
|
|
8697
8993
|
containerRef.current = element;
|
|
8698
8994
|
touchRef(element);
|
|
@@ -8705,7 +9001,7 @@ var init_DocumentContainer = __esm({
|
|
|
8705
9001
|
sepia: "bg-amber-50"
|
|
8706
9002
|
};
|
|
8707
9003
|
if (!document2) {
|
|
8708
|
-
return /* @__PURE__ */ (0,
|
|
9004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8709
9005
|
"div",
|
|
8710
9006
|
{
|
|
8711
9007
|
className: cn(
|
|
@@ -8714,11 +9010,53 @@ var init_DocumentContainer = __esm({
|
|
|
8714
9010
|
themeStyles[theme],
|
|
8715
9011
|
className
|
|
8716
9012
|
),
|
|
8717
|
-
children: /* @__PURE__ */ (0,
|
|
9013
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PDFLoadingScreen, { phase: isLoading ? "fetching" : "initializing" })
|
|
8718
9014
|
}
|
|
8719
9015
|
);
|
|
8720
9016
|
}
|
|
8721
|
-
|
|
9017
|
+
const renderPageContent = () => {
|
|
9018
|
+
if (pageLoadError && !currentPageObj) {
|
|
9019
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
9020
|
+
"div",
|
|
9021
|
+
{
|
|
9022
|
+
className: "relative bg-white shadow-lg flex flex-col items-center justify-center gap-2 text-gray-500",
|
|
9023
|
+
style: {
|
|
9024
|
+
width: DEFAULT_PAGE_WIDTH * scale,
|
|
9025
|
+
height: DEFAULT_PAGE_HEIGHT * scale
|
|
9026
|
+
},
|
|
9027
|
+
"data-page-number": currentPage,
|
|
9028
|
+
children: [
|
|
9029
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { className: "w-8 h-8 text-red-400", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
|
9030
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "text-sm", children: [
|
|
9031
|
+
"Failed to load page ",
|
|
9032
|
+
currentPage
|
|
9033
|
+
] })
|
|
9034
|
+
]
|
|
9035
|
+
}
|
|
9036
|
+
);
|
|
9037
|
+
}
|
|
9038
|
+
if (isLoadingPage && !currentPageObj) {
|
|
9039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
9040
|
+
PageSkeleton,
|
|
9041
|
+
{
|
|
9042
|
+
pageNumber: currentPage,
|
|
9043
|
+
width: Math.floor(DEFAULT_PAGE_WIDTH * scale),
|
|
9044
|
+
height: Math.floor(DEFAULT_PAGE_HEIGHT * scale),
|
|
9045
|
+
isFirstPage: currentPage === 1 && documentLoadingState !== "ready"
|
|
9046
|
+
}
|
|
9047
|
+
);
|
|
9048
|
+
}
|
|
9049
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
9050
|
+
PDFPage,
|
|
9051
|
+
{
|
|
9052
|
+
pageNumber: currentPage,
|
|
9053
|
+
page: currentPageObj,
|
|
9054
|
+
scale,
|
|
9055
|
+
rotation
|
|
9056
|
+
}
|
|
9057
|
+
);
|
|
9058
|
+
};
|
|
9059
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
8722
9060
|
"div",
|
|
8723
9061
|
{
|
|
8724
9062
|
ref: setContainerRef,
|
|
@@ -8731,16 +9069,8 @@ var init_DocumentContainer = __esm({
|
|
|
8731
9069
|
className
|
|
8732
9070
|
),
|
|
8733
9071
|
children: [
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
{
|
|
8737
|
-
pageNumber: currentPage,
|
|
8738
|
-
page: currentPageObj,
|
|
8739
|
-
scale,
|
|
8740
|
-
rotation
|
|
8741
|
-
}
|
|
8742
|
-
),
|
|
8743
|
-
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
9072
|
+
renderPageContent(),
|
|
9073
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8744
9074
|
SelectionToolbar,
|
|
8745
9075
|
{
|
|
8746
9076
|
selection,
|
|
@@ -8749,7 +9079,7 @@ var init_DocumentContainer = __esm({
|
|
|
8749
9079
|
activeColor
|
|
8750
9080
|
}
|
|
8751
9081
|
),
|
|
8752
|
-
/* @__PURE__ */ (0,
|
|
9082
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
8753
9083
|
HighlightPopover,
|
|
8754
9084
|
{
|
|
8755
9085
|
highlight: selectedHighlight,
|
|
@@ -8760,8 +9090,7 @@ var init_DocumentContainer = __esm({
|
|
|
8760
9090
|
onDelete: deleteHighlight,
|
|
8761
9091
|
onClose: handleClosePopover
|
|
8762
9092
|
}
|
|
8763
|
-
)
|
|
8764
|
-
isLoadingPage && !currentPageObj && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "fixed bottom-4 right-4 px-3 py-2 bg-black/75 text-white text-sm rounded-lg", children: "Loading..." })
|
|
9093
|
+
)
|
|
8765
9094
|
]
|
|
8766
9095
|
}
|
|
8767
9096
|
);
|
|
@@ -8770,22 +9099,23 @@ var init_DocumentContainer = __esm({
|
|
|
8770
9099
|
});
|
|
8771
9100
|
|
|
8772
9101
|
// src/components/PDFViewer/VirtualizedDocumentContainer.tsx
|
|
8773
|
-
var
|
|
9102
|
+
var import_react38, import_jsx_runtime24, DEFAULT_PAGE_WIDTH2, DEFAULT_PAGE_HEIGHT2, VirtualizedDocumentContainer;
|
|
8774
9103
|
var init_VirtualizedDocumentContainer = __esm({
|
|
8775
9104
|
"src/components/PDFViewer/VirtualizedDocumentContainer.tsx"() {
|
|
8776
9105
|
"use strict";
|
|
8777
|
-
|
|
9106
|
+
import_react38 = require("react");
|
|
8778
9107
|
init_PDFPage2();
|
|
8779
9108
|
init_PDFLoadingScreen2();
|
|
9109
|
+
init_PageSkeleton();
|
|
8780
9110
|
init_hooks();
|
|
8781
9111
|
init_useHighlights();
|
|
8782
9112
|
init_SelectionToolbar2();
|
|
8783
9113
|
init_HighlightPopover2();
|
|
8784
9114
|
init_utils();
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
VirtualizedDocumentContainer = (0,
|
|
9115
|
+
import_jsx_runtime24 = require("react/jsx-runtime");
|
|
9116
|
+
DEFAULT_PAGE_WIDTH2 = 612;
|
|
9117
|
+
DEFAULT_PAGE_HEIGHT2 = 792;
|
|
9118
|
+
VirtualizedDocumentContainer = (0, import_react38.memo)(function VirtualizedDocumentContainer2({
|
|
8789
9119
|
overscan = 2,
|
|
8790
9120
|
pageGap = 16,
|
|
8791
9121
|
enableTouchGestures = true,
|
|
@@ -8806,17 +9136,17 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8806
9136
|
} = usePDFViewer();
|
|
8807
9137
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
8808
9138
|
const { viewerStore } = usePDFViewerStores();
|
|
8809
|
-
const containerRef = (0,
|
|
8810
|
-
const scrollContainerRef = (0,
|
|
8811
|
-
const documentRef = (0,
|
|
8812
|
-
const pageCache = (0,
|
|
8813
|
-
const pageDimensionsCache = (0,
|
|
8814
|
-
const baseScaleRef = (0,
|
|
9139
|
+
const containerRef = (0, import_react38.useRef)(null);
|
|
9140
|
+
const scrollContainerRef = (0, import_react38.useRef)(null);
|
|
9141
|
+
const documentRef = (0, import_react38.useRef)(null);
|
|
9142
|
+
const pageCache = (0, import_react38.useRef)(/* @__PURE__ */ new Map());
|
|
9143
|
+
const pageDimensionsCache = (0, import_react38.useRef)(/* @__PURE__ */ new Map());
|
|
9144
|
+
const baseScaleRef = (0, import_react38.useRef)(scale);
|
|
8815
9145
|
const isTouchDevice = useIsTouchDevice();
|
|
8816
|
-
const [visiblePages, setVisiblePages] = (0,
|
|
8817
|
-
const [pageObjects, setPageObjects] = (0,
|
|
8818
|
-
const [totalHeight, setTotalHeight] = (0,
|
|
8819
|
-
const [pageInfos, setPageInfos] = (0,
|
|
9146
|
+
const [visiblePages, setVisiblePages] = (0, import_react38.useState)([1]);
|
|
9147
|
+
const [pageObjects, setPageObjects] = (0, import_react38.useState)(/* @__PURE__ */ new Map());
|
|
9148
|
+
const [totalHeight, setTotalHeight] = (0, import_react38.useState)(0);
|
|
9149
|
+
const [pageInfos, setPageInfos] = (0, import_react38.useState)([]);
|
|
8820
9150
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
8821
9151
|
const {
|
|
8822
9152
|
createHighlightFromSelection,
|
|
@@ -8826,7 +9156,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8826
9156
|
selectHighlight,
|
|
8827
9157
|
activeColor
|
|
8828
9158
|
} = useHighlights();
|
|
8829
|
-
(0,
|
|
9159
|
+
(0, import_react38.useEffect)(() => {
|
|
8830
9160
|
if (document2 !== documentRef.current) {
|
|
8831
9161
|
documentRef.current = document2;
|
|
8832
9162
|
pageCache.current.clear();
|
|
@@ -8834,7 +9164,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8834
9164
|
setPageObjects(/* @__PURE__ */ new Map());
|
|
8835
9165
|
}
|
|
8836
9166
|
}, [document2]);
|
|
8837
|
-
(0,
|
|
9167
|
+
(0, import_react38.useEffect)(() => {
|
|
8838
9168
|
if (!document2 || numPages === 0) return;
|
|
8839
9169
|
const calculatePageInfos = async () => {
|
|
8840
9170
|
const infos = [];
|
|
@@ -8851,7 +9181,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8851
9181
|
dimensions = { width: viewport.width, height: viewport.height };
|
|
8852
9182
|
pageDimensionsCache.current.set(i, dimensions);
|
|
8853
9183
|
} catch {
|
|
8854
|
-
dimensions = { width:
|
|
9184
|
+
dimensions = { width: DEFAULT_PAGE_WIDTH2, height: DEFAULT_PAGE_HEIGHT2 };
|
|
8855
9185
|
}
|
|
8856
9186
|
}
|
|
8857
9187
|
const scaledHeight = Math.floor(dimensions.height * scale);
|
|
@@ -8867,7 +9197,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8867
9197
|
};
|
|
8868
9198
|
calculatePageInfos();
|
|
8869
9199
|
}, [document2, numPages, scale, rotation, pageGap]);
|
|
8870
|
-
const updateVisiblePages = (0,
|
|
9200
|
+
const updateVisiblePages = (0, import_react38.useCallback)(() => {
|
|
8871
9201
|
if (!scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8872
9202
|
const container = scrollContainerRef.current;
|
|
8873
9203
|
const scrollTop = container.scrollTop;
|
|
@@ -8899,7 +9229,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8899
9229
|
goToPage(firstVisiblePage);
|
|
8900
9230
|
}
|
|
8901
9231
|
}, [pageInfos, overscan, currentPage, goToPage]);
|
|
8902
|
-
(0,
|
|
9232
|
+
(0, import_react38.useEffect)(() => {
|
|
8903
9233
|
const container = scrollContainerRef.current;
|
|
8904
9234
|
if (!container) return;
|
|
8905
9235
|
const handleScroll = () => {
|
|
@@ -8909,7 +9239,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8909
9239
|
updateVisiblePages();
|
|
8910
9240
|
return () => container.removeEventListener("scroll", handleScroll);
|
|
8911
9241
|
}, [updateVisiblePages]);
|
|
8912
|
-
(0,
|
|
9242
|
+
(0, import_react38.useEffect)(() => {
|
|
8913
9243
|
if (!document2) return;
|
|
8914
9244
|
const loadPages = async () => {
|
|
8915
9245
|
const newPageObjects = new Map(pageObjects);
|
|
@@ -8946,7 +9276,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8946
9276
|
};
|
|
8947
9277
|
loadPages();
|
|
8948
9278
|
}, [document2, visiblePages, pageObjects]);
|
|
8949
|
-
(0,
|
|
9279
|
+
(0, import_react38.useEffect)(() => {
|
|
8950
9280
|
if (!scrollToPageRequest || !scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8951
9281
|
const { page, requestId, behavior } = scrollToPageRequest;
|
|
8952
9282
|
const pageInfo = pageInfos.find((p) => p.pageNumber === page);
|
|
@@ -8984,7 +9314,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
8984
9314
|
handleScrollEnd();
|
|
8985
9315
|
}
|
|
8986
9316
|
}, [scrollToPageRequest, pageInfos, pageGap, viewerStore]);
|
|
8987
|
-
(0,
|
|
9317
|
+
(0, import_react38.useEffect)(() => {
|
|
8988
9318
|
if (scrollToPageRequest) return;
|
|
8989
9319
|
if (!scrollContainerRef.current || pageInfos.length === 0) return;
|
|
8990
9320
|
const pageInfo = pageInfos.find((p) => p.pageNumber === currentPage);
|
|
@@ -9001,14 +9331,14 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9001
9331
|
}
|
|
9002
9332
|
}
|
|
9003
9333
|
}, [currentPage, pageInfos, pageGap, scrollToPageRequest]);
|
|
9004
|
-
const handlePinchZoom = (0,
|
|
9334
|
+
const handlePinchZoom = (0, import_react38.useCallback)(
|
|
9005
9335
|
(pinchScale) => {
|
|
9006
9336
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
9007
9337
|
setScale(newScale);
|
|
9008
9338
|
},
|
|
9009
9339
|
[setScale]
|
|
9010
9340
|
);
|
|
9011
|
-
(0,
|
|
9341
|
+
(0, import_react38.useEffect)(() => {
|
|
9012
9342
|
baseScaleRef.current = scale;
|
|
9013
9343
|
}, [scale]);
|
|
9014
9344
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -9017,20 +9347,20 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9017
9347
|
onSwipeRight: previousPage,
|
|
9018
9348
|
enabled: enableTouchGestures && isTouchDevice
|
|
9019
9349
|
});
|
|
9020
|
-
const setContainerRef = (0,
|
|
9350
|
+
const setContainerRef = (0, import_react38.useCallback)(
|
|
9021
9351
|
(element) => {
|
|
9022
9352
|
scrollContainerRef.current = element;
|
|
9023
9353
|
touchRef(element);
|
|
9024
9354
|
},
|
|
9025
9355
|
[touchRef]
|
|
9026
9356
|
);
|
|
9027
|
-
const getPageElement = (0,
|
|
9357
|
+
const getPageElement = (0, import_react38.useCallback)(
|
|
9028
9358
|
(pageNumber) => {
|
|
9029
9359
|
return containerRef.current?.querySelector(`[data-page-number="${pageNumber}"]`);
|
|
9030
9360
|
},
|
|
9031
9361
|
[]
|
|
9032
9362
|
);
|
|
9033
|
-
const handleCreateHighlight = (0,
|
|
9363
|
+
const handleCreateHighlight = (0, import_react38.useCallback)(
|
|
9034
9364
|
(color) => {
|
|
9035
9365
|
if (!selection) return;
|
|
9036
9366
|
const pageElement = getPageElement(selection.pageNumber);
|
|
@@ -9040,13 +9370,13 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9040
9370
|
},
|
|
9041
9371
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
9042
9372
|
);
|
|
9043
|
-
const handleColorChange = (0,
|
|
9373
|
+
const handleColorChange = (0, import_react38.useCallback)(
|
|
9044
9374
|
(id, color) => {
|
|
9045
9375
|
updateHighlight(id, { color });
|
|
9046
9376
|
},
|
|
9047
9377
|
[updateHighlight]
|
|
9048
9378
|
);
|
|
9049
|
-
const handleCommentChange = (0,
|
|
9379
|
+
const handleCommentChange = (0, import_react38.useCallback)(
|
|
9050
9380
|
(id, comment) => {
|
|
9051
9381
|
updateHighlight(id, { comment: comment || void 0 });
|
|
9052
9382
|
},
|
|
@@ -9058,7 +9388,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9058
9388
|
sepia: "bg-amber-50"
|
|
9059
9389
|
};
|
|
9060
9390
|
if (!document2) {
|
|
9061
|
-
return /* @__PURE__ */ (0,
|
|
9391
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9062
9392
|
"div",
|
|
9063
9393
|
{
|
|
9064
9394
|
className: cn(
|
|
@@ -9067,11 +9397,11 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9067
9397
|
themeStyles[theme],
|
|
9068
9398
|
className
|
|
9069
9399
|
),
|
|
9070
|
-
children: /* @__PURE__ */ (0,
|
|
9400
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(PDFLoadingScreen, { phase: isLoading ? "fetching" : "initializing" })
|
|
9071
9401
|
}
|
|
9072
9402
|
);
|
|
9073
9403
|
}
|
|
9074
|
-
return /* @__PURE__ */ (0,
|
|
9404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
9075
9405
|
"div",
|
|
9076
9406
|
{
|
|
9077
9407
|
ref: containerRef,
|
|
@@ -9082,7 +9412,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9082
9412
|
className
|
|
9083
9413
|
),
|
|
9084
9414
|
children: [
|
|
9085
|
-
/* @__PURE__ */ (0,
|
|
9415
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9086
9416
|
"div",
|
|
9087
9417
|
{
|
|
9088
9418
|
ref: setContainerRef,
|
|
@@ -9091,7 +9421,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9091
9421
|
// Smooth scrolling on iOS
|
|
9092
9422
|
WebkitOverflowScrolling: "touch"
|
|
9093
9423
|
},
|
|
9094
|
-
children: /* @__PURE__ */ (0,
|
|
9424
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9095
9425
|
"div",
|
|
9096
9426
|
{
|
|
9097
9427
|
className: "relative mx-auto",
|
|
@@ -9102,8 +9432,9 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9102
9432
|
children: pageInfos.filter((info) => visiblePages.includes(info.pageNumber)).map((info) => {
|
|
9103
9433
|
const page = pageObjects.get(info.pageNumber);
|
|
9104
9434
|
const dimensions = pageDimensionsCache.current.get(info.pageNumber);
|
|
9105
|
-
const scaledWidth = dimensions ? Math.floor(dimensions.width * scale) : Math.floor(
|
|
9106
|
-
|
|
9435
|
+
const scaledWidth = dimensions ? Math.floor(dimensions.width * scale) : Math.floor(DEFAULT_PAGE_WIDTH2 * scale);
|
|
9436
|
+
const scaledHeight = dimensions ? Math.floor(dimensions.height * scale) : Math.floor(DEFAULT_PAGE_HEIGHT2 * scale);
|
|
9437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9107
9438
|
"div",
|
|
9108
9439
|
{
|
|
9109
9440
|
className: "absolute left-1/2 -translate-x-1/2",
|
|
@@ -9111,14 +9442,22 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9111
9442
|
top: info.top,
|
|
9112
9443
|
width: scaledWidth
|
|
9113
9444
|
},
|
|
9114
|
-
children: /* @__PURE__ */ (0,
|
|
9445
|
+
children: page ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9115
9446
|
PDFPage,
|
|
9116
9447
|
{
|
|
9117
9448
|
pageNumber: info.pageNumber,
|
|
9118
|
-
page
|
|
9449
|
+
page,
|
|
9119
9450
|
scale,
|
|
9120
9451
|
rotation
|
|
9121
9452
|
}
|
|
9453
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9454
|
+
PageSkeleton,
|
|
9455
|
+
{
|
|
9456
|
+
pageNumber: info.pageNumber,
|
|
9457
|
+
width: scaledWidth,
|
|
9458
|
+
height: scaledHeight,
|
|
9459
|
+
isFirstPage: info.pageNumber === 1
|
|
9460
|
+
}
|
|
9122
9461
|
)
|
|
9123
9462
|
},
|
|
9124
9463
|
info.pageNumber
|
|
@@ -9128,7 +9467,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9128
9467
|
)
|
|
9129
9468
|
}
|
|
9130
9469
|
),
|
|
9131
|
-
/* @__PURE__ */ (0,
|
|
9470
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9132
9471
|
SelectionToolbar,
|
|
9133
9472
|
{
|
|
9134
9473
|
selection,
|
|
@@ -9137,7 +9476,7 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9137
9476
|
activeColor
|
|
9138
9477
|
}
|
|
9139
9478
|
),
|
|
9140
|
-
/* @__PURE__ */ (0,
|
|
9479
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
9141
9480
|
HighlightPopover,
|
|
9142
9481
|
{
|
|
9143
9482
|
highlight: selectedHighlight,
|
|
@@ -9157,15 +9496,15 @@ var init_VirtualizedDocumentContainer = __esm({
|
|
|
9157
9496
|
});
|
|
9158
9497
|
|
|
9159
9498
|
// src/components/PDFViewer/ContinuousScrollContainer.tsx
|
|
9160
|
-
var
|
|
9499
|
+
var import_react39, import_jsx_runtime25, ContinuousScrollContainer;
|
|
9161
9500
|
var init_ContinuousScrollContainer = __esm({
|
|
9162
9501
|
"src/components/PDFViewer/ContinuousScrollContainer.tsx"() {
|
|
9163
9502
|
"use strict";
|
|
9164
|
-
|
|
9503
|
+
import_react39 = require("react");
|
|
9165
9504
|
init_VirtualizedDocumentContainer();
|
|
9166
|
-
|
|
9167
|
-
ContinuousScrollContainer = (0,
|
|
9168
|
-
return /* @__PURE__ */ (0,
|
|
9505
|
+
import_jsx_runtime25 = require("react/jsx-runtime");
|
|
9506
|
+
ContinuousScrollContainer = (0, import_react39.memo)(function ContinuousScrollContainer2(props) {
|
|
9507
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
9169
9508
|
VirtualizedDocumentContainer,
|
|
9170
9509
|
{
|
|
9171
9510
|
overscan: 3,
|
|
@@ -9178,11 +9517,11 @@ var init_ContinuousScrollContainer = __esm({
|
|
|
9178
9517
|
});
|
|
9179
9518
|
|
|
9180
9519
|
// src/components/PDFViewer/DualPageContainer.tsx
|
|
9181
|
-
var
|
|
9520
|
+
var import_react40, import_jsx_runtime26, DualPageContainer;
|
|
9182
9521
|
var init_DualPageContainer = __esm({
|
|
9183
9522
|
"src/components/PDFViewer/DualPageContainer.tsx"() {
|
|
9184
9523
|
"use strict";
|
|
9185
|
-
|
|
9524
|
+
import_react40 = require("react");
|
|
9186
9525
|
init_PDFPage2();
|
|
9187
9526
|
init_PDFLoadingScreen2();
|
|
9188
9527
|
init_hooks();
|
|
@@ -9190,8 +9529,8 @@ var init_DualPageContainer = __esm({
|
|
|
9190
9529
|
init_SelectionToolbar2();
|
|
9191
9530
|
init_HighlightPopover2();
|
|
9192
9531
|
init_utils();
|
|
9193
|
-
|
|
9194
|
-
DualPageContainer = (0,
|
|
9532
|
+
import_jsx_runtime26 = require("react/jsx-runtime");
|
|
9533
|
+
DualPageContainer = (0, import_react40.memo)(function DualPageContainer2({
|
|
9195
9534
|
showCover = true,
|
|
9196
9535
|
bookSpread = true,
|
|
9197
9536
|
pageGap = 4,
|
|
@@ -9211,13 +9550,13 @@ var init_DualPageContainer = __esm({
|
|
|
9211
9550
|
} = usePDFViewer();
|
|
9212
9551
|
const scrollToPageRequest = useViewerStore((s) => s.scrollToPageRequest);
|
|
9213
9552
|
const { viewerStore } = usePDFViewerStores();
|
|
9214
|
-
const containerRef = (0,
|
|
9215
|
-
const documentRef = (0,
|
|
9216
|
-
const baseScaleRef = (0,
|
|
9553
|
+
const containerRef = (0, import_react40.useRef)(null);
|
|
9554
|
+
const documentRef = (0, import_react40.useRef)(null);
|
|
9555
|
+
const baseScaleRef = (0, import_react40.useRef)(scale);
|
|
9217
9556
|
const isTouchDevice = useIsTouchDevice();
|
|
9218
|
-
const [leftPage, setLeftPage] = (0,
|
|
9219
|
-
const [rightPage, setRightPage] = (0,
|
|
9220
|
-
const [isLoading, setIsLoading] = (0,
|
|
9557
|
+
const [leftPage, setLeftPage] = (0, import_react40.useState)(null);
|
|
9558
|
+
const [rightPage, setRightPage] = (0, import_react40.useState)(null);
|
|
9559
|
+
const [isLoading, setIsLoading] = (0, import_react40.useState)(false);
|
|
9221
9560
|
const { selection, clearSelection, copySelection } = useTextSelection();
|
|
9222
9561
|
const {
|
|
9223
9562
|
createHighlightFromSelection,
|
|
@@ -9227,7 +9566,7 @@ var init_DualPageContainer = __esm({
|
|
|
9227
9566
|
selectHighlight,
|
|
9228
9567
|
activeColor
|
|
9229
9568
|
} = useHighlights();
|
|
9230
|
-
const getSpreadPages = (0,
|
|
9569
|
+
const getSpreadPages = (0, import_react40.useCallback)(
|
|
9231
9570
|
(page) => {
|
|
9232
9571
|
if (showCover && page === 1) {
|
|
9233
9572
|
return { left: null, right: 1 };
|
|
@@ -9271,14 +9610,14 @@ var init_DualPageContainer = __esm({
|
|
|
9271
9610
|
},
|
|
9272
9611
|
[showCover, bookSpread, numPages]
|
|
9273
9612
|
);
|
|
9274
|
-
(0,
|
|
9613
|
+
(0, import_react40.useEffect)(() => {
|
|
9275
9614
|
if (document2 !== documentRef.current) {
|
|
9276
9615
|
documentRef.current = document2;
|
|
9277
9616
|
setLeftPage(null);
|
|
9278
9617
|
setRightPage(null);
|
|
9279
9618
|
}
|
|
9280
9619
|
}, [document2]);
|
|
9281
|
-
(0,
|
|
9620
|
+
(0, import_react40.useEffect)(() => {
|
|
9282
9621
|
if (!document2) {
|
|
9283
9622
|
setLeftPage(null);
|
|
9284
9623
|
setRightPage(null);
|
|
@@ -9324,7 +9663,7 @@ var init_DualPageContainer = __esm({
|
|
|
9324
9663
|
cancelled = true;
|
|
9325
9664
|
};
|
|
9326
9665
|
}, [document2, currentPage, getSpreadPages, scrollToPageRequest, viewerStore]);
|
|
9327
|
-
const goToPreviousSpread = (0,
|
|
9666
|
+
const goToPreviousSpread = (0, import_react40.useCallback)(() => {
|
|
9328
9667
|
const spread2 = getSpreadPages(currentPage);
|
|
9329
9668
|
const leftmostPage = spread2.left || spread2.right || currentPage;
|
|
9330
9669
|
if (showCover && leftmostPage === 2) {
|
|
@@ -9336,21 +9675,21 @@ var init_DualPageContainer = __esm({
|
|
|
9336
9675
|
goToPage(newPage);
|
|
9337
9676
|
}
|
|
9338
9677
|
}, [currentPage, showCover, getSpreadPages, goToPage]);
|
|
9339
|
-
const goToNextSpread = (0,
|
|
9678
|
+
const goToNextSpread = (0, import_react40.useCallback)(() => {
|
|
9340
9679
|
const spread2 = getSpreadPages(currentPage);
|
|
9341
9680
|
const rightmostPage = spread2.right || spread2.left || currentPage;
|
|
9342
9681
|
if (rightmostPage < numPages) {
|
|
9343
9682
|
goToPage(Math.min(numPages, rightmostPage + 1));
|
|
9344
9683
|
}
|
|
9345
9684
|
}, [currentPage, numPages, getSpreadPages, goToPage]);
|
|
9346
|
-
const handlePinchZoom = (0,
|
|
9685
|
+
const handlePinchZoom = (0, import_react40.useCallback)(
|
|
9347
9686
|
(pinchScale) => {
|
|
9348
9687
|
const newScale = Math.max(0.25, Math.min(4, baseScaleRef.current * pinchScale));
|
|
9349
9688
|
setScale(newScale);
|
|
9350
9689
|
},
|
|
9351
9690
|
[setScale]
|
|
9352
9691
|
);
|
|
9353
|
-
(0,
|
|
9692
|
+
(0, import_react40.useEffect)(() => {
|
|
9354
9693
|
baseScaleRef.current = scale;
|
|
9355
9694
|
}, [scale]);
|
|
9356
9695
|
const { ref: touchRef } = useTouchGestures({
|
|
@@ -9359,20 +9698,20 @@ var init_DualPageContainer = __esm({
|
|
|
9359
9698
|
onSwipeRight: goToPreviousSpread,
|
|
9360
9699
|
enabled: enableTouchGestures && isTouchDevice
|
|
9361
9700
|
});
|
|
9362
|
-
const setContainerRef = (0,
|
|
9701
|
+
const setContainerRef = (0, import_react40.useCallback)(
|
|
9363
9702
|
(element) => {
|
|
9364
9703
|
containerRef.current = element;
|
|
9365
9704
|
touchRef(element);
|
|
9366
9705
|
},
|
|
9367
9706
|
[touchRef]
|
|
9368
9707
|
);
|
|
9369
|
-
const getPageElement = (0,
|
|
9708
|
+
const getPageElement = (0, import_react40.useCallback)(
|
|
9370
9709
|
(pageNumber) => {
|
|
9371
9710
|
return containerRef.current?.querySelector(`[data-page-number="${pageNumber}"]`);
|
|
9372
9711
|
},
|
|
9373
9712
|
[]
|
|
9374
9713
|
);
|
|
9375
|
-
const handleCreateHighlight = (0,
|
|
9714
|
+
const handleCreateHighlight = (0, import_react40.useCallback)(
|
|
9376
9715
|
(color) => {
|
|
9377
9716
|
if (!selection) return;
|
|
9378
9717
|
const pageElement = getPageElement(selection.pageNumber);
|
|
@@ -9382,13 +9721,13 @@ var init_DualPageContainer = __esm({
|
|
|
9382
9721
|
},
|
|
9383
9722
|
[selection, getPageElement, createHighlightFromSelection, scale, clearSelection]
|
|
9384
9723
|
);
|
|
9385
|
-
const handleColorChange = (0,
|
|
9724
|
+
const handleColorChange = (0, import_react40.useCallback)(
|
|
9386
9725
|
(id, color) => {
|
|
9387
9726
|
updateHighlight(id, { color });
|
|
9388
9727
|
},
|
|
9389
9728
|
[updateHighlight]
|
|
9390
9729
|
);
|
|
9391
|
-
const handleCommentChange = (0,
|
|
9730
|
+
const handleCommentChange = (0, import_react40.useCallback)(
|
|
9392
9731
|
(id, comment) => {
|
|
9393
9732
|
updateHighlight(id, { comment: comment || void 0 });
|
|
9394
9733
|
},
|
|
@@ -9401,7 +9740,7 @@ var init_DualPageContainer = __esm({
|
|
|
9401
9740
|
};
|
|
9402
9741
|
const spread = getSpreadPages(currentPage);
|
|
9403
9742
|
if (!document2) {
|
|
9404
|
-
return /* @__PURE__ */ (0,
|
|
9743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9405
9744
|
"div",
|
|
9406
9745
|
{
|
|
9407
9746
|
className: cn(
|
|
@@ -9410,11 +9749,11 @@ var init_DualPageContainer = __esm({
|
|
|
9410
9749
|
themeStyles[theme],
|
|
9411
9750
|
className
|
|
9412
9751
|
),
|
|
9413
|
-
children: /* @__PURE__ */ (0,
|
|
9752
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PDFLoadingScreen, { phase: isDocumentLoading ? "fetching" : "initializing" })
|
|
9414
9753
|
}
|
|
9415
9754
|
);
|
|
9416
9755
|
}
|
|
9417
|
-
return /* @__PURE__ */ (0,
|
|
9756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
9418
9757
|
"div",
|
|
9419
9758
|
{
|
|
9420
9759
|
ref: setContainerRef,
|
|
@@ -9427,13 +9766,13 @@ var init_DualPageContainer = __esm({
|
|
|
9427
9766
|
className
|
|
9428
9767
|
),
|
|
9429
9768
|
children: [
|
|
9430
|
-
/* @__PURE__ */ (0,
|
|
9769
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
9431
9770
|
"div",
|
|
9432
9771
|
{
|
|
9433
9772
|
className: "flex items-center",
|
|
9434
9773
|
style: { gap: pageGap },
|
|
9435
9774
|
children: [
|
|
9436
|
-
spread.left && /* @__PURE__ */ (0,
|
|
9775
|
+
spread.left && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9437
9776
|
PDFPage,
|
|
9438
9777
|
{
|
|
9439
9778
|
pageNumber: spread.left,
|
|
@@ -9442,14 +9781,14 @@ var init_DualPageContainer = __esm({
|
|
|
9442
9781
|
rotation
|
|
9443
9782
|
}
|
|
9444
9783
|
),
|
|
9445
|
-
spread.left && spread.right && /* @__PURE__ */ (0,
|
|
9784
|
+
spread.left && spread.right && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9446
9785
|
"div",
|
|
9447
9786
|
{
|
|
9448
9787
|
className: "w-px h-full bg-gray-300 dark:bg-gray-600 opacity-50",
|
|
9449
9788
|
style: { minHeight: "100%" }
|
|
9450
9789
|
}
|
|
9451
9790
|
),
|
|
9452
|
-
spread.right && /* @__PURE__ */ (0,
|
|
9791
|
+
spread.right && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9453
9792
|
PDFPage,
|
|
9454
9793
|
{
|
|
9455
9794
|
pageNumber: spread.right,
|
|
@@ -9458,7 +9797,7 @@ var init_DualPageContainer = __esm({
|
|
|
9458
9797
|
rotation
|
|
9459
9798
|
}
|
|
9460
9799
|
),
|
|
9461
|
-
(!spread.left || !spread.right) && /* @__PURE__ */ (0,
|
|
9800
|
+
(!spread.left || !spread.right) && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9462
9801
|
"div",
|
|
9463
9802
|
{
|
|
9464
9803
|
className: "flex items-center justify-center",
|
|
@@ -9471,7 +9810,7 @@ var init_DualPageContainer = __esm({
|
|
|
9471
9810
|
]
|
|
9472
9811
|
}
|
|
9473
9812
|
),
|
|
9474
|
-
/* @__PURE__ */ (0,
|
|
9813
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9475
9814
|
SelectionToolbar,
|
|
9476
9815
|
{
|
|
9477
9816
|
selection,
|
|
@@ -9480,7 +9819,7 @@ var init_DualPageContainer = __esm({
|
|
|
9480
9819
|
activeColor
|
|
9481
9820
|
}
|
|
9482
9821
|
),
|
|
9483
|
-
/* @__PURE__ */ (0,
|
|
9822
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
9484
9823
|
HighlightPopover,
|
|
9485
9824
|
{
|
|
9486
9825
|
highlight: selectedHighlight,
|
|
@@ -9492,7 +9831,7 @@ var init_DualPageContainer = __esm({
|
|
|
9492
9831
|
onClose: () => selectHighlight(null)
|
|
9493
9832
|
}
|
|
9494
9833
|
),
|
|
9495
|
-
isLoading && /* @__PURE__ */ (0,
|
|
9834
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "fixed bottom-4 right-4 px-3 py-2 bg-black/75 text-white text-sm rounded-lg", children: "Loading..." })
|
|
9496
9835
|
]
|
|
9497
9836
|
}
|
|
9498
9837
|
);
|
|
@@ -9501,15 +9840,15 @@ var init_DualPageContainer = __esm({
|
|
|
9501
9840
|
});
|
|
9502
9841
|
|
|
9503
9842
|
// src/components/FloatingZoomControls/FloatingZoomControls.tsx
|
|
9504
|
-
var
|
|
9843
|
+
var import_react41, import_jsx_runtime27, FloatingZoomControls;
|
|
9505
9844
|
var init_FloatingZoomControls = __esm({
|
|
9506
9845
|
"src/components/FloatingZoomControls/FloatingZoomControls.tsx"() {
|
|
9507
9846
|
"use strict";
|
|
9508
|
-
|
|
9847
|
+
import_react41 = require("react");
|
|
9509
9848
|
init_hooks();
|
|
9510
9849
|
init_utils();
|
|
9511
|
-
|
|
9512
|
-
FloatingZoomControls = (0,
|
|
9850
|
+
import_jsx_runtime27 = require("react/jsx-runtime");
|
|
9851
|
+
FloatingZoomControls = (0, import_react41.memo)(function FloatingZoomControls2({
|
|
9513
9852
|
position = "bottom-right",
|
|
9514
9853
|
className,
|
|
9515
9854
|
showFitToWidth = true,
|
|
@@ -9519,20 +9858,20 @@ var init_FloatingZoomControls = __esm({
|
|
|
9519
9858
|
const { viewerStore } = usePDFViewerStores();
|
|
9520
9859
|
const scale = useViewerStore((s) => s.scale);
|
|
9521
9860
|
const document2 = useViewerStore((s) => s.document);
|
|
9522
|
-
const handleZoomIn = (0,
|
|
9861
|
+
const handleZoomIn = (0, import_react41.useCallback)(() => {
|
|
9523
9862
|
const currentScale = viewerStore.getState().scale;
|
|
9524
9863
|
const newScale = Math.min(4, currentScale + 0.05);
|
|
9525
9864
|
viewerStore.getState().setScale(newScale);
|
|
9526
9865
|
}, [viewerStore]);
|
|
9527
|
-
const handleZoomOut = (0,
|
|
9866
|
+
const handleZoomOut = (0, import_react41.useCallback)(() => {
|
|
9528
9867
|
const currentScale = viewerStore.getState().scale;
|
|
9529
9868
|
const newScale = Math.max(0.1, currentScale - 0.05);
|
|
9530
9869
|
viewerStore.getState().setScale(newScale);
|
|
9531
9870
|
}, [viewerStore]);
|
|
9532
|
-
const handleFitToWidth = (0,
|
|
9871
|
+
const handleFitToWidth = (0, import_react41.useCallback)(() => {
|
|
9533
9872
|
viewerStore.getState().setScale(1);
|
|
9534
9873
|
}, [viewerStore]);
|
|
9535
|
-
const handleFitToPage = (0,
|
|
9874
|
+
const handleFitToPage = (0, import_react41.useCallback)(() => {
|
|
9536
9875
|
viewerStore.getState().setScale(0.75);
|
|
9537
9876
|
}, [viewerStore]);
|
|
9538
9877
|
if (!document2) return null;
|
|
@@ -9543,7 +9882,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9543
9882
|
"top-left": "top-4 left-4"
|
|
9544
9883
|
};
|
|
9545
9884
|
const zoomPercentage = Math.round(scale * 100);
|
|
9546
|
-
return /* @__PURE__ */ (0,
|
|
9885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
9547
9886
|
"div",
|
|
9548
9887
|
{
|
|
9549
9888
|
className: cn(
|
|
@@ -9555,7 +9894,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9555
9894
|
className
|
|
9556
9895
|
),
|
|
9557
9896
|
children: [
|
|
9558
|
-
/* @__PURE__ */ (0,
|
|
9897
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9559
9898
|
"button",
|
|
9560
9899
|
{
|
|
9561
9900
|
onClick: handleZoomOut,
|
|
@@ -9569,14 +9908,14 @@ var init_FloatingZoomControls = __esm({
|
|
|
9569
9908
|
disabled: scale <= 0.25,
|
|
9570
9909
|
title: "Zoom Out",
|
|
9571
9910
|
"aria-label": "Zoom Out",
|
|
9572
|
-
children: /* @__PURE__ */ (0,
|
|
9911
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20 12H4" }) })
|
|
9573
9912
|
}
|
|
9574
9913
|
),
|
|
9575
|
-
showZoomLevel && /* @__PURE__ */ (0,
|
|
9914
|
+
showZoomLevel && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "min-w-[48px] text-center text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
9576
9915
|
zoomPercentage,
|
|
9577
9916
|
"%"
|
|
9578
9917
|
] }),
|
|
9579
|
-
/* @__PURE__ */ (0,
|
|
9918
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9580
9919
|
"button",
|
|
9581
9920
|
{
|
|
9582
9921
|
onClick: handleZoomIn,
|
|
@@ -9590,11 +9929,11 @@ var init_FloatingZoomControls = __esm({
|
|
|
9590
9929
|
disabled: scale >= 4,
|
|
9591
9930
|
title: "Zoom In",
|
|
9592
9931
|
"aria-label": "Zoom In",
|
|
9593
|
-
children: /* @__PURE__ */ (0,
|
|
9932
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 4v16m8-8H4" }) })
|
|
9594
9933
|
}
|
|
9595
9934
|
),
|
|
9596
|
-
(showFitToWidth || showFitToPage) && /* @__PURE__ */ (0,
|
|
9597
|
-
showFitToWidth && /* @__PURE__ */ (0,
|
|
9935
|
+
(showFitToWidth || showFitToPage) && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "w-px h-6 bg-gray-200 dark:bg-gray-700 mx-1" }),
|
|
9936
|
+
showFitToWidth && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9598
9937
|
"button",
|
|
9599
9938
|
{
|
|
9600
9939
|
onClick: handleFitToWidth,
|
|
@@ -9606,10 +9945,10 @@ var init_FloatingZoomControls = __esm({
|
|
|
9606
9945
|
),
|
|
9607
9946
|
title: "Fit to Width",
|
|
9608
9947
|
"aria-label": "Fit to Width",
|
|
9609
|
-
children: /* @__PURE__ */ (0,
|
|
9948
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" }) })
|
|
9610
9949
|
}
|
|
9611
9950
|
),
|
|
9612
|
-
showFitToPage && /* @__PURE__ */ (0,
|
|
9951
|
+
showFitToPage && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
9613
9952
|
"button",
|
|
9614
9953
|
{
|
|
9615
9954
|
onClick: handleFitToPage,
|
|
@@ -9621,7 +9960,7 @@ var init_FloatingZoomControls = __esm({
|
|
|
9621
9960
|
),
|
|
9622
9961
|
title: "Fit to Page",
|
|
9623
9962
|
"aria-label": "Fit to Page",
|
|
9624
|
-
children: /* @__PURE__ */ (0,
|
|
9963
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) })
|
|
9625
9964
|
}
|
|
9626
9965
|
)
|
|
9627
9966
|
]
|
|
@@ -9683,11 +10022,11 @@ function calculateMatchRects3(textItems, startOffset, length, viewport) {
|
|
|
9683
10022
|
}
|
|
9684
10023
|
return rects;
|
|
9685
10024
|
}
|
|
9686
|
-
var
|
|
10025
|
+
var import_react42, import_jsx_runtime28, PDFViewerInner, PDFViewerInnerWithRef, PDFViewerClient;
|
|
9687
10026
|
var init_PDFViewerClient = __esm({
|
|
9688
10027
|
"src/components/PDFViewer/PDFViewerClient.tsx"() {
|
|
9689
10028
|
"use strict";
|
|
9690
|
-
|
|
10029
|
+
import_react42 = require("react");
|
|
9691
10030
|
init_hooks();
|
|
9692
10031
|
init_utils();
|
|
9693
10032
|
init_Toolbar2();
|
|
@@ -9699,8 +10038,8 @@ var init_PDFViewerClient = __esm({
|
|
|
9699
10038
|
init_FloatingZoomControls2();
|
|
9700
10039
|
init_PDFLoadingScreen2();
|
|
9701
10040
|
init_utils();
|
|
9702
|
-
|
|
9703
|
-
PDFViewerInner = (0,
|
|
10041
|
+
import_jsx_runtime28 = require("react/jsx-runtime");
|
|
10042
|
+
PDFViewerInner = (0, import_react42.memo)(function PDFViewerInner2({
|
|
9704
10043
|
src,
|
|
9705
10044
|
initialPage = 1,
|
|
9706
10045
|
page: controlledPage,
|
|
@@ -9727,19 +10066,19 @@ var init_PDFViewerClient = __esm({
|
|
|
9727
10066
|
onReady
|
|
9728
10067
|
}) {
|
|
9729
10068
|
const { viewerStore, annotationStore, searchStore } = usePDFViewerStores();
|
|
9730
|
-
const mountedRef = (0,
|
|
9731
|
-
const [, setLoadState] = (0,
|
|
9732
|
-
const onDocumentLoadRef = (0,
|
|
9733
|
-
const onErrorRef = (0,
|
|
9734
|
-
const onPageChangeRef = (0,
|
|
9735
|
-
const onScaleChangeRef = (0,
|
|
9736
|
-
const onZoomChangeRef = (0,
|
|
9737
|
-
const onPageRenderStartRef = (0,
|
|
9738
|
-
const onPageRenderCompleteRef = (0,
|
|
9739
|
-
const onHighlightAddedRef = (0,
|
|
9740
|
-
const onHighlightRemovedRef = (0,
|
|
9741
|
-
const onAnnotationAddedRef = (0,
|
|
9742
|
-
const onReadyRef = (0,
|
|
10069
|
+
const mountedRef = (0, import_react42.useRef)(true);
|
|
10070
|
+
const [, setLoadState] = (0, import_react42.useState)("idle");
|
|
10071
|
+
const onDocumentLoadRef = (0, import_react42.useRef)(onDocumentLoad);
|
|
10072
|
+
const onErrorRef = (0, import_react42.useRef)(onError);
|
|
10073
|
+
const onPageChangeRef = (0, import_react42.useRef)(onPageChange);
|
|
10074
|
+
const onScaleChangeRef = (0, import_react42.useRef)(onScaleChange);
|
|
10075
|
+
const onZoomChangeRef = (0, import_react42.useRef)(onZoomChange);
|
|
10076
|
+
const onPageRenderStartRef = (0, import_react42.useRef)(onPageRenderStart);
|
|
10077
|
+
const onPageRenderCompleteRef = (0, import_react42.useRef)(onPageRenderComplete);
|
|
10078
|
+
const onHighlightAddedRef = (0, import_react42.useRef)(onHighlightAdded);
|
|
10079
|
+
const onHighlightRemovedRef = (0, import_react42.useRef)(onHighlightRemoved);
|
|
10080
|
+
const onAnnotationAddedRef = (0, import_react42.useRef)(onAnnotationAdded);
|
|
10081
|
+
const onReadyRef = (0, import_react42.useRef)(onReady);
|
|
9743
10082
|
onDocumentLoadRef.current = onDocumentLoad;
|
|
9744
10083
|
onErrorRef.current = onError;
|
|
9745
10084
|
onPageChangeRef.current = onPageChange;
|
|
@@ -9752,8 +10091,8 @@ var init_PDFViewerClient = __esm({
|
|
|
9752
10091
|
onAnnotationAddedRef.current = onAnnotationAdded;
|
|
9753
10092
|
onReadyRef.current = onReady;
|
|
9754
10093
|
const isControlled = controlledPage !== void 0;
|
|
9755
|
-
const prevControlledPageRef = (0,
|
|
9756
|
-
const srcIdRef = (0,
|
|
10094
|
+
const prevControlledPageRef = (0, import_react42.useRef)(controlledPage);
|
|
10095
|
+
const srcIdRef = (0, import_react42.useRef)(null);
|
|
9757
10096
|
const currentPage = useViewerStore((s) => s.currentPage);
|
|
9758
10097
|
const scale = useViewerStore((s) => s.scale);
|
|
9759
10098
|
const theme = useViewerStore((s) => s.theme);
|
|
@@ -9761,9 +10100,10 @@ var init_PDFViewerClient = __esm({
|
|
|
9761
10100
|
const loadingProgress = useViewerStore((s) => s.loadingProgress);
|
|
9762
10101
|
const error = useViewerStore((s) => s.error);
|
|
9763
10102
|
const sidebarOpen = useViewerStore((s) => s.sidebarOpen);
|
|
10103
|
+
const streamingProgress = useViewerStore((s) => s.streamingProgress);
|
|
9764
10104
|
const srcId = getSrcIdentifier(src);
|
|
9765
|
-
const handleRef = (0,
|
|
9766
|
-
(0,
|
|
10105
|
+
const handleRef = (0, import_react42.useRef)(null);
|
|
10106
|
+
(0, import_react42.useEffect)(() => {
|
|
9767
10107
|
const handle = {
|
|
9768
10108
|
// ==================== Text Highlighting ====================
|
|
9769
10109
|
highlightText: async (text, options) => {
|
|
@@ -10181,14 +10521,14 @@ var init_PDFViewerClient = __esm({
|
|
|
10181
10521
|
handleRef.current = handle;
|
|
10182
10522
|
onReadyRef.current?.(handle);
|
|
10183
10523
|
}, [viewerStore, annotationStore, searchStore]);
|
|
10184
|
-
const handleRetry = (0,
|
|
10524
|
+
const handleRetry = (0, import_react42.useCallback)(() => {
|
|
10185
10525
|
srcIdRef.current = null;
|
|
10186
10526
|
viewerStore.getState().setError(null);
|
|
10187
10527
|
setLoadState("idle");
|
|
10188
10528
|
}, [viewerStore]);
|
|
10189
|
-
const abortControllerRef = (0,
|
|
10190
|
-
const currentSrcRef = (0,
|
|
10191
|
-
(0,
|
|
10529
|
+
const abortControllerRef = (0, import_react42.useRef)(null);
|
|
10530
|
+
const currentSrcRef = (0, import_react42.useRef)(null);
|
|
10531
|
+
(0, import_react42.useEffect)(() => {
|
|
10192
10532
|
mountedRef.current = true;
|
|
10193
10533
|
return () => {
|
|
10194
10534
|
mountedRef.current = false;
|
|
@@ -10213,7 +10553,8 @@ var init_PDFViewerClient = __esm({
|
|
|
10213
10553
|
viewerStore.getState().setError(null);
|
|
10214
10554
|
};
|
|
10215
10555
|
}, [viewerStore]);
|
|
10216
|
-
(0,
|
|
10556
|
+
const cancelLoaderRef = (0, import_react42.useRef)(null);
|
|
10557
|
+
(0, import_react42.useEffect)(() => {
|
|
10217
10558
|
if (srcIdRef.current === srcId && viewerStore.getState().document) {
|
|
10218
10559
|
return;
|
|
10219
10560
|
}
|
|
@@ -10223,6 +10564,10 @@ var init_PDFViewerClient = __esm({
|
|
|
10223
10564
|
if (abortControllerRef.current) {
|
|
10224
10565
|
abortControllerRef.current.abort();
|
|
10225
10566
|
}
|
|
10567
|
+
if (cancelLoaderRef.current) {
|
|
10568
|
+
cancelLoaderRef.current();
|
|
10569
|
+
cancelLoaderRef.current = null;
|
|
10570
|
+
}
|
|
10226
10571
|
const abortController = new AbortController();
|
|
10227
10572
|
abortControllerRef.current = abortController;
|
|
10228
10573
|
const currentDoc = viewerStore.getState().document;
|
|
@@ -10235,100 +10580,130 @@ var init_PDFViewerClient = __esm({
|
|
|
10235
10580
|
viewerStore.setState({
|
|
10236
10581
|
document: null,
|
|
10237
10582
|
isLoading: true,
|
|
10238
|
-
loadingProgress: { phase: "
|
|
10239
|
-
error: null
|
|
10583
|
+
loadingProgress: { phase: "initializing" },
|
|
10584
|
+
error: null,
|
|
10585
|
+
documentLoadingState: "initializing",
|
|
10586
|
+
firstPageReady: false,
|
|
10587
|
+
streamingProgress: null
|
|
10240
10588
|
});
|
|
10241
10589
|
setLoadState("loading");
|
|
10242
10590
|
let lastProgressUpdate = 0;
|
|
10243
10591
|
let lastPercent = -1;
|
|
10244
10592
|
const PROGRESS_THROTTLE_MS = 100;
|
|
10245
10593
|
const PROGRESS_MIN_CHANGE = 5;
|
|
10246
|
-
const
|
|
10247
|
-
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
onProgress: ({ loaded, total }) => {
|
|
10254
|
-
if (!mountedRef.current || srcIdRef.current !== loadId || abortController.signal.aborted) {
|
|
10255
|
-
return;
|
|
10256
|
-
}
|
|
10257
|
-
const now = Date.now();
|
|
10258
|
-
const percent = total > 0 ? Math.round(loaded / total * 100) : 0;
|
|
10259
|
-
const timePassed = now - lastProgressUpdate >= PROGRESS_THROTTLE_MS;
|
|
10260
|
-
const percentChanged = Math.abs(percent - lastPercent) >= PROGRESS_MIN_CHANGE;
|
|
10261
|
-
const isComplete = percent >= 100;
|
|
10262
|
-
if (timePassed && percentChanged || isComplete) {
|
|
10263
|
-
lastProgressUpdate = now;
|
|
10264
|
-
lastPercent = percent;
|
|
10265
|
-
viewerStore.getState().setLoadingProgress({
|
|
10266
|
-
phase: "fetching",
|
|
10267
|
-
percent,
|
|
10268
|
-
bytesLoaded: loaded,
|
|
10269
|
-
totalBytes: total
|
|
10270
|
-
});
|
|
10271
|
-
}
|
|
10272
|
-
}
|
|
10273
|
-
});
|
|
10274
|
-
if (mountedRef.current && srcIdRef.current === loadId && !abortController.signal.aborted) {
|
|
10275
|
-
viewerStore.getState().setDocument(document2);
|
|
10276
|
-
setLoadState("loaded");
|
|
10277
|
-
if (initialPage !== 1 || typeof initialScale === "number" || initialScale === "page-fit") {
|
|
10278
|
-
const updates = {};
|
|
10279
|
-
if (initialPage !== 1) {
|
|
10280
|
-
updates.currentPage = Math.max(1, Math.min(initialPage, numPages));
|
|
10281
|
-
}
|
|
10282
|
-
if (typeof initialScale === "number") {
|
|
10283
|
-
updates.scale = initialScale;
|
|
10284
|
-
} else if (initialScale === "page-fit") {
|
|
10285
|
-
updates.scale = 0.75;
|
|
10286
|
-
}
|
|
10287
|
-
if (Object.keys(updates).length > 0) {
|
|
10288
|
-
viewerStore.setState(updates);
|
|
10289
|
-
}
|
|
10290
|
-
}
|
|
10291
|
-
onDocumentLoadRef.current?.({ document: document2, numPages });
|
|
10292
|
-
} else {
|
|
10293
|
-
document2.destroy();
|
|
10594
|
+
const { promise, cancel } = loadDocumentWithCallbacks({
|
|
10595
|
+
src,
|
|
10596
|
+
workerSrc,
|
|
10597
|
+
signal: abortController.signal,
|
|
10598
|
+
onProgress: ({ loaded, total }) => {
|
|
10599
|
+
if (!mountedRef.current || srcIdRef.current !== loadId || abortController.signal.aborted) {
|
|
10600
|
+
return;
|
|
10294
10601
|
}
|
|
10295
|
-
|
|
10296
|
-
|
|
10602
|
+
const now = Date.now();
|
|
10603
|
+
const percent = total > 0 ? Math.round(loaded / total * 100) : 0;
|
|
10604
|
+
const timePassed = now - lastProgressUpdate >= PROGRESS_THROTTLE_MS;
|
|
10605
|
+
const percentChanged = Math.abs(percent - lastPercent) >= PROGRESS_MIN_CHANGE;
|
|
10606
|
+
const isComplete = percent >= 100;
|
|
10607
|
+
if (timePassed && percentChanged || isComplete) {
|
|
10608
|
+
lastProgressUpdate = now;
|
|
10609
|
+
lastPercent = percent;
|
|
10610
|
+
viewerStore.setState({
|
|
10611
|
+
loadingProgress: {
|
|
10612
|
+
phase: "fetching",
|
|
10613
|
+
percent,
|
|
10614
|
+
bytesLoaded: loaded,
|
|
10615
|
+
totalBytes: total
|
|
10616
|
+
},
|
|
10617
|
+
streamingProgress: { loaded, total },
|
|
10618
|
+
documentLoadingState: "loading"
|
|
10619
|
+
});
|
|
10620
|
+
}
|
|
10621
|
+
},
|
|
10622
|
+
onDocumentReady: (document2, numPages) => {
|
|
10623
|
+
if (!mountedRef.current || srcIdRef.current !== loadId || abortController.signal.aborted) {
|
|
10297
10624
|
return;
|
|
10298
10625
|
}
|
|
10299
|
-
|
|
10300
|
-
|
|
10626
|
+
viewerStore.setState({
|
|
10627
|
+
document: document2,
|
|
10628
|
+
numPages,
|
|
10629
|
+
loadingProgress: { phase: "parsing" },
|
|
10630
|
+
documentLoadingState: "loading"
|
|
10631
|
+
});
|
|
10632
|
+
},
|
|
10633
|
+
onFirstPageReady: () => {
|
|
10634
|
+
if (!mountedRef.current || srcIdRef.current !== loadId || abortController.signal.aborted) {
|
|
10301
10635
|
return;
|
|
10302
10636
|
}
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10637
|
+
viewerStore.setState({
|
|
10638
|
+
isLoading: false,
|
|
10639
|
+
firstPageReady: true,
|
|
10640
|
+
loadingProgress: null,
|
|
10641
|
+
documentLoadingState: "ready"
|
|
10642
|
+
});
|
|
10643
|
+
setLoadState("loaded");
|
|
10644
|
+
}
|
|
10645
|
+
});
|
|
10646
|
+
cancelLoaderRef.current = cancel;
|
|
10647
|
+
promise.then(({ document: document2, numPages }) => {
|
|
10648
|
+
if (mountedRef.current && srcIdRef.current === loadId && !abortController.signal.aborted) {
|
|
10649
|
+
if (!viewerStore.getState().document) {
|
|
10650
|
+
viewerStore.getState().setDocument(document2);
|
|
10308
10651
|
}
|
|
10652
|
+
if (initialPage !== 1 || typeof initialScale === "number" || initialScale === "page-fit") {
|
|
10653
|
+
const updates = {};
|
|
10654
|
+
if (initialPage !== 1) {
|
|
10655
|
+
updates.currentPage = Math.max(1, Math.min(initialPage, numPages));
|
|
10656
|
+
}
|
|
10657
|
+
if (typeof initialScale === "number") {
|
|
10658
|
+
updates.scale = initialScale;
|
|
10659
|
+
} else if (initialScale === "page-fit") {
|
|
10660
|
+
updates.scale = 0.75;
|
|
10661
|
+
}
|
|
10662
|
+
if (Object.keys(updates).length > 0) {
|
|
10663
|
+
viewerStore.setState(updates);
|
|
10664
|
+
}
|
|
10665
|
+
}
|
|
10666
|
+
onDocumentLoadRef.current?.({ document: document2, numPages });
|
|
10309
10667
|
}
|
|
10310
|
-
}
|
|
10311
|
-
|
|
10668
|
+
}).catch((err) => {
|
|
10669
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
10670
|
+
return;
|
|
10671
|
+
}
|
|
10672
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
10673
|
+
if (abortController.signal.aborted || errorMessage.includes("network error") || errorMessage.includes("aborted")) {
|
|
10674
|
+
return;
|
|
10675
|
+
}
|
|
10676
|
+
if (mountedRef.current && srcIdRef.current === loadId) {
|
|
10677
|
+
const error2 = err instanceof Error ? err : new Error("Failed to load document");
|
|
10678
|
+
viewerStore.getState().setError(error2);
|
|
10679
|
+
setLoadState("error");
|
|
10680
|
+
onErrorRef.current?.(error2);
|
|
10681
|
+
}
|
|
10682
|
+
});
|
|
10312
10683
|
return () => {
|
|
10313
10684
|
abortController.abort();
|
|
10685
|
+
if (cancelLoaderRef.current) {
|
|
10686
|
+
cancelLoaderRef.current();
|
|
10687
|
+
cancelLoaderRef.current = null;
|
|
10688
|
+
}
|
|
10314
10689
|
};
|
|
10315
10690
|
}, [srcId, src, workerSrc, initialPage, initialScale, viewerStore]);
|
|
10316
|
-
const prevPageRef = (0,
|
|
10317
|
-
(0,
|
|
10691
|
+
const prevPageRef = (0, import_react42.useRef)(currentPage);
|
|
10692
|
+
(0, import_react42.useEffect)(() => {
|
|
10318
10693
|
if (prevPageRef.current !== currentPage) {
|
|
10319
10694
|
prevPageRef.current = currentPage;
|
|
10320
10695
|
onPageChangeRef.current?.(currentPage);
|
|
10321
10696
|
}
|
|
10322
10697
|
}, [currentPage]);
|
|
10323
|
-
const prevScaleRef = (0,
|
|
10324
|
-
(0,
|
|
10698
|
+
const prevScaleRef = (0, import_react42.useRef)(scale);
|
|
10699
|
+
(0, import_react42.useEffect)(() => {
|
|
10325
10700
|
if (prevScaleRef.current !== scale) {
|
|
10326
10701
|
prevScaleRef.current = scale;
|
|
10327
10702
|
onScaleChangeRef.current?.(scale);
|
|
10328
10703
|
onZoomChangeRef.current?.(scale);
|
|
10329
10704
|
}
|
|
10330
10705
|
}, [scale]);
|
|
10331
|
-
(0,
|
|
10706
|
+
(0, import_react42.useEffect)(() => {
|
|
10332
10707
|
if (!isControlled || controlledPage === void 0) return;
|
|
10333
10708
|
if (prevControlledPageRef.current === controlledPage) return;
|
|
10334
10709
|
prevControlledPageRef.current = controlledPage;
|
|
@@ -10341,7 +10716,7 @@ var init_PDFViewerClient = __esm({
|
|
|
10341
10716
|
if (error) {
|
|
10342
10717
|
if (errorComponent) {
|
|
10343
10718
|
const errorContent = typeof errorComponent === "function" ? errorComponent(error, handleRetry) : errorComponent;
|
|
10344
|
-
return /* @__PURE__ */ (0,
|
|
10719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10345
10720
|
"div",
|
|
10346
10721
|
{
|
|
10347
10722
|
className: cn(
|
|
@@ -10355,7 +10730,7 @@ var init_PDFViewerClient = __esm({
|
|
|
10355
10730
|
}
|
|
10356
10731
|
);
|
|
10357
10732
|
}
|
|
10358
|
-
return /* @__PURE__ */ (0,
|
|
10733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10359
10734
|
"div",
|
|
10360
10735
|
{
|
|
10361
10736
|
className: cn(
|
|
@@ -10365,10 +10740,10 @@ var init_PDFViewerClient = __esm({
|
|
|
10365
10740
|
themeClass,
|
|
10366
10741
|
className
|
|
10367
10742
|
),
|
|
10368
|
-
children: /* @__PURE__ */ (0,
|
|
10369
|
-
/* @__PURE__ */ (0,
|
|
10370
|
-
/* @__PURE__ */ (0,
|
|
10371
|
-
/* @__PURE__ */ (0,
|
|
10743
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "text-center p-8", children: [
|
|
10744
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-red-500 text-lg font-semibold mb-2", children: "Failed to load PDF" }),
|
|
10745
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "text-gray-500 text-sm", children: error.message }),
|
|
10746
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10372
10747
|
"button",
|
|
10373
10748
|
{
|
|
10374
10749
|
onClick: handleRetry,
|
|
@@ -10383,15 +10758,15 @@ var init_PDFViewerClient = __esm({
|
|
|
10383
10758
|
const renderContainer = () => {
|
|
10384
10759
|
switch (viewMode) {
|
|
10385
10760
|
case "continuous":
|
|
10386
|
-
return /* @__PURE__ */ (0,
|
|
10761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ContinuousScrollContainer, {});
|
|
10387
10762
|
case "dual":
|
|
10388
|
-
return /* @__PURE__ */ (0,
|
|
10763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DualPageContainer, {});
|
|
10389
10764
|
case "single":
|
|
10390
10765
|
default:
|
|
10391
|
-
return /* @__PURE__ */ (0,
|
|
10766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DocumentContainer, {});
|
|
10392
10767
|
}
|
|
10393
10768
|
};
|
|
10394
|
-
return /* @__PURE__ */ (0,
|
|
10769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
10395
10770
|
"div",
|
|
10396
10771
|
{
|
|
10397
10772
|
className: cn(
|
|
@@ -10403,14 +10778,14 @@ var init_PDFViewerClient = __esm({
|
|
|
10403
10778
|
className
|
|
10404
10779
|
),
|
|
10405
10780
|
children: [
|
|
10406
|
-
showToolbar && /* @__PURE__ */ (0,
|
|
10407
|
-
showAnnotationToolbar && /* @__PURE__ */ (0,
|
|
10408
|
-
/* @__PURE__ */ (0,
|
|
10409
|
-
showSidebar && sidebarOpen && /* @__PURE__ */ (0,
|
|
10781
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Toolbar, {}),
|
|
10782
|
+
showAnnotationToolbar && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AnnotationToolbar, {}),
|
|
10783
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "flex flex-1 overflow-hidden", children: [
|
|
10784
|
+
showSidebar && sidebarOpen && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Sidebar, {}),
|
|
10410
10785
|
renderContainer()
|
|
10411
10786
|
] }),
|
|
10412
|
-
showFloatingZoom && /* @__PURE__ */ (0,
|
|
10413
|
-
isLoading && /* @__PURE__ */ (0,
|
|
10787
|
+
showFloatingZoom && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FloatingZoomControls, { position: "bottom-right" }),
|
|
10788
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "absolute inset-0 z-50", children: loadingComponent ?? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10414
10789
|
PDFLoadingScreen,
|
|
10415
10790
|
{
|
|
10416
10791
|
phase: loadingProgress?.phase ?? "fetching",
|
|
@@ -10418,15 +10793,23 @@ var init_PDFViewerClient = __esm({
|
|
|
10418
10793
|
bytesLoaded: loadingProgress?.bytesLoaded,
|
|
10419
10794
|
totalBytes: loadingProgress?.totalBytes
|
|
10420
10795
|
}
|
|
10421
|
-
) })
|
|
10796
|
+
) }),
|
|
10797
|
+
!isLoading && streamingProgress && streamingProgress.total > 0 && streamingProgress.loaded < streamingProgress.total && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "absolute bottom-20 right-4 z-40 px-3 py-2 bg-gray-900/80 text-white text-xs rounded-lg shadow-lg flex items-center gap-2", children: [
|
|
10798
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin" }),
|
|
10799
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: "Loading pages..." }),
|
|
10800
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "text-white/60", children: [
|
|
10801
|
+
Math.round(streamingProgress.loaded / streamingProgress.total * 100),
|
|
10802
|
+
"%"
|
|
10803
|
+
] })
|
|
10804
|
+
] })
|
|
10422
10805
|
]
|
|
10423
10806
|
}
|
|
10424
10807
|
);
|
|
10425
10808
|
});
|
|
10426
|
-
PDFViewerInnerWithRef = (0,
|
|
10809
|
+
PDFViewerInnerWithRef = (0, import_react42.forwardRef)(
|
|
10427
10810
|
function PDFViewerInnerWithRef2(props, ref) {
|
|
10428
|
-
const handleRef = (0,
|
|
10429
|
-
const handleReady = (0,
|
|
10811
|
+
const handleRef = (0, import_react42.useRef)(null);
|
|
10812
|
+
const handleReady = (0, import_react42.useCallback)((handle) => {
|
|
10430
10813
|
handleRef.current = handle;
|
|
10431
10814
|
if (typeof ref === "function") {
|
|
10432
10815
|
ref(handle);
|
|
@@ -10434,17 +10817,17 @@ var init_PDFViewerClient = __esm({
|
|
|
10434
10817
|
ref.current = handle;
|
|
10435
10818
|
}
|
|
10436
10819
|
}, [ref]);
|
|
10437
|
-
return /* @__PURE__ */ (0,
|
|
10820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PDFViewerInner, { ...props, onReady: handleReady });
|
|
10438
10821
|
}
|
|
10439
10822
|
);
|
|
10440
|
-
PDFViewerClient = (0,
|
|
10441
|
-
(0,
|
|
10442
|
-
return /* @__PURE__ */ (0,
|
|
10823
|
+
PDFViewerClient = (0, import_react42.memo)(
|
|
10824
|
+
(0, import_react42.forwardRef)(function PDFViewerClient2(props, ref) {
|
|
10825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
10443
10826
|
PDFViewerProvider,
|
|
10444
10827
|
{
|
|
10445
10828
|
theme: props.theme,
|
|
10446
10829
|
defaultSidebarPanel: props.defaultSidebarPanel,
|
|
10447
|
-
children: /* @__PURE__ */ (0,
|
|
10830
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(PDFViewerInnerWithRef, { ref, ...props })
|
|
10448
10831
|
}
|
|
10449
10832
|
);
|
|
10450
10833
|
})
|
|
@@ -10453,20 +10836,20 @@ var init_PDFViewerClient = __esm({
|
|
|
10453
10836
|
});
|
|
10454
10837
|
|
|
10455
10838
|
// src/components/PDFViewer/PDFViewer.tsx
|
|
10456
|
-
var
|
|
10839
|
+
var import_react43, import_jsx_runtime29, PDFViewerClient3, PDFViewerLoading, PDFViewer;
|
|
10457
10840
|
var init_PDFViewer = __esm({
|
|
10458
10841
|
"src/components/PDFViewer/PDFViewer.tsx"() {
|
|
10459
10842
|
"use strict";
|
|
10460
|
-
|
|
10843
|
+
import_react43 = require("react");
|
|
10461
10844
|
init_utils();
|
|
10462
|
-
|
|
10463
|
-
PDFViewerClient3 = (0,
|
|
10845
|
+
import_jsx_runtime29 = require("react/jsx-runtime");
|
|
10846
|
+
PDFViewerClient3 = (0, import_react43.lazy)(
|
|
10464
10847
|
() => Promise.resolve().then(() => (init_PDFViewerClient(), PDFViewerClient_exports)).then((mod) => ({ default: mod.PDFViewerClient }))
|
|
10465
10848
|
);
|
|
10466
|
-
PDFViewerLoading = (0,
|
|
10849
|
+
PDFViewerLoading = (0, import_react43.memo)(function PDFViewerLoading2({
|
|
10467
10850
|
className
|
|
10468
10851
|
}) {
|
|
10469
|
-
return /* @__PURE__ */ (0,
|
|
10852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
10470
10853
|
"div",
|
|
10471
10854
|
{
|
|
10472
10855
|
className: cn(
|
|
@@ -10475,18 +10858,18 @@ var init_PDFViewer = __esm({
|
|
|
10475
10858
|
"bg-white dark:bg-gray-900",
|
|
10476
10859
|
className
|
|
10477
10860
|
),
|
|
10478
|
-
children: /* @__PURE__ */ (0,
|
|
10479
|
-
/* @__PURE__ */ (0,
|
|
10480
|
-
/* @__PURE__ */ (0,
|
|
10861
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "flex flex-col items-center", children: [
|
|
10862
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "w-8 h-8 border-4 border-blue-500 border-t-transparent rounded-full animate-spin" }),
|
|
10863
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: "mt-2 text-sm text-gray-500", children: "Loading PDF viewer..." })
|
|
10481
10864
|
] }) })
|
|
10482
10865
|
}
|
|
10483
10866
|
);
|
|
10484
10867
|
});
|
|
10485
|
-
PDFViewer = (0,
|
|
10868
|
+
PDFViewer = (0, import_react43.memo)(function PDFViewer2(props) {
|
|
10486
10869
|
if (typeof window === "undefined") {
|
|
10487
|
-
return /* @__PURE__ */ (0,
|
|
10870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PDFViewerLoading, { className: props.className });
|
|
10488
10871
|
}
|
|
10489
|
-
return /* @__PURE__ */ (0,
|
|
10872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_react43.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PDFViewerLoading, { className: props.className }), children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(PDFViewerClient3, { ...props }) });
|
|
10490
10873
|
});
|
|
10491
10874
|
}
|
|
10492
10875
|
});
|
|
@@ -10589,6 +10972,7 @@ __export(index_exports, {
|
|
|
10589
10972
|
isPDFJSInitialized: () => isPDFJSInitialized,
|
|
10590
10973
|
isPointInRect: () => isPointInRect,
|
|
10591
10974
|
loadDocument: () => loadDocument,
|
|
10975
|
+
loadDocumentWithCallbacks: () => loadDocumentWithCallbacks,
|
|
10592
10976
|
loadHighlights: () => loadHighlights,
|
|
10593
10977
|
loadStudentData: () => loadStudentData,
|
|
10594
10978
|
mergeAdjacentRects: () => mergeAdjacentRects,
|
|
@@ -10639,9 +11023,9 @@ init_HighlightPopover2();
|
|
|
10639
11023
|
init_AnnotationToolbar2();
|
|
10640
11024
|
|
|
10641
11025
|
// src/components/Annotations/StickyNote.tsx
|
|
10642
|
-
var
|
|
11026
|
+
var import_react44 = require("react");
|
|
10643
11027
|
init_utils();
|
|
10644
|
-
var
|
|
11028
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
10645
11029
|
var NOTE_COLORS = [
|
|
10646
11030
|
"#fef08a",
|
|
10647
11031
|
// yellow
|
|
@@ -10654,7 +11038,7 @@ var NOTE_COLORS = [
|
|
|
10654
11038
|
"#fed7aa"
|
|
10655
11039
|
// orange
|
|
10656
11040
|
];
|
|
10657
|
-
var StickyNote = (0,
|
|
11041
|
+
var StickyNote = (0, import_react44.memo)(function StickyNote2({
|
|
10658
11042
|
note,
|
|
10659
11043
|
scale,
|
|
10660
11044
|
isSelected,
|
|
@@ -10667,37 +11051,37 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10667
11051
|
onDragStart,
|
|
10668
11052
|
className
|
|
10669
11053
|
}) {
|
|
10670
|
-
const [isExpanded, setIsExpanded] = (0,
|
|
10671
|
-
const [localContent, setLocalContent] = (0,
|
|
10672
|
-
const textareaRef = (0,
|
|
10673
|
-
const noteRef = (0,
|
|
10674
|
-
(0,
|
|
11054
|
+
const [isExpanded, setIsExpanded] = (0, import_react44.useState)(false);
|
|
11055
|
+
const [localContent, setLocalContent] = (0, import_react44.useState)(note.content);
|
|
11056
|
+
const textareaRef = (0, import_react44.useRef)(null);
|
|
11057
|
+
const noteRef = (0, import_react44.useRef)(null);
|
|
11058
|
+
(0, import_react44.useEffect)(() => {
|
|
10675
11059
|
setLocalContent(note.content);
|
|
10676
11060
|
}, [note.content]);
|
|
10677
|
-
(0,
|
|
11061
|
+
(0, import_react44.useEffect)(() => {
|
|
10678
11062
|
if (isEditing && textareaRef.current) {
|
|
10679
11063
|
textareaRef.current.focus();
|
|
10680
11064
|
textareaRef.current.select();
|
|
10681
11065
|
}
|
|
10682
11066
|
}, [isEditing]);
|
|
10683
|
-
const handleClick = (0,
|
|
11067
|
+
const handleClick = (0, import_react44.useCallback)((e) => {
|
|
10684
11068
|
e.stopPropagation();
|
|
10685
11069
|
onSelect?.();
|
|
10686
11070
|
if (!isExpanded) {
|
|
10687
11071
|
setIsExpanded(true);
|
|
10688
11072
|
}
|
|
10689
11073
|
}, [isExpanded, onSelect]);
|
|
10690
|
-
const handleDoubleClick = (0,
|
|
11074
|
+
const handleDoubleClick = (0, import_react44.useCallback)((e) => {
|
|
10691
11075
|
e.stopPropagation();
|
|
10692
11076
|
onStartEdit?.();
|
|
10693
11077
|
}, [onStartEdit]);
|
|
10694
|
-
const handleBlur = (0,
|
|
11078
|
+
const handleBlur = (0, import_react44.useCallback)(() => {
|
|
10695
11079
|
if (isEditing && localContent !== note.content) {
|
|
10696
11080
|
onUpdate?.({ content: localContent });
|
|
10697
11081
|
}
|
|
10698
11082
|
onEndEdit?.();
|
|
10699
11083
|
}, [isEditing, localContent, note.content, onUpdate, onEndEdit]);
|
|
10700
|
-
const handleKeyDown = (0,
|
|
11084
|
+
const handleKeyDown = (0, import_react44.useCallback)((e) => {
|
|
10701
11085
|
if (e.key === "Escape") {
|
|
10702
11086
|
setLocalContent(note.content);
|
|
10703
11087
|
onEndEdit?.();
|
|
@@ -10705,16 +11089,16 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10705
11089
|
handleBlur();
|
|
10706
11090
|
}
|
|
10707
11091
|
}, [note.content, onEndEdit, handleBlur]);
|
|
10708
|
-
const handleColorChange = (0,
|
|
11092
|
+
const handleColorChange = (0, import_react44.useCallback)((color) => {
|
|
10709
11093
|
onUpdate?.({ color });
|
|
10710
11094
|
}, [onUpdate]);
|
|
10711
|
-
const handleCollapse = (0,
|
|
11095
|
+
const handleCollapse = (0, import_react44.useCallback)((e) => {
|
|
10712
11096
|
e.stopPropagation();
|
|
10713
11097
|
setIsExpanded(false);
|
|
10714
11098
|
onEndEdit?.();
|
|
10715
11099
|
}, [onEndEdit]);
|
|
10716
11100
|
if (!isExpanded) {
|
|
10717
|
-
return /* @__PURE__ */ (0,
|
|
11101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10718
11102
|
"div",
|
|
10719
11103
|
{
|
|
10720
11104
|
ref: noteRef,
|
|
@@ -10735,14 +11119,14 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10735
11119
|
onMouseDown: onDragStart,
|
|
10736
11120
|
onTouchStart: onDragStart,
|
|
10737
11121
|
title: note.content || "Empty note",
|
|
10738
|
-
children: /* @__PURE__ */ (0,
|
|
11122
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10739
11123
|
"svg",
|
|
10740
11124
|
{
|
|
10741
11125
|
className: "w-4 h-4 opacity-70",
|
|
10742
11126
|
fill: "currentColor",
|
|
10743
11127
|
viewBox: "0 0 20 20",
|
|
10744
11128
|
style: { color: "#333" },
|
|
10745
|
-
children: /* @__PURE__ */ (0,
|
|
11129
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10746
11130
|
"path",
|
|
10747
11131
|
{
|
|
10748
11132
|
fillRule: "evenodd",
|
|
@@ -10755,7 +11139,7 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10755
11139
|
}
|
|
10756
11140
|
);
|
|
10757
11141
|
}
|
|
10758
|
-
return /* @__PURE__ */ (0,
|
|
11142
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
10759
11143
|
"div",
|
|
10760
11144
|
{
|
|
10761
11145
|
ref: noteRef,
|
|
@@ -10773,14 +11157,14 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10773
11157
|
},
|
|
10774
11158
|
onClick: handleClick,
|
|
10775
11159
|
children: [
|
|
10776
|
-
/* @__PURE__ */ (0,
|
|
11160
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
10777
11161
|
"div",
|
|
10778
11162
|
{
|
|
10779
11163
|
className: "flex items-center justify-between px-2 py-1 border-b border-black/10 cursor-move",
|
|
10780
11164
|
onMouseDown: onDragStart,
|
|
10781
11165
|
onTouchStart: onDragStart,
|
|
10782
11166
|
children: [
|
|
10783
|
-
/* @__PURE__ */ (0,
|
|
11167
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "flex gap-1", children: NOTE_COLORS.map((color) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10784
11168
|
"button",
|
|
10785
11169
|
{
|
|
10786
11170
|
className: cn(
|
|
@@ -10797,8 +11181,8 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10797
11181
|
},
|
|
10798
11182
|
color
|
|
10799
11183
|
)) }),
|
|
10800
|
-
/* @__PURE__ */ (0,
|
|
10801
|
-
/* @__PURE__ */ (0,
|
|
11184
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex gap-1", children: [
|
|
11185
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10802
11186
|
"button",
|
|
10803
11187
|
{
|
|
10804
11188
|
className: "p-0.5 hover:bg-black/10 rounded",
|
|
@@ -10807,23 +11191,23 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10807
11191
|
onDelete?.();
|
|
10808
11192
|
},
|
|
10809
11193
|
title: "Delete note",
|
|
10810
|
-
children: /* @__PURE__ */ (0,
|
|
11194
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { className: "w-3.5 h-3.5 text-gray-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" }) })
|
|
10811
11195
|
}
|
|
10812
11196
|
),
|
|
10813
|
-
/* @__PURE__ */ (0,
|
|
11197
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10814
11198
|
"button",
|
|
10815
11199
|
{
|
|
10816
11200
|
className: "p-0.5 hover:bg-black/10 rounded",
|
|
10817
11201
|
onClick: handleCollapse,
|
|
10818
11202
|
title: "Collapse note",
|
|
10819
|
-
children: /* @__PURE__ */ (0,
|
|
11203
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { className: "w-3.5 h-3.5 text-gray-600", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
10820
11204
|
}
|
|
10821
11205
|
)
|
|
10822
11206
|
] })
|
|
10823
11207
|
]
|
|
10824
11208
|
}
|
|
10825
11209
|
),
|
|
10826
|
-
/* @__PURE__ */ (0,
|
|
11210
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "p-2", children: isEditing ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10827
11211
|
"textarea",
|
|
10828
11212
|
{
|
|
10829
11213
|
ref: textareaRef,
|
|
@@ -10838,7 +11222,7 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10838
11222
|
onKeyDown: handleKeyDown,
|
|
10839
11223
|
placeholder: "Enter note..."
|
|
10840
11224
|
}
|
|
10841
|
-
) : /* @__PURE__ */ (0,
|
|
11225
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
10842
11226
|
"div",
|
|
10843
11227
|
{
|
|
10844
11228
|
className: cn(
|
|
@@ -10849,16 +11233,16 @@ var StickyNote = (0, import_react43.memo)(function StickyNote2({
|
|
|
10849
11233
|
children: note.content || "Double-click to edit..."
|
|
10850
11234
|
}
|
|
10851
11235
|
) }),
|
|
10852
|
-
/* @__PURE__ */ (0,
|
|
11236
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "px-2 pb-1 text-[10px] text-gray-500", children: new Date(note.updatedAt).toLocaleDateString() })
|
|
10853
11237
|
]
|
|
10854
11238
|
}
|
|
10855
11239
|
);
|
|
10856
11240
|
});
|
|
10857
11241
|
|
|
10858
11242
|
// src/components/Annotations/DrawingCanvas.tsx
|
|
10859
|
-
var
|
|
11243
|
+
var import_react45 = require("react");
|
|
10860
11244
|
init_utils();
|
|
10861
|
-
var
|
|
11245
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
10862
11246
|
function pointsToSvgPath(points) {
|
|
10863
11247
|
if (points.length === 0) return "";
|
|
10864
11248
|
if (points.length === 1) {
|
|
@@ -10896,7 +11280,7 @@ function simplifyPath(points, tolerance = 1) {
|
|
|
10896
11280
|
result.push(points[points.length - 1]);
|
|
10897
11281
|
return result;
|
|
10898
11282
|
}
|
|
10899
|
-
var DrawingCanvas = (0,
|
|
11283
|
+
var DrawingCanvas = (0, import_react45.memo)(function DrawingCanvas2({
|
|
10900
11284
|
width,
|
|
10901
11285
|
height,
|
|
10902
11286
|
scale,
|
|
@@ -10906,10 +11290,10 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10906
11290
|
onDrawingComplete,
|
|
10907
11291
|
className
|
|
10908
11292
|
}) {
|
|
10909
|
-
const svgRef = (0,
|
|
10910
|
-
const [isDrawing, setIsDrawing] = (0,
|
|
10911
|
-
const [currentPath, setCurrentPath] = (0,
|
|
10912
|
-
const getPoint = (0,
|
|
11293
|
+
const svgRef = (0, import_react45.useRef)(null);
|
|
11294
|
+
const [isDrawing, setIsDrawing] = (0, import_react45.useState)(false);
|
|
11295
|
+
const [currentPath, setCurrentPath] = (0, import_react45.useState)([]);
|
|
11296
|
+
const getPoint = (0, import_react45.useCallback)((e) => {
|
|
10913
11297
|
if (!svgRef.current) return null;
|
|
10914
11298
|
const svg = svgRef.current;
|
|
10915
11299
|
const rect = svg.getBoundingClientRect();
|
|
@@ -10929,7 +11313,7 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10929
11313
|
y: (clientY - rect.top) / scale
|
|
10930
11314
|
};
|
|
10931
11315
|
}, [scale]);
|
|
10932
|
-
const handleStart = (0,
|
|
11316
|
+
const handleStart = (0, import_react45.useCallback)((e) => {
|
|
10933
11317
|
if (!isActive) return;
|
|
10934
11318
|
const point = getPoint(e);
|
|
10935
11319
|
if (point) {
|
|
@@ -10937,14 +11321,14 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10937
11321
|
setCurrentPath([point]);
|
|
10938
11322
|
}
|
|
10939
11323
|
}, [isActive, getPoint]);
|
|
10940
|
-
const handleMove = (0,
|
|
11324
|
+
const handleMove = (0, import_react45.useCallback)((e) => {
|
|
10941
11325
|
if (!isDrawing || !isActive) return;
|
|
10942
11326
|
const point = getPoint(e);
|
|
10943
11327
|
if (point) {
|
|
10944
11328
|
setCurrentPath((prev) => [...prev, point]);
|
|
10945
11329
|
}
|
|
10946
11330
|
}, [isDrawing, isActive, getPoint]);
|
|
10947
|
-
const handleEnd = (0,
|
|
11331
|
+
const handleEnd = (0, import_react45.useCallback)(() => {
|
|
10948
11332
|
if (!isDrawing) return;
|
|
10949
11333
|
setIsDrawing(false);
|
|
10950
11334
|
if (currentPath.length >= 2) {
|
|
@@ -10953,7 +11337,7 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10953
11337
|
}
|
|
10954
11338
|
setCurrentPath([]);
|
|
10955
11339
|
}, [isDrawing, currentPath, onDrawingComplete]);
|
|
10956
|
-
return /* @__PURE__ */ (0,
|
|
11340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
10957
11341
|
"svg",
|
|
10958
11342
|
{
|
|
10959
11343
|
ref: svgRef,
|
|
@@ -10973,7 +11357,7 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10973
11357
|
onTouchStart: handleStart,
|
|
10974
11358
|
onTouchMove: handleMove,
|
|
10975
11359
|
onTouchEnd: handleEnd,
|
|
10976
|
-
children: isDrawing && currentPath.length > 0 && /* @__PURE__ */ (0,
|
|
11360
|
+
children: isDrawing && currentPath.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
10977
11361
|
"path",
|
|
10978
11362
|
{
|
|
10979
11363
|
d: pointsToSvgPath(currentPath),
|
|
@@ -10990,10 +11374,10 @@ var DrawingCanvas = (0, import_react44.memo)(function DrawingCanvas2({
|
|
|
10990
11374
|
});
|
|
10991
11375
|
|
|
10992
11376
|
// src/components/Annotations/ShapeRenderer.tsx
|
|
10993
|
-
var
|
|
11377
|
+
var import_react46 = require("react");
|
|
10994
11378
|
init_utils();
|
|
10995
|
-
var
|
|
10996
|
-
var ShapeRenderer = (0,
|
|
11379
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
11380
|
+
var ShapeRenderer = (0, import_react46.memo)(function ShapeRenderer2({
|
|
10997
11381
|
shape,
|
|
10998
11382
|
scale,
|
|
10999
11383
|
isSelected,
|
|
@@ -11003,18 +11387,18 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11003
11387
|
onDelete: _onDelete,
|
|
11004
11388
|
className
|
|
11005
11389
|
}) {
|
|
11006
|
-
const [_isDragging, setIsDragging] = (0,
|
|
11007
|
-
const [_isResizing, setIsResizing] = (0,
|
|
11008
|
-
const [activeHandle, setActiveHandle] = (0,
|
|
11009
|
-
const startPosRef = (0,
|
|
11010
|
-
const startShapeRef = (0,
|
|
11390
|
+
const [_isDragging, setIsDragging] = (0, import_react46.useState)(false);
|
|
11391
|
+
const [_isResizing, setIsResizing] = (0, import_react46.useState)(false);
|
|
11392
|
+
const [activeHandle, setActiveHandle] = (0, import_react46.useState)(null);
|
|
11393
|
+
const startPosRef = (0, import_react46.useRef)({ x: 0, y: 0 });
|
|
11394
|
+
const startShapeRef = (0, import_react46.useRef)({ x: 0, y: 0, width: 0, height: 0 });
|
|
11011
11395
|
const { shapeType, x, y, width, height, color, strokeWidth, id: _id } = shape;
|
|
11012
11396
|
const scaledX = x * scale;
|
|
11013
11397
|
const scaledY = y * scale;
|
|
11014
11398
|
const scaledWidth = width * scale;
|
|
11015
11399
|
const scaledHeight = height * scale;
|
|
11016
11400
|
const scaledStroke = strokeWidth * scale;
|
|
11017
|
-
const getResizeHandles = (0,
|
|
11401
|
+
const getResizeHandles = (0, import_react46.useCallback)(() => {
|
|
11018
11402
|
const handleSize = 8;
|
|
11019
11403
|
const half = handleSize / 2;
|
|
11020
11404
|
return [
|
|
@@ -11028,7 +11412,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11028
11412
|
{ position: "w", cursor: "ew-resize", x: scaledX - half, y: scaledY + scaledHeight / 2 - half }
|
|
11029
11413
|
];
|
|
11030
11414
|
}, [scaledX, scaledY, scaledWidth, scaledHeight]);
|
|
11031
|
-
const handleMouseDown = (0,
|
|
11415
|
+
const handleMouseDown = (0, import_react46.useCallback)((e, handle) => {
|
|
11032
11416
|
e.stopPropagation();
|
|
11033
11417
|
onSelect?.();
|
|
11034
11418
|
if (!isEditing) return;
|
|
@@ -11104,7 +11488,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11104
11488
|
document.addEventListener("mousemove", handleMouseMove);
|
|
11105
11489
|
document.addEventListener("mouseup", handleMouseUp);
|
|
11106
11490
|
}, [isEditing, x, y, width, height, scale, onSelect, onUpdate]);
|
|
11107
|
-
const renderShape2 = (0,
|
|
11491
|
+
const renderShape2 = (0, import_react46.useCallback)(() => {
|
|
11108
11492
|
const commonProps = {
|
|
11109
11493
|
stroke: color,
|
|
11110
11494
|
strokeWidth: scaledStroke,
|
|
@@ -11116,7 +11500,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11116
11500
|
};
|
|
11117
11501
|
switch (shapeType) {
|
|
11118
11502
|
case "rect":
|
|
11119
|
-
return /* @__PURE__ */ (0,
|
|
11503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11120
11504
|
"rect",
|
|
11121
11505
|
{
|
|
11122
11506
|
x: scaledX,
|
|
@@ -11127,7 +11511,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11127
11511
|
}
|
|
11128
11512
|
);
|
|
11129
11513
|
case "circle":
|
|
11130
|
-
return /* @__PURE__ */ (0,
|
|
11514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11131
11515
|
"ellipse",
|
|
11132
11516
|
{
|
|
11133
11517
|
cx: scaledX + scaledWidth / 2,
|
|
@@ -11138,7 +11522,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11138
11522
|
}
|
|
11139
11523
|
);
|
|
11140
11524
|
case "line":
|
|
11141
|
-
return /* @__PURE__ */ (0,
|
|
11525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11142
11526
|
"line",
|
|
11143
11527
|
{
|
|
11144
11528
|
x1: scaledX,
|
|
@@ -11158,22 +11542,22 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11158
11542
|
const arrow1Y = endY - arrowLength * Math.sin(angle - arrowAngle);
|
|
11159
11543
|
const arrow2X = endX - arrowLength * Math.cos(angle + arrowAngle);
|
|
11160
11544
|
const arrow2Y = endY - arrowLength * Math.sin(angle + arrowAngle);
|
|
11161
|
-
return /* @__PURE__ */ (0,
|
|
11162
|
-
/* @__PURE__ */ (0,
|
|
11163
|
-
/* @__PURE__ */ (0,
|
|
11164
|
-
/* @__PURE__ */ (0,
|
|
11545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { children: [
|
|
11546
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("line", { x1: scaledX, y1: scaledY, x2: endX, y2: endY, ...commonProps }),
|
|
11547
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("line", { x1: endX, y1: endY, x2: arrow1X, y2: arrow1Y, ...commonProps }),
|
|
11548
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("line", { x1: endX, y1: endY, x2: arrow2X, y2: arrow2Y, ...commonProps })
|
|
11165
11549
|
] });
|
|
11166
11550
|
default:
|
|
11167
11551
|
return null;
|
|
11168
11552
|
}
|
|
11169
11553
|
}, [shapeType, scaledX, scaledY, scaledWidth, scaledHeight, color, scaledStroke, isSelected]);
|
|
11170
|
-
return /* @__PURE__ */ (0,
|
|
11554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
|
|
11171
11555
|
"g",
|
|
11172
11556
|
{
|
|
11173
11557
|
className: cn("shape-renderer", className),
|
|
11174
11558
|
onMouseDown: (e) => handleMouseDown(e),
|
|
11175
11559
|
children: [
|
|
11176
|
-
/* @__PURE__ */ (0,
|
|
11560
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11177
11561
|
"rect",
|
|
11178
11562
|
{
|
|
11179
11563
|
x: scaledX - 5,
|
|
@@ -11186,7 +11570,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11186
11570
|
}
|
|
11187
11571
|
),
|
|
11188
11572
|
renderShape2(),
|
|
11189
|
-
isSelected && /* @__PURE__ */ (0,
|
|
11573
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11190
11574
|
"rect",
|
|
11191
11575
|
{
|
|
11192
11576
|
x: scaledX - 2,
|
|
@@ -11199,7 +11583,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11199
11583
|
strokeDasharray: "4 2"
|
|
11200
11584
|
}
|
|
11201
11585
|
),
|
|
11202
|
-
isSelected && isEditing && getResizeHandles().map((handle) => /* @__PURE__ */ (0,
|
|
11586
|
+
isSelected && isEditing && getResizeHandles().map((handle) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11203
11587
|
"rect",
|
|
11204
11588
|
{
|
|
11205
11589
|
x: handle.x,
|
|
@@ -11219,7 +11603,7 @@ var ShapeRenderer = (0, import_react45.memo)(function ShapeRenderer2({
|
|
|
11219
11603
|
}
|
|
11220
11604
|
);
|
|
11221
11605
|
});
|
|
11222
|
-
var ShapePreview = (0,
|
|
11606
|
+
var ShapePreview = (0, import_react46.memo)(function ShapePreview2({
|
|
11223
11607
|
shapeType,
|
|
11224
11608
|
startPoint,
|
|
11225
11609
|
endPoint,
|
|
@@ -11240,9 +11624,9 @@ var ShapePreview = (0, import_react45.memo)(function ShapePreview2({
|
|
|
11240
11624
|
};
|
|
11241
11625
|
switch (shapeType) {
|
|
11242
11626
|
case "rect":
|
|
11243
|
-
return /* @__PURE__ */ (0,
|
|
11627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("rect", { x, y, width, height, ...commonProps });
|
|
11244
11628
|
case "circle":
|
|
11245
|
-
return /* @__PURE__ */ (0,
|
|
11629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11246
11630
|
"ellipse",
|
|
11247
11631
|
{
|
|
11248
11632
|
cx: x + width / 2,
|
|
@@ -11253,7 +11637,7 @@ var ShapePreview = (0, import_react45.memo)(function ShapePreview2({
|
|
|
11253
11637
|
}
|
|
11254
11638
|
);
|
|
11255
11639
|
case "line":
|
|
11256
|
-
return /* @__PURE__ */ (0,
|
|
11640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11257
11641
|
"line",
|
|
11258
11642
|
{
|
|
11259
11643
|
x1: startPoint.x * scale,
|
|
@@ -11275,8 +11659,8 @@ var ShapePreview = (0, import_react45.memo)(function ShapePreview2({
|
|
|
11275
11659
|
const arrow1Y = endY - arrowLength * Math.sin(angle - arrowAngle);
|
|
11276
11660
|
const arrow2X = endX - arrowLength * Math.cos(angle + arrowAngle);
|
|
11277
11661
|
const arrow2Y = endY - arrowLength * Math.sin(angle + arrowAngle);
|
|
11278
|
-
return /* @__PURE__ */ (0,
|
|
11279
|
-
/* @__PURE__ */ (0,
|
|
11662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { children: [
|
|
11663
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
11280
11664
|
"line",
|
|
11281
11665
|
{
|
|
11282
11666
|
x1: startPoint.x * scale,
|
|
@@ -11286,8 +11670,8 @@ var ShapePreview = (0, import_react45.memo)(function ShapePreview2({
|
|
|
11286
11670
|
...commonProps
|
|
11287
11671
|
}
|
|
11288
11672
|
),
|
|
11289
|
-
/* @__PURE__ */ (0,
|
|
11290
|
-
/* @__PURE__ */ (0,
|
|
11673
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("line", { x1: endX, y1: endY, x2: arrow1X, y2: arrow1Y, ...commonProps }),
|
|
11674
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("line", { x1: endX, y1: endY, x2: arrow2X, y2: arrow2Y, ...commonProps })
|
|
11291
11675
|
] });
|
|
11292
11676
|
default:
|
|
11293
11677
|
return null;
|
|
@@ -11295,10 +11679,10 @@ var ShapePreview = (0, import_react45.memo)(function ShapePreview2({
|
|
|
11295
11679
|
});
|
|
11296
11680
|
|
|
11297
11681
|
// src/components/Annotations/QuickNoteButton.tsx
|
|
11298
|
-
var
|
|
11682
|
+
var import_react47 = require("react");
|
|
11299
11683
|
init_utils();
|
|
11300
|
-
var
|
|
11301
|
-
var QuickNoteButton = (0,
|
|
11684
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
11685
|
+
var QuickNoteButton = (0, import_react47.memo)(function QuickNoteButton2({
|
|
11302
11686
|
pageNumber,
|
|
11303
11687
|
scale,
|
|
11304
11688
|
position = "top-right",
|
|
@@ -11306,8 +11690,8 @@ var QuickNoteButton = (0, import_react46.memo)(function QuickNoteButton2({
|
|
|
11306
11690
|
className,
|
|
11307
11691
|
visible = true
|
|
11308
11692
|
}) {
|
|
11309
|
-
const [isHovered, setIsHovered] = (0,
|
|
11310
|
-
const handleClick = (0,
|
|
11693
|
+
const [isHovered, setIsHovered] = (0, import_react47.useState)(false);
|
|
11694
|
+
const handleClick = (0, import_react47.useCallback)(
|
|
11311
11695
|
(e) => {
|
|
11312
11696
|
e.stopPropagation();
|
|
11313
11697
|
const x = position === "top-right" ? 80 : 80;
|
|
@@ -11319,7 +11703,7 @@ var QuickNoteButton = (0, import_react46.memo)(function QuickNoteButton2({
|
|
|
11319
11703
|
if (!visible) {
|
|
11320
11704
|
return null;
|
|
11321
11705
|
}
|
|
11322
|
-
return /* @__PURE__ */ (0,
|
|
11706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
11323
11707
|
"button",
|
|
11324
11708
|
{
|
|
11325
11709
|
onClick: handleClick,
|
|
@@ -11341,7 +11725,7 @@ var QuickNoteButton = (0, import_react46.memo)(function QuickNoteButton2({
|
|
|
11341
11725
|
),
|
|
11342
11726
|
title: "Add quick note",
|
|
11343
11727
|
"aria-label": "Add quick note",
|
|
11344
|
-
children: /* @__PURE__ */ (0,
|
|
11728
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
11345
11729
|
"svg",
|
|
11346
11730
|
{
|
|
11347
11731
|
className: "w-4 h-4 text-yellow-900",
|
|
@@ -11349,7 +11733,7 @@ var QuickNoteButton = (0, import_react46.memo)(function QuickNoteButton2({
|
|
|
11349
11733
|
viewBox: "0 0 24 24",
|
|
11350
11734
|
stroke: "currentColor",
|
|
11351
11735
|
strokeWidth: 2,
|
|
11352
|
-
children: /* @__PURE__ */ (0,
|
|
11736
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4v16m8-8H4" })
|
|
11353
11737
|
}
|
|
11354
11738
|
)
|
|
11355
11739
|
}
|
|
@@ -11357,10 +11741,10 @@ var QuickNoteButton = (0, import_react46.memo)(function QuickNoteButton2({
|
|
|
11357
11741
|
});
|
|
11358
11742
|
|
|
11359
11743
|
// src/components/Annotations/QuickNotePopover.tsx
|
|
11360
|
-
var
|
|
11744
|
+
var import_react48 = require("react");
|
|
11361
11745
|
init_utils();
|
|
11362
|
-
var
|
|
11363
|
-
var QuickNotePopover = (0,
|
|
11746
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
11747
|
+
var QuickNotePopover = (0, import_react48.memo)(function QuickNotePopover2({
|
|
11364
11748
|
visible,
|
|
11365
11749
|
position,
|
|
11366
11750
|
initialContent = "",
|
|
@@ -11369,21 +11753,21 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11369
11753
|
onCancel,
|
|
11370
11754
|
className
|
|
11371
11755
|
}) {
|
|
11372
|
-
const [content, setContent] = (0,
|
|
11373
|
-
const textareaRef = (0,
|
|
11374
|
-
const popoverRef = (0,
|
|
11375
|
-
const [adjustedPosition, setAdjustedPosition] = (0,
|
|
11376
|
-
(0,
|
|
11756
|
+
const [content, setContent] = (0, import_react48.useState)(initialContent);
|
|
11757
|
+
const textareaRef = (0, import_react48.useRef)(null);
|
|
11758
|
+
const popoverRef = (0, import_react48.useRef)(null);
|
|
11759
|
+
const [adjustedPosition, setAdjustedPosition] = (0, import_react48.useState)(position);
|
|
11760
|
+
(0, import_react48.useEffect)(() => {
|
|
11377
11761
|
if (visible && textareaRef.current) {
|
|
11378
11762
|
textareaRef.current.focus();
|
|
11379
11763
|
}
|
|
11380
11764
|
}, [visible]);
|
|
11381
|
-
(0,
|
|
11765
|
+
(0, import_react48.useEffect)(() => {
|
|
11382
11766
|
if (visible) {
|
|
11383
11767
|
setContent(initialContent);
|
|
11384
11768
|
}
|
|
11385
11769
|
}, [visible, initialContent]);
|
|
11386
|
-
(0,
|
|
11770
|
+
(0, import_react48.useEffect)(() => {
|
|
11387
11771
|
if (!visible || !popoverRef.current) return;
|
|
11388
11772
|
const rect = popoverRef.current.getBoundingClientRect();
|
|
11389
11773
|
const padding = 10;
|
|
@@ -11402,14 +11786,14 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11402
11786
|
}
|
|
11403
11787
|
setAdjustedPosition({ x, y });
|
|
11404
11788
|
}, [position, visible]);
|
|
11405
|
-
const handleSave = (0,
|
|
11789
|
+
const handleSave = (0, import_react48.useCallback)(() => {
|
|
11406
11790
|
if (content.trim()) {
|
|
11407
11791
|
onSave(content.trim());
|
|
11408
11792
|
} else {
|
|
11409
11793
|
onCancel();
|
|
11410
11794
|
}
|
|
11411
11795
|
}, [content, onSave, onCancel]);
|
|
11412
|
-
const handleKeyDown = (0,
|
|
11796
|
+
const handleKeyDown = (0, import_react48.useCallback)(
|
|
11413
11797
|
(e) => {
|
|
11414
11798
|
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11415
11799
|
e.preventDefault();
|
|
@@ -11424,7 +11808,7 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11424
11808
|
if (!visible) {
|
|
11425
11809
|
return null;
|
|
11426
11810
|
}
|
|
11427
|
-
return /* @__PURE__ */ (0,
|
|
11811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
|
|
11428
11812
|
"div",
|
|
11429
11813
|
{
|
|
11430
11814
|
ref: popoverRef,
|
|
@@ -11443,15 +11827,15 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11443
11827
|
top: adjustedPosition.y
|
|
11444
11828
|
},
|
|
11445
11829
|
children: [
|
|
11446
|
-
agentLastStatement && /* @__PURE__ */ (0,
|
|
11447
|
-
/* @__PURE__ */ (0,
|
|
11448
|
-
/* @__PURE__ */ (0,
|
|
11830
|
+
agentLastStatement && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "mb-2 p-2 bg-blue-50 dark:bg-blue-900/50 rounded text-xs text-blue-600 dark:text-blue-300 border border-blue-100 dark:border-blue-800", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-start gap-1", children: [
|
|
11831
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("svg", { className: "w-3 h-3 mt-0.5 flex-shrink-0", fill: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) }),
|
|
11832
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "line-clamp-2", children: [
|
|
11449
11833
|
"AI discussed: \u201C",
|
|
11450
11834
|
agentLastStatement,
|
|
11451
11835
|
"\u201D"
|
|
11452
11836
|
] })
|
|
11453
11837
|
] }) }),
|
|
11454
|
-
/* @__PURE__ */ (0,
|
|
11838
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
11455
11839
|
"textarea",
|
|
11456
11840
|
{
|
|
11457
11841
|
ref: textareaRef,
|
|
@@ -11470,13 +11854,13 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11470
11854
|
)
|
|
11471
11855
|
}
|
|
11472
11856
|
),
|
|
11473
|
-
/* @__PURE__ */ (0,
|
|
11474
|
-
/* @__PURE__ */ (0,
|
|
11857
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex items-center justify-between mt-2", children: [
|
|
11858
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "text-xs text-gray-500 dark:text-gray-400", children: [
|
|
11475
11859
|
navigator.platform.includes("Mac") ? "\u2318" : "Ctrl",
|
|
11476
11860
|
"+Enter to save"
|
|
11477
11861
|
] }),
|
|
11478
|
-
/* @__PURE__ */ (0,
|
|
11479
|
-
/* @__PURE__ */ (0,
|
|
11862
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "flex gap-2", children: [
|
|
11863
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
11480
11864
|
"button",
|
|
11481
11865
|
{
|
|
11482
11866
|
onClick: onCancel,
|
|
@@ -11489,7 +11873,7 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11489
11873
|
children: "Cancel"
|
|
11490
11874
|
}
|
|
11491
11875
|
),
|
|
11492
|
-
/* @__PURE__ */ (0,
|
|
11876
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
11493
11877
|
"button",
|
|
11494
11878
|
{
|
|
11495
11879
|
onClick: handleSave,
|
|
@@ -11512,10 +11896,10 @@ var QuickNotePopover = (0, import_react47.memo)(function QuickNotePopover2({
|
|
|
11512
11896
|
});
|
|
11513
11897
|
|
|
11514
11898
|
// src/components/AskAbout/AskAboutOverlay.tsx
|
|
11515
|
-
var
|
|
11899
|
+
var import_react49 = require("react");
|
|
11516
11900
|
init_utils();
|
|
11517
|
-
var
|
|
11518
|
-
var AskAboutOverlay = (0,
|
|
11901
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
11902
|
+
var AskAboutOverlay = (0, import_react49.memo)(function AskAboutOverlay2({
|
|
11519
11903
|
visible,
|
|
11520
11904
|
progress,
|
|
11521
11905
|
position,
|
|
@@ -11529,7 +11913,7 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11529
11913
|
const radius = (size - strokeWidth) / 2;
|
|
11530
11914
|
const circumference = 2 * Math.PI * radius;
|
|
11531
11915
|
const strokeDashoffset = circumference * (1 - progress);
|
|
11532
|
-
return /* @__PURE__ */ (0,
|
|
11916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
11533
11917
|
"div",
|
|
11534
11918
|
{
|
|
11535
11919
|
className: cn(
|
|
@@ -11542,7 +11926,7 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11542
11926
|
top: position.y - size / 2
|
|
11543
11927
|
},
|
|
11544
11928
|
children: [
|
|
11545
|
-
/* @__PURE__ */ (0,
|
|
11929
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
11546
11930
|
"svg",
|
|
11547
11931
|
{
|
|
11548
11932
|
width: size,
|
|
@@ -11550,7 +11934,7 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11550
11934
|
viewBox: `0 0 ${size} ${size}`,
|
|
11551
11935
|
className: "transform -rotate-90",
|
|
11552
11936
|
children: [
|
|
11553
|
-
/* @__PURE__ */ (0,
|
|
11937
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11554
11938
|
"circle",
|
|
11555
11939
|
{
|
|
11556
11940
|
cx: size / 2,
|
|
@@ -11561,7 +11945,7 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11561
11945
|
strokeWidth
|
|
11562
11946
|
}
|
|
11563
11947
|
),
|
|
11564
|
-
/* @__PURE__ */ (0,
|
|
11948
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11565
11949
|
"circle",
|
|
11566
11950
|
{
|
|
11567
11951
|
cx: size / 2,
|
|
@@ -11579,12 +11963,12 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11579
11963
|
]
|
|
11580
11964
|
}
|
|
11581
11965
|
),
|
|
11582
|
-
/* @__PURE__ */ (0,
|
|
11966
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11583
11967
|
"div",
|
|
11584
11968
|
{
|
|
11585
11969
|
className: "absolute inset-0 flex items-center justify-center",
|
|
11586
11970
|
style: { color: progress >= 1 ? "#22c55e" : "white" },
|
|
11587
|
-
children: progress >= 1 ? /* @__PURE__ */ (0,
|
|
11971
|
+
children: progress >= 1 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11588
11972
|
"svg",
|
|
11589
11973
|
{
|
|
11590
11974
|
width: "24",
|
|
@@ -11595,9 +11979,9 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11595
11979
|
strokeWidth: "2",
|
|
11596
11980
|
strokeLinecap: "round",
|
|
11597
11981
|
strokeLinejoin: "round",
|
|
11598
|
-
children: /* @__PURE__ */ (0,
|
|
11982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("polyline", { points: "20 6 9 17 4 12" })
|
|
11599
11983
|
}
|
|
11600
|
-
) : /* @__PURE__ */ (0,
|
|
11984
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
11601
11985
|
"svg",
|
|
11602
11986
|
{
|
|
11603
11987
|
width: "20",
|
|
@@ -11609,9 +11993,9 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11609
11993
|
strokeLinecap: "round",
|
|
11610
11994
|
strokeLinejoin: "round",
|
|
11611
11995
|
children: [
|
|
11612
|
-
/* @__PURE__ */ (0,
|
|
11613
|
-
/* @__PURE__ */ (0,
|
|
11614
|
-
/* @__PURE__ */ (0,
|
|
11996
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
11997
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
|
|
11998
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("line", { x1: "12", y1: "17", x2: "12.01", y2: "17" })
|
|
11615
11999
|
]
|
|
11616
12000
|
}
|
|
11617
12001
|
)
|
|
@@ -11623,10 +12007,10 @@ var AskAboutOverlay = (0, import_react48.memo)(function AskAboutOverlay2({
|
|
|
11623
12007
|
});
|
|
11624
12008
|
|
|
11625
12009
|
// src/components/AskAbout/AskAboutTrigger.tsx
|
|
11626
|
-
var
|
|
12010
|
+
var import_react50 = require("react");
|
|
11627
12011
|
init_utils();
|
|
11628
|
-
var
|
|
11629
|
-
var AskAboutTrigger = (0,
|
|
12012
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
12013
|
+
var AskAboutTrigger = (0, import_react50.memo)(function AskAboutTrigger2({
|
|
11630
12014
|
position,
|
|
11631
12015
|
onConfirm,
|
|
11632
12016
|
onCancel,
|
|
@@ -11634,9 +12018,9 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11634
12018
|
autoHideDelay = 5e3,
|
|
11635
12019
|
className
|
|
11636
12020
|
}) {
|
|
11637
|
-
const [adjustedPosition, setAdjustedPosition] = (0,
|
|
11638
|
-
const triggerRef = (0,
|
|
11639
|
-
(0,
|
|
12021
|
+
const [adjustedPosition, setAdjustedPosition] = (0, import_react50.useState)(position);
|
|
12022
|
+
const triggerRef = (0, import_react50.useRef)(null);
|
|
12023
|
+
(0, import_react50.useEffect)(() => {
|
|
11640
12024
|
if (!visible || !triggerRef.current) return;
|
|
11641
12025
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
11642
12026
|
const padding = 10;
|
|
@@ -11652,19 +12036,19 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11652
12036
|
}
|
|
11653
12037
|
setAdjustedPosition({ x, y });
|
|
11654
12038
|
}, [position, visible]);
|
|
11655
|
-
(0,
|
|
12039
|
+
(0, import_react50.useEffect)(() => {
|
|
11656
12040
|
if (!visible || autoHideDelay === 0) return;
|
|
11657
12041
|
const timer = setTimeout(onCancel, autoHideDelay);
|
|
11658
12042
|
return () => clearTimeout(timer);
|
|
11659
12043
|
}, [visible, autoHideDelay, onCancel]);
|
|
11660
|
-
const handleConfirm = (0,
|
|
12044
|
+
const handleConfirm = (0, import_react50.useCallback)(
|
|
11661
12045
|
(e) => {
|
|
11662
12046
|
e.stopPropagation();
|
|
11663
12047
|
onConfirm();
|
|
11664
12048
|
},
|
|
11665
12049
|
[onConfirm]
|
|
11666
12050
|
);
|
|
11667
|
-
const handleCancel = (0,
|
|
12051
|
+
const handleCancel = (0, import_react50.useCallback)(
|
|
11668
12052
|
(e) => {
|
|
11669
12053
|
e.stopPropagation();
|
|
11670
12054
|
onCancel();
|
|
@@ -11674,7 +12058,7 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11674
12058
|
if (!visible) {
|
|
11675
12059
|
return null;
|
|
11676
12060
|
}
|
|
11677
|
-
return /* @__PURE__ */ (0,
|
|
12061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
11678
12062
|
"div",
|
|
11679
12063
|
{
|
|
11680
12064
|
ref: triggerRef,
|
|
@@ -11693,8 +12077,8 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11693
12077
|
transform: "translate(-50%, 0)"
|
|
11694
12078
|
},
|
|
11695
12079
|
children: [
|
|
11696
|
-
/* @__PURE__ */ (0,
|
|
11697
|
-
/* @__PURE__ */ (0,
|
|
12080
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "text-sm text-gray-600 dark:text-gray-300 px-2", children: "Ask about this?" }),
|
|
12081
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
11698
12082
|
"button",
|
|
11699
12083
|
{
|
|
11700
12084
|
onClick: handleConfirm,
|
|
@@ -11707,7 +12091,7 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11707
12091
|
children: "Ask"
|
|
11708
12092
|
}
|
|
11709
12093
|
),
|
|
11710
|
-
/* @__PURE__ */ (0,
|
|
12094
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
11711
12095
|
"button",
|
|
11712
12096
|
{
|
|
11713
12097
|
onClick: handleCancel,
|
|
@@ -11727,11 +12111,11 @@ var AskAboutTrigger = (0, import_react49.memo)(function AskAboutTrigger2({
|
|
|
11727
12111
|
});
|
|
11728
12112
|
|
|
11729
12113
|
// src/components/Minimap/Minimap.tsx
|
|
11730
|
-
var
|
|
12114
|
+
var import_react51 = require("react");
|
|
11731
12115
|
init_hooks();
|
|
11732
12116
|
init_utils();
|
|
11733
|
-
var
|
|
11734
|
-
var PageIndicator = (0,
|
|
12117
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
12118
|
+
var PageIndicator = (0, import_react51.memo)(function PageIndicator2({
|
|
11735
12119
|
pageNumber,
|
|
11736
12120
|
status,
|
|
11737
12121
|
isBookmarked,
|
|
@@ -11745,7 +12129,7 @@ var PageIndicator = (0, import_react50.memo)(function PageIndicator2({
|
|
|
11745
12129
|
if (status === "visited") return "bg-green-400";
|
|
11746
12130
|
return "bg-gray-200 dark:bg-gray-700";
|
|
11747
12131
|
};
|
|
11748
|
-
return /* @__PURE__ */ (0,
|
|
12132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
11749
12133
|
"button",
|
|
11750
12134
|
{
|
|
11751
12135
|
onClick,
|
|
@@ -11761,13 +12145,13 @@ var PageIndicator = (0, import_react50.memo)(function PageIndicator2({
|
|
|
11761
12145
|
title: `Page ${pageNumber}${isBookmarked ? " (bookmarked)" : ""}`,
|
|
11762
12146
|
"aria-label": `Go to page ${pageNumber}`,
|
|
11763
12147
|
children: [
|
|
11764
|
-
isBookmarked && !compact && /* @__PURE__ */ (0,
|
|
11765
|
-
showNumber && !compact && /* @__PURE__ */ (0,
|
|
12148
|
+
isBookmarked && !compact && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "absolute -top-1 -right-1 w-2 h-2 bg-yellow-500 rounded-full border border-white" }),
|
|
12149
|
+
showNumber && !compact && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "absolute inset-0 flex items-center justify-center text-[8px] font-medium text-white", children: pageNumber })
|
|
11766
12150
|
]
|
|
11767
12151
|
}
|
|
11768
12152
|
);
|
|
11769
12153
|
});
|
|
11770
|
-
var Minimap = (0,
|
|
12154
|
+
var Minimap = (0, import_react51.memo)(function Minimap2({
|
|
11771
12155
|
variant = "sidebar",
|
|
11772
12156
|
floatingPosition = "right",
|
|
11773
12157
|
maxHeight = 300,
|
|
@@ -11780,18 +12164,18 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11780
12164
|
const currentPage = useViewerStore((s) => s.currentPage);
|
|
11781
12165
|
const numPages = useViewerStore((s) => s.numPages);
|
|
11782
12166
|
const goToPage = useViewerStore((s) => s.goToPage);
|
|
11783
|
-
const bookmarkedPages = (0,
|
|
12167
|
+
const bookmarkedPages = (0, import_react51.useMemo)(() => {
|
|
11784
12168
|
return new Set(bookmarks.map((b) => b.pageNumber));
|
|
11785
12169
|
}, [bookmarks]);
|
|
11786
12170
|
const compact = numPages > 50;
|
|
11787
|
-
const handlePageClick = (0,
|
|
12171
|
+
const handlePageClick = (0, import_react51.useCallback)(
|
|
11788
12172
|
(pageNumber) => {
|
|
11789
12173
|
goToPage(pageNumber);
|
|
11790
12174
|
onPageClick?.(pageNumber);
|
|
11791
12175
|
},
|
|
11792
12176
|
[goToPage, onPageClick]
|
|
11793
12177
|
);
|
|
11794
|
-
const getPageStatus = (0,
|
|
12178
|
+
const getPageStatus = (0, import_react51.useCallback)(
|
|
11795
12179
|
(pageNumber) => {
|
|
11796
12180
|
if (pageNumber === currentPage) return "current";
|
|
11797
12181
|
if (bookmarkedPages.has(pageNumber)) return "bookmarked";
|
|
@@ -11800,11 +12184,11 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11800
12184
|
},
|
|
11801
12185
|
[currentPage, visitedPages, bookmarkedPages]
|
|
11802
12186
|
);
|
|
11803
|
-
const pageIndicators = (0,
|
|
12187
|
+
const pageIndicators = (0, import_react51.useMemo)(() => {
|
|
11804
12188
|
const pages = [];
|
|
11805
12189
|
for (let i = 1; i <= numPages; i++) {
|
|
11806
12190
|
pages.push(
|
|
11807
|
-
/* @__PURE__ */ (0,
|
|
12191
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11808
12192
|
PageIndicator,
|
|
11809
12193
|
{
|
|
11810
12194
|
pageNumber: i,
|
|
@@ -11825,16 +12209,16 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11825
12209
|
if (numPages === 0) {
|
|
11826
12210
|
return null;
|
|
11827
12211
|
}
|
|
11828
|
-
const content = /* @__PURE__ */ (0,
|
|
11829
|
-
/* @__PURE__ */ (0,
|
|
11830
|
-
/* @__PURE__ */ (0,
|
|
11831
|
-
/* @__PURE__ */ (0,
|
|
11832
|
-
/* @__PURE__ */ (0,
|
|
12212
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
12213
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mb-3", children: [
|
|
12214
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mb-1", children: [
|
|
12215
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Progress" }),
|
|
12216
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { children: [
|
|
11833
12217
|
progressPercentage,
|
|
11834
12218
|
"%"
|
|
11835
12219
|
] })
|
|
11836
12220
|
] }),
|
|
11837
|
-
/* @__PURE__ */ (0,
|
|
12221
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "h-1.5 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11838
12222
|
"div",
|
|
11839
12223
|
{
|
|
11840
12224
|
className: "h-full bg-green-500 rounded-full transition-all duration-300",
|
|
@@ -11842,7 +12226,7 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11842
12226
|
}
|
|
11843
12227
|
) })
|
|
11844
12228
|
] }),
|
|
11845
|
-
/* @__PURE__ */ (0,
|
|
12229
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11846
12230
|
"div",
|
|
11847
12231
|
{
|
|
11848
12232
|
className: cn(
|
|
@@ -11853,21 +12237,21 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11853
12237
|
children: pageIndicators
|
|
11854
12238
|
}
|
|
11855
12239
|
),
|
|
11856
|
-
/* @__PURE__ */ (0,
|
|
11857
|
-
/* @__PURE__ */ (0,
|
|
11858
|
-
/* @__PURE__ */ (0,
|
|
11859
|
-
/* @__PURE__ */ (0,
|
|
12240
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "mt-3 pt-2 border-t border-gray-200 dark:border-gray-700", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex flex-wrap gap-3 text-xs text-gray-500 dark:text-gray-400", children: [
|
|
12241
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12242
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "w-2 h-2 rounded-sm bg-blue-500" }),
|
|
12243
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Current" })
|
|
11860
12244
|
] }),
|
|
11861
|
-
/* @__PURE__ */ (0,
|
|
11862
|
-
/* @__PURE__ */ (0,
|
|
11863
|
-
/* @__PURE__ */ (0,
|
|
12245
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12246
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "w-2 h-2 rounded-sm bg-green-400" }),
|
|
12247
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Visited" })
|
|
11864
12248
|
] }),
|
|
11865
|
-
/* @__PURE__ */ (0,
|
|
11866
|
-
/* @__PURE__ */ (0,
|
|
11867
|
-
/* @__PURE__ */ (0,
|
|
12249
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
12250
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "w-2 h-2 rounded-sm bg-yellow-400" }),
|
|
12251
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { children: "Bookmarked" })
|
|
11868
12252
|
] })
|
|
11869
12253
|
] }) }),
|
|
11870
|
-
/* @__PURE__ */ (0,
|
|
12254
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-2 text-xs text-gray-500 dark:text-gray-400", children: [
|
|
11871
12255
|
visitedCount,
|
|
11872
12256
|
" of ",
|
|
11873
12257
|
numPages,
|
|
@@ -11875,7 +12259,7 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11875
12259
|
] })
|
|
11876
12260
|
] });
|
|
11877
12261
|
if (variant === "floating") {
|
|
11878
|
-
return /* @__PURE__ */ (0,
|
|
12262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
11879
12263
|
"div",
|
|
11880
12264
|
{
|
|
11881
12265
|
className: cn(
|
|
@@ -11891,13 +12275,13 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11891
12275
|
),
|
|
11892
12276
|
style: { maxHeight },
|
|
11893
12277
|
children: [
|
|
11894
|
-
/* @__PURE__ */ (0,
|
|
12278
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "text-sm font-semibold text-gray-700 dark:text-gray-200 mb-2", children: "Reading Progress" }),
|
|
11895
12279
|
content
|
|
11896
12280
|
]
|
|
11897
12281
|
}
|
|
11898
12282
|
);
|
|
11899
12283
|
}
|
|
11900
|
-
return /* @__PURE__ */ (0,
|
|
12284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11901
12285
|
"div",
|
|
11902
12286
|
{
|
|
11903
12287
|
className: cn(
|
|
@@ -11915,13 +12299,13 @@ var Minimap = (0, import_react50.memo)(function Minimap2({
|
|
|
11915
12299
|
init_FloatingZoomControls2();
|
|
11916
12300
|
|
|
11917
12301
|
// src/components/PDFThumbnailNav/PDFThumbnailNav.tsx
|
|
11918
|
-
var
|
|
12302
|
+
var import_react52 = require("react");
|
|
11919
12303
|
init_hooks();
|
|
11920
12304
|
init_utils();
|
|
11921
|
-
var
|
|
12305
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
11922
12306
|
var DEFAULT_WIDTH = 612;
|
|
11923
12307
|
var DEFAULT_HEIGHT = 792;
|
|
11924
|
-
var PDFThumbnailNav = (0,
|
|
12308
|
+
var PDFThumbnailNav = (0, import_react52.memo)(function PDFThumbnailNav2({
|
|
11925
12309
|
thumbnailScale = 0.15,
|
|
11926
12310
|
orientation = "vertical",
|
|
11927
12311
|
maxVisible = 10,
|
|
@@ -11932,14 +12316,14 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
11932
12316
|
}) {
|
|
11933
12317
|
const { document: document2, numPages, currentPage } = usePDFViewer();
|
|
11934
12318
|
const { viewerStore } = usePDFViewerStores();
|
|
11935
|
-
const containerRef = (0,
|
|
11936
|
-
const [thumbnails, setThumbnails] = (0,
|
|
11937
|
-
const [visibleRange, setVisibleRange] = (0,
|
|
11938
|
-
const renderQueueRef = (0,
|
|
11939
|
-
const pageCache = (0,
|
|
12319
|
+
const containerRef = (0, import_react52.useRef)(null);
|
|
12320
|
+
const [thumbnails, setThumbnails] = (0, import_react52.useState)(/* @__PURE__ */ new Map());
|
|
12321
|
+
const [visibleRange, setVisibleRange] = (0, import_react52.useState)({ start: 1, end: maxVisible });
|
|
12322
|
+
const renderQueueRef = (0, import_react52.useRef)(/* @__PURE__ */ new Set());
|
|
12323
|
+
const pageCache = (0, import_react52.useRef)(/* @__PURE__ */ new Map());
|
|
11940
12324
|
const thumbnailWidth = Math.floor(DEFAULT_WIDTH * thumbnailScale);
|
|
11941
12325
|
const thumbnailHeight = Math.floor(DEFAULT_HEIGHT * thumbnailScale);
|
|
11942
|
-
const updateVisibleRange = (0,
|
|
12326
|
+
const updateVisibleRange = (0, import_react52.useCallback)(() => {
|
|
11943
12327
|
if (!containerRef.current || numPages === 0) return;
|
|
11944
12328
|
const container = containerRef.current;
|
|
11945
12329
|
const isHorizontal2 = orientation === "horizontal";
|
|
@@ -11951,7 +12335,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
11951
12335
|
const lastVisible = Math.min(numPages, firstVisible + visibleCount);
|
|
11952
12336
|
setVisibleRange({ start: firstVisible, end: lastVisible });
|
|
11953
12337
|
}, [numPages, orientation, thumbnailWidth, thumbnailHeight, gap]);
|
|
11954
|
-
(0,
|
|
12338
|
+
(0, import_react52.useEffect)(() => {
|
|
11955
12339
|
const container = containerRef.current;
|
|
11956
12340
|
if (!container) return;
|
|
11957
12341
|
const handleScroll = () => {
|
|
@@ -11961,7 +12345,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
11961
12345
|
updateVisibleRange();
|
|
11962
12346
|
return () => container.removeEventListener("scroll", handleScroll);
|
|
11963
12347
|
}, [updateVisibleRange]);
|
|
11964
|
-
(0,
|
|
12348
|
+
(0, import_react52.useEffect)(() => {
|
|
11965
12349
|
if (!document2) {
|
|
11966
12350
|
setThumbnails(/* @__PURE__ */ new Map());
|
|
11967
12351
|
pageCache.current.clear();
|
|
@@ -12016,7 +12400,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12016
12400
|
};
|
|
12017
12401
|
renderThumbnails();
|
|
12018
12402
|
}, [document2, visibleRange, thumbnailScale, thumbnails]);
|
|
12019
|
-
(0,
|
|
12403
|
+
(0, import_react52.useEffect)(() => {
|
|
12020
12404
|
if (!containerRef.current || numPages === 0) return;
|
|
12021
12405
|
const container = containerRef.current;
|
|
12022
12406
|
const isHorizontal2 = orientation === "horizontal";
|
|
@@ -12032,12 +12416,12 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12032
12416
|
});
|
|
12033
12417
|
}
|
|
12034
12418
|
}, [currentPage, numPages, orientation, thumbnailWidth, thumbnailHeight, gap]);
|
|
12035
|
-
const handleThumbnailClick = (0,
|
|
12419
|
+
const handleThumbnailClick = (0, import_react52.useCallback)((pageNum) => {
|
|
12036
12420
|
onThumbnailClick?.(pageNum);
|
|
12037
12421
|
viewerStore.getState().requestScrollToPage(pageNum, "smooth");
|
|
12038
12422
|
}, [onThumbnailClick, viewerStore]);
|
|
12039
12423
|
if (!document2 || numPages === 0) {
|
|
12040
|
-
return /* @__PURE__ */ (0,
|
|
12424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12041
12425
|
"div",
|
|
12042
12426
|
{
|
|
12043
12427
|
className: cn(
|
|
@@ -12058,7 +12442,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12058
12442
|
}
|
|
12059
12443
|
const isHorizontal = orientation === "horizontal";
|
|
12060
12444
|
const totalSize = numPages * ((isHorizontal ? thumbnailWidth : thumbnailHeight) + gap) - gap;
|
|
12061
|
-
return /* @__PURE__ */ (0,
|
|
12445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12062
12446
|
"div",
|
|
12063
12447
|
{
|
|
12064
12448
|
ref: containerRef,
|
|
@@ -12072,7 +12456,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12072
12456
|
style: {
|
|
12073
12457
|
...isHorizontal ? { overflowX: "auto", overflowY: "hidden" } : { overflowX: "hidden", overflowY: "auto" }
|
|
12074
12458
|
},
|
|
12075
|
-
children: /* @__PURE__ */ (0,
|
|
12459
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12076
12460
|
"div",
|
|
12077
12461
|
{
|
|
12078
12462
|
className: cn(
|
|
@@ -12089,7 +12473,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12089
12473
|
const thumbnail = thumbnails.get(pageNum);
|
|
12090
12474
|
const isActive = pageNum === currentPage;
|
|
12091
12475
|
const isVisible = pageNum >= visibleRange.start && pageNum <= visibleRange.end;
|
|
12092
|
-
return /* @__PURE__ */ (0,
|
|
12476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
12093
12477
|
"div",
|
|
12094
12478
|
{
|
|
12095
12479
|
className: cn(
|
|
@@ -12114,7 +12498,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12114
12498
|
}
|
|
12115
12499
|
},
|
|
12116
12500
|
children: [
|
|
12117
|
-
/* @__PURE__ */ (0,
|
|
12501
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12118
12502
|
"div",
|
|
12119
12503
|
{
|
|
12120
12504
|
className: "relative bg-white dark:bg-gray-700",
|
|
@@ -12122,7 +12506,7 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12122
12506
|
width: thumbnailWidth,
|
|
12123
12507
|
height: thumbnailHeight
|
|
12124
12508
|
},
|
|
12125
|
-
children: isVisible && thumbnail?.canvas ? /* @__PURE__ */ (0,
|
|
12509
|
+
children: isVisible && thumbnail?.canvas ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12126
12510
|
"img",
|
|
12127
12511
|
{
|
|
12128
12512
|
src: thumbnail.canvas.toDataURL(),
|
|
@@ -12130,10 +12514,10 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12130
12514
|
className: "w-full h-full object-contain",
|
|
12131
12515
|
loading: "lazy"
|
|
12132
12516
|
}
|
|
12133
|
-
) : /* @__PURE__ */ (0,
|
|
12517
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "absolute inset-0 flex items-center justify-center text-gray-400 dark:text-gray-500 text-xs", children: pageNum })
|
|
12134
12518
|
}
|
|
12135
12519
|
),
|
|
12136
|
-
showPageNumbers && /* @__PURE__ */ (0,
|
|
12520
|
+
showPageNumbers && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
12137
12521
|
"div",
|
|
12138
12522
|
{
|
|
12139
12523
|
className: cn(
|
|
@@ -12156,10 +12540,10 @@ var PDFThumbnailNav = (0, import_react51.memo)(function PDFThumbnailNav2({
|
|
|
12156
12540
|
});
|
|
12157
12541
|
|
|
12158
12542
|
// src/components/ErrorBoundary/PDFErrorBoundary.tsx
|
|
12159
|
-
var
|
|
12543
|
+
var import_react53 = require("react");
|
|
12160
12544
|
init_utils();
|
|
12161
|
-
var
|
|
12162
|
-
var PDFErrorBoundary = class extends
|
|
12545
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
12546
|
+
var PDFErrorBoundary = class extends import_react53.Component {
|
|
12163
12547
|
constructor(props) {
|
|
12164
12548
|
super(props);
|
|
12165
12549
|
this.handleReset = () => {
|
|
@@ -12186,7 +12570,7 @@ var PDFErrorBoundary = class extends import_react52.Component {
|
|
|
12186
12570
|
return fallback;
|
|
12187
12571
|
}
|
|
12188
12572
|
if (showDefaultUI) {
|
|
12189
|
-
return /* @__PURE__ */ (0,
|
|
12573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12190
12574
|
DefaultErrorUI,
|
|
12191
12575
|
{
|
|
12192
12576
|
error,
|
|
@@ -12205,7 +12589,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12205
12589
|
const isNetworkError = error.message.includes("fetch") || error.message.includes("network") || error.message.includes("Failed to load");
|
|
12206
12590
|
let title = "Something went wrong";
|
|
12207
12591
|
let description = error.message;
|
|
12208
|
-
let icon = /* @__PURE__ */ (0,
|
|
12592
|
+
let icon = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { className: "w-12 h-12 text-red-500", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12209
12593
|
"path",
|
|
12210
12594
|
{
|
|
12211
12595
|
strokeLinecap: "round",
|
|
@@ -12217,7 +12601,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12217
12601
|
if (isPDFError) {
|
|
12218
12602
|
title = "Unable to load PDF";
|
|
12219
12603
|
description = "The PDF file could not be loaded. It may be corrupted or in an unsupported format.";
|
|
12220
|
-
icon = /* @__PURE__ */ (0,
|
|
12604
|
+
icon = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { className: "w-12 h-12 text-red-500", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12221
12605
|
"path",
|
|
12222
12606
|
{
|
|
12223
12607
|
strokeLinecap: "round",
|
|
@@ -12229,7 +12613,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12229
12613
|
} else if (isNetworkError) {
|
|
12230
12614
|
title = "Network error";
|
|
12231
12615
|
description = "Unable to fetch the PDF file. Please check your internet connection and try again.";
|
|
12232
|
-
icon = /* @__PURE__ */ (0,
|
|
12616
|
+
icon = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { className: "w-12 h-12 text-red-500", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12233
12617
|
"path",
|
|
12234
12618
|
{
|
|
12235
12619
|
strokeLinecap: "round",
|
|
@@ -12239,7 +12623,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12239
12623
|
}
|
|
12240
12624
|
) });
|
|
12241
12625
|
}
|
|
12242
|
-
return /* @__PURE__ */ (0,
|
|
12626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
12243
12627
|
"div",
|
|
12244
12628
|
{
|
|
12245
12629
|
className: cn(
|
|
@@ -12252,14 +12636,14 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12252
12636
|
),
|
|
12253
12637
|
children: [
|
|
12254
12638
|
icon,
|
|
12255
|
-
/* @__PURE__ */ (0,
|
|
12256
|
-
/* @__PURE__ */ (0,
|
|
12257
|
-
/* @__PURE__ */ (0,
|
|
12258
|
-
/* @__PURE__ */ (0,
|
|
12259
|
-
/* @__PURE__ */ (0,
|
|
12639
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("h2", { className: "mt-4 text-xl font-semibold text-gray-900 dark:text-gray-100", children: title }),
|
|
12640
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400 max-w-md", children: description }),
|
|
12641
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("details", { className: "mt-4 text-left max-w-md w-full", children: [
|
|
12642
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("summary", { className: "cursor-pointer text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200", children: "Technical details" }),
|
|
12643
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("pre", { className: "mt-2 p-2 bg-gray-100 dark:bg-gray-800 rounded text-xs overflow-auto", children: error.stack || error.message })
|
|
12260
12644
|
] }),
|
|
12261
|
-
/* @__PURE__ */ (0,
|
|
12262
|
-
/* @__PURE__ */ (0,
|
|
12645
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "mt-6 flex gap-3", children: [
|
|
12646
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12263
12647
|
"button",
|
|
12264
12648
|
{
|
|
12265
12649
|
onClick: onReset,
|
|
@@ -12273,7 +12657,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12273
12657
|
children: "Try again"
|
|
12274
12658
|
}
|
|
12275
12659
|
),
|
|
12276
|
-
/* @__PURE__ */ (0,
|
|
12660
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12277
12661
|
"button",
|
|
12278
12662
|
{
|
|
12279
12663
|
onClick: () => window.location.reload(),
|
|
@@ -12293,7 +12677,7 @@ function DefaultErrorUI({ error, onReset, className }) {
|
|
|
12293
12677
|
);
|
|
12294
12678
|
}
|
|
12295
12679
|
function withErrorBoundary({ component, ...props }) {
|
|
12296
|
-
return /* @__PURE__ */ (0,
|
|
12680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PDFErrorBoundary, { ...props, children: component });
|
|
12297
12681
|
}
|
|
12298
12682
|
|
|
12299
12683
|
// src/components/index.ts
|
|
@@ -12392,6 +12776,7 @@ init_utils();
|
|
|
12392
12776
|
isPDFJSInitialized,
|
|
12393
12777
|
isPointInRect,
|
|
12394
12778
|
loadDocument,
|
|
12779
|
+
loadDocumentWithCallbacks,
|
|
12395
12780
|
loadHighlights,
|
|
12396
12781
|
loadStudentData,
|
|
12397
12782
|
mergeAdjacentRects,
|