Trim unused code editor languages
This commit is contained in:
@@ -28,15 +28,9 @@
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.20.0",
|
||||
"@codemirror/commands": "^6.10.0",
|
||||
"@codemirror/lang-css": "^6.3.1",
|
||||
"@codemirror/lang-html": "^6.4.11",
|
||||
"@codemirror/lang-javascript": "^6.2.4",
|
||||
"@codemirror/lang-json": "^6.0.2",
|
||||
"@codemirror/lang-markdown": "^6.5.0",
|
||||
"@codemirror/lang-python": "^6.2.1",
|
||||
"@codemirror/lang-sql": "^6.10.0",
|
||||
"@codemirror/lang-xml": "^6.1.0",
|
||||
"@codemirror/lang-yaml": "^6.1.2",
|
||||
"@codemirror/language": "^6.11.3",
|
||||
"@codemirror/state": "^6.5.2",
|
||||
"@codemirror/theme-one-dark": "^6.1.3",
|
||||
|
||||
@@ -4,14 +4,6 @@ import type { CodeLanguage } from './types';
|
||||
|
||||
// 语言扩展懒加载映射
|
||||
const languageLoaders: Record<CodeLanguage, () => Promise<Extension>> = {
|
||||
javascript: async () => {
|
||||
const { javascript } = await import('@codemirror/lang-javascript');
|
||||
return javascript();
|
||||
},
|
||||
typescript: async () => {
|
||||
const { javascript } = await import('@codemirror/lang-javascript');
|
||||
return javascript({ typescript: true });
|
||||
},
|
||||
python: async () => {
|
||||
const { python } = await import('@codemirror/lang-python');
|
||||
return python();
|
||||
@@ -24,26 +16,6 @@ const languageLoaders: Record<CodeLanguage, () => Promise<Extension>> = {
|
||||
const { json } = await import('@codemirror/lang-json');
|
||||
return json();
|
||||
},
|
||||
html: async () => {
|
||||
const { html } = await import('@codemirror/lang-html');
|
||||
return html();
|
||||
},
|
||||
css: async () => {
|
||||
const { css } = await import('@codemirror/lang-css');
|
||||
return css();
|
||||
},
|
||||
markdown: async () => {
|
||||
const { markdown } = await import('@codemirror/lang-markdown');
|
||||
return markdown();
|
||||
},
|
||||
xml: async () => {
|
||||
const { xml } = await import('@codemirror/lang-xml');
|
||||
return xml();
|
||||
},
|
||||
yaml: async () => {
|
||||
const { yaml } = await import('@codemirror/lang-yaml');
|
||||
return yaml();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -65,14 +37,7 @@ export async function getLanguageExtension(
|
||||
* 支持的语言列表
|
||||
*/
|
||||
export const supportedLanguages: CodeLanguage[] = [
|
||||
'javascript',
|
||||
'typescript',
|
||||
'python',
|
||||
'sql',
|
||||
'json',
|
||||
'html',
|
||||
'css',
|
||||
'markdown',
|
||||
'xml',
|
||||
'yaml',
|
||||
];
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
import type { EditorView } from '@codemirror/view';
|
||||
|
||||
export type CodeLanguage =
|
||||
| 'css'
|
||||
| 'html'
|
||||
| 'javascript'
|
||||
| 'json'
|
||||
| 'markdown'
|
||||
| 'python'
|
||||
| 'sql'
|
||||
| 'typescript'
|
||||
| 'xml'
|
||||
| 'yaml';
|
||||
| 'sql';
|
||||
|
||||
export interface CodeEditorProps {
|
||||
/** 代码内容 */
|
||||
|
||||
Reference in New Issue
Block a user