Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const onPressEndA = event => {
// to relay through state machine instead:
// interactionService.send({ type: 'PRESS_END_A', controller: event.target })
if (canUndo && interactionService.state.value !== "character_posing") {
dispatch(ActionCreators.undo())
playSound('undo')
}
}
_onKeyUp (e) {
const {store} = this.context;
const {controls} = this._state;
// don't react on shortcuts if inactive or minimized
if (!controls.isActive || controls.isMinimize) { return; }
// don't react if `alt` key is not set
if ( !e.altKey ) { return; }
switch (e.which) {
// z
case 90: { return store.dispatch(ActionCreators.undo()); }
// x
case 88: { return store.dispatch(ActionCreators.redo()); }
// d
case 68: { return store.dispatch({ type: 'POINT_DELETE' }); }
// \
case 220: { return e.shiftKey && this._tryToReset(store); }
}
}
keyListener(e) {
let key = e.keyCode ? e.keyCode : e.which;
if (key === 9) {
e.preventDefault();
return;
}
// Checks what element has the cursor focus currently
let focus = document.activeElement.className;
let notText = (!document.activeElement.type || focus.indexOf('rib') !== -1) && focus.indexOf('form-control') === -1 && focus.indexOf('tituloCurso') === -1 && focus.indexOf('cke_editable') === -1;
// Ctrl + Z
if (key === 90 && e.ctrlKey) {
if (notText) {
this.props.dispatch(ActionCreators.undo());
}
}
// Ctrl + Y
if (key === 89 && e.ctrlKey) {
if (notText) {
this.props.dispatch(ActionCreators.redo());
}
}
// Ctrl + A
if (key === 192 && e.ctrlKey) {
this.duplicateNavItem(this.props.navItemSelected);
}
if (key === 80 && e.ctrlKey && e.shiftKey) {
e.cancelBubble = true;
e.preventDefault();
it('should dispatch a redux-undo .undo() action ', () => {
const { getState, dispatch } = setup({
dashboardLayout: { past: ['non-empty'] },
});
const thunk = undoLayoutAction();
thunk(dispatch, getState);
expect(dispatch.callCount).toBe(1);
expect(dispatch.getCall(0).args[0]).toEqual(UndoActionCreators.undo());
});
undo={() => {this.dispatchAndSetState(ActionCreators.undo());}}
redo={() => {this.dispatchAndSetState(ActionCreators.redo());}}
return (dispatch, getState) => {
dispatch(UndoActionCreators.undo());
const { dashboardLayout, dashboardState } = getState();
if (
dashboardLayout.past.length === 0 &&
!dashboardState.maxUndoHistoryExceeded &&
!dashboardState.updatedColorScheme
) {
dispatch(setUnsavedChanges(false));
}
};
}
historyBack() {
let { dispatch } = this.props;
dispatch(ActionCreators.undo());
}
<button> props.dispatch(ActionCreators.undo())}>Undo</button>
<button> props.dispatch(ActionCreators.redo())}>Redo</button>
undo() {
dispatch(undoActions.undo())
},
redo() {
onClick={() => dispatch(ActionCreators.undo())}
icon={}