Skip to content

Commit

Permalink
Reenable the Nav block in the Site Editor only
Browse files Browse the repository at this point in the history
Shanelessly copied from #37065 (props to @adamziel
  • Loading branch information
getdave committed Dec 10, 2021
1 parent 1c4af1a commit 1653fd6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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';
Expand Down

0 comments on commit 1653fd6

Please sign in to comment.