cleanup allowed_blocks logic and add mechanism for disabling blade template for specific block
This commit is contained in:
@@ -1,45 +1,45 @@
|
||||
import domReady from '@wordpress/dom-ready';
|
||||
import blockWhitelist from '../json/core-block-whitelist.json';
|
||||
|
||||
domReady(() => {
|
||||
const TEXT_EDITOR_BLOCKS = [
|
||||
// Design
|
||||
'core/separator',
|
||||
'core/spacer',
|
||||
|
||||
// Media
|
||||
'core/cover',
|
||||
'core/file',
|
||||
'core/gallery',
|
||||
'core/image',
|
||||
'core/media-text',
|
||||
'core/audio',
|
||||
'core/video',
|
||||
|
||||
// Text
|
||||
'core/footnotes',
|
||||
'core/heading',
|
||||
'core/list',
|
||||
'core/code',
|
||||
'core/details',
|
||||
'core/list-item',
|
||||
'core/missing',
|
||||
'core/paragraph',
|
||||
'core/preformatted',
|
||||
'core/pullquote',
|
||||
'core/quote',
|
||||
'core/table',
|
||||
'core/verse',
|
||||
];
|
||||
|
||||
const restrictEditorParentBlocks = (settings, name) => {
|
||||
const TEXT_EDITOR_BLOCKS = [
|
||||
// Design
|
||||
'core/separator',
|
||||
'core/spacer',
|
||||
|
||||
// Media
|
||||
'core/cover',
|
||||
'core/file',
|
||||
'core/gallery',
|
||||
'core/image',
|
||||
'core/media-text',
|
||||
'core/audio',
|
||||
'core/video',
|
||||
|
||||
// Text
|
||||
'core/footnotes',
|
||||
'core/heading',
|
||||
'core/list',
|
||||
'core/code',
|
||||
'core/details',
|
||||
'core/freeform',
|
||||
'core/list-item',
|
||||
'core/missing',
|
||||
'core/paragraph',
|
||||
'core/preformatted',
|
||||
'core/pullquote',
|
||||
'core/quote',
|
||||
'core/table',
|
||||
'core/verse',
|
||||
];
|
||||
|
||||
if (TEXT_EDITOR_BLOCKS.includes(name)) {
|
||||
settings.parent = ['acf/badegg-editor']
|
||||
settings.parent = [
|
||||
'acf/badegg-editor',
|
||||
'badegg/article',
|
||||
];
|
||||
}
|
||||
|
||||
// console.log(settings, name)
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
[
|
||||
"core/button",
|
||||
"core/comment-template",
|
||||
"core/home-link",
|
||||
"core/navigation-link",
|
||||
"core/navigation-submenu",
|
||||
"core/buttons",
|
||||
"core/column",
|
||||
"core/columns",
|
||||
"core/group",
|
||||
"core/more",
|
||||
"core/nextpage",
|
||||
"core/separator",
|
||||
"core/spacer",
|
||||
"core/text-columns",
|
||||
|
||||
"core/embed",
|
||||
|
||||
"core/cover",
|
||||
"core/file",
|
||||
"core/gallery",
|
||||
"core/image",
|
||||
"core/media-text",
|
||||
"core/audio",
|
||||
"core/video",
|
||||
|
||||
"core/block",
|
||||
|
||||
"core/footnotes",
|
||||
"core/heading",
|
||||
"core/list",
|
||||
"core/code",
|
||||
"core/details",
|
||||
"core/freeform",
|
||||
"core/list-item",
|
||||
"core/missing",
|
||||
"core/paragraph",
|
||||
"core/preformatted",
|
||||
"core/pullquote",
|
||||
"core/quote",
|
||||
"core/table",
|
||||
"core/verse",
|
||||
|
||||
"core/avatar",
|
||||
"core/comment-author-name",
|
||||
"core/comment-content",
|
||||
"core/comment-date",
|
||||
"core/comment-edit-link",
|
||||
"core/comment-reply-link",
|
||||
"core/comments",
|
||||
"core/comments-pagination",
|
||||
"core/comments-pagination-next",
|
||||
"core/comments-pagination-numbers",
|
||||
"core/comments-pagination-previous",
|
||||
"core/comments-title",
|
||||
"core/loginout",
|
||||
"core/navigation",
|
||||
"core/pattern",
|
||||
"core/post-author",
|
||||
"core/post-author-biography",
|
||||
"core/post-author-name",
|
||||
"core/post-comments-form",
|
||||
"core/post-content",
|
||||
"core/post-date",
|
||||
"core/post-excerpt",
|
||||
"core/post-featured-image",
|
||||
"core/post-navigation-link",
|
||||
"core/post-template",
|
||||
"core/post-terms",
|
||||
"core/post-title",
|
||||
"core/query",
|
||||
"core/query-no-results",
|
||||
"core/query-pagination",
|
||||
"core/query-pagination-next",
|
||||
"core/query-pagination-numbers",
|
||||
"core/query-pagination-previous",
|
||||
"core/query-title",
|
||||
"core/read-more",
|
||||
"core/site-logo",
|
||||
"core/site-tagline",
|
||||
"core/site-title",
|
||||
"core/template-part",
|
||||
"core/term-description",
|
||||
"core/post-comments",
|
||||
|
||||
"core/legacy-widget",
|
||||
"core/widget-group",
|
||||
"core/archives",
|
||||
"core/calendar",
|
||||
"core/categories",
|
||||
"core/latest-comments",
|
||||
"core/latest-posts",
|
||||
"core/page-list",
|
||||
"core/page-list-item",
|
||||
"core/rss",
|
||||
"core/search",
|
||||
"core/shortcode",
|
||||
"core/social-link",
|
||||
"core/tag-cloud",
|
||||
"core/html",
|
||||
"core/social-links"
|
||||
]
|
||||
@@ -41,7 +41,7 @@ class Editor
|
||||
$themeURL = get_template_directory_uri();
|
||||
|
||||
if($is_preview && @$block['data']['inserter']):
|
||||
echo '<img style="display: block; width: 100%" src="' . $themeURL . '/resources/views/blocks/' . $name . '/' . $name . '.jpg" />';
|
||||
echo '<img style="display: block; width: 100%" src="' . $themeURL . '/resources/views/acf-blocks/' . $name . '/' . $name . '.jpg" />';
|
||||
return;
|
||||
endif;
|
||||
|
||||
|
||||
10
resources/views/blocks/article/block.json
Normal file
10
resources/views/blocks/article/block.json
Normal 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"
|
||||
}
|
||||
3
resources/views/blocks/article/editor.scss
Normal file
3
resources/views/blocks/article/editor.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.block-badegg-example-editor {
|
||||
display: block;
|
||||
}
|
||||
41
resources/views/blocks/article/index.jsx
Normal file
41
resources/views/blocks/article/index.jsx
Normal 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>
|
||||
)
|
||||
}
|
||||
});
|
||||
3
resources/views/blocks/article/render.blade.php
Normal file
3
resources/views/blocks/article/render.blade.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<section class="block-badegg-article">
|
||||
<h2>Bad Egg Article Block (Blade)</h2>
|
||||
</section>
|
||||
3
resources/views/blocks/article/style.scss
Normal file
3
resources/views/blocks/article/style.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.block-badegg-hero {
|
||||
display: block;
|
||||
}
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user