UNPKG

@wordpress/editor

Version:
8 lines (7 loc) 1.19 kB
{ "version": 3, "sources": ["../../../src/components/document-outline/check.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Component check if there are any headings (core/heading blocks) present in the document.\n *\n * @param {Object} props Props.\n * @param {React.ReactNode} props.children Children to be rendered.\n *\n * @return {React.ReactNode} The component to be rendered or null if there are headings.\n */\nexport default function DocumentOutlineCheck( { children } ) {\n\tconst hasHeadings = useSelect( ( select ) => {\n\t\tconst { getGlobalBlockCount } = select( blockEditorStore );\n\n\t\treturn getGlobalBlockCount( 'core/heading' ) > 0;\n\t} );\n\n\tif ( ! hasHeadings ) {\n\t\treturn null;\n\t}\n\n\treturn children;\n}\n"], "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,SAAS,wBAAwB;AAU3B,SAAR,qBAAuC,EAAE,SAAS,GAAI;AAC5D,QAAM,cAAc,UAAW,CAAE,WAAY;AAC5C,UAAM,EAAE,oBAAoB,IAAI,OAAQ,gBAAiB;AAEzD,WAAO,oBAAqB,cAAe,IAAI;AAAA,EAChD,CAAE;AAEF,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAEA,SAAO;AACR;", "names": [] }