diff --git a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts index 7324868b0..babe02f69 100644 --- a/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts +++ b/apps/client/src/widgets/type_widgets/abstract_code_type_widget.ts @@ -56,13 +56,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget { * @param {*} content the new content of the note. */ _update(note: { mime: string }, content: string) { - this.codeEditor.dispatch({ - changes: { - from: 0, - to: this.codeEditor.state.doc.length, - insert: content || "", - } - }) + this.codeEditor.setText(content); // this.codeEditor.clearHistory(); // let info = CodeMirror.findModeByMIME(note.mime); diff --git a/packages/codemirror/src/index.ts b/packages/codemirror/src/index.ts index 8ee32032e..20c76b227 100644 --- a/packages/codemirror/src/index.ts +++ b/packages/codemirror/src/index.ts @@ -11,4 +11,14 @@ export default class CodeMirror extends EditorView { ] }); } + + setText(content: string) { + this.dispatch({ + changes: { + from: 0, + to: this.state.doc.length, + insert: content || "", + } + }) + } }