viewer
This commit is contained in:
@@ -875,9 +875,8 @@ const DetailPanel = ({
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
onOpenPreview(singleDoc.id);
|
onOpenPreview(singleDoc.id);
|
||||||
}}
|
}}
|
||||||
aria-label="Open preview"
|
aria-label="Maximize"
|
||||||
title="Open preview"
|
title="Maximize"
|
||||||
disabled={!singleHasPreview}
|
|
||||||
>
|
>
|
||||||
<WindowMaximizeIcon className="icon--flip-y" />
|
<WindowMaximizeIcon className="icon--flip-y" />
|
||||||
</button>,
|
</button>,
|
||||||
|
|||||||
@@ -73,9 +73,15 @@ const DocumentViewerPanel = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentType = (document.content_type || '').toLowerCase();
|
const normalizedContentType = (previewEntry.contentType
|
||||||
|
|| document.content_type
|
||||||
|
|| '')
|
||||||
|
.toLowerCase();
|
||||||
|
const isImage = normalizedContentType.startsWith('image/');
|
||||||
|
const isPdf = normalizedContentType === 'application/pdf'
|
||||||
|
|| normalizedContentType === 'application/x-pdf';
|
||||||
|
|
||||||
if (contentType.startsWith('image/')) {
|
if (isImage) {
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={previewEntry.url}
|
src={previewEntry.url}
|
||||||
@@ -86,6 +92,7 @@ const DocumentViewerPanel = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPdf) {
|
||||||
return (
|
return (
|
||||||
<iframe
|
<iframe
|
||||||
src={previewEntry.url}
|
src={previewEntry.url}
|
||||||
@@ -93,7 +100,33 @@ const DocumentViewerPanel = ({
|
|||||||
className="document-viewer__object"
|
className="document-viewer__object"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}, [previewEntry?.url, document]);
|
}
|
||||||
|
|
||||||
|
const displayContentType = document.content_type || previewEntry.contentType || 'this file type';
|
||||||
|
const displayFilename = previewEntry.filename
|
||||||
|
|| document.filename
|
||||||
|
|| document.original_name
|
||||||
|
|| 'download';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="document-viewer__unsupported">
|
||||||
|
<div className="document-viewer__unsupported-message">
|
||||||
|
Preview is not available for {displayContentType} files.
|
||||||
|
</div>
|
||||||
|
<div className="document-viewer__unsupported-filename">{displayFilename}</div>
|
||||||
|
<a
|
||||||
|
className="button-link document-viewer__unsupported-download"
|
||||||
|
href={previewEntry.url}
|
||||||
|
download={displayFilename}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<DownloadIcon />
|
||||||
|
<span>Download</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}, [previewEntry, document]);
|
||||||
|
|
||||||
const metadataPayload = useMemo(() => {
|
const metadataPayload = useMemo(() => {
|
||||||
if (!document || !document.metadata || Object.keys(document.metadata).length === 0) {
|
if (!document || !document.metadata || Object.keys(document.metadata).length === 0) {
|
||||||
|
|||||||
@@ -1053,6 +1053,38 @@ button.danger:hover:not([disabled]) {
|
|||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.document-viewer__unsupported {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
padding: 2rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
text-align: center;
|
||||||
|
background: var(--surface-subtle);
|
||||||
|
}
|
||||||
|
|
||||||
|
.document-viewer__unsupported-filename {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.document-viewer__unsupported-message {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: var(--fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.document-viewer__unsupported-download {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.document-viewer__unsupported-download svg {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
.tags-panel__body {
|
.tags-panel__body {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user