mirror of
https://github.com/langgenius/dify.git
synced 2026-03-23 23:37:55 +08:00
Implement MVP features for skill editor based on design doc: - Add Zustand store with Tab, FileTree, and Dirty slices - Rewrite file tree using react-arborist for virtual scrolling - Implement Tab↔FileTree sync with auto-reveal on tab activation - Add upload functionality (new folder, upload file) - Implement Monaco editor with dirty state tracking and Ctrl+S save - Add i18n translations (en-US and zh-Hans)
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { FileAppearanceTypeEnum } from '@/app/components/base/file-uploader/types'
|
|
|
|
export const getFileIconType = (name: string) => {
|
|
const extension = name.split('.').pop()?.toLowerCase() ?? ''
|
|
|
|
if (['md', 'markdown', 'mdx'].includes(extension))
|
|
return FileAppearanceTypeEnum.markdown
|
|
|
|
if (['json', 'yaml', 'yml', 'toml', 'js', 'jsx', 'ts', 'tsx', 'py', 'schema'].includes(extension))
|
|
return FileAppearanceTypeEnum.code
|
|
|
|
return FileAppearanceTypeEnum.document
|
|
}
|
|
|
|
/**
|
|
* Get Monaco editor language from file name extension
|
|
*/
|
|
export const getFileLanguage = (name: string): string => {
|
|
const extension = name.split('.').pop()?.toLowerCase() ?? ''
|
|
|
|
const languageMap: Record<string, string> = {
|
|
// Markdown
|
|
md: 'markdown',
|
|
markdown: 'markdown',
|
|
mdx: 'markdown',
|
|
// JSON
|
|
json: 'json',
|
|
jsonl: 'json',
|
|
// YAML
|
|
yaml: 'yaml',
|
|
yml: 'yaml',
|
|
// JavaScript/TypeScript
|
|
js: 'javascript',
|
|
jsx: 'javascript',
|
|
ts: 'typescript',
|
|
tsx: 'typescript',
|
|
// Python
|
|
py: 'python',
|
|
// Others
|
|
html: 'html',
|
|
css: 'css',
|
|
xml: 'xml',
|
|
sql: 'sql',
|
|
sh: 'shell',
|
|
bash: 'shell',
|
|
}
|
|
|
|
return languageMap[extension] ?? 'plaintext'
|
|
}
|