From 1653fd63f64cfe424a3069f5c18b2d4f55ae8196 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 10 Dec 2021 16:13:16 +0000 Subject: [PATCH] Reenable the Nav block in the Site Editor only Shanelessly copied from https://github.com/WordPress/gutenberg/pull/37065 (props to @adamziel --- packages/edit-site/src/index.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js index c06d8987d99089..d79b4dcd0533d8 100644 --- a/packages/edit-site/src/index.js +++ b/packages/edit-site/src/index.js @@ -15,6 +15,7 @@ import { import { store as editorStore } from '@wordpress/editor'; import { store as viewportStore } from '@wordpress/viewport'; import { getQueryArgs } from '@wordpress/url'; +import { addFilter, removeFilter } from '@wordpress/hooks'; /** * Internal dependencies @@ -81,8 +82,17 @@ export function initializeEditor( id, settings ) { const target = document.getElementById( id ); + addFilter( + 'blocks.registerBlockType', + 'core/edit-site/block-register', + addInsertersupportForNavigationBlock + ); + dispatch( blocksStore ).__experimentalReapplyBlockTypeFilters(); registerCoreBlocks(); + + removeFilter( 'blocks.registerBlockType', 'core/edit-site/block-register' ); + if ( process.env.GUTENBERG_PHASE === 2 ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: true, @@ -92,6 +102,19 @@ export function initializeEditor( id, settings ) { reinitializeEditor( target, settings ); } +function addInsertersupportForNavigationBlock( definition ) { + if ( definition.name === 'core/navigation' ) { + return { + ...definition, + supports: { + ...definition.supports, + inserter: true, + }, + }; + } + return definition; +} + export { default as __experimentalMainDashboardButton } from './components/main-dashboard-button'; export { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle'; export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';