Skip to content

Commit 9bfe669

Browse files
authored
Integrate CodeMirror command registry and keymap (#2)
1 parent 6910a1b commit 9bfe669

File tree

9 files changed

+1845
-536
lines changed

9 files changed

+1845
-536
lines changed

src/codemirror/baseExtensions.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { closeBrackets } from "@codemirror/autocomplete";
2+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
3+
import {
4+
bracketMatching,
5+
defaultHighlightStyle,
6+
foldGutter,
7+
indentOnInput,
8+
syntaxHighlighting,
9+
} from "@codemirror/language";
10+
import { highlightSelectionMatches } from "@codemirror/search";
11+
import { EditorState } from "@codemirror/state";
12+
import {
13+
crosshairCursor,
14+
drawSelection,
15+
dropCursor,
16+
highlightActiveLine,
17+
highlightSpecialChars,
18+
keymap,
19+
rectangularSelection,
20+
} from "@codemirror/view";
21+
22+
/**
23+
* Base extensions roughly matching the useful parts of CodeMirror's basicSetup
24+
* @returns {import("@codemirror/state").Extension[]}
25+
*/
26+
export default function createBaseExtensions() {
27+
return [
28+
highlightSpecialChars(),
29+
history(),
30+
drawSelection(),
31+
dropCursor(),
32+
EditorState.allowMultipleSelections.of(true),
33+
indentOnInput(),
34+
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
35+
bracketMatching(),
36+
closeBrackets(),
37+
rectangularSelection(),
38+
crosshairCursor(),
39+
highlightActiveLine(),
40+
highlightSelectionMatches(),
41+
foldGutter(),
42+
keymap.of([...defaultKeymap, ...historyKeymap]),
43+
];
44+
}

0 commit comments

Comments
 (0)