@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
35 lines (33 loc) • 877 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = DocumentOutlineCheck;
var _data = require("@wordpress/data");
var _blockEditor = require("@wordpress/block-editor");
/**
* WordPress dependencies
*/
/**
* Component check if there are any headings (core/heading blocks) present in the document.
*
* @param {Object} props Props.
* @param {Element} props.children Children to be rendered.
*
* @return {Component|null} The component to be rendered or null if there are headings.
*/
function DocumentOutlineCheck({
children
}) {
const hasHeadings = (0, _data.useSelect)(select => {
const {
getGlobalBlockCount
} = select(_blockEditor.store);
return getGlobalBlockCount('core/heading') > 0;
});
if (hasHeadings) {
return null;
}
return children;
}
//# sourceMappingURL=check.js.map