@@ -7,19 +7,25 @@ import { mayResolveUrl } from '@/lib/utils/mediaUrlUtils'
77import { pathBasename } from "@/lib/utils/pathUtils"
88import { useAppSelector } from '@/lib/hooks'
99
10- interface PdfCellRendererProps {
11- value : unknown
10+ interface PdfCellContentProps {
11+ /** URL that goes into the iframe — may be a regular URL or a data: URL. */
12+ pdfUrl : string
13+ /** User-friendly identifier shown in header and copied on click (e.g. original path or filename). */
14+ copyValue : string
15+ /** URL used for external open; defaults to copyValue when omitted. */
16+ openUrl ?: string
1217}
1318
14- const PdfCellRenderer = memo ( function PdfCellRenderer ( { value } : PdfCellRendererProps ) {
15- const tablePath = useAppSelector ( ( state ) => state . ui . tablePath )
16- const baseUrl = useAppSelector ( ( state ) => state . ui . baseUrl )
17- const originalUrl = String ( value ) . trim ( )
18-
19- const resolvedUrl = mayResolveUrl ( { value, tablePath, baseUrl } )
20-
21- // Extract filename from URL
22- const filename = pathBasename ( originalUrl )
19+ /**
20+ * Shared PDF cell content that renders a FileText-icon cell and an iframe popover.
21+ * Accepts both regular URLs and data: URLs (for inline BLOB bytes).
22+ */
23+ export const PdfCellContent = memo ( function PdfCellContent ( {
24+ pdfUrl,
25+ copyValue,
26+ openUrl,
27+ } : PdfCellContentProps ) {
28+ const filename = pathBasename ( copyValue )
2329
2430 const cellContent = (
2531 < div className = "flex items-center gap-2 px-2 py-1" >
@@ -30,7 +36,7 @@ const PdfCellRenderer = memo(function PdfCellRenderer({ value }: PdfCellRenderer
3036
3137 const popoverContent = (
3238 < iframe
33- src = { resolvedUrl }
39+ src = { pdfUrl }
3440 className = "w-full h-full border-0"
3541 title = "PDF Preview"
3642 />
@@ -40,11 +46,24 @@ const PdfCellRenderer = memo(function PdfCellRenderer({ value }: PdfCellRenderer
4046 < CellPopover
4147 cellContent = { cellContent }
4248 popoverContent = { popoverContent }
43- url = { resolvedUrl }
44- copyValue = { originalUrl }
49+ url = { openUrl ?? copyValue }
50+ copyValue = { copyValue }
4551 popoverClassName = "w-[600px] h-[500px]"
4652 />
4753 )
4854} )
4955
56+ interface PdfCellRendererProps {
57+ value : unknown
58+ }
59+
60+ const PdfCellRenderer = memo ( function PdfCellRenderer ( { value } : PdfCellRendererProps ) {
61+ const tablePath = useAppSelector ( ( state ) => state . ui . tablePath )
62+ const baseUrl = useAppSelector ( ( state ) => state . ui . baseUrl )
63+ const originalUrl = String ( value ) . trim ( )
64+ const resolvedUrl = mayResolveUrl ( { value, tablePath, baseUrl } )
65+
66+ return < PdfCellContent pdfUrl = { resolvedUrl } copyValue = { originalUrl } openUrl = { resolvedUrl } />
67+ } )
68+
5069export default PdfCellRenderer
0 commit comments