File "get-editor-blocks.js"

Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/utils/get-editor-blocks.js
File size: 498 B (498 B bytes)
MIME-type: text/plain
Charset: utf-8

Download   Open   Edit   Advanced Editor &nnbsp; Back

/**
 * Return the blocks with its inner blocks.
 *
 * @return {Array} The blocks array.
 */
export default () => {
	const blocks = wp.data.select( 'core/block-editor' ).getBlocks();

	return blocks.map( ( block ) => {
		if ( 'core/widget-area' !== block.name ) {
			return block;
		}

		// For the widget editor we need to manually get the inner blocks.
		const innerBlocks = wp.data.select( 'core/block-editor' ).getBlocks( block.clientId );

		return {
			...block,
			innerBlocks,
		};
	} );
};