@cannyminds/dms-file-viewers 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-FZYMVHF6.mjs → chunk-4DJJINTB.mjs} +54 -55
- package/dist/chunk-4DJJINTB.mjs.map +1 -0
- package/dist/chunk-677DWENS.mjs +133 -0
- package/dist/chunk-677DWENS.mjs.map +1 -0
- package/dist/chunk-77UARJVQ.js +133 -0
- package/dist/chunk-77UARJVQ.js.map +1 -0
- package/dist/{chunk-LKBM4O47.mjs → chunk-7BLEPGZ4.mjs} +67 -61
- package/dist/chunk-7BLEPGZ4.mjs.map +1 -0
- package/dist/{chunk-QRYIHDRT.mjs → chunk-BHMFZTZ7.mjs} +54 -55
- package/dist/chunk-BHMFZTZ7.mjs.map +1 -0
- package/dist/{chunk-XQBXRMB7.mjs → chunk-BONT4K3R.mjs} +14 -8
- package/dist/chunk-BONT4K3R.mjs.map +1 -0
- package/dist/{chunk-3STHCDAC.js → chunk-DDT3GC3C.js} +425 -164
- package/dist/chunk-DDT3GC3C.js.map +1 -0
- package/dist/{chunk-EMP7RZM2.js → chunk-DOOYIHGW.js} +52 -53
- package/dist/chunk-DOOYIHGW.js.map +1 -0
- package/dist/{chunk-73ZIFR3P.mjs → chunk-J2YW5DHC.mjs} +457 -196
- package/dist/chunk-J2YW5DHC.mjs.map +1 -0
- package/dist/{chunk-BNHQYEZ7.js → chunk-SBEFC7HP.js} +203 -158
- package/dist/chunk-SBEFC7HP.js.map +1 -0
- package/dist/{chunk-4RL77HKO.js → chunk-SNEIVT4R.js} +52 -53
- package/dist/chunk-SNEIVT4R.js.map +1 -0
- package/dist/{chunk-7JTIG6OU.js → chunk-WP55NYFS.js} +67 -61
- package/dist/chunk-WP55NYFS.js.map +1 -0
- package/dist/{chunk-NOLXOOIP.mjs → chunk-YHMHDPLQ.mjs} +200 -155
- package/dist/chunk-YHMHDPLQ.mjs.map +1 -0
- package/dist/{chunk-GNWU6XHH.js → chunk-Z3IUTTJQ.js} +15 -9
- package/dist/{chunk-GNWU6XHH.js.map → chunk-Z3IUTTJQ.js.map} +1 -1
- package/dist/components/viewers/AudioViewer.d.mts +1 -1
- package/dist/components/viewers/AudioViewer.d.ts +1 -1
- package/dist/components/viewers/AudioViewer.js +2 -2
- package/dist/components/viewers/AudioViewer.mjs +1 -1
- package/dist/components/viewers/DefaultViewer.d.mts +1 -1
- package/dist/components/viewers/DefaultViewer.d.ts +1 -1
- package/dist/components/viewers/DefaultViewer.js +3 -2
- package/dist/components/viewers/DefaultViewer.js.map +1 -1
- package/dist/components/viewers/DefaultViewer.mjs +2 -1
- package/dist/components/viewers/ImageViewer.d.mts +1 -1
- package/dist/components/viewers/ImageViewer.d.ts +1 -1
- package/dist/components/viewers/ImageViewer.js +3 -3
- package/dist/components/viewers/ImageViewer.mjs +2 -2
- package/dist/components/viewers/PDFViewer.d.mts +1 -1
- package/dist/components/viewers/PDFViewer.d.ts +1 -1
- package/dist/components/viewers/PDFViewer.js +2 -2
- package/dist/components/viewers/PDFViewer.mjs +1 -1
- package/dist/components/viewers/TIFFViewer.d.mts +1 -1
- package/dist/components/viewers/TIFFViewer.d.ts +1 -1
- package/dist/components/viewers/TIFFViewer.js +2 -2
- package/dist/components/viewers/TIFFViewer.mjs +1 -1
- package/dist/components/viewers/TextViewer.d.mts +1 -1
- package/dist/components/viewers/TextViewer.d.ts +1 -1
- package/dist/components/viewers/TextViewer.js +2 -2
- package/dist/components/viewers/TextViewer.mjs +1 -1
- package/dist/components/viewers/VideoViewer.d.mts +1 -1
- package/dist/components/viewers/VideoViewer.d.ts +1 -1
- package/dist/components/viewers/VideoViewer.js +2 -2
- package/dist/components/viewers/VideoViewer.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +30 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{types-CquKzJLE.d.mts → types-C6IEfcTM.d.mts} +13 -1
- package/dist/{types-CquKzJLE.d.ts → types-C6IEfcTM.d.ts} +13 -1
- package/package.json +1 -1
- package/dist/chunk-3STHCDAC.js.map +0 -1
- package/dist/chunk-4RL77HKO.js.map +0 -1
- package/dist/chunk-73ZIFR3P.mjs.map +0 -1
- package/dist/chunk-7JTIG6OU.js.map +0 -1
- package/dist/chunk-BNHQYEZ7.js.map +0 -1
- package/dist/chunk-EMP7RZM2.js.map +0 -1
- package/dist/chunk-FZYMVHF6.mjs.map +0 -1
- package/dist/chunk-LKBM4O47.mjs.map +0 -1
- package/dist/chunk-NOLXOOIP.mjs.map +0 -1
- package/dist/chunk-QLJKOQTP.mjs +0 -78
- package/dist/chunk-QLJKOQTP.mjs.map +0 -1
- package/dist/chunk-QRYIHDRT.mjs.map +0 -1
- package/dist/chunk-XQBXRMB7.mjs.map +0 -1
- package/dist/chunk-Z7FUO5RX.js +0 -78
- package/dist/chunk-Z7FUO5RX.js.map +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
var _chunkRE4XRGSVjs = require('./chunk-RE4XRGSV.js');
|
|
6
6
|
|
|
7
7
|
// src/components/viewers/PDFViewer.tsx
|
|
8
|
-
var _react = require('react');
|
|
8
|
+
var _react = require('react');
|
|
9
9
|
var _pdfviewer = require('@cannyminds/pdf-viewer');
|
|
10
10
|
var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
|
|
11
11
|
var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
|
|
@@ -49,11 +49,17 @@ var SearchSidebar = ({
|
|
|
49
49
|
totalResults,
|
|
50
50
|
searchKeyword,
|
|
51
51
|
searchResults = [],
|
|
52
|
-
isSearching = false
|
|
52
|
+
isSearching = false,
|
|
53
|
+
isSyntheticResults = false
|
|
53
54
|
}) => {
|
|
54
55
|
const [searchTerm, setSearchTerm] = _react.useState.call(void 0, searchKeyword || "");
|
|
55
56
|
const [hasSearched, setHasSearched] = _react.useState.call(void 0, false);
|
|
56
57
|
const contentRef = _react.useRef.call(void 0, null);
|
|
58
|
+
_react.useEffect.call(void 0, () => {
|
|
59
|
+
if (searchKeyword && searchKeyword !== searchTerm) {
|
|
60
|
+
setSearchTerm(searchKeyword);
|
|
61
|
+
}
|
|
62
|
+
}, [searchKeyword]);
|
|
57
63
|
_react.useLayoutEffect.call(void 0, () => {
|
|
58
64
|
const element = contentRef.current;
|
|
59
65
|
if (!element) return;
|
|
@@ -89,20 +95,29 @@ var SearchSidebar = ({
|
|
|
89
95
|
background-color: transparent;
|
|
90
96
|
}
|
|
91
97
|
.search-sidebar-content::-webkit-scrollbar-thumb {
|
|
92
|
-
background-color: rgba(
|
|
98
|
+
background-color: rgba(128, 128, 128, 0.3);
|
|
93
99
|
border-radius: 8px;
|
|
94
100
|
border: 4px solid transparent;
|
|
95
101
|
background-clip: padding-box;
|
|
96
102
|
transition: all 0.15s ease;
|
|
97
103
|
}
|
|
98
104
|
.search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
|
|
99
|
-
background-color: rgba(
|
|
105
|
+
background-color: rgba(128, 128, 128, 0.5);
|
|
100
106
|
border: 2px solid transparent;
|
|
101
107
|
}
|
|
102
108
|
.search-sidebar-content::-webkit-scrollbar-thumb:active {
|
|
103
|
-
background-color: rgba(25, 118, 210, 0.
|
|
109
|
+
background-color: rgba(25, 118, 210, 0.8);
|
|
104
110
|
border: 1px solid transparent;
|
|
105
111
|
}
|
|
112
|
+
|
|
113
|
+
@media (prefers-color-scheme: dark) {
|
|
114
|
+
.search-sidebar-content::-webkit-scrollbar-thumb {
|
|
115
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
116
|
+
}
|
|
117
|
+
.search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
|
|
118
|
+
background-color: rgba(255, 255, 255, 0.35);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
106
121
|
|
|
107
122
|
/* Tamil font support for search results */
|
|
108
123
|
.search-result-text {
|
|
@@ -344,12 +359,13 @@ var SearchSidebar = ({
|
|
|
344
359
|
width: 80,
|
|
345
360
|
height: 80,
|
|
346
361
|
borderRadius: "50%",
|
|
347
|
-
backgroundColor: "
|
|
362
|
+
backgroundColor: "primary.light",
|
|
348
363
|
display: "flex",
|
|
349
364
|
alignItems: "center",
|
|
350
365
|
justifyContent: "center",
|
|
351
366
|
margin: "0 auto",
|
|
352
|
-
mb: 3
|
|
367
|
+
mb: 3,
|
|
368
|
+
opacity: 0.2
|
|
353
369
|
},
|
|
354
370
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FindInPage2.default, { sx: { fontSize: 40, color: "primary.main" } })
|
|
355
371
|
}
|
|
@@ -361,12 +377,13 @@ var SearchSidebar = ({
|
|
|
361
377
|
{
|
|
362
378
|
variant: "body2",
|
|
363
379
|
sx: {
|
|
364
|
-
color: "
|
|
380
|
+
color: "white",
|
|
365
381
|
fontWeight: 600,
|
|
366
|
-
backgroundColor: "
|
|
382
|
+
backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(144, 202, 249, 0.16)" : "primary.light",
|
|
367
383
|
padding: "6px 16px",
|
|
368
384
|
borderRadius: "16px",
|
|
369
|
-
display: "inline-block"
|
|
385
|
+
display: "inline-block",
|
|
386
|
+
opacity: 0.9
|
|
370
387
|
},
|
|
371
388
|
children: [
|
|
372
389
|
'"',
|
|
@@ -384,14 +401,15 @@ var SearchSidebar = ({
|
|
|
384
401
|
width: 80,
|
|
385
402
|
height: 80,
|
|
386
403
|
borderRadius: "50%",
|
|
387
|
-
backgroundColor: "
|
|
404
|
+
backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(255, 152, 0, 0.12)" : "warning.light",
|
|
388
405
|
display: "flex",
|
|
389
406
|
alignItems: "center",
|
|
390
407
|
justifyContent: "center",
|
|
391
408
|
margin: "0 auto",
|
|
392
|
-
mb: 3
|
|
409
|
+
mb: 3,
|
|
410
|
+
opacity: 0.6
|
|
393
411
|
},
|
|
394
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "
|
|
412
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Search2.default, { sx: { fontSize: 40, color: "warning.main" } })
|
|
395
413
|
}
|
|
396
414
|
),
|
|
397
415
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
|
|
@@ -404,8 +422,9 @@ var SearchSidebar = ({
|
|
|
404
422
|
] })
|
|
405
423
|
] })
|
|
406
424
|
] }),
|
|
407
|
-
totalResults > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { p: 2 }, children: Object.
|
|
425
|
+
totalResults > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
|
|
408
426
|
const pageNumber = parseInt(pageNum);
|
|
427
|
+
const pageResults = resultsByPage[pageNumber];
|
|
409
428
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { mb: 3 }, children: [
|
|
410
429
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
411
430
|
_material.Typography,
|
|
@@ -435,15 +454,15 @@ var SearchSidebar = ({
|
|
|
435
454
|
mx: 1,
|
|
436
455
|
mb: 1.5,
|
|
437
456
|
borderRadius: "8px",
|
|
438
|
-
border: "
|
|
457
|
+
border: "2px solid",
|
|
439
458
|
borderColor: result.index === currentResultIndex ? "primary.main" : "divider",
|
|
440
|
-
backgroundColor:
|
|
459
|
+
backgroundColor: "background.paper",
|
|
441
460
|
cursor: "pointer",
|
|
442
461
|
transition: "all 0.2s ease",
|
|
443
|
-
boxShadow:
|
|
462
|
+
boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 3px rgba(0, 0, 0, 0.3)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
|
|
444
463
|
"&:hover": {
|
|
445
464
|
borderColor: "primary.main",
|
|
446
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
465
|
+
boxShadow: (theme) => theme.palette.mode === "dark" ? "0 2px 8px rgba(255, 255, 255, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.1)",
|
|
447
466
|
transform: "translateY(-1px)"
|
|
448
467
|
}
|
|
449
468
|
},
|
|
@@ -471,8 +490,180 @@ var SearchSidebar = ({
|
|
|
471
490
|
);
|
|
472
491
|
};
|
|
473
492
|
|
|
493
|
+
// src/components/viewers/pdf/PasswordDialog.tsx
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
var _Lock = require('@mui/icons-material/Lock'); var _Lock2 = _interopRequireDefault(_Lock);
|
|
510
|
+
var _Visibility = require('@mui/icons-material/Visibility'); var _Visibility2 = _interopRequireDefault(_Visibility);
|
|
511
|
+
var _VisibilityOff = require('@mui/icons-material/VisibilityOff'); var _VisibilityOff2 = _interopRequireDefault(_VisibilityOff);
|
|
512
|
+
|
|
513
|
+
var PasswordDialog = ({
|
|
514
|
+
open,
|
|
515
|
+
fileName,
|
|
516
|
+
onSubmit,
|
|
517
|
+
onCancel,
|
|
518
|
+
error
|
|
519
|
+
}) => {
|
|
520
|
+
const [password, setPassword] = _react.useState.call(void 0, "");
|
|
521
|
+
const [showPassword, setShowPassword] = _react.useState.call(void 0, false);
|
|
522
|
+
_react.useEffect.call(void 0, () => {
|
|
523
|
+
if (open) {
|
|
524
|
+
setPassword("");
|
|
525
|
+
setShowPassword(false);
|
|
526
|
+
}
|
|
527
|
+
}, [open]);
|
|
528
|
+
const handleSubmit = (e) => {
|
|
529
|
+
e.preventDefault();
|
|
530
|
+
if (password.trim()) {
|
|
531
|
+
onSubmit(password);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const handleTogglePasswordVisibility = () => {
|
|
535
|
+
setShowPassword(!showPassword);
|
|
536
|
+
};
|
|
537
|
+
const handleKeyPress = (e) => {
|
|
538
|
+
if (e.key === "Enter" && password.trim()) {
|
|
539
|
+
handleSubmit(e);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
543
|
+
_material.Dialog,
|
|
544
|
+
{
|
|
545
|
+
open,
|
|
546
|
+
onClose: onCancel,
|
|
547
|
+
maxWidth: "sm",
|
|
548
|
+
fullWidth: true,
|
|
549
|
+
PaperProps: {
|
|
550
|
+
sx: {
|
|
551
|
+
borderRadius: 2
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
children: [
|
|
555
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
556
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
|
|
557
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
558
|
+
_material.Box,
|
|
559
|
+
{
|
|
560
|
+
sx: {
|
|
561
|
+
width: 40,
|
|
562
|
+
height: 40,
|
|
563
|
+
borderRadius: "50%",
|
|
564
|
+
backgroundColor: "primary.light",
|
|
565
|
+
display: "flex",
|
|
566
|
+
alignItems: "center",
|
|
567
|
+
justifyContent: "center",
|
|
568
|
+
opacity: 0.9
|
|
569
|
+
},
|
|
570
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Lock2.default, { sx: { color: "white", fontSize: 20 } })
|
|
571
|
+
}
|
|
572
|
+
),
|
|
573
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
|
|
574
|
+
] }),
|
|
575
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
576
|
+
_material.IconButton,
|
|
577
|
+
{
|
|
578
|
+
size: "small",
|
|
579
|
+
onClick: onCancel,
|
|
580
|
+
sx: { color: "text.secondary" },
|
|
581
|
+
"aria-label": "Close dialog",
|
|
582
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Close2.default, { fontSize: "small" })
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
] }) }),
|
|
586
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogContent, { sx: { pt: 2 }, children: [
|
|
587
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
|
|
588
|
+
"This PDF is password protected. Please enter the password to view",
|
|
589
|
+
" ",
|
|
590
|
+
fileName && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
|
|
591
|
+
'"',
|
|
592
|
+
fileName,
|
|
593
|
+
'"'
|
|
594
|
+
] })
|
|
595
|
+
] }),
|
|
596
|
+
error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Alert, { severity: "error", sx: { mb: 2 }, children: error }),
|
|
597
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "form", { onSubmit: handleSubmit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
598
|
+
_material.TextField,
|
|
599
|
+
{
|
|
600
|
+
fullWidth: true,
|
|
601
|
+
autoFocus: true,
|
|
602
|
+
type: showPassword ? "text" : "password",
|
|
603
|
+
label: "Password",
|
|
604
|
+
placeholder: "Enter password",
|
|
605
|
+
value: password,
|
|
606
|
+
onChange: (e) => setPassword(e.target.value),
|
|
607
|
+
onKeyPress: handleKeyPress,
|
|
608
|
+
error: Boolean(error),
|
|
609
|
+
InputProps: {
|
|
610
|
+
endAdornment: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.InputAdornment, { position: "end", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
611
|
+
_material.IconButton,
|
|
612
|
+
{
|
|
613
|
+
onClick: handleTogglePasswordVisibility,
|
|
614
|
+
edge: "end",
|
|
615
|
+
size: "small",
|
|
616
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
617
|
+
children: showPassword ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _VisibilityOff2.default, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Visibility2.default, {})
|
|
618
|
+
}
|
|
619
|
+
) })
|
|
620
|
+
},
|
|
621
|
+
sx: {
|
|
622
|
+
"& .MuiOutlinedInput-root": {
|
|
623
|
+
borderRadius: 2
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
) })
|
|
628
|
+
] }),
|
|
629
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
|
|
630
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
631
|
+
_material.Button,
|
|
632
|
+
{
|
|
633
|
+
onClick: onCancel,
|
|
634
|
+
variant: "outlined",
|
|
635
|
+
sx: {
|
|
636
|
+
borderRadius: 2,
|
|
637
|
+
textTransform: "none",
|
|
638
|
+
px: 3
|
|
639
|
+
},
|
|
640
|
+
children: "Cancel"
|
|
641
|
+
}
|
|
642
|
+
),
|
|
643
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
644
|
+
_material.Button,
|
|
645
|
+
{
|
|
646
|
+
onClick: handleSubmit,
|
|
647
|
+
variant: "contained",
|
|
648
|
+
disabled: !password.trim(),
|
|
649
|
+
sx: {
|
|
650
|
+
borderRadius: 2,
|
|
651
|
+
textTransform: "none",
|
|
652
|
+
px: 3,
|
|
653
|
+
boxShadow: 2
|
|
654
|
+
},
|
|
655
|
+
children: "Unlock PDF"
|
|
656
|
+
}
|
|
657
|
+
)
|
|
658
|
+
] })
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
};
|
|
663
|
+
|
|
474
664
|
// src/components/viewers/PDFViewer.tsx
|
|
475
665
|
|
|
666
|
+
var HeadlessPDFViewer = _pdfviewer.PDFViewer;
|
|
476
667
|
var toolbarStyles = `
|
|
477
668
|
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');
|
|
478
669
|
|
|
@@ -502,7 +693,7 @@ var toolbarStyles = `
|
|
|
502
693
|
.pdf-viewer-header {
|
|
503
694
|
display: flex;
|
|
504
695
|
align-items: center;
|
|
505
|
-
justify-content:
|
|
696
|
+
justify-content: flex-start;
|
|
506
697
|
gap: 8px;
|
|
507
698
|
padding: 3px 16px 0 16px;
|
|
508
699
|
background: #fff;
|
|
@@ -641,7 +832,9 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
641
832
|
onMetadataClick,
|
|
642
833
|
onPropertiesClick,
|
|
643
834
|
onDownloadClick,
|
|
644
|
-
onPrintClick
|
|
835
|
+
onPrintClick,
|
|
836
|
+
initialSearchText,
|
|
837
|
+
initialSearchPages
|
|
645
838
|
} = props;
|
|
646
839
|
const [pdfBuffer, setPdfBuffer] = _react.useState.call(void 0, null);
|
|
647
840
|
const [state, setState] = _react.useState.call(void 0, "idle");
|
|
@@ -670,6 +863,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
670
863
|
const [searchResults, setSearchResults] = _react.useState.call(void 0, []);
|
|
671
864
|
const [currentSearchResultIndex, setCurrentSearchResultIndex] = _react.useState.call(void 0, 0);
|
|
672
865
|
const [totalSearchResults, setTotalSearchResults] = _react.useState.call(void 0, 0);
|
|
866
|
+
const [autoExecuteSearch, setAutoExecuteSearch] = _react.useState.call(void 0, !!initialSearchText);
|
|
867
|
+
const [isPasswordDialogOpen, setIsPasswordDialogOpen] = _react.useState.call(void 0, false);
|
|
868
|
+
const [passwordError, setPasswordError] = _react.useState.call(void 0, "");
|
|
869
|
+
const [passwordResolve, setPasswordResolve] = _react.useState.call(void 0, null);
|
|
673
870
|
_react.useEffect.call(void 0, () => {
|
|
674
871
|
setSearchQuery("");
|
|
675
872
|
setSearchResults([]);
|
|
@@ -685,79 +882,102 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
685
882
|
setPdfBuffer(null);
|
|
686
883
|
}, [file]);
|
|
687
884
|
_react.useEffect.call(void 0, () => {
|
|
688
|
-
if (state
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
}, 500);
|
|
885
|
+
if (state !== "ready") return;
|
|
886
|
+
const container = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
|
|
887
|
+
if (container) {
|
|
888
|
+
setPdfContainer(container);
|
|
889
|
+
return;
|
|
695
890
|
}
|
|
891
|
+
const observer = new MutationObserver(() => {
|
|
892
|
+
const foundContainer = document.querySelector('[data-pdf-viewer], .embedpdf-viewport, [role="document"]');
|
|
893
|
+
if (foundContainer) {
|
|
894
|
+
setPdfContainer(foundContainer);
|
|
895
|
+
observer.disconnect();
|
|
896
|
+
}
|
|
897
|
+
});
|
|
898
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
899
|
+
return () => observer.disconnect();
|
|
696
900
|
}, [state]);
|
|
697
901
|
_react.useEffect.call(void 0, () => {
|
|
698
|
-
if (state
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
let
|
|
702
|
-
|
|
703
|
-
await new Promise((resolve) =>
|
|
704
|
-
|
|
705
|
-
|
|
902
|
+
if (state !== "ready" || totalPages > 0) return;
|
|
903
|
+
const initializePageCount = async () => {
|
|
904
|
+
const waitForViewer = async (maxAttempts = 10) => {
|
|
905
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
906
|
+
if (pdfViewerRef.current) return pdfViewerRef.current;
|
|
907
|
+
await new Promise((resolve) => requestAnimationFrame(
|
|
908
|
+
() => setTimeout(resolve, Math.min(100 * Math.pow(2, i), 1e3))
|
|
909
|
+
));
|
|
706
910
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
911
|
+
return null;
|
|
912
|
+
};
|
|
913
|
+
const viewer = await waitForViewer();
|
|
914
|
+
if (!viewer) return;
|
|
915
|
+
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
916
|
+
try {
|
|
917
|
+
const count = _optionalChain([viewer, 'access', _ => _.navigation, 'optionalAccess', _2 => _2.getTotalPages, 'optionalCall', _3 => _3()]);
|
|
918
|
+
if (count && count > 1) {
|
|
919
|
+
setTotalPages(count);
|
|
920
|
+
return;
|
|
716
921
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
922
|
+
} catch (e) {
|
|
923
|
+
}
|
|
924
|
+
try {
|
|
925
|
+
const results = await _optionalChain([viewer, 'access', _4 => _4.search, 'optionalAccess', _5 => _5.searchText, 'optionalCall', _6 => _6("e")]);
|
|
926
|
+
if (_optionalChain([results, 'optionalAccess', _7 => _7.results]) && results.results.length > 0) {
|
|
927
|
+
const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
|
|
928
|
+
const count = Math.max(...pageIndices) + 1;
|
|
929
|
+
_optionalChain([viewer, 'access', _8 => _8.search, 'optionalAccess', _9 => _9.stopSearch, 'optionalCall', _10 => _10()]);
|
|
930
|
+
setTotalPages(count);
|
|
931
|
+
return;
|
|
727
932
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
if (pages && pages.length > 0) {
|
|
933
|
+
} catch (error2) {
|
|
934
|
+
}
|
|
935
|
+
try {
|
|
936
|
+
const selectors = [
|
|
937
|
+
"[data-page-index]",
|
|
938
|
+
"[data-page-number]",
|
|
939
|
+
".embedpdf-page",
|
|
940
|
+
'[role="article"]',
|
|
941
|
+
"canvas[data-page]",
|
|
942
|
+
".react-pdf__Page"
|
|
943
|
+
];
|
|
944
|
+
for (const selector of selectors) {
|
|
945
|
+
const pages = document.querySelectorAll(selector);
|
|
946
|
+
if (pages.length > 0) {
|
|
744
947
|
setTotalPages(pages.length);
|
|
745
948
|
return;
|
|
746
949
|
}
|
|
747
|
-
} catch (error2) {
|
|
748
950
|
}
|
|
749
|
-
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
}
|
|
951
|
+
} catch (error2) {
|
|
952
|
+
}
|
|
953
|
+
setTotalPages(1);
|
|
954
|
+
};
|
|
955
|
+
initializePageCount();
|
|
753
956
|
}, [state, totalPages]);
|
|
957
|
+
_react.useEffect.call(void 0, () => {
|
|
958
|
+
if (state !== "ready" || !autoExecuteSearch || !initialSearchText) return;
|
|
959
|
+
const scheduleSearch = (callback) => {
|
|
960
|
+
if ("requestIdleCallback" in window) {
|
|
961
|
+
requestIdleCallback(callback, { timeout: 2e3 });
|
|
962
|
+
} else {
|
|
963
|
+
requestAnimationFrame(() => setTimeout(callback, 0));
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
scheduleSearch(() => {
|
|
967
|
+
if (!pdfViewerRef.current) return;
|
|
968
|
+
setIsSidebarOpen(true);
|
|
969
|
+
setSearchQuery(initialSearchText);
|
|
970
|
+
handleSidebarSearch(initialSearchText, initialSearchPages);
|
|
971
|
+
setAutoExecuteSearch(false);
|
|
972
|
+
});
|
|
973
|
+
}, [state, autoExecuteSearch, initialSearchText, initialSearchPages]);
|
|
754
974
|
_react.useEffect.call(void 0, () => {
|
|
755
975
|
if (state === "ready" && pdfViewerRef.current) {
|
|
756
976
|
const updateInfo = () => {
|
|
757
|
-
const current = _optionalChain([pdfViewerRef, 'access',
|
|
758
|
-
const total = _optionalChain([pdfViewerRef, 'access',
|
|
759
|
-
const zoomValue = _optionalChain([pdfViewerRef, 'access',
|
|
760
|
-
const currentSearchState = _optionalChain([pdfViewerRef, 'access',
|
|
977
|
+
const current = _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.navigation, 'access', _13 => _13.getCurrentPage, 'call', _14 => _14()]) || 1;
|
|
978
|
+
const total = _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.navigation, 'access', _17 => _17.getTotalPages, 'call', _18 => _18()]) || 0;
|
|
979
|
+
const zoomValue = _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.getZoom, 'call', _22 => _22()]);
|
|
980
|
+
const currentSearchState = _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.search, 'access', _25 => _25.getSearchState, 'call', _26 => _26()]);
|
|
761
981
|
setCurrentPage(current);
|
|
762
982
|
if (total > 0 && total !== totalPages) {
|
|
763
983
|
setTotalPages(total);
|
|
@@ -773,115 +993,115 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
773
993
|
}, [state, totalPages]);
|
|
774
994
|
_react.useImperativeHandle.call(void 0, ref, () => ({
|
|
775
995
|
zoomIn: () => {
|
|
776
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
996
|
+
_optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.zoomIn, 'call', _30 => _30()]);
|
|
777
997
|
updateZoomDisplay();
|
|
778
998
|
},
|
|
779
999
|
zoomOut: () => {
|
|
780
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1000
|
+
_optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.zoomOut, 'call', _34 => _34()]);
|
|
781
1001
|
updateZoomDisplay();
|
|
782
1002
|
},
|
|
783
1003
|
setZoom: (level) => {
|
|
784
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1004
|
+
_optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.zoom, 'access', _37 => _37.setZoom, 'call', _38 => _38(level)]);
|
|
785
1005
|
updateZoomDisplay();
|
|
786
1006
|
},
|
|
787
1007
|
resetZoom: () => {
|
|
788
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1008
|
+
_optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.zoom, 'access', _41 => _41.resetZoom, 'call', _42 => _42()]);
|
|
789
1009
|
updateZoomDisplay();
|
|
790
1010
|
},
|
|
791
1011
|
getZoom: () => {
|
|
792
|
-
const zoom2 = _optionalChain([pdfViewerRef, 'access',
|
|
1012
|
+
const zoom2 = _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.zoom, 'access', _45 => _45.getZoom, 'call', _46 => _46()]);
|
|
793
1013
|
return typeof zoom2 === "number" ? zoom2 : 1;
|
|
794
1014
|
},
|
|
795
1015
|
goToPage: (page) => {
|
|
796
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1016
|
+
_optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.goToPage, 'call', _50 => _50(page)]);
|
|
797
1017
|
setCurrentPage(page);
|
|
798
1018
|
},
|
|
799
|
-
getCurrentPage: () => _optionalChain([pdfViewerRef, 'access',
|
|
800
|
-
getTotalPages: () => _optionalChain([pdfViewerRef, 'access',
|
|
1019
|
+
getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.getCurrentPage, 'call', _54 => _54()]) || 1,
|
|
1020
|
+
getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.getTotalPages, 'call', _58 => _58()]) || 0,
|
|
801
1021
|
nextPage: () => {
|
|
802
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1022
|
+
_optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.nextPage, 'call', _62 => _62()]);
|
|
803
1023
|
updatePageDisplay();
|
|
804
1024
|
},
|
|
805
1025
|
previousPage: () => {
|
|
806
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1026
|
+
_optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.previousPage, 'call', _66 => _66()]);
|
|
807
1027
|
updatePageDisplay();
|
|
808
1028
|
},
|
|
809
1029
|
goToFirstPage: () => {
|
|
810
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1030
|
+
_optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.goToFirstPage, 'call', _70 => _70()]);
|
|
811
1031
|
updatePageDisplay();
|
|
812
1032
|
},
|
|
813
1033
|
goToLastPage: () => {
|
|
814
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1034
|
+
_optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToLastPage, 'call', _74 => _74()]);
|
|
815
1035
|
updatePageDisplay();
|
|
816
1036
|
},
|
|
817
1037
|
searchText: async (keyword) => {
|
|
818
1038
|
setIsSearching(true);
|
|
819
|
-
const results = await _optionalChain([pdfViewerRef, 'access',
|
|
1039
|
+
const results = await _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.search, 'access', _77 => _77.searchText, 'call', _78 => _78(keyword)]);
|
|
820
1040
|
setIsSearching(false);
|
|
821
1041
|
setSearchQuery(keyword);
|
|
822
1042
|
return results;
|
|
823
1043
|
},
|
|
824
1044
|
nextResult: () => {
|
|
825
|
-
const index = _optionalChain([pdfViewerRef, 'access',
|
|
1045
|
+
const index = _optionalChain([pdfViewerRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.search, 'access', _81 => _81.nextResult, 'call', _82 => _82()]) || -1;
|
|
826
1046
|
return index;
|
|
827
1047
|
},
|
|
828
1048
|
previousResult: () => {
|
|
829
|
-
const index = _optionalChain([pdfViewerRef, 'access',
|
|
1049
|
+
const index = _optionalChain([pdfViewerRef, 'access', _83 => _83.current, 'optionalAccess', _84 => _84.search, 'access', _85 => _85.previousResult, 'call', _86 => _86()]) || -1;
|
|
830
1050
|
return index;
|
|
831
1051
|
},
|
|
832
|
-
goToResult: (index) => _optionalChain([pdfViewerRef, 'access',
|
|
1052
|
+
goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _87 => _87.current, 'optionalAccess', _88 => _88.search, 'access', _89 => _89.goToResult, 'call', _90 => _90(index)]) || -1,
|
|
833
1053
|
stopSearch: () => {
|
|
834
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1054
|
+
_optionalChain([pdfViewerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.search, 'access', _93 => _93.stopSearch, 'call', _94 => _94()]);
|
|
835
1055
|
setSearchQuery("");
|
|
836
1056
|
},
|
|
837
|
-
getSearchState: () => _optionalChain([pdfViewerRef, 'access',
|
|
838
|
-
getSelectedText: () => _optionalChain([pdfViewerRef, 'access',
|
|
839
|
-
clearSelection: () => _optionalChain([pdfViewerRef, 'access',
|
|
1057
|
+
getSearchState: () => _optionalChain([pdfViewerRef, 'access', _95 => _95.current, 'optionalAccess', _96 => _96.search, 'access', _97 => _97.getSearchState, 'call', _98 => _98()]) || null,
|
|
1058
|
+
getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.selection, 'access', _101 => _101.getSelectedText, 'call', _102 => _102()]) || "",
|
|
1059
|
+
clearSelection: () => _optionalChain([pdfViewerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.selection, 'access', _105 => _105.clearSelection, 'call', _106 => _106()])
|
|
840
1060
|
}), []);
|
|
841
1061
|
const updatePageDisplay = () => {
|
|
842
|
-
|
|
843
|
-
const current = _optionalChain([pdfViewerRef, 'access',
|
|
1062
|
+
requestAnimationFrame(() => {
|
|
1063
|
+
const current = _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.navigation, 'access', _109 => _109.getCurrentPage, 'call', _110 => _110()]) || 1;
|
|
844
1064
|
setCurrentPage(current);
|
|
845
|
-
}
|
|
1065
|
+
});
|
|
846
1066
|
};
|
|
847
1067
|
const updateZoomDisplay = () => {
|
|
848
|
-
|
|
849
|
-
const zoomValue = _optionalChain([pdfViewerRef, 'access',
|
|
1068
|
+
requestAnimationFrame(() => {
|
|
1069
|
+
const zoomValue = _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.zoom, 'access', _113 => _113.getZoom, 'call', _114 => _114()]);
|
|
850
1070
|
if (typeof zoomValue === "number") {
|
|
851
1071
|
setZoom(Math.round(zoomValue * 100));
|
|
852
1072
|
}
|
|
853
|
-
}
|
|
1073
|
+
});
|
|
854
1074
|
};
|
|
855
1075
|
const handleZoomIn = () => {
|
|
856
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1076
|
+
_optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.zoom, 'access', _117 => _117.zoomIn, 'call', _118 => _118()]);
|
|
857
1077
|
updateZoomDisplay();
|
|
858
1078
|
};
|
|
859
1079
|
const handleZoomOut = () => {
|
|
860
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1080
|
+
_optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.zoom, 'access', _121 => _121.zoomOut, 'call', _122 => _122()]);
|
|
861
1081
|
updateZoomDisplay();
|
|
862
1082
|
};
|
|
863
1083
|
const handleFitToWidth = () => {
|
|
864
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1084
|
+
_optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.zoom, 'access', _125 => _125.fitToWidth, 'call', _126 => _126()]);
|
|
865
1085
|
updateZoomDisplay();
|
|
866
1086
|
};
|
|
867
1087
|
const handleFitToPage = () => {
|
|
868
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1088
|
+
_optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.zoom, 'access', _129 => _129.fitToPage, 'call', _130 => _130()]);
|
|
869
1089
|
updateZoomDisplay();
|
|
870
1090
|
};
|
|
871
1091
|
const handlePreviousPage = () => {
|
|
872
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1092
|
+
_optionalChain([pdfViewerRef, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.navigation, 'access', _133 => _133.previousPage, 'call', _134 => _134()]);
|
|
873
1093
|
updatePageDisplay();
|
|
874
1094
|
};
|
|
875
1095
|
const handleNextPage = () => {
|
|
876
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1096
|
+
_optionalChain([pdfViewerRef, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.navigation, 'access', _137 => _137.nextPage, 'call', _138 => _138()]);
|
|
877
1097
|
updatePageDisplay();
|
|
878
1098
|
};
|
|
879
1099
|
const handleFirstPage = () => {
|
|
880
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1100
|
+
_optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.navigation, 'access', _141 => _141.goToFirstPage, 'call', _142 => _142()]);
|
|
881
1101
|
updatePageDisplay();
|
|
882
1102
|
};
|
|
883
1103
|
const handleLastPage = () => {
|
|
884
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1104
|
+
_optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.navigation, 'access', _145 => _145.goToLastPage, 'call', _146 => _146()]);
|
|
885
1105
|
updatePageDisplay();
|
|
886
1106
|
};
|
|
887
1107
|
const handlePageInput = (e) => {
|
|
@@ -891,7 +1111,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
891
1111
|
return;
|
|
892
1112
|
}
|
|
893
1113
|
if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
|
|
894
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1114
|
+
_optionalChain([pdfViewerRef, 'access', _147 => _147.current, 'optionalAccess', _148 => _148.navigation, 'access', _149 => _149.goToPage, 'call', _150 => _150(page)]);
|
|
895
1115
|
setCurrentPage(page);
|
|
896
1116
|
}
|
|
897
1117
|
};
|
|
@@ -900,7 +1120,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
900
1120
|
const value = e.target.value;
|
|
901
1121
|
const page = parseInt(value, 10);
|
|
902
1122
|
if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
|
|
903
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1123
|
+
_optionalChain([pdfViewerRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.navigation, 'access', _153 => _153.goToPage, 'call', _154 => _154(page)]);
|
|
904
1124
|
setCurrentPage(page);
|
|
905
1125
|
}
|
|
906
1126
|
}
|
|
@@ -908,7 +1128,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
908
1128
|
const handleSearch = async () => {
|
|
909
1129
|
if (searchQuery.trim()) {
|
|
910
1130
|
setIsSearching(true);
|
|
911
|
-
const results = await _optionalChain([pdfViewerRef, 'access',
|
|
1131
|
+
const results = await _optionalChain([pdfViewerRef, 'access', _155 => _155.current, 'optionalAccess', _156 => _156.search, 'access', _157 => _157.searchText, 'call', _158 => _158(searchQuery)]);
|
|
912
1132
|
setIsSearching(false);
|
|
913
1133
|
if (results && results.results) {
|
|
914
1134
|
const formattedResults = results.results.map((result, index) => {
|
|
@@ -952,13 +1172,13 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
952
1172
|
handleSearch();
|
|
953
1173
|
}
|
|
954
1174
|
};
|
|
955
|
-
const handleSidebarSearch = async (keyword) => {
|
|
1175
|
+
const handleSidebarSearch = async (keyword, pageNumbers) => {
|
|
956
1176
|
setSearchQuery(keyword);
|
|
957
1177
|
if (keyword.trim()) {
|
|
958
1178
|
setIsSearching(true);
|
|
959
|
-
const results = await _optionalChain([pdfViewerRef, 'access',
|
|
1179
|
+
const results = await _optionalChain([pdfViewerRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.search, 'access', _161 => _161.searchText, 'call', _162 => _162(keyword)]);
|
|
960
1180
|
setIsSearching(false);
|
|
961
|
-
if (results && results.results) {
|
|
1181
|
+
if (results && results.results && results.results.length > 0) {
|
|
962
1182
|
const formattedResults = results.results.map((result, index) => {
|
|
963
1183
|
let textContent = "";
|
|
964
1184
|
let contextContent = "";
|
|
@@ -987,9 +1207,21 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
987
1207
|
setCurrentSearchResultIndex(0);
|
|
988
1208
|
if (formattedResults.length > 0) {
|
|
989
1209
|
const firstPageNumber = formattedResults[0].pageNumber;
|
|
990
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1210
|
+
_optionalChain([pdfViewerRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.navigation, 'access', _165 => _165.goToPage, 'call', _166 => _166(firstPageNumber)]);
|
|
991
1211
|
setCurrentPage(firstPageNumber);
|
|
992
1212
|
}
|
|
1213
|
+
} else if (pageNumbers && pageNumbers.length > 0) {
|
|
1214
|
+
const fallbackResults = pageNumbers.map((pageNum, index) => ({
|
|
1215
|
+
pageNumber: pageNum,
|
|
1216
|
+
text: keyword,
|
|
1217
|
+
context: `"${keyword}" found on this page ${pageNum}`,
|
|
1218
|
+
index
|
|
1219
|
+
}));
|
|
1220
|
+
setSearchResults(fallbackResults);
|
|
1221
|
+
setTotalSearchResults(fallbackResults.length);
|
|
1222
|
+
setCurrentSearchResultIndex(0);
|
|
1223
|
+
_optionalChain([pdfViewerRef, 'access', _167 => _167.current, 'optionalAccess', _168 => _168.navigation, 'access', _169 => _169.goToPage, 'call', _170 => _170(pageNumbers[0])]);
|
|
1224
|
+
setCurrentPage(pageNumbers[0]);
|
|
993
1225
|
} else {
|
|
994
1226
|
setSearchResults([]);
|
|
995
1227
|
setTotalSearchResults(0);
|
|
@@ -997,16 +1229,16 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
997
1229
|
}
|
|
998
1230
|
} else {
|
|
999
1231
|
setSearchResults([]);
|
|
1000
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1232
|
+
_optionalChain([pdfViewerRef, 'access', _171 => _171.current, 'optionalAccess', _172 => _172.search, 'access', _173 => _173.stopSearch, 'call', _174 => _174()]);
|
|
1001
1233
|
setTotalSearchResults(0);
|
|
1002
1234
|
setCurrentSearchResultIndex(0);
|
|
1003
1235
|
}
|
|
1004
1236
|
};
|
|
1005
1237
|
const handleSearchResultClick = (pageNumber, resultIndex) => {
|
|
1006
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1238
|
+
_optionalChain([pdfViewerRef, 'access', _175 => _175.current, 'optionalAccess', _176 => _176.navigation, 'access', _177 => _177.goToPage, 'call', _178 => _178(pageNumber)]);
|
|
1007
1239
|
setCurrentSearchResultIndex(resultIndex);
|
|
1008
1240
|
setCurrentPage(pageNumber);
|
|
1009
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1241
|
+
_optionalChain([pdfViewerRef, 'access', _179 => _179.current, 'optionalAccess', _180 => _180.search, 'access', _181 => _181.goToResult, 'call', _182 => _182(resultIndex)]);
|
|
1010
1242
|
};
|
|
1011
1243
|
const toggleSidebar = () => {
|
|
1012
1244
|
setIsSidebarOpen(!isSidebarOpen);
|
|
@@ -1015,10 +1247,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
1015
1247
|
if (currentSearchResultIndex < totalSearchResults - 1) {
|
|
1016
1248
|
const nextIndex = currentSearchResultIndex + 1;
|
|
1017
1249
|
setCurrentSearchResultIndex(nextIndex);
|
|
1018
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1250
|
+
_optionalChain([pdfViewerRef, 'access', _183 => _183.current, 'optionalAccess', _184 => _184.search, 'access', _185 => _185.nextResult, 'call', _186 => _186()]);
|
|
1019
1251
|
if (searchResults[nextIndex]) {
|
|
1020
1252
|
const pageNumber = searchResults[nextIndex].pageNumber;
|
|
1021
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1253
|
+
_optionalChain([pdfViewerRef, 'access', _187 => _187.current, 'optionalAccess', _188 => _188.navigation, 'access', _189 => _189.goToPage, 'call', _190 => _190(pageNumber)]);
|
|
1022
1254
|
setCurrentPage(pageNumber);
|
|
1023
1255
|
}
|
|
1024
1256
|
}
|
|
@@ -1027,30 +1259,14 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
1027
1259
|
if (currentSearchResultIndex > 0) {
|
|
1028
1260
|
const prevIndex = currentSearchResultIndex - 1;
|
|
1029
1261
|
setCurrentSearchResultIndex(prevIndex);
|
|
1030
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1262
|
+
_optionalChain([pdfViewerRef, 'access', _191 => _191.current, 'optionalAccess', _192 => _192.search, 'access', _193 => _193.previousResult, 'call', _194 => _194()]);
|
|
1031
1263
|
if (searchResults[prevIndex]) {
|
|
1032
1264
|
const pageNumber = searchResults[prevIndex].pageNumber;
|
|
1033
|
-
_optionalChain([pdfViewerRef, 'access',
|
|
1265
|
+
_optionalChain([pdfViewerRef, 'access', _195 => _195.current, 'optionalAccess', _196 => _196.navigation, 'access', _197 => _197.goToPage, 'call', _198 => _198(pageNumber)]);
|
|
1034
1266
|
setCurrentPage(pageNumber);
|
|
1035
1267
|
}
|
|
1036
1268
|
}
|
|
1037
1269
|
};
|
|
1038
|
-
const handleDownload = () => {
|
|
1039
|
-
if (onDownloadClick) {
|
|
1040
|
-
onDownloadClick();
|
|
1041
|
-
return;
|
|
1042
|
-
}
|
|
1043
|
-
if (!pdfBuffer) return;
|
|
1044
|
-
const blob = new Blob([pdfBuffer], { type: "application/pdf" });
|
|
1045
|
-
const url = URL.createObjectURL(blob);
|
|
1046
|
-
const link = document.createElement("a");
|
|
1047
|
-
link.href = url;
|
|
1048
|
-
link.download = resolvedFileName;
|
|
1049
|
-
document.body.appendChild(link);
|
|
1050
|
-
link.click();
|
|
1051
|
-
document.body.removeChild(link);
|
|
1052
|
-
URL.revokeObjectURL(url);
|
|
1053
|
-
};
|
|
1054
1270
|
const handlePrint = () => {
|
|
1055
1271
|
if (onPrintClick) {
|
|
1056
1272
|
onPrintClick();
|
|
@@ -1069,28 +1285,42 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
1069
1285
|
document.body.appendChild(iframe);
|
|
1070
1286
|
iframe.onload = () => {
|
|
1071
1287
|
try {
|
|
1072
|
-
|
|
1288
|
+
requestAnimationFrame(() => {
|
|
1073
1289
|
const iframeWindow = iframe.contentWindow;
|
|
1074
1290
|
if (!iframeWindow) return;
|
|
1075
1291
|
iframeWindow.focus();
|
|
1076
1292
|
iframeWindow.print();
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1293
|
+
const cleanup = () => {
|
|
1294
|
+
requestAnimationFrame(() => {
|
|
1079
1295
|
try {
|
|
1080
|
-
document.body.
|
|
1296
|
+
if (document.body.contains(iframe)) {
|
|
1297
|
+
document.body.removeChild(iframe);
|
|
1298
|
+
}
|
|
1081
1299
|
URL.revokeObjectURL(blobUrl);
|
|
1082
1300
|
} catch (e) {
|
|
1083
1301
|
}
|
|
1084
|
-
}
|
|
1302
|
+
});
|
|
1085
1303
|
};
|
|
1086
1304
|
if ("onafterprint" in iframeWindow) {
|
|
1087
|
-
iframeWindow.onafterprint =
|
|
1305
|
+
iframeWindow.onafterprint = cleanup;
|
|
1088
1306
|
} else {
|
|
1089
|
-
|
|
1307
|
+
const visibilityHandler = () => {
|
|
1308
|
+
if (!document.hidden) {
|
|
1309
|
+
cleanup();
|
|
1310
|
+
document.removeEventListener("visibilitychange", visibilityHandler);
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
document.addEventListener("visibilitychange", visibilityHandler);
|
|
1314
|
+
setTimeout(() => {
|
|
1315
|
+
cleanup();
|
|
1316
|
+
document.removeEventListener("visibilitychange", visibilityHandler);
|
|
1317
|
+
}, 5e3);
|
|
1090
1318
|
}
|
|
1091
|
-
}
|
|
1319
|
+
});
|
|
1092
1320
|
} catch (error2) {
|
|
1093
|
-
document.body.
|
|
1321
|
+
if (document.body.contains(iframe)) {
|
|
1322
|
+
document.body.removeChild(iframe);
|
|
1323
|
+
}
|
|
1094
1324
|
URL.revokeObjectURL(blobUrl);
|
|
1095
1325
|
}
|
|
1096
1326
|
};
|
|
@@ -1126,21 +1356,39 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
|
|
|
1126
1356
|
}
|
|
1127
1357
|
setPdfBuffer(arrayBuffer);
|
|
1128
1358
|
setState("ready");
|
|
1129
|
-
_optionalChain([onLoad, 'optionalCall',
|
|
1359
|
+
_optionalChain([onLoad, 'optionalCall', _199 => _199()]);
|
|
1130
1360
|
} catch (err) {
|
|
1131
1361
|
const errorMessage = err.message || "Failed to load PDF";
|
|
1132
1362
|
setState("error");
|
|
1133
1363
|
setError(errorMessage);
|
|
1134
|
-
_optionalChain([onError, 'optionalCall',
|
|
1364
|
+
_optionalChain([onError, 'optionalCall', _200 => _200(err)]);
|
|
1135
1365
|
}
|
|
1136
1366
|
};
|
|
1137
1367
|
loadPDF();
|
|
1138
1368
|
}, [file, onLoad, onError]);
|
|
1139
1369
|
const handlePasswordRequest = _react.useCallback.call(void 0, async (fileName2) => {
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1370
|
+
return new Promise((resolve) => {
|
|
1371
|
+
setPasswordResolve(() => resolve);
|
|
1372
|
+
setPasswordError("");
|
|
1373
|
+
setIsPasswordDialogOpen(true);
|
|
1374
|
+
});
|
|
1143
1375
|
}, []);
|
|
1376
|
+
const handlePasswordSubmit = _react.useCallback.call(void 0, (password) => {
|
|
1377
|
+
if (passwordResolve) {
|
|
1378
|
+
passwordResolve(password);
|
|
1379
|
+
setPasswordResolve(null);
|
|
1380
|
+
setIsPasswordDialogOpen(false);
|
|
1381
|
+
setPasswordError("");
|
|
1382
|
+
}
|
|
1383
|
+
}, [passwordResolve]);
|
|
1384
|
+
const handlePasswordCancel = _react.useCallback.call(void 0, () => {
|
|
1385
|
+
if (passwordResolve) {
|
|
1386
|
+
passwordResolve(null);
|
|
1387
|
+
setPasswordResolve(null);
|
|
1388
|
+
setIsPasswordDialogOpen(false);
|
|
1389
|
+
setPasswordError("");
|
|
1390
|
+
}
|
|
1391
|
+
}, [passwordResolve]);
|
|
1144
1392
|
if (state === "loading") {
|
|
1145
1393
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { style: {
|
|
1146
1394
|
display: "flex",
|
|
@@ -1366,11 +1614,14 @@ Enter password for ${fileName2 || "document"}:`);
|
|
|
1366
1614
|
] })
|
|
1367
1615
|
] }),
|
|
1368
1616
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "pdf-viewer-main", children: [
|
|
1369
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children:
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1617
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1618
|
+
HeadlessPDFViewer,
|
|
1619
|
+
{
|
|
1620
|
+
ref: pdfViewerRef,
|
|
1621
|
+
pdfBuffer,
|
|
1622
|
+
onPasswordRequest: handlePasswordRequest
|
|
1623
|
+
}
|
|
1624
|
+
) }),
|
|
1374
1625
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1375
1626
|
SearchSidebar,
|
|
1376
1627
|
{
|
|
@@ -1387,7 +1638,17 @@ Enter password for ${fileName2 || "document"}:`);
|
|
|
1387
1638
|
isSearching
|
|
1388
1639
|
}
|
|
1389
1640
|
)
|
|
1390
|
-
] })
|
|
1641
|
+
] }),
|
|
1642
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1643
|
+
PasswordDialog,
|
|
1644
|
+
{
|
|
1645
|
+
open: isPasswordDialogOpen,
|
|
1646
|
+
fileName: resolvedFileName,
|
|
1647
|
+
onSubmit: handlePasswordSubmit,
|
|
1648
|
+
onCancel: handlePasswordCancel,
|
|
1649
|
+
error: passwordError
|
|
1650
|
+
}
|
|
1651
|
+
)
|
|
1391
1652
|
] });
|
|
1392
1653
|
});
|
|
1393
1654
|
PDFViewerContent.displayName = "PDFViewerContent";
|
|
@@ -1399,4 +1660,4 @@ PDFViewer.displayName = "PDFViewer";
|
|
|
1399
1660
|
|
|
1400
1661
|
|
|
1401
1662
|
exports.PDFViewer = PDFViewer;
|
|
1402
|
-
//# sourceMappingURL=chunk-
|
|
1663
|
+
//# sourceMappingURL=chunk-DDT3GC3C.js.map
|