aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/editor
diff options
context:
space:
mode:
Diffstat (limited to 'language-web/src/main/js/editor')
-rw-r--r--language-web/src/main/js/editor/EditorButtons.tsx9
-rw-r--r--language-web/src/main/js/editor/EditorStore.ts6
2 files changed, 13 insertions, 2 deletions
diff --git a/language-web/src/main/js/editor/EditorButtons.tsx b/language-web/src/main/js/editor/EditorButtons.tsx
index 09ce33dd..150aa00d 100644
--- a/language-web/src/main/js/editor/EditorButtons.tsx
+++ b/language-web/src/main/js/editor/EditorButtons.tsx
@@ -7,6 +7,7 @@ import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
7import CheckIcon from '@mui/icons-material/Check'; 7import CheckIcon from '@mui/icons-material/Check';
8import ErrorIcon from '@mui/icons-material/Error'; 8import ErrorIcon from '@mui/icons-material/Error';
9import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered'; 9import FormatListNumberedIcon from '@mui/icons-material/FormatListNumbered';
10import FormatPaint from '@mui/icons-material/FormatPaint';
10import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; 11import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
11import RedoIcon from '@mui/icons-material/Redo'; 12import RedoIcon from '@mui/icons-material/Redo';
12import SearchIcon from '@mui/icons-material/Search'; 13import SearchIcon from '@mui/icons-material/Search';
@@ -47,7 +48,6 @@ export const EditorButtons = observer(() => {
47 disabled={!editorStore.canUndo} 48 disabled={!editorStore.canUndo}
48 onClick={() => editorStore.undo()} 49 onClick={() => editorStore.undo()}
49 aria-label="Undo" 50 aria-label="Undo"
50 value="undo"
51 > 51 >
52 <UndoIcon fontSize="small" /> 52 <UndoIcon fontSize="small" />
53 </IconButton> 53 </IconButton>
@@ -55,7 +55,6 @@ export const EditorButtons = observer(() => {
55 disabled={!editorStore.canRedo} 55 disabled={!editorStore.canRedo}
56 onClick={() => editorStore.redo()} 56 onClick={() => editorStore.redo()}
57 aria-label="Redo" 57 aria-label="Redo"
58 value="redo"
59 > 58 >
60 <RedoIcon fontSize="small" /> 59 <RedoIcon fontSize="small" />
61 </IconButton> 60 </IconButton>
@@ -88,6 +87,12 @@ export const EditorButtons = observer(() => {
88 {getLintIcon(editorStore.highestDiagnosticLevel)} 87 {getLintIcon(editorStore.highestDiagnosticLevel)}
89 </ToggleButton> 88 </ToggleButton>
90 </ToggleButtonGroup> 89 </ToggleButtonGroup>
90 <IconButton
91 onClick={() => editorStore.formatText()}
92 aria-label="Automatic format"
93 >
94 <FormatPaint fontSize="small" />
95 </IconButton>
91 </Stack> 96 </Stack>
92 ); 97 );
93}); 98});
diff --git a/language-web/src/main/js/editor/EditorStore.ts b/language-web/src/main/js/editor/EditorStore.ts
index 059233f4..5760de28 100644
--- a/language-web/src/main/js/editor/EditorStore.ts
+++ b/language-web/src/main/js/editor/EditorStore.ts
@@ -115,6 +115,7 @@ export class EditorStore {
115 lineNumbers(), 115 lineNumbers(),
116 foldGutter(), 116 foldGutter(),
117 keymap.of([ 117 keymap.of([
118 { key: 'Mod-Shift-f', run: () => this.formatText() },
118 ...closeBracketsKeymap, 119 ...closeBracketsKeymap,
119 ...commentKeymap, 120 ...commentKeymap,
120 ...completionKeymap, 121 ...completionKeymap,
@@ -280,4 +281,9 @@ export class EditorStore {
280 toggleLintPanel(): void { 281 toggleLintPanel(): void {
281 this.setLintPanelOpen(!this.showLintPanel); 282 this.setLintPanelOpen(!this.showLintPanel);
282 } 283 }
284
285 formatText(): boolean {
286 this.client.formatText();
287 return true;
288 }
283} 289}