@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 2.97 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/template-part-content-panel/index.js"],
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { TEMPLATE_PART_POST_TYPE } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\nconst { BlockQuickNavigation } = unlock( blockEditorPrivateApis );\n\nfunction TemplatePartContentPanelInner() {\n\tconst blockTypes = useSelect( ( select ) => {\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\treturn getBlockTypes();\n\t}, [] );\n\tconst themeBlockNames = useMemo( () => {\n\t\treturn blockTypes\n\t\t\t.filter( ( blockType ) => {\n\t\t\t\treturn blockType.category === 'theme';\n\t\t\t} )\n\t\t\t.map( ( { name } ) => name );\n\t}, [ blockTypes ] );\n\tconst themeBlocks = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlocksByName } = select( blockEditorStore );\n\t\t\treturn getBlocksByName( themeBlockNames );\n\t\t},\n\t\t[ themeBlockNames ]\n\t);\n\tif ( themeBlocks.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<PanelBody title={ __( 'Content' ) }>\n\t\t\t<BlockQuickNavigation clientIds={ themeBlocks } />\n\t\t</PanelBody>\n\t);\n}\n\nexport default function TemplatePartContentPanel() {\n\tconst postType = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType } = select( editorStore );\n\t\treturn getCurrentPostType();\n\t}, [] );\n\tif ( postType !== TEMPLATE_PART_POST_TYPE ) {\n\t\treturn null;\n\t}\n\n\treturn <T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