Skip to content

Commit

Permalink
Editor: Remove the 'all' rendering mode (#58935)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
  • Loading branch information
3 people committed Feb 13, 2024
1 parent 333aee8 commit 2c21a45
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 1 addition & 4 deletions packages/edit-post/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -111,7 +109,6 @@ function Editor( {
updatePreferredStyleVariations,
onNavigateToEntityRecord,
onNavigateToPreviousEntityRecord,
defaultRenderingMode,
]
);

Expand Down
10 changes: 2 additions & 8 deletions packages/edit-post/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-post/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
} );

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2c21a45

Please sign in to comment.