diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js index 390d9d314d4906..f07f9eed5121d6 100644 --- a/packages/edit-site/src/index.js +++ b/packages/edit-site/src/index.js @@ -4,6 +4,7 @@ import { store as blocksStore } from '@wordpress/blocks'; import { registerCoreBlocks, + __experimentalGetCoreBlocks, __experimentalRegisterExperimentalCoreBlocks, } from '@wordpress/block-library'; import { dispatch } from '@wordpress/data'; @@ -16,7 +17,6 @@ import { import { store as editorStore } from '@wordpress/editor'; import { store as interfaceStore } from '@wordpress/interface'; import { store as preferencesStore } from '@wordpress/preferences'; -import { addFilter } from '@wordpress/hooks'; import { registerLegacyWidgetBlock } from '@wordpress/widgets'; /** @@ -41,32 +41,17 @@ export function initializeEditor( id, settings ) { settings.__experimentalFetchRichUrlData = fetchUrlData; dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters(); - registerCoreBlocks(); + const coreBlocks = __experimentalGetCoreBlocks().filter( + ( { name } ) => name !== 'core/freeform' + ); + registerCoreBlocks( coreBlocks ); + dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' ); registerLegacyWidgetBlock( { inserter: false } ); if ( process.env.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: true, } ); } - /* - * Prevent adding the Clasic block in the site editor. - * Only add the filter when the site editor is initialized, not imported. - * Also only add the filter(s) after registerCoreBlocks() - * so that common filters in the block library are not overwritten. - * - * This usage here is inspired by previous usage of the filter in the post editor: - * https://github.com/WordPress/gutenberg/pull/37157 - */ - addFilter( - 'blockEditor.__unstableCanInsertBlockType', - 'removeClassicBlockFromInserter', - ( canInsert, blockType ) => { - if ( blockType.name === 'core/freeform' ) { - return false; - } - return canInsert; - } - ); // We dispatch actions and update the store synchronously before rendering // so that we won't trigger unnecessary re-renders with useEffect.