feat: 替换 textarea 为 CodeMirror 6 编辑器

新增功能:
- CodeMirror 6 专业编辑器替代原生 textarea
- 语法高亮(Markdown 专用)
- 行号(内置,精确同步)
- 代码折叠(foldGutter)
- 括号匹配
- 多光标选区(rectangularSelection)
- 内置搜索高亮(highlightSelectionMatches)
- undo/redo 原生支持(history)
- Tab 缩进(indentWithTab)
- 暗色主题(oneDark)

新增文件:
- useCodeMirror.ts: CodeMirror 初始化 Hook
- EditorToolbar.tsx: 格式化工具栏(B/I/S/标题/列表/引用/代码/链接/图片)
- Editor.tsx: 重写为 CodeMirror 组件

格式化工具栏按钮:
- 粗体/斜体/删除线/行内代码
- H1/H2/H3 标题
- 无序列表/有序列表/引用/代码块
- 链接/图片

快捷键:
- Ctrl+B 粗体
- Ctrl+I 斜体
This commit is contained in:
thzxx
2026-05-27 23:04:05 +08:00
parent b3987e9abd
commit 1cc4206b32
6 changed files with 459 additions and 305 deletions
+1 -1
View File
@@ -193,7 +193,7 @@ export default function App() {
{viewMode !== 'preview' && (
<div id="editor-panel" style={editorStyle}>
<SearchBar />
<Editor />
<Editor darkMode={darkMode} />
</div>
)}
{viewMode !== 'editor' && <Resizer onResize={saveSplitRatio} />}