Add feature to view if it can undo or redo
See original GitHub issueI was thinking if it would be possible to add apis to check if it can undo or redo. I was thinking maybe: canUndo
and canRedo
which would return true or false. it would be nice to also store history change itself like: history
store.history()
// returned object:
{
undo: {
depth: 3,
changes: [
"bears",
"bears.females",
"allPopulation"
],
// same for redo
}
Of course this is a proposal and any comment is welcome.
Or we could even attach the apis to undo
and redo
directly like so: undo.history
or undo.depth
or undo.canUndo
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:27 (15 by maintainers)
Top Results From Across the Web
Undo or redo typing or design changes - Microsoft Support
You can undo and redo up to 20 of your last typing or design actions in Access. To undo an action, press Ctrl...
Read more >Implement Undo and Redo features of a Text Editor
“REDO”: Restores the most recent UNDO operation performed on the document. “READ”: Reads and prints the contents of the documents. Examples:.
Read more >Undo/redo and history in Adobe Photoshop
Undo or redo multiple steps in Photoshop. Use the History panel to control the state of your images in Adobe Photoshop.
Read more >Filter undo and redo for editing—ArcGIS Pro | Documentation
On the Quick Access toolbar, you can filter the undo stack and roll back a selected range of edits without undoing mapping changes,...
Read more >Undo or redo changes in Pages on Mac - Apple Support
You can undo recent changes you make to a document, then redo them if you change your mind. Do any of the following:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @vixalien and @feuersteiner,
As far as the
canUndo
,canRedo
,undoDepth
,redoDepth
functionality, since those are computed values, I don’t think it is necessary to add the to main temporal store in the zundo middleware. However, I think a meta-data helper function would be useful to add so I’ll work on that.For the time being, here is a code sandbox
canUndo
,canRedo
,undoDepth
,redoDepth
that implementscanUndo
,canRedo
,undoDepth
, andredoDepth
with zundo v2.Thanks for the feedback!
If I only use the
.temporal
store in my component, it doesn’t get re-rendered when I callundo()
orredo()
becausepastStates
andfutureStates
are not changing identity (not 100% about this), they’re simply being changed in place withpush
andsplice
.It works in your demos, because you have everything in one component, but if there’s a component that is using just the temporal state, it breaks.