Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 81ba259

Browse files
author
Tarun Vijwani
authored
Merge branch 'trunk' into release/9.9.0
2 parents aaeabc3 + b39da86 commit 81ba259

File tree

33 files changed

+490
-155
lines changed

33 files changed

+490
-155
lines changed

assets/js/blocks/cart-checkout-shared/editor-utils.ts

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@
22
* External dependencies
33
*/
44
import { getBlockTypes } from '@wordpress/blocks';
5+
import { applyCheckoutFilter } from '@woocommerce/blocks-checkout';
6+
import { CART_STORE_KEY } from '@woocommerce/block-data';
7+
import { select } from '@wordpress/data';
58

69
// List of core block types to allow in inner block areas.
710
const coreBlockTypes = [ 'core/paragraph', 'core/image', 'core/separator' ];
811

912
/**
1013
* Gets a list of allowed blocks types under a specific parent block type.
1114
*/
12-
export const getAllowedBlocks = ( block: string ): string[] => [
13-
...getBlockTypes()
14-
.filter( ( blockType ) =>
15-
( blockType?.parent || [] ).includes( block )
16-
)
17-
.map( ( { name } ) => name ),
18-
...coreBlockTypes,
19-
];
15+
export const getAllowedBlocks = ( block: string ): string[] => {
16+
const additionalCartCheckoutInnerBlockTypes = applyCheckoutFilter( {
17+
filterName: 'additionalCartCheckoutInnerBlockTypes',
18+
defaultValue: [],
19+
extensions: select( CART_STORE_KEY ).getCartData().extensions,
20+
arg: { block },
21+
validation: ( value ) => {
22+
if (
23+
Array.isArray( value ) &&
24+
value.every( ( item ) => typeof item === 'string' )
25+
) {
26+
return true;
27+
}
28+
throw new Error(
29+
'allowedBlockTypes filters must return an array of strings.'
30+
);
31+
},
32+
} );
33+
34+
// Convert to set here so that we remove duplicated block types.
35+
return Array.from(
36+
new Set( [
37+
...getBlockTypes()
38+
.filter( ( blockType ) =>
39+
( blockType?.parent || [] ).includes( block )
40+
)
41+
.map( ( { name } ) => name ),
42+
...coreBlockTypes,
43+
...additionalCartCheckoutInnerBlockTypes,
44+
] )
45+
);
46+
};

assets/js/blocks/checkout/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
}
3939
},
4040
"textdomain": "woo-gutenberg-products-block",
41-
"apiVersion": 2
41+
"apiVersion": 2,
42+
"$schema": "https://schemas.wp.org/trunk/block.json"
4243
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/empty-mini-cart-contents-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"parent": [ "woocommerce/mini-cart-contents" ],
2525
"textdomain": "woo-gutenberg-products-block",
26-
"apiVersion": 2
26+
"apiVersion": 2,
27+
"$schema": "https://schemas.wp.org/trunk/block.json"
2728
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/filled-mini-cart-contents-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"parent": [ "woocommerce/mini-cart-contents" ],
2525
"textdomain": "woo-gutenberg-products-block",
26-
"apiVersion": 2
26+
"apiVersion": 2,
27+
"$schema": "https://schemas.wp.org/trunk/block.json"
2728
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-cart-button-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
],
3838
"parent": [ "woocommerce/mini-cart-footer-block" ],
3939
"textdomain": "woo-gutenberg-products-block",
40-
"apiVersion": 2
40+
"apiVersion": 2,
41+
"$schema": "https://schemas.wp.org/trunk/block.json"
4142
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-checkout-button-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@
3939
"woocommerce/mini-cart-footer-block"
4040
],
4141
"textdomain": "woo-gutenberg-products-block",
42-
"apiVersion": 2
42+
"apiVersion": 2,
43+
"$schema": "https://schemas.wp.org/trunk/block.json"
4344
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"parent": [ "woocommerce/filled-mini-cart-contents-block" ],
2525
"textdomain": "woo-gutenberg-products-block",
26-
"apiVersion": 2
26+
"apiVersion": 2,
27+
"$schema": "https://schemas.wp.org/trunk/block.json"
2728
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-items-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"parent": [ "woocommerce/filled-mini-cart-contents-block" ],
2525
"textdomain": "woo-gutenberg-products-block",
26-
"apiVersion": 2
26+
"apiVersion": 2,
27+
"$schema": "https://schemas.wp.org/trunk/block.json"
2728
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-products-table-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
},
2424
"parent": [ "woocommerce/mini-cart-items-block" ],
2525
"textdomain": "woo-gutenberg-products-block",
26-
"apiVersion": 2
26+
"apiVersion": 2,
27+
"$schema": "https://schemas.wp.org/trunk/block.json"
2728
}

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
],
3838
"parent": [ "woocommerce/empty-mini-cart-contents-block" ],
3939
"textdomain": "woo-gutenberg-products-block",
40-
"apiVersion": 2
40+
"apiVersion": 2,
41+
"$schema": "https://schemas.wp.org/trunk/block.json"
4142
}

0 commit comments

Comments
 (0)