You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m trying to build my own Block Editor and I would like to reset all blocks to their last saved state by dismissing all unsaved changes when switching from Edit Mode to Preview Mode without reloading the page.
then parse its raw content as well, add them to an array with all other blocks currently on the page and throw it altogether into the resetBlocks() method. The behavior I’m getting is that the saved Reusable Blocks are just added to the current page, in addition to the edited Reusable Blocks, so that there are now duplicates on the page. I’m not quite sure why this is happening and I’m wondering if anybody knows what’s going on or if anybody has an idea of how it could be done.
Any help is greatly appreciated :)
Thank you!
P.S. It could be done if I could get the block content from all the InnerBlocks inside Reusable Blocks, but these InnerBlocks are always multiple layers deep nested, differently for all individual Reusable Blocks, which are again different for every website. So that seems like an impossible task for me.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I’m trying to build my own Block Editor and I would like to reset all blocks to their last saved state by dismissing all unsaved changes when switching from Edit Mode to Preview Mode without reloading the page.
Currently it works fine with all “normal” blocks:
Unfortunately it doesn’t work as expected with Reusable Blocks.
For example I can get all saved Reusable Blocks with
const savedReusableBlocks = select('core').getEntityRecords('postType','wp_block');
then parse its raw content as well, add them to an array with all other blocks currently on the page and throw it altogether into the resetBlocks() method. The behavior I’m getting is that the saved Reusable Blocks are just added to the current page, in addition to the edited Reusable Blocks, so that there are now duplicates on the page. I’m not quite sure why this is happening and I’m wondering if anybody knows what’s going on or if anybody has an idea of how it could be done.
Any help is greatly appreciated :)
Thank you!
P.S. It could be done if I could get the block content from all the InnerBlocks inside Reusable Blocks, but these InnerBlocks are always multiple layers deep nested, differently for all individual Reusable Blocks, which are again different for every website. So that seems like an impossible task for me.
Beta Was this translation helpful? Give feedback.
All reactions