-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multi-entity multi-property undo redo (#50911)
- Loading branch information
1 parent
dd99224
commit 41907dc
Showing
10 changed files
with
336 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import type { State, UndoEdit } from './selectors'; | ||
|
||
type Optional< T > = T | undefined; | ||
|
||
/** | ||
* Returns the previous edit from the current undo offset | ||
* for the entity records edits history, if any. | ||
* | ||
* @param state State tree. | ||
* | ||
* @return The edit. | ||
*/ | ||
export function getUndoEdits( state: State ): Optional< UndoEdit[] > { | ||
return state.undo.list[ state.undo.list.length - 1 + state.undo.offset ]; | ||
} | ||
|
||
/** | ||
* Returns the next edit from the current undo offset | ||
* for the entity records edits history, if any. | ||
* | ||
* @param state State tree. | ||
* | ||
* @return The edit. | ||
*/ | ||
export function getRedoEdits( state: State ): Optional< UndoEdit[] > { | ||
return state.undo.list[ state.undo.list.length + state.undo.offset ]; | ||
} |
Oops, something went wrong.