Reputation: 15
I'm creating a custom gutenberg block,but i want to disable or remove insert block button on top and bottom of block. Also,i want to not allow add more block in by click button add.
I'm working on WordPress 5.2.3
<InnerBlocks
template={ [ 'item' ] }
templateLock={ false }
allowedBlocks={ false }
/>
Upvotes: 1
Views: 2064
Reputation: 568
Define your block template with the InnerBlocks you want in the respective order (and with possible placeholders, nested blocks...) – as a multidimensional array. And put this right below your component imports at the top of the block file.
const TEMPLATE = [
['foo/block1', {}, []],
['foo/block2', {}, []],
]
In your edit function use
<InnerBlocks
template={TEMPLATE}
templateLock="all"
/>
"all"
locks the template completely, no blocks can be added,
removed or re-ordered "false"
template is not locked "insert"
blocks can only be re-orderedAs you don’t want any blocks to be added you can omit allowedBlocks
. This would only be necessary to allow certain blocks to be added (in combination with templateLock="false"
)
Upvotes: 5