diff --git a/web/src/apps/TextEditor/TextEditor.tsx b/web/src/apps/TextEditor/TextEditor.tsx index 97cb3f0..cc6c922 100644 --- a/web/src/apps/TextEditor/TextEditor.tsx +++ b/web/src/apps/TextEditor/TextEditor.tsx @@ -24,27 +24,124 @@ export const TextEditorApp: React.FC = ({ filePath, entry, on const isMarkdown = ext === 'md' || ext === 'markdown'; const monacoLanguage = useMemo(() => { switch (ext) { - case 'json': - return 'json'; + // Web technologies case 'js': + case 'jsx': return 'javascript'; case 'ts': + case 'tsx': return 'typescript'; case 'html': + case 'htm': return 'html'; case 'css': return 'css'; - case 'py': - return 'python'; - case 'sh': - return 'shell'; + case 'scss': + case 'sass': + return 'scss'; + case 'less': + return 'less'; + case 'vue': + return 'html'; // Vue files are primarily HTML with some JS/TS + + // Data formats + case 'json': + return 'json'; case 'yaml': case 'yml': return 'yaml'; case 'xml': return 'xml'; + case 'toml': + return 'ini'; // TOML is similar to INI + case 'ini': + case 'cfg': + case 'conf': + return 'ini'; + + // Programming languages + case 'py': + return 'python'; + case 'java': + return 'java'; + case 'c': + return 'c'; + case 'cpp': + case 'cc': + case 'cxx': + return 'cpp'; + case 'h': + case 'hpp': + case 'hxx': + return 'cpp'; // Header files use C++ highlighting + case 'php': + return 'php'; + case 'rb': + return 'ruby'; + case 'go': + return 'go'; + case 'rs': + return 'rust'; + case 'swift': + return 'swift'; + case 'kt': + return 'kotlin'; + case 'scala': + return 'scala'; + case 'cs': + return 'csharp'; + case 'fs': + return 'fsharp'; + case 'vb': + return 'vb'; + case 'pl': + case 'pm': + return 'perl'; + case 'r': + return 'r'; + case 'lua': + return 'lua'; + case 'dart': + return 'dart'; + + // Database + case 'sql': + return 'sql'; + + // Shell and scripts + case 'sh': + case 'bash': + case 'zsh': + case 'fish': + return 'shell'; + case 'ps1': + return 'powershell'; + case 'bat': + case 'cmd': + return 'bat'; + + // Build and config files + case 'dockerfile': + return 'dockerfile'; + case 'makefile': + return 'makefile'; + case 'gradle': + return 'groovy'; + case 'cmake': + return 'cmake'; + + // Markdown + case 'md': + case 'markdown': + return 'markdown'; + + // Plain text and logs case 'txt': case 'log': + case 'gitignore': + case 'gitattributes': + case 'editorconfig': + case 'prettierrc': default: return 'plaintext'; } diff --git a/web/src/apps/TextEditor/index.ts b/web/src/apps/TextEditor/index.ts index ccae4f0..796c709 100644 --- a/web/src/apps/TextEditor/index.ts +++ b/web/src/apps/TextEditor/index.ts @@ -8,8 +8,27 @@ export const descriptor: AppDescriptor = { supported: (entry) => { if (entry.is_dir) return false; const ext = entry.name.split('.').pop()?.toLowerCase() || ''; - // Supports common text and markdown formats - return ['txt', 'md', 'markdown', 'json', 'yaml', 'yml', 'xml', 'html', 'css', 'js', 'ts', 'py', 'sh', 'log'].includes(ext); + // Supports common text and code formats + return [ + // Text formats + 'txt', 'md', 'markdown', 'log', + // Data formats + 'json', 'yaml', 'yml', 'xml', 'toml', 'ini', 'cfg', 'conf', + // Web technologies + 'html', 'htm', 'css', 'scss', 'sass', 'less', 'js', 'jsx', 'ts', 'tsx', 'vue', + // Programming languages + 'py', 'java', 'c', 'cpp', 'cc', 'cxx', 'h', 'hpp', 'hxx', + 'php', 'rb', 'go', 'rs', 'swift', 'kt', 'scala', 'clj', 'cljs', + 'cs', 'vb', 'fs', 'pl', 'pm', 'r', 'lua', 'dart', 'elm', + // Database + 'sql', + // Shell and scripts + 'sh', 'bash', 'zsh', 'fish', 'ps1', 'bat', 'cmd', + // Build and config files + 'dockerfile', 'makefile', 'gradle', 'cmake', + // Other common text files + 'gitignore', 'gitattributes', 'editorconfig', 'prettierrc' + ].includes(ext); }, component: TextEditorApp, default: true, diff --git a/web/src/pages/FileExplorerPage/components/FileIcons.tsx b/web/src/pages/FileExplorerPage/components/FileIcons.tsx index 47929dc..8e75a3e 100644 --- a/web/src/pages/FileExplorerPage/components/FileIcons.tsx +++ b/web/src/pages/FileExplorerPage/components/FileIcons.tsx @@ -45,9 +45,9 @@ export const getFileIcon = (fileName: string, size: number = 16, resolvedMode: ' if (['xls', 'xlsx'].includes(ext)) return make(, '#52c41a'); if (['ppt', 'pptx'].includes(ext)) return make(, '#fa8c16'); if (['zip', 'rar', '7z', 'tar', 'gz', 'bz2', 'xz'].includes(ext)) return make(, '#faad14'); - if (['js','jsx','ts','tsx','vue','html','css','scss','less','json','xml','yaml','yml','py','java','cpp','c','h','php','rb','go','rs','swift','kt'].includes(ext)) return make(, '#13c2c2'); + if (['js','jsx','ts','tsx','vue','html','htm','css','scss','sass','less','json','xml','yaml','yml','py','java','cpp','cc','cxx','c','h','hpp','hxx','php','rb','go','rs','rust','swift','kt','scala','clj','cljs','cs','vb','fs','pl','pm','r','lua','dart','elm'].includes(ext)) return make(, '#13c2c2'); if (['md', 'markdown'].includes(ext)) return make(, '#1890ff'); - if (['txt', 'log', 'ini', 'cfg', 'conf'].includes(ext)) return make(, '#8c8c8c'); + if (['txt', 'log', 'ini', 'cfg', 'conf', 'sh', 'bash', 'zsh', 'fish', 'ps1', 'bat', 'cmd', 'dockerfile', 'makefile', 'gradle', 'cmake', 'gitignore', 'gitattributes', 'editorconfig', 'prettierrc'].includes(ext)) return make(, '#8c8c8c'); if (['ttf', 'otf', 'woff', 'woff2', 'eot'].includes(ext)) return make(, '#eb2f96'); if (['db', 'sqlite', 'sql'].includes(ext)) return make(, '#fa541c'); if (['env', 'config', 'properties', 'toml'].includes(ext)) return make(, '#faad14');