From 8cb16bc4472cabb9ef290b235f17de8af4390816 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 12 Feb 2024 14:03:28 +0100 Subject: [PATCH] Editor: Remove the 'all' rendering mode --- docs/reference-guides/data/data-core-editor.md | 2 +- packages/edit-post/src/editor.js | 5 +---- packages/edit-post/src/index.js | 10 ++-------- packages/edit-post/src/store/selectors.js | 2 +- .../block-editor/use-site-editor-settings.js | 4 +++- packages/editor/src/components/editor-canvas/index.js | 2 +- packages/editor/src/store/actions.js | 2 +- packages/editor/src/store/reducer.js | 2 +- 8 files changed, 11 insertions(+), 18 deletions(-) diff --git a/docs/reference-guides/data/data-core-editor.md b/docs/reference-guides/data/data-core-editor.md index 5cae4759654018..72083022041643 100644 --- a/docs/reference-guides/data/data-core-editor.md +++ b/docs/reference-guides/data/data-core-editor.md @@ -1409,7 +1409,7 @@ Returns an action used to set the rendering mode of the post editor. We support _Parameters_ -- _mode_ `string`: Mode (one of 'post-only', 'template-locked' or 'all'). +- _mode_ `string`: Mode (one of 'post-only' or 'template-locked'). ### setTemplateValidity diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index 7c572c4a91fcf2..7b961098fc3daa 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -89,15 +89,13 @@ function Editor( { ); const { updatePreferredStyleVariations } = useDispatch( editPostStore ); - const defaultRenderingMode = - currentPost.postType === 'wp_template' ? 'all' : 'post-only'; const editorSettings = useMemo( () => ( { ...settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, - defaultRenderingMode, + defaultRenderingMode: 'post-only', __experimentalPreferredStyleVariations: { value: preferredStyleVariations, onChange: updatePreferredStyleVariations, @@ -111,7 +109,6 @@ function Editor( { updatePreferredStyleVariations, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, - defaultRenderingMode, ] ); diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 78c79227c9d897..08bc7c5aa7002c 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -103,10 +103,7 @@ export function initializeEditor( 'blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', ( canInsert, blockType ) => { - if ( - select( editorStore ).getRenderingMode() === 'post-only' && - blockType.name === 'core/template-part' - ) { + if ( blockType.name === 'core/template-part' ) { return false; } return canInsert; @@ -128,10 +125,7 @@ export function initializeEditor( rootClientId, { getBlockParentsByBlockName } ) => { - if ( - select( editorStore ).getRenderingMode() === 'post-only' && - blockType.name === 'core/post-content' - ) { + if ( blockType.name === 'core/post-content' ) { return ( getBlockParentsByBlockName( rootClientId, 'core/query' ) .length > 0 diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js index 1a39a516da8f52..f5b4a27e158ea0 100644 --- a/packages/edit-post/src/store/selectors.js +++ b/packages/edit-post/src/store/selectors.js @@ -556,7 +556,7 @@ export const isEditingTemplate = createRegistrySelector( ( select ) => () => { since: '6.5', alternative: `select( 'core/editor' ).getRenderingMode`, } ); - return select( editorStore ).getRenderingMode() !== 'post-only'; + return select( editorStore ).getCurrentPostType() !== 'post-only'; } ); /** diff --git a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js index a99ea627268950..0c7dbe8ec3d04f 100644 --- a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js +++ b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js @@ -144,7 +144,9 @@ export function useSpecificEditorSettings() { [] ); const archiveLabels = useArchiveLabel( templateSlug ); - const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'all'; + const defaultRenderingMode = postWithTemplate + ? 'template-locked' + : 'post-only'; const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); const defaultEditorSettings = useMemo( () => { diff --git a/packages/editor/src/components/editor-canvas/index.js b/packages/editor/src/components/editor-canvas/index.js index 489694bb8adfd5..f011f285644c0e 100644 --- a/packages/editor/src/components/editor-canvas/index.js +++ b/packages/editor/src/components/editor-canvas/index.js @@ -110,7 +110,7 @@ function EditorCanvas( { if ( postTypeSlug === 'wp_block' ) { _wrapperBlockName = 'core/block'; - } else if ( ! _renderingMode === 'post-only' ) { + } else if ( _renderingMode === 'post-only' ) { _wrapperBlockName = 'core/post-content'; } diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 8d716a04346dae..4c0f1078fde655 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -585,7 +585,7 @@ export function updateEditorSettings( settings ) { * - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template. * - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable. * - * @param {string} mode Mode (one of 'post-only', 'template-locked' or 'all'). + * @param {string} mode Mode (one of 'post-only' or 'template-locked'). */ export const setRenderingMode = ( mode ) => diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js index 978a5c8697410a..b2ae6b5224b14c 100644 --- a/packages/editor/src/store/reducer.js +++ b/packages/editor/src/store/reducer.js @@ -266,7 +266,7 @@ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) { return state; } -export function renderingMode( state = 'all', action ) { +export function renderingMode( state = 'post-only', action ) { switch ( action.type ) { case 'SET_RENDERING_MODE': return action.mode;