2023-04-06 18:40:43 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Icon, mediaAndText } from '@wordpress/icons';
|
|
|
|
import { getBlockMap } from '@woocommerce/atomic-utils';
|
|
|
|
import type { InnerBlockTemplate } from '@wordpress/blocks';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import metadata from './block.json';
|
|
|
|
import { VARIATION_NAME as PRODUCT_TITLE_VARIATION_NAME } from '../product-query/variations/elements/product-title';
|
|
|
|
import { VARIATION_NAME as PRODUCT_SUMMARY_VARIATION_NAME } from '../product-query/variations/elements/product-summary';
|
2023-04-11 14:41:34 +00:00
|
|
|
import { ImageSizing } from '../../atomic/blocks/product-elements/image/types';
|
2023-04-06 18:40:43 +00:00
|
|
|
|
|
|
|
export const BLOCK_ICON = (
|
|
|
|
<Icon
|
|
|
|
icon={ mediaAndText }
|
|
|
|
className="wc-block-editor-components-block-icon"
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const DEFAULT_INNER_BLOCKS: InnerBlockTemplate[] = [
|
|
|
|
[
|
|
|
|
'core/columns',
|
|
|
|
{},
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'core/column',
|
|
|
|
{},
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'woocommerce/product-image',
|
|
|
|
{
|
|
|
|
showSaleBadge: false,
|
|
|
|
isDescendentOfSingleProductBlock: true,
|
2023-04-11 14:41:34 +00:00
|
|
|
imageSizing: ImageSizing.SINGLE,
|
2023-04-06 18:40:43 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'core/column',
|
|
|
|
{},
|
|
|
|
[
|
|
|
|
[
|
|
|
|
'core/post-title',
|
|
|
|
{
|
|
|
|
headingLevel: 2,
|
|
|
|
isLink: true,
|
|
|
|
__woocommerceNamespace:
|
|
|
|
PRODUCT_TITLE_VARIATION_NAME,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'woocommerce/product-rating',
|
|
|
|
{ isDescendentOfSingleProductBlock: true },
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'woocommerce/product-price',
|
|
|
|
{ isDescendentOfSingleProductBlock: true },
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'core/post-excerpt',
|
|
|
|
{
|
|
|
|
__woocommerceNamespace:
|
|
|
|
PRODUCT_SUMMARY_VARIATION_NAME,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[ 'woocommerce/add-to-cart-form' ],
|
|
|
|
[ 'woocommerce/product-meta' ],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
export const ALLOWED_INNER_BLOCKS = [
|
|
|
|
'core/columns',
|
|
|
|
'core/column',
|
2024-03-25 13:59:57 +00:00
|
|
|
'core/post-title',
|
|
|
|
'core/post-excerpt',
|
|
|
|
'woocommerce/add-to-cart-form',
|
|
|
|
'woocommerce/product-meta',
|
2023-04-06 18:40:43 +00:00
|
|
|
...Object.keys( getBlockMap( metadata.name ) ),
|
|
|
|
];
|