aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/editor')
-rw-r--r--subprojects/frontend/src/editor/EditorArea.tsx6
-rw-r--r--subprojects/frontend/src/editor/EditorButtons.tsx6
-rw-r--r--subprojects/frontend/src/editor/EditorPane.tsx6
-rw-r--r--subprojects/frontend/src/editor/EditorStore.ts42
-rw-r--r--subprojects/frontend/src/editor/GenerateButton.tsx6
-rw-r--r--subprojects/frontend/src/editor/PanelStore.ts18
-rw-r--r--subprojects/frontend/src/editor/SearchPanelPortal.tsx6
-rw-r--r--subprojects/frontend/src/editor/SearchPanelStore.ts3
-rw-r--r--subprojects/frontend/src/editor/SearchToolbar.tsx6
9 files changed, 44 insertions, 55 deletions
diff --git a/subprojects/frontend/src/editor/EditorArea.tsx b/subprojects/frontend/src/editor/EditorArea.tsx
index 1c9b031b..7c5ac5fb 100644
--- a/subprojects/frontend/src/editor/EditorArea.tsx
+++ b/subprojects/frontend/src/editor/EditorArea.tsx
@@ -5,7 +5,7 @@ import React, { useCallback, useEffect } from 'react';
5import type EditorStore from './EditorStore'; 5import type EditorStore from './EditorStore';
6import EditorTheme from './EditorTheme'; 6import EditorTheme from './EditorTheme';
7 7
8function EditorArea({ 8export default observer(function EditorArea({
9 editorStore, 9 editorStore,
10}: { 10}: {
11 editorStore: EditorStore; 11 editorStore: EditorStore;
@@ -32,6 +32,4 @@ function EditorArea({
32 ref={editorParentRef} 32 ref={editorParentRef}
33 /> 33 />
34 ); 34 );
35} 35});
36
37export default observer(EditorArea);
diff --git a/subprojects/frontend/src/editor/EditorButtons.tsx b/subprojects/frontend/src/editor/EditorButtons.tsx
index cbe7c424..d2273c6c 100644
--- a/subprojects/frontend/src/editor/EditorButtons.tsx
+++ b/subprojects/frontend/src/editor/EditorButtons.tsx
@@ -32,7 +32,7 @@ function getLintIcon(severity: Diagnostic['severity'] | undefined) {
32 } 32 }
33} 33}
34 34
35function EditorButtons({ 35export default observer(function EditorButtons({
36 editorStore, 36 editorStore,
37}: { 37}: {
38 editorStore: EditorStore | undefined; 38 editorStore: EditorStore | undefined;
@@ -102,6 +102,4 @@ function EditorButtons({
102 </IconButton> 102 </IconButton>
103 </Stack> 103 </Stack>
104 ); 104 );
105} 105});
106
107export default observer(EditorButtons);
diff --git a/subprojects/frontend/src/editor/EditorPane.tsx b/subprojects/frontend/src/editor/EditorPane.tsx
index df43d2c9..2651726c 100644
--- a/subprojects/frontend/src/editor/EditorPane.tsx
+++ b/subprojects/frontend/src/editor/EditorPane.tsx
@@ -29,7 +29,7 @@ function EditorLoading(): JSX.Element {
29 ); 29 );
30} 30}
31 31
32function EditorPane(): JSX.Element { 32export default observer(function EditorPane(): JSX.Element {
33 const { editorStore } = useRootStore(); 33 const { editorStore } = useRootStore();
34 34
35 return ( 35 return (
@@ -50,6 +50,4 @@ function EditorPane(): JSX.Element {
50 </Box> 50 </Box>
51 </Stack> 51 </Stack>
52 ); 52 );
53} 53});
54
55export default observer(EditorPane);
diff --git a/subprojects/frontend/src/editor/EditorStore.ts b/subprojects/frontend/src/editor/EditorStore.ts
index b634a427..4407376b 100644
--- a/subprojects/frontend/src/editor/EditorStore.ts
+++ b/subprojects/frontend/src/editor/EditorStore.ts
@@ -13,7 +13,7 @@ import {
13 type EditorState, 13 type EditorState,
14} from '@codemirror/state'; 14} from '@codemirror/state';
15import { type Command, EditorView } from '@codemirror/view'; 15import { type Command, EditorView } from '@codemirror/view';
16import { action, computed, makeObservable, observable } from 'mobx'; 16import { makeAutoObservable, observable } from 'mobx';
17import { nanoid } from 'nanoid'; 17import { nanoid } from 'nanoid';
18 18
19import getLogger from '../utils/getLogger'; 19import getLogger from '../utils/getLogger';
@@ -57,29 +57,15 @@ export default class EditorStore {
57 this.client = new XtextClient(this); 57 this.client = new XtextClient(this);
58 this.searchPanel = new SearchPanelStore(this); 58 this.searchPanel = new SearchPanelStore(this);
59 this.lintPanel = new LintPanelStore(this); 59 this.lintPanel = new LintPanelStore(this);
60 makeObservable(this, { 60 makeAutoObservable<EditorStore, 'client'>(this, {
61 id: false,
61 state: observable.ref, 62 state: observable.ref,
63 client: false,
62 view: observable.ref, 64 view: observable.ref,
63 showLineNumbers: observable, 65 searchPanel: false,
64 errorCount: observable, 66 lintPanel: false,
65 warningCount: observable, 67 contentAssist: false,
66 infoCount: observable, 68 formatText: false,
67 highestDiagnosticLevel: computed,
68 canUndo: computed,
69 canRedo: computed,
70 setDarkMode: action,
71 setEditorParent: action,
72 dispatch: action,
73 dispatchTransaction: action,
74 doCommand: action,
75 doStateCommand: action,
76 updateDiagnostics: action,
77 nextDiagnostic: action,
78 updateOccurrences: action,
79 updateSemanticHighlighting: action,
80 undo: action,
81 redo: action,
82 toggleLineNumbers: action,
83 }); 69 });
84 } 70 }
85 71
@@ -141,13 +127,11 @@ export default class EditorStore {
141 } 127 }
142 } 128 }
143 129
144 private readonly dispatchTransactionWithoutView = action( 130 private dispatchTransactionWithoutView(tr: Transaction): void {
145 (tr: Transaction) => { 131 log.trace('Editor transaction', tr);
146 log.trace('Editor transaction', tr); 132 this.state = tr.state;
147 this.state = tr.state; 133 this.client.onTransaction(tr);
148 this.client.onTransaction(tr); 134 }
149 },
150 );
151 135
152 doCommand(command: Command): boolean { 136 doCommand(command: Command): boolean {
153 if (this.view === undefined) { 137 if (this.view === undefined) {
diff --git a/subprojects/frontend/src/editor/GenerateButton.tsx b/subprojects/frontend/src/editor/GenerateButton.tsx
index a28f6b4b..5254f6cb 100644
--- a/subprojects/frontend/src/editor/GenerateButton.tsx
+++ b/subprojects/frontend/src/editor/GenerateButton.tsx
@@ -7,7 +7,7 @@ import type EditorStore from './EditorStore';
7 7
8const GENERATE_LABEL = 'Generate'; 8const GENERATE_LABEL = 'Generate';
9 9
10function GenerateButton({ 10export default observer(function GenerateButton({
11 editorStore, 11 editorStore,
12}: { 12}: {
13 editorStore: EditorStore | undefined; 13 editorStore: EditorStore | undefined;
@@ -53,6 +53,4 @@ function GenerateButton({
53 {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`} 53 {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`}
54 </Button> 54 </Button>
55 ); 55 );
56} 56});
57
58export default observer(GenerateButton);
diff --git a/subprojects/frontend/src/editor/PanelStore.ts b/subprojects/frontend/src/editor/PanelStore.ts
index e0e2b2f4..4f827280 100644
--- a/subprojects/frontend/src/editor/PanelStore.ts
+++ b/subprojects/frontend/src/editor/PanelStore.ts
@@ -18,13 +18,29 @@ export default class PanelStore {
18 private readonly closeCommand: Command, 18 private readonly closeCommand: Command,
19 protected readonly store: EditorStore, 19 protected readonly store: EditorStore,
20 ) { 20 ) {
21 makeObservable(this, { 21 makeObservable<
22 PanelStore,
23 | 'openCommand'
24 | 'closeCommand'
25 | 'store'
26 | 'setState'
27 | 'doOpen'
28 | 'doClose'
29 >(this, {
30 panelClass: false,
31 openCommand: false,
32 closeCommand: false,
33 store: false,
22 state: observable, 34 state: observable,
23 element: observable, 35 element: observable,
36 id: false,
24 open: action, 37 open: action,
25 close: action, 38 close: action,
26 toggle: action, 39 toggle: action,
40 setState: false,
27 synchronizeStateToView: action, 41 synchronizeStateToView: action,
42 doOpen: false,
43 doClose: false,
28 }); 44 });
29 } 45 }
30 46
diff --git a/subprojects/frontend/src/editor/SearchPanelPortal.tsx b/subprojects/frontend/src/editor/SearchPanelPortal.tsx
index e8301489..b6b375e3 100644
--- a/subprojects/frontend/src/editor/SearchPanelPortal.tsx
+++ b/subprojects/frontend/src/editor/SearchPanelPortal.tsx
@@ -5,7 +5,7 @@ import React from 'react';
5import type EditorStore from './EditorStore'; 5import type EditorStore from './EditorStore';
6import SearchToolbar from './SearchToolbar'; 6import SearchToolbar from './SearchToolbar';
7 7
8function SearchPanelPortal({ 8export default observer(function SearchPanelPortal({
9 editorStore: { searchPanel: searchPanelStore }, 9 editorStore: { searchPanel: searchPanelStore },
10}: { 10}: {
11 editorStore: EditorStore; 11 editorStore: EditorStore;
@@ -20,6 +20,4 @@ function SearchPanelPortal({
20 <SearchToolbar searchPanelStore={searchPanelStore} /> 20 <SearchToolbar searchPanelStore={searchPanelStore} />
21 </Portal> 21 </Portal>
22 ); 22 );
23} 23});
24
25export default observer(SearchPanelPortal);
diff --git a/subprojects/frontend/src/editor/SearchPanelStore.ts b/subprojects/frontend/src/editor/SearchPanelStore.ts
index 8dd02ae6..65d595a8 100644
--- a/subprojects/frontend/src/editor/SearchPanelStore.ts
+++ b/subprojects/frontend/src/editor/SearchPanelStore.ts
@@ -21,7 +21,7 @@ export default class SearchPanelStore extends PanelStore {
21 // Use a custom class name to avoid specificity issues with 21 // Use a custom class name to avoid specificity issues with
22 // CodeMirror `.cm-search.cm-panel` CSS styles. 22 // CodeMirror `.cm-search.cm-panel` CSS styles.
23 super('refinery-cm-search', openSearchPanel, closeSearchPanel, store); 23 super('refinery-cm-search', openSearchPanel, closeSearchPanel, store);
24 makeObservable(this, { 24 makeObservable<SearchPanelStore, 'selectSearchField'>(this, {
25 searchField: observable.ref, 25 searchField: observable.ref,
26 query: computed, 26 query: computed,
27 invalidRegexp: computed, 27 invalidRegexp: computed,
@@ -32,6 +32,7 @@ export default class SearchPanelStore extends PanelStore {
32 findPrevious: action, 32 findPrevious: action,
33 replaceNext: action, 33 replaceNext: action,
34 replaceAll: action, 34 replaceAll: action,
35 selectSearchField: false,
35 }); 36 });
36 } 37 }
37 38
diff --git a/subprojects/frontend/src/editor/SearchToolbar.tsx b/subprojects/frontend/src/editor/SearchToolbar.tsx
index 895f1ca1..a9b9811d 100644
--- a/subprojects/frontend/src/editor/SearchToolbar.tsx
+++ b/subprojects/frontend/src/editor/SearchToolbar.tsx
@@ -27,7 +27,7 @@ const DimLabel = styled(FormControlLabel)(({ theme }) => ({
27 }, 27 },
28})); 28}));
29 29
30function SearchToolbar({ 30export default observer(function SearchToolbar({
31 searchPanelStore, 31 searchPanelStore,
32}: { 32}: {
33 searchPanelStore: SearchPanelStore; 33 searchPanelStore: SearchPanelStore;
@@ -271,6 +271,4 @@ function SearchToolbar({
271 </Stack> 271 </Stack>
272 </Toolbar> 272 </Toolbar>
273 ); 273 );
274} 274});
275
276export default observer(SearchToolbar);