Skip to content

Commit 951c3b0

Browse files
committed
refactor: prevent undo of the initial value (#9)
1 parent 954d8cc commit 951c3b0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

projects/code-editor/code-editor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
1717

1818
import { indentWithTab } from '@codemirror/commands';
1919
import { LanguageDescription, indentUnit } from '@codemirror/language';
20-
import { Annotation, Compartment, EditorState, Extension, StateEffect } from '@codemirror/state';
20+
import {
21+
Annotation,
22+
Compartment,
23+
EditorState,
24+
Extension,
25+
StateEffect,
26+
Transaction,
27+
} from '@codemirror/state';
2128
import { oneDark } from '@codemirror/theme-one-dark';
2229
import { EditorView, highlightWhitespace, keymap, placeholder } from '@codemirror/view';
2330
import { basicSetup, minimalSetup } from 'codemirror';
@@ -275,6 +282,7 @@ export class CodeEditor implements OnChanges, OnInit, OnDestroy, ControlValueAcc
275282
setValue(value: string) {
276283
this.view.dispatch({
277284
changes: { from: 0, to: this.view.state.doc.length, insert: value },
285+
annotations: Transaction.addToHistory.of(false),
278286
});
279287
}
280288

0 commit comments

Comments
 (0)