UNPKG

@wordpress/block-library

Version:
39 lines (37 loc) 1.33 kB
import { createElement } from "@wordpress/element"; /** * WordPress dependencies */ import { useEntityBlockEditor } from '@wordpress/core-data'; import { InnerBlocks, useInnerBlocksProps, useSetting, store as blockEditorStore } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; export default function TemplatePartInnerBlocks(_ref) { let { postId: id, hasInnerBlocks, layout, tagName: TagName, blockProps } = _ref; const themeSupportsLayout = useSelect(select => { var _getSettings; const { getSettings } = select(blockEditorStore); return (_getSettings = getSettings()) === null || _getSettings === void 0 ? void 0 : _getSettings.supportsLayout; }, []); const defaultLayout = useSetting('layout') || {}; const usedLayout = !!layout && layout.inherit ? defaultLayout : layout; const [blocks, onInput, onChange] = useEntityBlockEditor('postType', 'wp_template_part', { id }); const innerBlocksProps = useInnerBlocksProps(blockProps, { value: blocks, onInput, onChange, renderAppender: hasInnerBlocks ? undefined : InnerBlocks.ButtonBlockAppender, __experimentalLayout: themeSupportsLayout ? usedLayout : undefined }); return createElement(TagName, innerBlocksProps); } //# sourceMappingURL=inner-blocks.js.map