arthurclemens / javascript-undo-manager Goto Github PK
View Code? Open in Web Editor NEWSimple JavaScript undo and redo independent of other libraries
License: Other
Simple JavaScript undo and redo independent of other libraries
License: Other
⌘
+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?
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.
This is the version that we had been using: https://github.com/Spreadsheets/jQuery.sheet/blob/3.x/plugins/undomanager.js
We switched to bower, and now it seems everything is broken, I'm sure we just need to adjust how we've implemented, starting here: https://github.com/Spreadsheets/jQuery.sheet/blob/master/jquery.sheet.js#L8364
Please note the internal reference to "jS.undo.manager" is the instantiated UndoManager. Thanks in advance!
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.
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.
Is it possible to make ES6 and TS versions?
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]();
}
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
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
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
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"
}
},
});
``´
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:
So I just rollback to version 1.0.5 and lock the version in package.json.
In some cases I need only Undo without Redo ..it is not possible right now. Or to clear only last undo/redo step.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.