PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.1
JetFormBuilder — Dynamic Blocks Form Builder v3.1.1
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / package / blocks / helpers / blocksRecursiveIterator.js
jetformbuilder / assets / src / package / blocks / helpers Last commit date
ChangeNameByLabel.js 2 years ago ControlsSettings.js 2 years ago appendField.js 2 years ago blocksRecursiveIterator.js 2 years ago getAvailableFields.js 2 years ago getAvailableFieldsString.js 2 years ago getBlockControls.js 2 years ago getBlocksByName.js 2 years ago getCurrentInnerBlocks.js 2 years ago getFieldsWithoutCurrent.js 2 years ago getFormFieldsBlocks.js 2 years ago getInnerBlocks.js 2 years ago
blocksRecursiveIterator.js
69 lines
1 const { select } = wp.data;
2
3 function blocksRecursiveIterator( blockParserFunc ) {
4 const blocksRecursiveIterator = ( blocks, parent = null ) => {
5
6 blocks = blocks || select( 'core/block-editor' ).getBlocks();
7
8 blocks.forEach( block => {
9 blockParserFunc( block, parent );
10
11 if ( block.innerBlocks.length ) {
12 const currentParent = 'jet-forms/repeater-field' === block.name
13 ? block
14 : parent;
15
16 blocksRecursiveIterator(
17 block.innerBlocks,
18 currentParent,
19 );
20
21 return;
22 }
23
24 if ( 'core/block' !== block.name ) {
25 return;
26 }
27
28 /**
29 * Hardcode the receipt of internal blocks "Reusable block".
30 * This is the only way so far.
31 *
32 * Added after major refactoring
33 * @since 3.0.4
34 *
35 * Introduced
36 * @since 2.1.1
37 *
38 * @type {{clientId: String, innerBlocks: Array}[]}
39 */
40 let innerReusable = select( 'core/block-editor' )?.
41 __unstableGetClientIdsTree?.(
42 block.clientId,
43 );
44
45 if ( ! innerReusable?.length ) {
46 return;
47 }
48
49 const innerReusableIds = innerReusable.map(
50 ( { clientId } ) => clientId,
51 );
52
53 /**
54 * We update this variable because `__unstableGetClientIdsTree`
55 * returns insufficient information about the block.
56 * Namely, the `name` property is missing
57 */
58 innerReusable = select( 'core/block-editor' ).getBlocksByClientId(
59 innerReusableIds,
60 );
61
62 blocksRecursiveIterator( innerReusable );
63 } );
64 };
65
66 blocksRecursiveIterator();
67 }
68
69 export default blocksRecursiveIterator;