Skip to content

Commit

Permalink
set allowed blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mogmarsh committed Nov 30, 2023
1 parent 494fc9c commit f9df97c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions blocks/post-featured-image/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function Edit({
<Placeholder
className="block-editor-media-placeholder"
style={{ aspectRatio: '16 / 9' }}
withIllustration
/>
) : null}
</div>
Expand Down
11 changes: 11 additions & 0 deletions blocks/post/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ export default function Edit({
const cutoff = new Date();
cutoff.setMonth(cutoff.getMonth() - 3);

// TODO: Pass template and allowed blocks from PHP so they can be filtered.
const MY_TEMPLATE = [
['wp-newsletter-builder/post-featured-image', {}],
['wp-newsletter-builder/post-title', {}],
['wp-newsletter-builder/post-byline', {}],
['wp-newsletter-builder/post-excerpt', {}],
['wp-newsletter-builder/post-read-more', {}],
];
const ALLOWED_BLOCKS = [
'wp-newsletter-builder/post-byline',
'wp-newsletter-builder/post-content',
'wp-newsletter-builder/post-excerpt',
'wp-newsletter-builder/post-featured-image',
'wp-newsletter-builder/post-read-more',
'wp-newsletter-builder/post-title',
];

return (
<div {...useBlockProps({ className: `edit-${editPostType}` })}>
Expand Down Expand Up @@ -111,6 +120,8 @@ export default function Edit({
<InnerBlocks
// @ts-ignore
template={MY_TEMPLATE}
allowedBlocks={ALLOWED_BLOCKS}
templateLock={false}
/>
) : null}
<InspectorControls>
Expand Down

0 comments on commit f9df97c

Please sign in to comment.