refactor: migrate to Codemirror@6 and update editor functionalities#1586
refactor: migrate to Codemirror@6 and update editor functionalities#1586
Codemirror@6 and update editor functionalities#1586Conversation
Co-Authored-By: Saraph1nes <52569690+Saraph1nes@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 4dd9303 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
【预览链接】
|
|
Size Change: +713 kB (+10.81%) Total Size: 7.3 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the Cherry Markdown editor from CodeMirror 5.58.2 to CodeMirror 6.0.1+, introducing a comprehensive compatibility layer (CM6Adapter) to maintain backward compatibility with the existing API while leveraging the new architecture.
Key changes:
- Complete replacement of CodeMirror 5 with CodeMirror 6 modular packages
- Implementation of CM6Adapter class providing CM5-compatible API surface
- Migration of all editor-related utilities and components to CM6 APIs
- Updates to event handling, selection management, and DOM interactions
Reviewed changes
Copilot reviewed 44 out of 49 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Replaces CM5 dependencies with CM6 modular packages, upgrades TypeScript to 5.7.3 |
| types/editor.d.ts | Adds CM6Adapter interface with comprehensive API compatibility definitions |
| types/codemirror.d.ts | Replaces CM5 type extensions with CM6LineBlock interface |
| types/cherry.d.ts | Updates editor type from CM5 Editor to CM6 EditorView |
| src/Editor.js | Implements CM6Adapter class, migrates to CM6 APIs, adds custom syntax highlighter |
| src/Cherry.js | Updates all editor interactions to use CM6 APIs through adapter |
| src/Previewer.js | Adjusts scrolling logic and editor refresh calls for CM6 |
| src/utils/selection.js | Rewrites selection utilities using CM6 state/transaction APIs |
| src/utils/shortcutKey.js | Removes CM5 browser util dependency, implements platform detection |
| src/utils/regexp.js | Refactors regex construction to avoid backreference issues |
| src/utils/pasteHelper.js | Updates DOM queries and event handling for CM6 |
| src/utils/file.js | Changes from doc.replaceSelection to adapter.replaceSelection |
| src/utils/autoindent.js | Adapts list autoindent logic for CM6Adapter |
| src/toolbars/MenuBase.js | Comprehensive rewrite of selection/cursor manipulation for CM6 |
| src/toolbars/hooks/* | Updates all toolbar hooks to use CM6 state.doc.sliceString |
| src/toolbars/Bubble.js | Migrates to CM6 DOM structure (.cm-editor) and coordsAtPos API |
| src/toolbars/FloatMenu.js | Creates compatibility layer for cursor activity events |
| src/toolbars/Toolbar.js | Simplifies toolbar visibility methods |
| src/toolbars/Toc.js | Switches from CM5 events to Cherry event system |
| src/core/hooks/Suggester.js | Updates panel positioning using CM6 coordsAtPos |
| src/sass/*.scss | Updates CSS selectors from .CodeMirror-* to .cm-* |
| yarn.lock | Adds CM6 package dependencies and removes CM5 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodeMirror 5 → 6 参考以下进行未来测试覆盖✅ 核心 API 功能列表文档操作
选择操作
光标操作
坐标转换
滚动操作
搜索功能
标记功能
DOM 操作
🎬 事件系统
⚙️ 编辑器配置支持的配置项
⌨️ 键盘快捷键Sublime 风格快捷键 (默认)通过以下 keymap 组合实现:
支持的快捷键:
Vim 模式支持完整的 Vim 键位,可通过配置或运行时切换。 🎨 语法高亮支持的语法元素:
🔧 已修复的问题
📦 依赖变化
🏗️ 架构改进
✨ 新增功能
🧪 测试建议功能测试
性能测试
兼容性测试
📚 相关资源 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 50 out of 55 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated the cherry-markdown version to minor and refactored the editor to Codemirror@6 with related optimizations.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 59 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
清理了Suggester.js中的console.log和Bold.js中多余的getMoreSelection调用,以及H1.js中的调试日志。
…cent/cherry-markdown into upgrade_codemirror_v6_251213
Codemirror @6 and update editor functionalitiesCodemirror@6 and update editor functionalities
close #1204