11import { LitElement , html , css } from 'lit' ;
22import { EditorState } from "@codemirror/state" ;
33import { EditorView , lineNumbers , keymap , highlightActiveLineGutter , highlightSpecialChars } from "@codemirror/view" ;
4- import { defaultKeymap , indentWithTab } from "@codemirror/commands" ;
4+ import { defaultKeymap , indentWithTab , undo , redo , history } from "@codemirror/commands" ;
55import { autocompletion } from '@codemirror/autocomplete' ;
66import { xml } from '@codemirror/lang-xml' ;
77import { javascript } from '@codemirror/lang-javascript' ;
@@ -41,8 +41,8 @@ class QuiCodeBlock extends LitElement {
4141 display: block;
4242 height: 100%;
4343 }
44-
45- #codeMirrorContainer {
44+
45+ #codeMirrorContainer, .cm-editor {
4646 height: 100%;
4747 }
4848
@@ -159,6 +159,7 @@ class QuiCodeBlock extends LitElement {
159159 } ;
160160
161161 const conf = [
162+ history ( ) ,
162163 this . _detectMode ( ) ,
163164 this . _basicTheme ,
164165 highlightActiveLineGutter ( ) ,
@@ -168,8 +169,11 @@ class QuiCodeBlock extends LitElement {
168169 keymap . of ( [
169170 { key : "Shift-Enter" , run : shiftEnterCommand } ,
170171 indentWithTab ,
171- ...defaultKeymap
172- ] ) ,
172+ ...defaultKeymap ,
173+ { key : "Mod-z" , run : undo } , // Undo
174+ { key : "Mod-y" , run : redo } , // Redo
175+ { key : "Mod-Shift-z" , run : redo } // Redo (macOS)
176+ ] ) ,
173177 EditorView . updateListener . of ( ( update ) => {
174178 if ( update . docChanged ) {
175179 const value = update . state . doc . toString ( ) ;
0 commit comments