Update to Codemirror 6 (py-repl) (#814)

* Upgrade to codemirror v6

* Increase indentation to 4 spaces by default
This commit is contained in:
Jeff Glass
2022-10-04 08:49:42 -05:00
committed by GitHub
parent c70e121078
commit 8b97e4757f
3 changed files with 223 additions and 498 deletions

View File

@@ -1,5 +1,6 @@
import { basicSetup, EditorState, EditorView } from '@codemirror/basic-setup';
import { basicSetup, EditorView } from 'codemirror';
import { python } from '@codemirror/lang-python';
import { indentUnit } from '@codemirror/language'
import { Compartment, StateCommand } from '@codemirror/state';
import { keymap } from '@codemirror/view';
import { defaultKeymap } from '@codemirror/commands';
@@ -45,6 +46,7 @@ export class PyRepl extends BaseEvalElement {
const languageConf = new Compartment();
const extensions = [
indentUnit.of(" "),
basicSetup,
languageConf.of(python()),
keymap.of([
@@ -59,10 +61,8 @@ export class PyRepl extends BaseEvalElement {
}
this.editor = new EditorView({
state: EditorState.create({
doc: this.code.trim(),
extensions,
}),
doc: this.code.trim(),
extensions,
parent: this.editorNode,
});