重构:CodeMirror 架构优化
核心优化: - 新增统一导出避免多实例问题 - 语言加载器从动态改为静态导入 - 使用 Compartment 实现主题/语言动态切换 依赖清理: - 移除废弃的 @codemirror/highlight - 移除不再使用的 @codemirror/legacy-modes 组件优化: - CodeEditor 添加内容更新防抖 - 改进亮色主题样式 - 移除不必要的编辑器重建逻辑 构建配置: - 简化 Vite manualChunks 配置 - 优化依赖预加载列表 文档清理: - 删除过期的代码审查文档 - 更新版本号 0.3.0 → 0.3.2
This commit is contained in:
26
web/src/utils/codemirrorExports.js
Normal file
26
web/src/utils/codemirrorExports.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* CodeMirror 统一导出
|
||||
* 确保所有模块使用同一个 CodeMirror 实例,避免多实例问题
|
||||
*/
|
||||
|
||||
// Core
|
||||
export { EditorView, lineNumbers, highlightActiveLineGutter, keymap, drawSelection, dropCursor } from '@codemirror/view'
|
||||
export { EditorState, Compartment, Facet, StateEffect, StateField } from '@codemirror/state'
|
||||
export { defaultKeymap, history, historyKeymap } from '@codemirror/commands'
|
||||
export { bracketMatching, defaultHighlightStyle, syntaxHighlighting, StreamLanguage } from '@codemirror/language'
|
||||
export { oneDark } from '@codemirror/theme-one-dark'
|
||||
|
||||
// Language packages
|
||||
export { javascript } from '@codemirror/lang-javascript'
|
||||
export { json } from '@codemirror/lang-json'
|
||||
export { yaml } from '@codemirror/lang-yaml'
|
||||
export { html } from '@codemirror/lang-html'
|
||||
export { css } from '@codemirror/lang-css'
|
||||
export { cpp } from '@codemirror/lang-cpp'
|
||||
export { rust } from '@codemirror/lang-rust'
|
||||
export { go } from '@codemirror/lang-go'
|
||||
export { python } from '@codemirror/lang-python'
|
||||
export { php } from '@codemirror/lang-php'
|
||||
export { sql } from '@codemirror/lang-sql'
|
||||
export { markdown } from '@codemirror/lang-markdown'
|
||||
export { java } from '@codemirror/lang-java'
|
||||
Reference in New Issue
Block a user