Skip to content

Commit 1fdf274

Browse files
authored
Merge pull request #6 from seekrays/fix-code-editor
support tab key
2 parents bfecc58 + 2ccdd00 commit 1fdf274

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/CodeEditor.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import { oneDark } from "@codemirror/theme-one-dark";
1919
import { lineNumbers, keymap } from "@codemirror/view";
2020
import { autocompletion, closeBrackets } from "@codemirror/autocomplete";
2121
import { searchKeymap, highlightSelectionMatches } from "@codemirror/search";
22-
import { defaultKeymap, historyKeymap } from "@codemirror/commands";
22+
import {
23+
defaultKeymap,
24+
historyKeymap,
25+
indentWithTab,
26+
} from "@codemirror/commands";
2327
import { bracketMatching } from "@codemirror/language";
2428
2529
// 语言支持
@@ -138,7 +142,12 @@ const createEditor = () => {
138142
themeCompartment.of(props.theme === "dark" ? oneDark : []),
139143
140144
// 键盘快捷键
141-
keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap]),
145+
keymap.of([
146+
...defaultKeymap,
147+
...historyKeymap,
148+
...searchKeymap,
149+
indentWithTab,
150+
]),
142151
143152
// 编辑器功能
144153
EditorView.lineWrapping, // 自动换行

0 commit comments

Comments
 (0)