GithubHelp home page GithubHelp logo

arthurclemens / javascript-undo-manager Goto Github PK

View Code? Open in Web Editor NEW
437.0 437.0 79.0 176 KB

Simple JavaScript undo and redo independent of other libraries

License: Other

JavaScript 88.37% Shell 0.90% HTML 10.73%

javascript-undo-manager's People

Contributors

arthurclemens avatar jondum avatar nonplus avatar stannedelchev avatar ynonp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-undo-manager's Issues

Keyboard support for (⌘+Z, ⌘+Y, etc)

+Z for undo, +shift+Z and +Y for redo, or even a custom combination.

Is this something you would pursue or would you rather leave it to the dev to implement?

add undo/redo pair at separate times.

HI im trying to use undoManager to undo movement of an element, I have a function for when movement begins and when movement ends respectively. So I have written this:

                   dragstart: function (layer) {
                    // code to run when dragging starts
                        var dragstartx = layer.x;
                        var dragstarty = layer.y;
                        $canvas.undoManager.add({
                            undo:function(){
                                $canvas.setLayer(layer, {
                                    x:dragstartx,
                                    y:dragstarty
                                }).drawLayers();               
                            }
                        });


                    },
                    dragstop: function (layer){
                    // code to run when dragging starts
                        var dragstopx = layer.x;
                        var dragstopy = layer.y;
                        $canvas.undoManager.add({
                            redo:function(){
                                $canvas.setLayer(layer, {
                                    x:dragstopx,
                                    y:dragstopy
                                }).drawLayers();

                            }
                        });

                    },

This works almost perfect, the only issue is when you move twice and want to undo both, you have to actually hit redo 4 times because it seems to "insert" empty undo's whenever the dragstop adds the redo without specifying an undo.

bower.json - wrong main path

Hi, you have typo in your bower.json. The "main" parameter should point to "lib/undomanager.js" but instead it points to incorrect location "js/undomanager.js".
This generates problem for grunt-wiredep, because it generates wrong path to your js file.
Thanks.

Add getIndex() method

I'd like to show the undo/redo operations available to my users. I can access the list of operations using getCommands() but currently I can't tell where in the command stack the undo manager is. Adding an getIndex() method that returns the internal index value would solve this for me.

Alternatively, you could expose getUndoCommands() and getRedoCommands() methods.

Ignore tasks if redo doesn't exist

Could we please wrap execute() with a typeof so that we ignore it if the redo isn't a function?

if (typeof command[action] === "function") {
    command[action]();
}

Undo limit

Is it possible to set a limit on the number of undos? for example, each change may be rather large in memory and you may wish to conserve the build up of memory by limiting to 20-30 undos.

Thanks

Updating undo manager commands

Hi,

I am using undo manager for an app where I can draw svg elements like (rect, circle, text, ellipse).
When I create a single rect element it calls multiple create/update methods and I am adding commands in this method, which results in adding lot of undo and redo calls for a single element.
Can you pls let me know is it possible to update the undo manager to keep only one command for each svg element created.

Thanks

backbone version?

Hi, thank you for your useful utility!

"A backbone version of the undo manager is also provided" is stated in the README, where do I find it?

this.undoManager.bind('change', callback); doesn't work

How to use this with requireJS?

I cannot get it to work with requireJS. Tried to setup a shim and all but nothing. I cannot use the methods exported by the ctor function.

requirejs.config({
    baseUrl: "/js",
    paths: {
      undomanager: "lib/undomanager"
    },
    shim: {
      undomanager: {
        exports: "UndoManager"
      }
    },
  });
``´

can't install on Windows because of symlink in the 'postinstall' script

On Mac or Linux systems, the 'postinstall' script which is 'sh scripts/link-lib.sh' works well.

But on Windows, you know, it can't read the 'sh' script. There is also no 'symbol link' on Windows's file system.

When you install this package by using 'npm install' or 'yarn install' on Windows, there will be some error output like this:
image

So I just rollback to version 1.0.5 and lock the version in package.json.

Undo without Redo

In some cases I need only Undo without Redo ..it is not possible right now. Or to clear only last undo/redo step.

how to handle asyn commands?

Hello, nice lib. I'm trying to add do/redo functionallity, the only issue I have is that some of my commands (do/redos) are async, so it turns into rare behavior when I click "ctrl+z" pretty fast, because the last undo call is not waiting for the firsts calls. Is there a way to handle this ?

thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.