vip-governance-plugin icon indicating copy to clipboard operation
vip-governance-plugin copied to clipboard

Use a better solution for determining core nested blocks

Open ingeniumed opened this issue 2 years ago • 2 comments

The current approach to allowing critical core blocks is via a hardcoded map. There is a way to access the allowedBlocks property in the innerBlocks using the following command:

wp.data.select( 'core/block-editor' ).getAllowedBlocks('49abcad4-4be5-46d0-8db5-44760f15e0e7')

Using this in code causes a call stack exceeded. If this works, this would be a better solution long term.

ingeniumed avatar Aug 29 '23 07:08 ingeniumed

https://github.com/WordPress/gutenberg/blob/58f5e9a6a972d16aeca13693ce863bcedaf342b0/packages/block-editor/src/store/selectors.js#L2164

ingeniumed avatar Aug 29 '23 07:08 ingeniumed

This issue was brought up by a VIP customer on a recent call. They are hooking into the setDefaultBlockName function from @wordpress/blocks module. Perhaps this is another method to determine what core blocks are auto-inserted.

In this client's case, they are replacing the core paragraph block with a custom block, making our hard-coded map problematic.

smithjw1 avatar Nov 16 '23 17:11 smithjw1