@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
28 lines (22 loc) • 554 B
JavaScript
/**
* External dependencies
*/
import { filter } from 'lodash';
/**
* WordPress dependencies
*/
import { withSelect } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
function DocumentOutlineCheck( { blocks, children } ) {
const headings = filter(
blocks,
( block ) => block.name === 'core/heading'
);
if ( headings.length < 1 ) {
return null;
}
return children;
}
export default withSelect( ( select ) => ( {
blocks: select( blockEditorStore ).getBlocks(),
} ) )( DocumentOutlineCheck );