mimetype
This commit is contained in:
@@ -19,7 +19,7 @@ type DocumentLike = {
|
|||||||
|
|
||||||
type DocumentLink = {
|
type DocumentLink = {
|
||||||
url?: string;
|
url?: string;
|
||||||
contentType?: string | null;
|
mimeType?: string | null;
|
||||||
filename?: string | null;
|
filename?: string | null;
|
||||||
expiresAt?: number;
|
expiresAt?: number;
|
||||||
};
|
};
|
||||||
@@ -124,7 +124,7 @@ const useDocumentPreview = ({
|
|||||||
|
|
||||||
const entry: DocumentLink = {
|
const entry: DocumentLink = {
|
||||||
url: downloadUrl,
|
url: downloadUrl,
|
||||||
contentType: docResponse?.content_type || null,
|
mimeType: docResponse?.mime_type || null,
|
||||||
filename: docResponse?.filename,
|
filename: docResponse?.filename,
|
||||||
expiresAt: download?.expires_at,
|
expiresAt: download?.expires_at,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ import '../styles/workspace/workspace-cards.css';
|
|||||||
type Identifier = string | number;
|
type Identifier = string | number;
|
||||||
|
|
||||||
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
type TagLike = { id?: Identifier | null; label?: string; color?: string | null } | null;
|
||||||
type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
type DocumentLinkLike = { url?: string | null; mimeType?: string | null };
|
||||||
type OverlaySource = { url: string; alt?: string | null; contentType?: string | null };
|
type OverlaySource = { url: string; alt?: string | null; mimeType?: string | null };
|
||||||
|
|
||||||
export interface DeskDocument {
|
export interface DeskDocument {
|
||||||
id?: Identifier | null;
|
id?: Identifier | null;
|
||||||
@@ -68,7 +68,7 @@ interface OverlayOriginTransform {
|
|||||||
interface OverlayDisplay {
|
interface OverlayDisplay {
|
||||||
url: string;
|
url: string;
|
||||||
alt?: string | null;
|
alt?: string | null;
|
||||||
contentType?: string | null;
|
mimeType?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DocumentSizeInfo {
|
interface DocumentSizeInfo {
|
||||||
@@ -565,7 +565,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const docContentType = doc?.content_type ?? null;
|
const docMimeType = doc?.mime_type ?? null;
|
||||||
|
|
||||||
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
||||||
if (!entry?.url) {
|
if (!entry?.url) {
|
||||||
@@ -575,7 +575,7 @@ const DesktopWorkspace: React.FC<DesktopWorkspaceProps> = ({
|
|||||||
setOverlaySource({
|
setOverlaySource({
|
||||||
url: entry.url,
|
url: entry.url,
|
||||||
alt: doc.title,
|
alt: doc.title,
|
||||||
contentType: docContentType || undefined,
|
mimeType: docMimeType || undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import PdfViewer from '../preview/PdfViewer';
|
|||||||
type DocumentLike = {
|
type DocumentLike = {
|
||||||
id?: string | number;
|
id?: string | number;
|
||||||
title?: string;
|
title?: string;
|
||||||
content_type?: string | null;
|
mime_type?: string | null;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,13 +23,13 @@ type DisplayKind = 'image' | 'pdf';
|
|||||||
type DocumentLink = {
|
type DocumentLink = {
|
||||||
url: string;
|
url: string;
|
||||||
alt?: string;
|
alt?: string;
|
||||||
contentType?: string | null;
|
mimeType?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DocumentLikeWithPreview = DocumentLike & { documentLink?: DocumentLink };
|
type DocumentLikeWithPreview = DocumentLike & { documentLink?: DocumentLink };
|
||||||
|
|
||||||
const determineDisplayKind = (entry?: DocumentLink | null): DisplayKind => {
|
const determineDisplayKind = (entry?: DocumentLink | null): DisplayKind => {
|
||||||
const type = entry?.contentType?.toLowerCase?.() || '';
|
const type = entry?.mimeType?.toLowerCase?.() || '';
|
||||||
if (type.includes('pdf')) {
|
if (type.includes('pdf')) {
|
||||||
return 'pdf';
|
return 'pdf';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export interface SummaryDocument {
|
|||||||
title?: string | null;
|
title?: string | null;
|
||||||
original_name?: string | null;
|
original_name?: string | null;
|
||||||
filename?: string | null;
|
filename?: string | null;
|
||||||
content_type?: string | null;
|
mime_type?: string | null;
|
||||||
folder_id?: string | null;
|
folder_id?: string | null;
|
||||||
folder_name?: string;
|
folder_name?: string;
|
||||||
current_version?: DocumentVersion | null;
|
current_version?: DocumentVersion | null;
|
||||||
@@ -72,7 +72,7 @@ export interface MetadataDocumentLike {
|
|||||||
updated_at?: string | null;
|
updated_at?: string | null;
|
||||||
filename?: string | null;
|
filename?: string | null;
|
||||||
original_name?: string | null;
|
original_name?: string | null;
|
||||||
content_type?: string | null;
|
mime_type?: string | null;
|
||||||
metadata?: DocumentMetadataPayload | null;
|
metadata?: DocumentMetadataPayload | null;
|
||||||
current_version?: { checksum?: string | null } | null;
|
current_version?: { checksum?: string | null } | null;
|
||||||
}
|
}
|
||||||
@@ -105,7 +105,7 @@ export const describeDocumentSummary = (document?: SummaryDocument | null, optio
|
|||||||
{ key: 'updated', label: 'Updated at', value: formatDateLabel(doc.updated_at) },
|
{ key: 'updated', label: 'Updated at', value: formatDateLabel(doc.updated_at) },
|
||||||
{ key: 'folder', label: 'Folder', value: folderLabel, kind: 'folder' },
|
{ key: 'folder', label: 'Folder', value: folderLabel, kind: 'folder' },
|
||||||
{ key: 'size', label: 'Size', value: sizeLabel },
|
{ key: 'size', label: 'Size', value: sizeLabel },
|
||||||
{ key: 'content-type', label: 'Content type', value: doc.content_type || 'Unknown' },
|
{ key: 'mime-type', label: 'MIME type', value: doc.mime_type || 'Unknown' },
|
||||||
{ key: 'pages', label: 'Pages', value: pageCountLabel },
|
{ key: 'pages', label: 'Pages', value: pageCountLabel },
|
||||||
{ key: 'filename', label: 'Filename', value: doc.filename },
|
{ key: 'filename', label: 'Filename', value: doc.filename },
|
||||||
{ key: 'original-filename', label: 'Original filename', value: doc.original_name },
|
{ key: 'original-filename', label: 'Original filename', value: doc.original_name },
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ type Identifier = string | number;
|
|||||||
|
|
||||||
interface DocumentLinkLike {
|
interface DocumentLinkLike {
|
||||||
url?: string | null;
|
url?: string | null;
|
||||||
contentType?: string | null;
|
mimeType?: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Breadcrumb {
|
export interface Breadcrumb {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ interface DocumentsPanelProps extends DocumentsPanelInnerProps {
|
|||||||
|
|
||||||
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
const defaultGetDocumentAsset = (_doc?: unknown, _type?: string) => null;
|
||||||
|
|
||||||
export type DocumentLinkLike = { url?: string | null; contentType?: string | null };
|
export type DocumentLinkLike = { url?: string | null; mimeType?: string | null };
|
||||||
|
|
||||||
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
||||||
headerLeading = null,
|
headerLeading = null,
|
||||||
@@ -257,7 +257,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
const isDeskView = viewMode === 'desk';
|
const isDeskView = viewMode === 'desk';
|
||||||
|
|
||||||
type Identifier = string | number;
|
type Identifier = string | number;
|
||||||
type ZoomSource = { url: string; alt?: string | null; contentType?: string | null };
|
type ZoomSource = { url: string; alt?: string | null; mimeType?: string | null };
|
||||||
|
|
||||||
const [previewDocId, setPreviewDocId] = useState<Identifier | null>(null);
|
const [previewDocId, setPreviewDocId] = useState<Identifier | null>(null);
|
||||||
|
|
||||||
@@ -290,9 +290,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
cancelled = true;
|
cancelled = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const docContentType = previewDoc.content_type;
|
const documentMimeType = previewDoc.mime_type;
|
||||||
const versionContentType = previewDoc.current_version?.content_type;
|
|
||||||
const contentFallback = docContentType || versionContentType || null;
|
|
||||||
|
|
||||||
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
const applyEntry = (entry?: DocumentLinkLike | null) => {
|
||||||
if (!entry?.url) {
|
if (!entry?.url) {
|
||||||
@@ -302,7 +300,7 @@ const DocumentsPanelInner: React.FC<DocumentsPanelInnerProps> = ({
|
|||||||
setPreviewZoomSource({
|
setPreviewZoomSource({
|
||||||
url: entry.url,
|
url: entry.url,
|
||||||
alt: previewDoc.title,
|
alt: previewDoc.title,
|
||||||
contentType: entry.contentType || contentFallback || undefined,
|
mimeType: documentMimeType,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export interface DocumentVersionResponse {
|
|||||||
size_bytes: number;
|
size_bytes: number;
|
||||||
checksum: string;
|
checksum: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
content_type: string | null;
|
mime_type?: string | null;
|
||||||
metadata: Record<string, unknown>;
|
metadata: Record<string, unknown>;
|
||||||
download: DownloadLink;
|
download: DownloadLink;
|
||||||
assets?: AssetResponse[] | null;
|
assets?: AssetResponse[] | null;
|
||||||
@@ -44,7 +44,7 @@ export interface DocumentResponse {
|
|||||||
filename: string;
|
filename: string;
|
||||||
title: string;
|
title: string;
|
||||||
original_name: string;
|
original_name: string;
|
||||||
content_type?: string | null;
|
mime_type?: string | null;
|
||||||
folder_id?: string | null;
|
folder_id?: string | null;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import PdfViewer from './PdfViewer';
|
|||||||
interface DocumentLike {
|
interface DocumentLike {
|
||||||
id?: string | number;
|
id?: string | number;
|
||||||
title?: string;
|
title?: string;
|
||||||
content_type?: string;
|
mime_type?: string;
|
||||||
filename?: string;
|
filename?: string;
|
||||||
original_name?: string;
|
original_name?: string;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
@@ -15,7 +15,7 @@ interface DocumentLike {
|
|||||||
|
|
||||||
interface DocumentLink {
|
interface DocumentLink {
|
||||||
url?: string;
|
url?: string;
|
||||||
contentType?: string;
|
mimeType?: string;
|
||||||
filename?: string;
|
filename?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ const DocumentViewerLayout = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const normalizedContentType = (documentLink.contentType
|
const normalizedMimeType = (documentLink.mimeType
|
||||||
|| document.content_type
|
|| document.mime_type
|
||||||
|| '')
|
|| '')
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
const normalizedFilename = documentLink.filename
|
const normalizedFilename = documentLink.filename
|
||||||
@@ -109,12 +109,12 @@ const DocumentViewerLayout = ({
|
|||||||
|| document.original_name
|
|| document.original_name
|
||||||
|| '';
|
|| '';
|
||||||
const fileExtension = getFileExtension(normalizedFilename);
|
const fileExtension = getFileExtension(normalizedFilename);
|
||||||
const isImage = normalizedContentType.startsWith('image/');
|
const isImage = normalizedMimeType.startsWith('image/');
|
||||||
const isPdf = normalizedContentType === 'application/pdf'
|
const isPdf = normalizedMimeType === 'application/pdf'
|
||||||
|| normalizedContentType === 'application/x-pdf';
|
|| normalizedMimeType === 'application/x-pdf';
|
||||||
const isAudio = normalizedContentType.startsWith('audio/')
|
const isAudio = normalizedMimeType.startsWith('audio/')
|
||||||
|| AUDIO_EXTENSIONS.has(fileExtension);
|
|| AUDIO_EXTENSIONS.has(fileExtension);
|
||||||
const isVideo = normalizedContentType.startsWith('video/')
|
const isVideo = normalizedMimeType.startsWith('video/')
|
||||||
|| VIDEO_EXTENSIONS.has(fileExtension);
|
|| VIDEO_EXTENSIONS.has(fileExtension);
|
||||||
const mediaLabel = document.title
|
const mediaLabel = document.title
|
||||||
|| normalizedFilename
|
|| normalizedFilename
|
||||||
@@ -170,7 +170,7 @@ const DocumentViewerLayout = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const displayContentType = document.content_type || documentLink.contentType || 'this file type';
|
const displayMimeType = document.mime_type || documentLink.mimeType || 'this file type';
|
||||||
const displayFilename = documentLink.filename
|
const displayFilename = documentLink.filename
|
||||||
|| document.filename
|
|| document.filename
|
||||||
|| document.original_name
|
|| document.original_name
|
||||||
@@ -179,7 +179,7 @@ const DocumentViewerLayout = ({
|
|||||||
return (
|
return (
|
||||||
<div className="document-viewer__unsupported">
|
<div className="document-viewer__unsupported">
|
||||||
<div className="document-viewer__unsupported-message">
|
<div className="document-viewer__unsupported-message">
|
||||||
Preview is not available for {displayContentType} files.
|
Preview is not available for {displayMimeType} files.
|
||||||
</div>
|
</div>
|
||||||
<div className="document-viewer__unsupported-filename">{displayFilename}</div>
|
<div className="document-viewer__unsupported-filename">{displayFilename}</div>
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -32,20 +32,20 @@ import { usePanelResizeBindings } from '../app/PanelManagerContext';
|
|||||||
interface DocumentLike {
|
interface DocumentLike {
|
||||||
id?: string | number;
|
id?: string | number;
|
||||||
title?: string;
|
title?: string;
|
||||||
content_type?: string | null;
|
mime_type?: string | null;
|
||||||
issued_at?: string | null;
|
issued_at?: string | null;
|
||||||
folder_id?: string | null;
|
folder_id?: string | null;
|
||||||
correspondents?: Array<{ id?: string | number; name?: string }>;
|
correspondents?: Array<{ id?: string | number; name?: string }>;
|
||||||
current_version?: {
|
current_version?: {
|
||||||
version_number?: number;
|
version_number?: number;
|
||||||
download?: { url?: string | null; expires_at?: number } | null;
|
download?: { url?: string | null; expires_at?: number } | null;
|
||||||
version?: { content_type?: string | null } | null;
|
mime_type?: string | null;
|
||||||
filename?: string | null;
|
filename?: string | null;
|
||||||
} | null;
|
} | null;
|
||||||
documentLink?: {
|
documentLink?: {
|
||||||
url: string;
|
url: string;
|
||||||
alt?: string;
|
alt?: string;
|
||||||
contentType?: string | null;
|
mimeType?: string | null;
|
||||||
} | null;
|
} | null;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
}
|
}
|
||||||
@@ -268,11 +268,11 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
|
|||||||
if (!href) {
|
if (!href) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const contentType = document.content_type || null;
|
const mimeType = document.mime_type;
|
||||||
const filename = document.current_version?.filename || document.filename || document.title || null;
|
const filename = document.current_version?.filename || document.filename || document.title || null;
|
||||||
return {
|
return {
|
||||||
url: href,
|
url: href,
|
||||||
contentType,
|
mimeType,
|
||||||
filename,
|
filename,
|
||||||
};
|
};
|
||||||
}, [document, resolveApiPath]);
|
}, [document, resolveApiPath]);
|
||||||
@@ -363,11 +363,11 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
|
|||||||
if (!resolvedDocumentLink?.url || !document) {
|
if (!resolvedDocumentLink?.url || !document) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const normalizedContentType = document.content_type || null;
|
const normalizedMimeType = document.mime_type;
|
||||||
return {
|
return {
|
||||||
url: resolvedDocumentLink.url,
|
url: resolvedDocumentLink.url,
|
||||||
alt: document.title,
|
alt: document.title,
|
||||||
contentType: normalizedContentType || undefined,
|
mimeType: normalizedMimeType,
|
||||||
};
|
};
|
||||||
}, [document, resolvedDocumentLink?.url]);
|
}, [document, resolvedDocumentLink?.url]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user