use json lists in editor.js
This commit is contained in:
@@ -1,44 +1,12 @@
|
|||||||
import domReady from '@wordpress/dom-ready';
|
import domReady from '@wordpress/dom-ready';
|
||||||
import blockWhitelist from '../json/core-block-whitelist.json';
|
import blockParents from '../json/block-parents.json';
|
||||||
|
import blockWhitelist from '../json/block-core-whitelist.json';
|
||||||
import.meta.glob('../views/blocks/**/{index.jsx,index.js}', { eager: true })
|
import.meta.glob('../views/blocks/**/{index.jsx,index.js}', { eager: true })
|
||||||
|
|
||||||
domReady(() => {
|
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 restrictEditorParentBlocks = (settings, name) => {
|
||||||
if (TEXT_EDITOR_BLOCKS.includes(name)) {
|
if (blockWhitelist.includes(name)) {
|
||||||
settings.parent = [
|
settings.parent = blockParents;
|
||||||
'acf/badegg-editor',
|
|
||||||
'badegg/article',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
@@ -46,8 +14,7 @@ domReady(() => {
|
|||||||
|
|
||||||
wp.hooks.addFilter(
|
wp.hooks.addFilter(
|
||||||
'blocks.registerBlockType',
|
'blocks.registerBlockType',
|
||||||
'your-project-name/restrict-parent-blocks',
|
'badegg/restrict-parent-blocks',
|
||||||
restrictEditorParentBlocks
|
restrictEditorParentBlocks
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user