,
};
return iconMap[ext] || ;
}
function getFileType(filename: string): {
type: string;
icon: React.ReactNode;
color: string;
} {
const ext = filename.split(".").pop()?.toLowerCase() || "";
const imageExts = ["png", "jpg", "jpeg", "gif", "bmp", "svg", "webp"];
const videoExts = ["mp4", "avi", "mkv", "mov", "wmv", "flv", "webm"];
const audioExts = ["mp3", "wav", "flac", "ogg", "aac", "m4a"];
const textExts = ["txt", "readme"];
const markdownExts = ["md", "markdown", "mdown", "mkdn", "mdx"];
const pdfExts = ["pdf"];
const codeExts = [
"js",
"ts",
"jsx",
"tsx",
"py",
"java",
"cpp",
"c",
"cs",
"php",
"rb",
"go",
"rs",
"html",
"css",
"scss",
"less",
"json",
"xml",
"yaml",
"yml",
"toml",
"ini",
"conf",
"sh",
"bash",
"zsh",
"sql",
"vue",
"svelte",
];
if (imageExts.includes(ext)) {
return {
type: "image",
icon: Loading file...
{t("fileManager.largeFileWarningDesc", { size: formatFileSize(file.size, t), })}
{isTooLarge ? (File is too large (> 10MB) and cannot be opened as text for security reasons.
Do you want to continue opening this file as text? This may slow down your browser.
)}{file.name}
{onDownload && ( )}Loading image...
{children}
);
},
h1: ({ children }) => (
{children}
), ul: ({ children }) => ({children}), table: ({ children }) => (
{children}
);
},
h1: ({ children }) => (
{children}
), ul: ({ children }) => ({children}), table: ({ children }) => (
There was an error loading this PDF file.
{onDownload && ( )}Loading PDF...
Loading page...
{ext.toUpperCase()} • {formatFileSize(file.size, t)}
This file type is not supported for preview. You can download it to view in an external application.
{onDownload && ( )}