diff options
Diffstat (limited to 'language-web/src/main/js/editor/Editor.jsx')
-rw-r--r-- | language-web/src/main/js/editor/Editor.jsx | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/language-web/src/main/js/editor/Editor.jsx b/language-web/src/main/js/editor/Editor.jsx deleted file mode 100644 index 4cd9b3bd..00000000 --- a/language-web/src/main/js/editor/Editor.jsx +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | import { observer } from 'mobx-react-lite'; | ||
2 | import 'mode-problem'; | ||
3 | import React, { useCallback } from 'react'; | ||
4 | import { Controlled as CodeMirror } from 'react-codemirror2-react-17'; | ||
5 | import { createServices, removeServices } from 'xtext/xtext-codemirror'; | ||
6 | |||
7 | import { useRootStore } from '../RootStore'; | ||
8 | |||
9 | export default observer(() => { | ||
10 | const editorStore = useRootStore().editorStore; | ||
11 | |||
12 | const codeMirrorOptions = { | ||
13 | mode: 'xtext/problem', | ||
14 | indentUnit: 2, | ||
15 | theme: 'material-darker', | ||
16 | lineNumbers: editorStore.showLineNumbers, | ||
17 | }; | ||
18 | |||
19 | const xtextOptions = { | ||
20 | xtextLang: 'problem', | ||
21 | enableFormattingAction: true, | ||
22 | } | ||
23 | |||
24 | const editorDidMount = useCallback((editor) => { | ||
25 | createServices(editor, xtextOptions); | ||
26 | editorStore.updateEditor(editor); | ||
27 | }, [editorStore]); | ||
28 | |||
29 | const editorWillUnmount = useCallback((editor) => { | ||
30 | editorStore.editor = null; | ||
31 | removeServices(editor); | ||
32 | }, [editorStore]); | ||
33 | |||
34 | const onBeforeChange = useCallback((_editor, _data, value) => { | ||
35 | editorStore.updateValue(value); | ||
36 | }, [editorStore]); | ||
37 | |||
38 | const onChange = useCallback((_editor, _data, _value) => { | ||
39 | editorStore.reportChanged(); | ||
40 | }, [editorStore]); | ||
41 | |||
42 | return ( | ||
43 | <CodeMirror | ||
44 | value={editorStore.value} | ||
45 | options={codeMirrorOptions} | ||
46 | editorDidMount={editorDidMount} | ||
47 | editorWillUnmount={editorWillUnmount} | ||
48 | onBeforeChange={onBeforeChange} | ||
49 | onChange={onChange} | ||
50 | /> | ||
51 | ); | ||
52 | }); | ||