Specific block shown in inserter while adding block outside any block
Hello there, I hit a problem and cannot get over it :/ I've done some resarch but found nothing to use. The problem is: I want inserter show only section block if "add click" happens outside section block, but when "add click" happens inside section block, the inserter shows all blocks. Something similar to Divi Page Builder mechanism. This unables user to add any block outside section block (except section block itself ofc). The project is created using create-guten-block. I've tried allowed_blocks and setting parent but with no result. Does anyone have any clues how to solve it?
Hi There!
I don't think that's possible in Gutenberg. What you can probably do is to do a two levels setup.
Create a custom block (let's call it "root") that can only have the "section" block as a children using the "allowedBlocks" prop of InnerBlocks. And use a locked template for your CPT to automatically add this "root" block to your editor.
https://developer.wordpress.org/block-editor/developers/block-api/block-templates/
Also note that this tracker is not meant for help requests. Technical help requests have their own section of the support forum at https://wordpress.org/support/forum/wp-advanced/.
You may also ask for technical support at https://wordpress.stackexchange.com/.
Thank you!
Thanks for fint!