cleanup allowed_blocks logic and add mechanism for disabling blade template for specific block

This commit is contained in:
2025-12-12 13:12:37 +00:00
parent 917150bbe6
commit da8097e7c3
10 changed files with 136 additions and 161 deletions

View File

@@ -0,0 +1,10 @@
{
"apiVersion": 3,
"name": "badegg/article",
"title": "Article Builder",
"category": "badegg",
"description": "A wrapper to contain core blocks",
"editorScript": "article-editor-script",
"editorStyle": "article-editor-style",
"style": "article-style"
}

View File

@@ -0,0 +1,3 @@
.block-badegg-example-editor {
display: block;
}

View File

@@ -0,0 +1,41 @@
import { registerBlockType } from '@wordpress/blocks';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
import metadata from './block.json';
import allowedBlocks from '../../../json/core-block-whitelist.json';
registerBlockType(metadata.name, {
icon: {
src: 'format-aside',
foreground: '#f58762',
},
edit({ attributes, setAttributes }) {
const blockProps = useBlockProps();
return (
<section { ...blockProps }>
<div className="container">
<InnerBlocks
allowedBlocks={ allowedBlocks }
defaultBlock={
{
name: "core/paragraph",
attributes: {
placeholder: "start typing",
}
}
}
/>
</div>
</section>
);
},
save() {
return (
<section { ...useBlockProps.save() }>
<div className="container">
<InnerBlocks.Content />
</div>
</section>
)
}
});

View File

@@ -0,0 +1,3 @@
<section class="block-badegg-article">
<h2>Bad Egg Article Block (Blade)</h2>
</section>

View File

@@ -0,0 +1,3 @@
.block-badegg-hero {
display: block;
}

View File

@@ -1,7 +1,6 @@
import { registerBlockType } from '@wordpress/blocks';
registerBlockType('badegg/example', {
apiVersion: 3, // optional in JS, primarily in block.json
edit() {
return (
<section className="block-badegg-example">