codemirror 使用笔记草稿
import CodeMirror from "@uiw/react-codemirror";
import "codemirror/keymap/sublime";
import "codemirror/theme/monokai.css";
// 括号匹配和补全
import 'codemirror/addon/edit/closebrackets.js';
import 'codemirror/addon/edit/matchbrackets.js';
// 进行错误提示
import 'codemirror/addon/lint/lint.js';
import 'codemirror/addon/lint/lint.css';
import 'codemirror/addon/lint/javascript-lint.js';
(window as any).JSHINT = require('jshint').JSHINT;
const codeMirrorConfig = useMemo(() => ({
theme: "monokai",
keyMap: "sublime",
mode: "javascript",
lineNumbers: true,
autoCloseBrackets: true,
matchBrackets: true,
lint: {
esversion: 6
},
}), [])
<CodeMirror
value={config.value}
onChange={onEditorChange}
options={codeMirrorConfig}
/>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
编辑 (opens new window)
上次更新: 2023/08/23, 09:32:05