Skip to content

Commit 9e4720b

Browse files
CopilotBuckwich
andcommitted
Add CodeMirror history extension to enable undo/redo for clear operation
Co-authored-by: Buckwich <7346215+Buckwich@users.noreply.github.com>
1 parent d044260 commit 9e4720b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/components/Input/InputEditor.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
22
import { renderToStaticMarkup } from 'react-dom/server';
33

44
import { autocompletion, closeBrackets } from '@codemirror/autocomplete';
5-
import { defaultKeymap } from '@codemirror/commands';
5+
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
66
import { bracketMatching, indentOnInput } from '@codemirror/language';
77
import { Compartment, EditorState, Annotation } from '@codemirror/state';
88
import { EditorView, keymap, placeholder } from '@codemirror/view';
@@ -96,11 +96,13 @@ export default function InputEditor({
9696
const editorState = EditorState.create({
9797
doc: value,
9898
extensions: [
99+
history(),
99100
autocompletion(),
100101
closeBrackets(),
101102
bracketMatching(),
102103
indentOnInput(),
103104
keymap.of([
105+
...historyKeymap,
104106
...defaultKeymap
105107
]),
106108
new Compartment().of(json()),

0 commit comments

Comments
 (0)