How to use redux-undo - 10 common examples

To help you get started, we’ve selected a few redux-undo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / incubator-superset / superset / assets / spec / javascripts / dashboard / actions / dashboardLayout_spec.js View on Github external
it('should dispatch a redux-undo .redo() action ', () => {
      const { getState, dispatch } = setup();
      const thunk = redoLayoutAction();
      thunk(dispatch, getState);

      expect(dispatch.getCall(0).args[0]).toEqual(UndoActionCreators.redo());

      // redo/undo should trigger action for dashboardFilters
      expect(dashboardFilters.updateLayoutComponents.callCount).toEqual(1);
    });
github wonderunit / storyboarder / src / js / xr / src / use-interactions-manager.js View on Github external
const onPressEndB = event => {
    // to relay through state machine instead:
    // interactionService.send({ type: 'PRESS_END_B', controller: event.target })

    if (canRedo && interactionService.state.value !== "character_posing") {
      dispatch(ActionCreators.redo())
      playSound('redo')
    }
  }
github wonderunit / storyboarder / src / js / xr / src / use-interactions-manager.js View on Github external
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')
    }
  }
github mojs / mojs-curve-editor / app / js / tags / curve-editor.babel.jsx View on Github external
_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); }
    }
  }
github mojs / mojs-curve-editor / app / js / tags / curve-editor.babel.jsx View on Github external
_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); }
    }
  }
github ging / ediphy / _editor / containers / EditorApp.jsx View on Github external
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();
github apache / incubator-superset / superset / assets / spec / javascripts / dashboard / actions / dashboardLayout_spec.js View on Github external
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());
    });
github ging / ediphy / _editor / containers / EditorApp.jsx View on Github external
                        redo={() => {this.dispatchAndSetState(ActionCreators.redo());}}
                        visor={() =>{this.setState({ visorVisible: true });}}
github joker1007 / blackalbum / src / containers / root.js View on Github external
historyForward() {
    let { dispatch } = this.props;
    dispatch(ActionCreators.redo());
  }
github mickeyjsx / mickey / examples / counter-undo / src / App.jsx View on Github external
      <button> props.dispatch(ActionCreators.redo())}&gt;Redo</button>

redux-undo

simple undo/redo functionality for redux state containers

MIT
Latest version published 9 months ago

Package Health Score

69 / 100
Full package analysis