aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/editor/createEditorState.ts
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/editor/createEditorState.ts')
-rw-r--r--subprojects/frontend/src/editor/createEditorState.ts15
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';
27import { lintKeymap, lintGutter } from '@codemirror/lint'; 27import { lintKeymap, lintGutter } from '@codemirror/lint';
28import { search, searchKeymap } from '@codemirror/search'; 28import { search, searchKeymap } from '@codemirror/search';
29import { EditorState } from '@codemirror/state'; 29import { Compartment, EditorState, type Extension } from '@codemirror/state';
30import { 30import {
31 drawSelection, 31 drawSelection,
32 highlightActiveLine, 32 highlightActiveLine,
@@ -46,6 +46,12 @@ import exposeDiagnostics from './exposeDiagnostics';
46import findOccurrences from './findOccurrences'; 46import findOccurrences from './findOccurrences';
47import semanticHighlighting from './semanticHighlighting'; 47import semanticHighlighting from './semanticHighlighting';
48 48
49export const historyCompartment = new Compartment();
50
51export function createHistoryExtension(): Extension {
52 return history();
53}
54
49export default function createEditorState( 55export 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,