-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with adding undo/redo #15
base: master
Are you sure you want to change the base?
Conversation
|
||
|
||
export const getBlocks = ( state ) => { | ||
return state.present.blocks || []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this to allow for a default/fallback set of blocks, so that can reload blocks previously worked on;
export const getBlocks = ( state, defaultBlocks=[] ) => {
return state.present.blocks || defaultBlocks;
}
const blocks = useSelect((select) => select("getdavesbe").getBlocks(parse(storedBlocks)));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep although grabbing for storage is a side effect so should probably be handled in a control action. Still working that one out.
Co-authored-by: Patrick Lindsay <[email protected]>
Co-authored-by: Patrick Lindsay <[email protected]>
Still need to fix things so minor undo levels aren't created. Isolated Block Editor uses different actions to control the behaviour here. I need to look into this |
As requested in this #6 this PR shows a PoC for adding undo/redo functionality to the standalone editor.
It's far from perfect as the real undo/redo functionality in the Post editor is more sophisticated and accounts for more scenarios.
That said it works at a basic level and should act as a good kicking off point.