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