diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js index 9feab02d8157d1..8a65a4ff2cb08b 100644 --- a/packages/editor/src/components/provider/index.js +++ b/packages/editor/src/components/provider/index.js @@ -232,7 +232,7 @@ export const ExperimentalEditorProvider = withRegistryProvider( setRenderingMode( settings.defaultRenderingMode ?? 'post-only' ); }, [ settings.defaultRenderingMode, setRenderingMode ] ); - useHideBlocksFromInserter( post.type ); + useHideBlocksFromInserter( post.type, mode ); // Register the editor commands. useCommands(); diff --git a/packages/editor/src/components/provider/use-hide-blocks-from-inserter.js b/packages/editor/src/components/provider/use-hide-blocks-from-inserter.js index c3f9158602f9b0..4a1aaf18667462 100644 --- a/packages/editor/src/components/provider/use-hide-blocks-from-inserter.js +++ b/packages/editor/src/components/provider/use-hide-blocks-from-inserter.js @@ -18,8 +18,9 @@ const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = [ * the template part and post content blocks need to be hidden. * * @param {string} postType Post Type + * @param {string} mode Rendering mode */ -export function useHideBlocksFromInserter( postType ) { +export function useHideBlocksFromInserter( postType, mode ) { useEffect( () => { /* * Prevent adding template part in the editor. @@ -32,7 +33,8 @@ export function useHideBlocksFromInserter( postType ) { ! POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes( postType ) && - blockType.name === 'core/template-part' + blockType.name === 'core/template-part' && + mode === 'post-only' ) { return false; } @@ -77,5 +79,5 @@ export function useHideBlocksFromInserter( postType ) { 'removePostContentFromInserter' ); }; - }, [ postType ] ); + }, [ postType, mode ] ); }