Add a mechanism for themes to prevent insertion of new blocks at root of block template part #42775
Labels
[Feature] Block API
API that allows to express the block paradigm.
[Feature] Block Locking
The API allowing for the ability to lock/unlock blocks
[Feature] Template Editing Mode
Related to the template editor available in the Block Editor
[Feature] Templates API
Related to API powering block template functionality in the Site Editor
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
This came up while testing #42729. When a theme provides a block template part there are cases where the theme wants to wrap a template part in a single element and only allow the insertion of new blocks within that root. Let's take a site-wide notification area or even a Cookie banner as an example. As a theme author, I want editors to be able to visually edit the content of that template part. But I want to ensure that all the content is located within a full-width aligned group block.
I can already use the block locking attributes to prevent editors from being able to remove the wrapping group block for example. But I currently cannot prevent editors from inserting any additional blocks at the root level of the template part. Ideally, there would be a way similar to how the
templateLock
on custom post types works.What is your proposed solution?
It would be great to be able to define a
templateLock
at the level of individual template parts. This could be achieved via a metadata header in the.html
template part file. Or via thetemplateParts
key intheme.json
.The text was updated successfully, but these errors were encountered: