undo-redo icon indicating copy to clipboard operation
undo-redo copied to clipboard

Passing messages without saving result into undo history

Open bardt opened this issue 9 years ago • 8 comments

I there a way to ignore some messages? Say I'm in the middle of inputing text, and I don't want to save each letter into history, and save it only after input finished.

I'd suggest to introduce new kind of message (and corresponding function), Pass subaction.

Is it a good idea? Should I make a PR to demo what I suggest?

bardt avatar Jun 09 '16 04:06 bardt

PR would be very welcome :)

rohanorton avatar Jun 09 '16 09:06 rohanorton

@rohanorton I'll create it in a few days, after I try it on a real project.

bardt avatar Jun 10 '16 07:06 bardt

I had the same question a few days ago. What I did in my app is to add a new history state on space input so that the history is word based, and not letter based.

Here is the commit: https://github.com/cbenz/noteminer/commit/d0f654582635745be4b7bbe7dbe2e6ce9b2f6ec4#diff-de84bd170bc37fbce0a7076c0125dd29R768

I know it is quite hacky but perhaps it helps.

cbenz avatar Sep 27 '16 18:09 cbenz

I'm interested in this. I thought that a reasonable approach would be to use onfocus on the text input to create an 'undo block', then everything is put in that one block until the 'onblur' event which would close that block. I think I am more used to thinking of this in terms of object-oriented approaches. Interesting to see the mapPresent approach above. That also makes sense, though again you need some state to know when to apply that versus a new undo state. I think.

michaeljones avatar Jan 08 '18 11:01 michaeljones

redux-undo provide filtering and grouping for this https://github.com/omnidan/redux-undo

acateland avatar Jul 27 '18 14:07 acateland

I use a a series of 'hook' functions (one for undo-redo, another one for interacting with the DOM etc.).

janwirth avatar Feb 06 '20 13:02 janwirth

Old topic I know. But maybe someone is still interested. I made a version (F#) which is able to do "non-persistent" updates, transactions for bulk updates and jumping to a new present state by clicking in a list of states. Please, bear with me for the functional code. I'm pretty new to this stuff.

Todo List with Undo/Redo

KingKnecht avatar Dec 09 '20 21:12 KingKnecht

Can you also write an elm version pls :joy:

JK thank you for letting us know where to look to :)

janwirth avatar Dec 09 '20 21:12 janwirth