fix: 改用 importmap + esm.sh 解决 CodeMirror 多实例冲突
- 将 import 改回 bare specifier,通过 importmap 指向 esm.sh - esm.sh 在同一构建上下文中能识别共享依赖,确保 @codemirror/state 单例 - 消除 "Unrecognized extension value" instanceof 检查错误
This commit is contained in:
@ -1,28 +1,17 @@
|
||||
/**
|
||||
* MetaLab Markdown Editor — CodeMirror 6 版
|
||||
*
|
||||
* 功能:
|
||||
* - CodeMirror 6 编辑器,Markdown 语法高亮
|
||||
* - 工具栏:加粗/斜体/删除线/行内代码/标题/链接/图片/引用/代码块/列表/表格/分割线
|
||||
* - 快捷键:Ctrl+B/I/K/` Shift+I Tab Shift+Tab Ctrl+S Ctrl+Shift+P F11
|
||||
* - 粘贴图片 / 拖拽上传 / 进度反馈
|
||||
* - 分屏实时预览(Ctrl+Shift+P 切换)
|
||||
* - 代码块语言下拉选择器
|
||||
* - 自动保存草稿(localStorage + 后端)
|
||||
* - 字数/行数/阅读时间统计
|
||||
* - 全屏编辑模式(F11)
|
||||
* - 滚动同步(分屏模式下)
|
||||
*
|
||||
* CodeMirror 6 通过 esm.sh bundle 加载,所有依赖自动解析。
|
||||
* 依赖通过 importmap 指向 esm.sh,所有 @codemirror/@lezer 共享同一构建树,
|
||||
* 避免多实例导致的 "Unrecognized extension value" 错误。
|
||||
*/
|
||||
import { EditorState } from 'https://esm.sh/@codemirror/state@6.5.2';
|
||||
import { EditorView, keymap, lineNumbers, highlightActiveLine, drawSelection } from 'https://esm.sh/@codemirror/view@6.36.4';
|
||||
import { defaultKeymap, history, historyKeymap, indentWithTab } from 'https://esm.sh/@codemirror/commands@6.8.1';
|
||||
import { markdown, markdownLanguage } from 'https://esm.sh/@codemirror/lang-markdown@6.3.2';
|
||||
import { languages } from 'https://esm.sh/@codemirror/language-data@6.5.1';
|
||||
import { syntaxHighlighting, defaultHighlightStyle } from 'https://esm.sh/@codemirror/language@6.11.0';
|
||||
import { searchKeymap } from 'https://esm.sh/@codemirror/search@6.5.10';
|
||||
import { autocompletion } from 'https://esm.sh/@codemirror/autocomplete@6.18.6';
|
||||
import { EditorState } from '@codemirror/state';
|
||||
import { EditorView, keymap, lineNumbers, highlightActiveLine, drawSelection } from '@codemirror/view';
|
||||
import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands';
|
||||
import { markdown, markdownLanguage } from '@codemirror/lang-markdown';
|
||||
import { languages } from '@codemirror/language-data';
|
||||
import { syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
||||
import { searchKeymap } from '@codemirror/search';
|
||||
import { autocompletion } from '@codemirror/autocomplete';
|
||||
|
||||
/* ================================================================
|
||||
DOM 引用
|
||||
|
||||
Reference in New Issue
Block a user