@@ -131,7 +131,7 @@ export function EntityForm<M extends Record<string, any>>({
131
131
entityId : entityIdProp ,
132
132
collection,
133
133
path,
134
- values : valuesToBeSaved ,
134
+ values : valuesToBeSaved
135
135
} ) ;
136
136
} , false , 2000 ) ;
137
137
@@ -222,6 +222,29 @@ export function EntityForm<M extends Record<string, any>>({
222
222
}
223
223
} ) ;
224
224
225
+
226
+ useEffect ( ( ) => {
227
+
228
+ const handleKeyDown = ( e : KeyboardEvent ) => {
229
+ const isUndo = ( e . metaKey || e . ctrlKey ) && ! e . shiftKey && e . key . toLowerCase ( ) === "z" ;
230
+ const isRedo =
231
+ ( ( e . metaKey || e . ctrlKey ) && e . shiftKey && e . key . toLowerCase ( ) === "z" ) ||
232
+ ( ( e . metaKey || e . ctrlKey ) && ! e . shiftKey && e . key . toLowerCase ( ) === "y" ) ;
233
+
234
+ if ( isUndo && formex . canUndo ) {
235
+ e . preventDefault ( ) ;
236
+ formex . undo ( ) ;
237
+ } else if ( isRedo && formex . canRedo ) {
238
+ e . preventDefault ( ) ;
239
+ formex . redo ( ) ;
240
+ }
241
+ } ;
242
+
243
+ window . addEventListener ( "keydown" , handleKeyDown ) ;
244
+ return ( ) => window . removeEventListener ( "keydown" , handleKeyDown ) ;
245
+
246
+ } , [ formex ] ) ;
247
+
225
248
const resolvedCollection = useMemo ( ( ) => resolveCollection < M > ( {
226
249
collection,
227
250
path,
@@ -349,7 +372,7 @@ export function EntityForm<M extends Record<string, any>>({
349
372
path,
350
373
entityId,
351
374
values,
352
- previousValues,
375
+ previousValues
353
376
} ) ;
354
377
}
355
378
} ;
@@ -656,7 +679,7 @@ export function EntityForm<M extends Record<string, any>>({
656
679
< form
657
680
onSubmit = { formContext . formex . handleSubmit }
658
681
onReset = { ( ) => formex . resetForm ( {
659
- values : getInitialEntityValues ( collection , path , status , entity , customizationController . propertyConfigs ) as M ,
682
+ values : getInitialEntityValues ( collection , path , status , entity , customizationController . propertyConfigs ) as M
660
683
} ) }
661
684
noValidate
662
685
className = { cls ( "flex-1 flex flex-row w-full overflow-y-auto justify-center" , className ) } >
0 commit comments