diff options
Diffstat (limited to 'subprojects/frontend/src/editor/createEditorState.ts')
-rw-r--r-- | subprojects/frontend/src/editor/createEditorState.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/subprojects/frontend/src/editor/createEditorState.ts b/subprojects/frontend/src/editor/createEditorState.ts index 67b8fb9e..9b29228f 100644 --- a/subprojects/frontend/src/editor/createEditorState.ts +++ b/subprojects/frontend/src/editor/createEditorState.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/> | 2 | * SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/> |
3 | * | 3 | * |
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
@@ -26,7 +26,7 @@ import { | |||
26 | } from '@codemirror/language'; | 26 | } from '@codemirror/language'; |
27 | import { lintKeymap, lintGutter } from '@codemirror/lint'; | 27 | import { lintKeymap, lintGutter } from '@codemirror/lint'; |
28 | import { search, searchKeymap } from '@codemirror/search'; | 28 | import { search, searchKeymap } from '@codemirror/search'; |
29 | import { EditorState } from '@codemirror/state'; | 29 | import { Compartment, EditorState, type Extension } from '@codemirror/state'; |
30 | import { | 30 | import { |
31 | drawSelection, | 31 | drawSelection, |
32 | highlightActiveLine, | 32 | highlightActiveLine, |
@@ -46,6 +46,12 @@ import exposeDiagnostics from './exposeDiagnostics'; | |||
46 | import findOccurrences from './findOccurrences'; | 46 | import findOccurrences from './findOccurrences'; |
47 | import semanticHighlighting from './semanticHighlighting'; | 47 | import semanticHighlighting from './semanticHighlighting'; |
48 | 48 | ||
49 | export const historyCompartment = new Compartment(); | ||
50 | |||
51 | export function createHistoryExtension(): Extension { | ||
52 | return history(); | ||
53 | } | ||
54 | |||
49 | export default function createEditorState( | 55 | export default function createEditorState( |
50 | initialValue: string, | 56 | initialValue: string, |
51 | store: EditorStore, | 57 | store: EditorStore, |
@@ -66,7 +72,7 @@ export default function createEditorState( | |||
66 | highlightActiveLine(), | 72 | highlightActiveLine(), |
67 | highlightActiveLineGutter(), | 73 | highlightActiveLineGutter(), |
68 | highlightSpecialChars(), | 74 | highlightSpecialChars(), |
69 | history(), | 75 | historyCompartment.of([createHistoryExtension()]), |
70 | indentOnInput(), | 76 | indentOnInput(), |
71 | rectangularSelection(), | 77 | rectangularSelection(), |
72 | search({ | 78 | search({ |
@@ -103,6 +109,9 @@ export default function createEditorState( | |||
103 | }), | 109 | }), |
104 | keymap.of([ | 110 | keymap.of([ |
105 | { key: 'Mod-Shift-f', run: () => store.formatText() }, | 111 | { key: 'Mod-Shift-f', run: () => store.formatText() }, |
112 | { key: 'Ctrl-o', run: () => store.openFile() }, | ||
113 | { key: 'Ctrl-s', run: () => store.saveFile() }, | ||
114 | { key: 'Ctrl-Shift-s', run: () => store.saveFileAs() }, | ||
106 | ...closeBracketsKeymap, | 115 | ...closeBracketsKeymap, |
107 | ...completionKeymap, | 116 | ...completionKeymap, |
108 | ...foldKeymap, | 117 | ...foldKeymap, |