add allowedBlocks attribute
This commit is contained in:
parent
d1244444ba
commit
e54d899ef5
|
@ -11,6 +11,7 @@ import {
|
|||
ColorPicker,
|
||||
PanelBody,
|
||||
ToolbarGroup,
|
||||
// use __experimentalToolbarItem as ToolbarItem does not seem to be present(?)
|
||||
__experimentalToolbarItem as ToolbarItem,
|
||||
} from '@wordpress/components';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
|
@ -18,16 +19,19 @@ import { __ } from '@wordpress/i18n';
|
|||
const NAMESPACE = 'namespace'; // TODO
|
||||
const SLUG = 'slug'; // TODO
|
||||
const BLOCK_TITLE = 'Block Title'; // TODO
|
||||
const BLOCK_CATEGORIES = ['common', 'formatting', 'layout', 'widgets', 'embed'];
|
||||
const BLOCK_CATEGORY = BLOCK_CATEGORIES[3];
|
||||
|
||||
const INNER_TEMPLATE = [
|
||||
['core/heading', { placeholder: 'Article Title', className: 'heading' }],
|
||||
['core/paragraph', { placeholder: 'Article Text', className: 'text' }],
|
||||
];
|
||||
const ALLOWED_BLOCKS = ['core/image', 'core/paragraph'];
|
||||
|
||||
registerBlockType(`${NAMESPACE}/${SLUG}`, {
|
||||
title: __(BLOCK_TITLE, NAMESPACE),
|
||||
|
||||
category: 'widgets',
|
||||
category: BLOCK_CATEGORY,
|
||||
|
||||
supports: {
|
||||
// Removes support for an HTML mode.
|
||||
|
@ -87,6 +91,7 @@ registerBlockType(`${NAMESPACE}/${SLUG}`, {
|
|||
<div>
|
||||
<InnerBlocks
|
||||
template={INNER_TEMPLATE}
|
||||
allowedBlocks={ALLOWED_BLOCKS}
|
||||
templateLock="all"
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue