diff --git a/lib/init.php b/lib/init.php index 17c9d39f51ae4..d0af1b334929d 100644 --- a/lib/init.php +++ b/lib/init.php @@ -61,7 +61,7 @@ function gutenberg_menu() { // disable loading and enqueuing block editor scripts and styles add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false', 11 ); -add_filter( 'should_load_separate_core_block_assets', '__return_true' ); +// add_filter( 'should_load_separate_core_block_assets', '__return_true' ); // Add `editorScript` to Gutenberg block.json data if it's missing function add_core_editor_script( $metadata ) { diff --git a/packages/blocks/src/api/index.js b/packages/blocks/src/api/index.js index 28fab17bc5e07..83adf7447fd3d 100644 --- a/packages/blocks/src/api/index.js +++ b/packages/blocks/src/api/index.js @@ -121,6 +121,7 @@ export { setGroupingBlockName, getGroupingBlockName, getBlockType, + loadBlockType, getBlockTypes, getBlockSupport, hasBlockSupport, diff --git a/packages/blocks/src/store/selectors.js b/packages/blocks/src/store/selectors.js index 50b61a7f5710b..7461a3218945f 100644 --- a/packages/blocks/src/store/selectors.js +++ b/packages/blocks/src/store/selectors.js @@ -131,11 +131,6 @@ export function getBlockType( state, name ) { return state.blockTypes[ name ]; } -// export function loadBlockType( state, name ) { -// const blockType = state.blockTypes[ name ]; -// return blockType; -// } - /** * Returns block styles by block name. * diff --git a/packages/e2e-tests/specs/performance/post-editor.test.js b/packages/e2e-tests/specs/performance/post-editor.test.js index 9394d44619890..6d343add57747 100644 --- a/packages/e2e-tests/specs/performance/post-editor.test.js +++ b/packages/e2e-tests/specs/performance/post-editor.test.js @@ -37,10 +37,10 @@ import { jest.setTimeout( 1000000 ); async function loadHtmlIntoTheBlockEditor( html ) { - await page.evaluate( ( _html ) => { + await page.evaluate( async ( _html ) => { const { parse } = window.wp.blocks; const { dispatch } = window.wp.data; - const blocks = parse( _html ); + const blocks = await parse( _html ); blocks.forEach( ( block ) => { if ( block.name === 'core/image' ) { @@ -54,9 +54,10 @@ async function loadHtmlIntoTheBlockEditor( html ) { } async function load1000Paragraphs() { - await page.evaluate( () => { - const { createBlock } = window.wp.blocks; + await page.evaluate( async () => { + const { loadBlockType, createBlock } = window.wp.blocks; const { dispatch } = window.wp.data; + await loadBlockType( 'core/paragraph' ); const blocks = Array.from( { length: 1000 } ).map( () => createBlock( 'core/paragraph' ) ); diff --git a/packages/e2e-tests/specs/performance/site-editor.test.js b/packages/e2e-tests/specs/performance/site-editor.test.js index a1a2fa38e73cb..3753a90f31261 100644 --- a/packages/e2e-tests/specs/performance/site-editor.test.js +++ b/packages/e2e-tests/specs/performance/site-editor.test.js @@ -62,10 +62,10 @@ describe( 'Site Editor Performance', () => { await createNewPost( { postType: 'page' } ); - await page.evaluate( ( _html ) => { + await page.evaluate( async ( _html ) => { const { parse } = window.wp.blocks; const { dispatch } = window.wp.data; - const blocks = parse( _html ); + const blocks = await parse( _html ); blocks.forEach( ( block ) => { if ( block.name === 'core/image' ) { diff --git a/test/performance/utils.js b/test/performance/utils.js index e7bbb4206ee8d..c3950d7a7049e 100644 --- a/test/performance/utils.js +++ b/test/performance/utils.js @@ -155,10 +155,10 @@ export async function loadBlocksFromHtml( page, filepath ) { throw new Error( `File not found (${ filepath })` ); } - return await page.evaluate( ( html ) => { + return await page.evaluate( async ( html ) => { const { parse } = window.wp.blocks; const { dispatch } = window.wp.data; - const blocks = parse( html ); + const blocks = await parse( html ); blocks.forEach( ( block ) => { if ( block.name === 'core/image' ) { @@ -172,9 +172,10 @@ export async function loadBlocksFromHtml( page, filepath ) { } export async function load1000Paragraphs( page ) { - await page.evaluate( () => { - const { createBlock } = window.wp.blocks; + await page.evaluate( async () => { + const { loadBlockType, createBlock } = window.wp.blocks; const { dispatch } = window.wp.data; + await loadBlockType( 'core/paragraph' ); const blocks = Array.from( { length: 1000 } ).map( () => createBlock( 'core/paragraph' ) );