diff --git a/docs/reference-guides/data/data-core-edit-site.md b/docs/reference-guides/data/data-core-edit-site.md
index 523bb8d2bbff5..a6263b6c573b4 100644
--- a/docs/reference-guides/data/data-core-edit-site.md
+++ b/docs/reference-guides/data/data-core-edit-site.md
@@ -131,9 +131,9 @@ _Returns_
- `Object`: Settings.
-### hasPageContentLock
+### hasPageContentFocus
-Whether or not the editor is locked so that only page content can be edited.
+Whether or not the editor allows only page content to be edited.
_Parameters_
@@ -141,7 +141,7 @@ _Parameters_
_Returns_
-- `boolean`: Whether or not the editor is locked.
+- `boolean`: Whether or not focus is on editing page content.
### isFeatureActive
@@ -280,13 +280,13 @@ _Returns_
- `number`: The resolved template ID for the page route.
-### setHasPageContentLock
+### setHasPageContentFocus
-Sets whether or not the editor is locked so that only page content can be edited.
+Sets whether or not the editor allows only page content to be edited.
_Parameters_
-- _hasPageContentLock_ `boolean`: True to enable lock, false to disable.
+- _hasPageContentFocus_ `boolean`: True to allow only page content to be edited, false to allow template to be edited.
### setHomeTemplateId
diff --git a/packages/edit-site/src/components/block-editor/index.js b/packages/edit-site/src/components/block-editor/index.js
index a2409b3f1baa2..bfc36bc27aab8 100644
--- a/packages/edit-site/src/components/block-editor/index.js
+++ b/packages/edit-site/src/components/block-editor/index.js
@@ -39,9 +39,9 @@ import EditorCanvas from './editor-canvas';
import { unlock } from '../../private-apis';
import EditorCanvasContainer from '../editor-canvas-container';
import {
- PageContentLock,
- usePageContentLockNotifications,
-} from '../page-content-lock';
+ DisableNonPageContentBlocks,
+ usePageContentFocusNotifications,
+} from '../page-content-focus';
const { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );
@@ -53,21 +53,21 @@ const LAYOUT = {
export default function BlockEditor() {
const { setIsInserterOpened } = useDispatch( editSiteStore );
- const { storedSettings, templateType, canvasMode, hasPageContentLock } =
+ const { storedSettings, templateType, canvasMode, hasPageContentFocus } =
useSelect(
( select ) => {
const {
getSettings,
getEditedPostType,
getCanvasMode,
- hasPageContentLock: _hasPageContentLock,
+ hasPageContentFocus: _hasPageContentFocus,
} = unlock( select( editSiteStore ) );
return {
storedSettings: getSettings( setIsInserterOpened ),
templateType: getEditedPostType(),
canvasMode: getCanvasMode(),
- hasPageContentLock: _hasPageContentLock(),
+ hasPageContentFocus: _hasPageContentFocus(),
};
},
[ setIsInserterOpened ]
@@ -146,7 +146,7 @@ export default function BlockEditor() {
contentRef,
useClipboardHandler(),
useTypingObserver(),
- usePageContentLockNotifications(),
+ usePageContentFocusNotifications(),
] );
const isMobileViewport = useViewportMatch( 'small', '<' );
const { clearSelectedBlock } = useDispatch( blockEditorStore );
@@ -172,7 +172,7 @@ export default function BlockEditor() {
onChange={ onChange }
useSubRegistry={ false }
>
- { hasPageContentLock && }
+ { hasPageContentFocus && }
diff --git a/packages/edit-site/src/components/editor/index.js b/packages/edit-site/src/components/editor/index.js
index f70c6abd787d4..02dee2a48c96e 100644
--- a/packages/edit-site/src/components/editor/index.js
+++ b/packages/edit-site/src/components/editor/index.js
@@ -73,7 +73,7 @@ export default function Editor( { isLoading } ) {
isListViewOpen,
showIconLabels,
showBlockBreadcrumbs,
- hasPageContentLock,
+ hasPageContentFocus,
} = useSelect( ( select ) => {
const {
getEditedPostContext,
@@ -81,7 +81,7 @@ export default function Editor( { isLoading } ) {
getCanvasMode,
isInserterOpened,
isListViewOpened,
- hasPageContentLock: _hasPageContentLock,
+ hasPageContentFocus: _hasPageContentFocus,
} = unlock( select( editSiteStore ) );
const { __unstableGetEditorMode } = select( blockEditorStore );
const { getActiveComplementaryArea } = select( interfaceStore );
@@ -106,7 +106,7 @@ export default function Editor( { isLoading } ) {
'core/edit-site',
'showBlockBreadcrumbs'
),
- hasPageContentLock: _hasPageContentLock(),
+ hasPageContentFocus: _hasPageContentFocus(),
};
}, [] );
const { setEditedPostContext } = useDispatch( editSiteStore );
@@ -127,7 +127,7 @@ export default function Editor( { isLoading } ) {
const blockContext = useMemo( () => {
const { postType, postId, ...nonPostFields } = context ?? {};
return {
- ...( hasPageContentLock ? context : nonPostFields ),
+ ...( hasPageContentFocus ? context : nonPostFields ),
queryContext: [
context?.queryContext || { page: 1 },
( newQueryContext ) =>
@@ -140,7 +140,7 @@ export default function Editor( { isLoading } ) {
} ),
],
};
- }, [ hasPageContentLock, context, setEditedPostContext ] );
+ }, [ hasPageContentFocus, context, setEditedPostContext ] );
let title;
if ( hasLoadedPost ) {
@@ -230,7 +230,7 @@ export default function Editor( { isLoading } ) {
shouldShowBlockBreakcrumbs && (
( {
- hasPageContentLock: select( editSiteStore ).hasPageContentLock(),
+ hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),
context: select( editSiteStore ).getEditedPostContext(),
} ),
[]
@@ -50,16 +50,16 @@ function PageDocumentActions() {
context.postId
);
- const { setHasPageContentLock } = useDispatch( editSiteStore );
+ const { setHasPageContentFocus } = useDispatch( editSiteStore );
const [ hasEditedTemplate, setHasEditedTemplate ] = useState( false );
- const prevHasPageContentLock = useRef( false );
+ const prevHasPageContentFocus = useRef( false );
useEffect( () => {
- if ( prevHasPageContentLock.current && ! hasPageContentLock ) {
+ if ( prevHasPageContentFocus.current && ! hasPageContentFocus ) {
setHasEditedTemplate( true );
}
- prevHasPageContentLock.current = hasPageContentLock;
- }, [ hasPageContentLock ] );
+ prevHasPageContentFocus.current = hasPageContentFocus;
+ }, [ hasPageContentFocus ] );
if ( ! hasResolved ) {
return null;
@@ -73,7 +73,7 @@ function PageDocumentActions() {
);
}
- return hasPageContentLock ? (
+ return hasPageContentFocus ? (
setHasPageContentLock( true ) }
+ onBack={ () => setHasPageContentFocus( true ) }
/>
);
}
diff --git a/packages/edit-site/src/components/page-content-lock/constants.js b/packages/edit-site/src/components/page-content-focus/constants.js
similarity index 63%
rename from packages/edit-site/src/components/page-content-lock/constants.js
rename to packages/edit-site/src/components/page-content-focus/constants.js
index 668fe8af00d69..a81b2fd37563a 100644
--- a/packages/edit-site/src/components/page-content-lock/constants.js
+++ b/packages/edit-site/src/components/page-content-focus/constants.js
@@ -1,4 +1,4 @@
-export const CONTENT_BLOCK_TYPES = [
+export const PAGE_CONTENT_BLOCK_TYPES = [
'core/post-title',
'core/post-featured-image',
'core/post-content',
diff --git a/packages/edit-site/src/components/page-content-lock/use-disable-non-content-blocks.js b/packages/edit-site/src/components/page-content-focus/disable-non-page-content-blocks.js
similarity index 64%
rename from packages/edit-site/src/components/page-content-lock/use-disable-non-content-blocks.js
rename to packages/edit-site/src/components/page-content-focus/disable-non-page-content-blocks.js
index ce198909877f6..4a022daae44c9 100644
--- a/packages/edit-site/src/components/page-content-lock/use-disable-non-content-blocks.js
+++ b/packages/edit-site/src/components/page-content-focus/disable-non-page-content-blocks.js
@@ -10,20 +10,28 @@ import { useEffect } from '@wordpress/element';
* Internal dependencies
*/
import { unlock } from '../../private-apis';
-import { CONTENT_BLOCK_TYPES } from './constants';
+import { PAGE_CONTENT_BLOCK_TYPES } from './constants';
const { useBlockEditingMode } = unlock( blockEditorPrivateApis );
+/**
+ * Component that when rendered, makes it so that the site editor allows only
+ * page content to be edited.
+ */
+export function DisableNonPageContentBlocks() {
+ useDisableNonPageContentBlocks();
+}
+
/**
* Disables non-content blocks using the `useBlockEditingMode` hook.
*/
-export function useDisableNonContentBlocks() {
+export function useDisableNonPageContentBlocks() {
useBlockEditingMode( 'disabled' );
useEffect( () => {
addFilter(
'editor.BlockEdit',
'core/edit-site/disable-non-content-blocks',
- withDisableNonContentBlocks
+ withDisableNonPageContentBlocks
);
return () =>
removeFilter(
@@ -33,12 +41,12 @@ export function useDisableNonContentBlocks() {
}, [] );
}
-const withDisableNonContentBlocks = createHigherOrderComponent(
+const withDisableNonPageContentBlocks = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
- const isContent = CONTENT_BLOCK_TYPES.includes( props.name );
+ const isContent = PAGE_CONTENT_BLOCK_TYPES.includes( props.name );
const mode = isContent ? 'contentOnly' : undefined;
useBlockEditingMode( mode );
return ;
},
- 'withBlockEditingMode'
+ 'withDisableNonPageContentBlocks'
);
diff --git a/packages/edit-site/src/components/page-content-focus/index.js b/packages/edit-site/src/components/page-content-focus/index.js
new file mode 100644
index 0000000000000..81160f4a861f9
--- /dev/null
+++ b/packages/edit-site/src/components/page-content-focus/index.js
@@ -0,0 +1,2 @@
+export * from './disable-non-page-content-blocks';
+export { usePageContentFocusNotifications } from './use-page-content-focus-notifications';
diff --git a/packages/edit-site/src/components/page-content-lock/use-page-content-lock-notifications.js b/packages/edit-site/src/components/page-content-focus/use-page-content-focus-notifications.js
similarity index 76%
rename from packages/edit-site/src/components/page-content-lock/use-page-content-lock-notifications.js
rename to packages/edit-site/src/components/page-content-focus/use-page-content-focus-notifications.js
index 2a800317a33a9..a1ebc729294d5 100644
--- a/packages/edit-site/src/components/page-content-lock/use-page-content-lock-notifications.js
+++ b/packages/edit-site/src/components/page-content-focus/use-page-content-focus-notifications.js
@@ -20,7 +20,7 @@ import { store as editSiteStore } from '../../store';
* (using useMergeRefs()) to
* the editor iframe canvas.
*/
-export function usePageContentLockNotifications() {
+export function usePageContentFocusNotifications() {
const ref = useEditTemplateNotification();
useBackToPageNotification();
return ref;
@@ -28,7 +28,7 @@ export function usePageContentLockNotifications() {
/**
* Hook that displays a 'Edit your template to edit this block' notification
- * when the user is focusing on editing page content and clicks on a locked
+ * when the user is focusing on editing page content and clicks on a disabled
* template block.
*
* @return {import('react').RefObject} Ref which should be passed
@@ -36,22 +36,22 @@ export function usePageContentLockNotifications() {
* the editor iframe canvas.
*/
function useEditTemplateNotification() {
- const hasPageContentLock = useSelect(
- ( select ) => select( editSiteStore ).hasPageContentLock(),
+ const hasPageContentFocus = useSelect(
+ ( select ) => select( editSiteStore ).hasPageContentFocus(),
[]
);
const alreadySeen = useRef( false );
const { createInfoNotice } = useDispatch( noticesStore );
- const { setHasPageContentLock } = useDispatch( editSiteStore );
+ const { setHasPageContentFocus } = useDispatch( editSiteStore );
return useRefEffect(
( node ) => {
const handleClick = ( event ) => {
if (
! alreadySeen.current &&
- hasPageContentLock &&
+ hasPageContentFocus &&
event.target.classList.contains( 'is-root-container' )
) {
createInfoNotice(
@@ -63,7 +63,7 @@ function useEditTemplateNotification() {
{
label: __( 'Edit template' ),
onClick: () =>
- setHasPageContentLock( false ),
+ setHasPageContentFocus( false ),
},
],
}
@@ -75,10 +75,10 @@ function useEditTemplateNotification() {
return () => node.removeEventListener( 'click', handleClick );
},
[
- hasPageContentLock,
+ hasPageContentFocus,
alreadySeen,
createInfoNotice,
- setHasPageContentLock,
+ setHasPageContentFocus,
]
);
}
@@ -88,22 +88,22 @@ function useEditTemplateNotification() {
* switches from focusing on editing page content to editing a template.
*/
function useBackToPageNotification() {
- const hasPageContentLock = useSelect(
- ( select ) => select( editSiteStore ).hasPageContentLock(),
+ const hasPageContentFocus = useSelect(
+ ( select ) => select( editSiteStore ).hasPageContentFocus(),
[]
);
const alreadySeen = useRef( false );
- const prevHasPageContentLock = useRef( false );
+ const prevHasPageContentFocus = useRef( false );
const { createInfoNotice } = useDispatch( noticesStore );
- const { setHasPageContentLock } = useDispatch( editSiteStore );
+ const { setHasPageContentFocus } = useDispatch( editSiteStore );
useEffect( () => {
if (
! alreadySeen.current &&
- prevHasPageContentLock.current &&
- ! hasPageContentLock
+ prevHasPageContentFocus.current &&
+ ! hasPageContentFocus
) {
createInfoNotice( __( 'You are editing a template' ), {
isDismissible: true,
@@ -111,18 +111,18 @@ function useBackToPageNotification() {
actions: [
{
label: __( 'Back to page' ),
- onClick: () => setHasPageContentLock( true ),
+ onClick: () => setHasPageContentFocus( true ),
},
],
} );
alreadySeen.current = true;
}
- prevHasPageContentLock.current = hasPageContentLock;
+ prevHasPageContentFocus.current = hasPageContentFocus;
}, [
alreadySeen,
- prevHasPageContentLock,
- hasPageContentLock,
+ prevHasPageContentFocus,
+ hasPageContentFocus,
createInfoNotice,
- setHasPageContentLock,
+ setHasPageContentFocus,
] );
}
diff --git a/packages/edit-site/src/components/page-content-lock/index.js b/packages/edit-site/src/components/page-content-lock/index.js
deleted file mode 100644
index 83d096fb39f5d..0000000000000
--- a/packages/edit-site/src/components/page-content-lock/index.js
+++ /dev/null
@@ -1,14 +0,0 @@
-/**
- * Internal dependencies
- */
-import { useDisableNonContentBlocks } from './use-disable-non-content-blocks';
-
-/**
- * Component that when rendered, locks the site editor so that only page content
- * can be edited.
- */
-export function PageContentLock() {
- useDisableNonContentBlocks();
-}
-
-export { usePageContentLockNotifications } from './use-page-content-lock-notifications';
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/index.js b/packages/edit-site/src/components/sidebar-edit-mode/index.js
index 78ada88a4d5fa..80a02c11bd88f 100644
--- a/packages/edit-site/src/components/sidebar-edit-mode/index.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/index.js
@@ -33,7 +33,7 @@ export function SidebarComplementaryAreaFills() {
isEditorSidebarOpened,
hasBlockSelection,
supportsGlobalStyles,
- hasPageContentLock,
+ hasPageContentFocus,
} = useSelect( ( select ) => {
const _sidebar =
select( interfaceStore ).getActiveComplementaryArea( STORE_NAME );
@@ -48,7 +48,7 @@ export function SidebarComplementaryAreaFills() {
hasBlockSelection:
!! select( blockEditorStore ).getBlockSelectionStart(),
supportsGlobalStyles: ! settings?.supportsTemplatePartsMode,
- hasPageContentLock: select( editSiteStore ).hasPageContentLock(),
+ hasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),
};
}, [] );
const { enableComplementaryArea } = useDispatch( interfaceStore );
@@ -56,7 +56,7 @@ export function SidebarComplementaryAreaFills() {
useEffect( () => {
// Don't automatically switch tab when the sidebar is closed or when we
// are focused on page content.
- if ( ! isEditorSidebarOpened || hasPageContentLock ) {
+ if ( ! isEditorSidebarOpened || hasPageContentFocus ) {
return;
}
if ( hasBlockSelection ) {
@@ -64,7 +64,7 @@ export function SidebarComplementaryAreaFills() {
} else {
enableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );
}
- }, [ hasBlockSelection, isEditorSidebarOpened, hasPageContentLock ] );
+ }, [ hasBlockSelection, isEditorSidebarOpened, hasPageContentFocus ] );
let sidebarName = sidebar;
if ( ! isEditorSidebarOpened ) {
@@ -83,7 +83,7 @@ export function SidebarComplementaryAreaFills() {
>
{ sidebarName === SIDEBAR_TEMPLATE && (
<>
- { hasPageContentLock ? (
+ { hasPageContentFocus ? (
) : (
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/content-blocks-list.js b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/content-blocks-list.js
index 9035c5677f91a..66f8ba28bcf14 100644
--- a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/content-blocks-list.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/content-blocks-list.js
@@ -14,7 +14,7 @@ import { store as blockEditorStore, BlockIcon } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
-import { CONTENT_BLOCK_TYPES } from '../../page-content-lock/constants';
+import { PAGE_CONTENT_BLOCK_TYPES } from '../../page-content-focus/constants';
// TODO: This overlaps a lot with BlockInspectorLockedBlocks in
// @wordpress/block-editor. DRY them into a single component.
@@ -29,7 +29,7 @@ export default function ContentBlocksList() {
} = select( blockEditorStore );
return getClientIdsWithDescendants().flatMap( ( clientId ) => {
const blockName = getBlockName( clientId );
- if ( ! CONTENT_BLOCK_TYPES.includes( blockName ) ) {
+ if ( ! PAGE_CONTENT_BLOCK_TYPES.includes( blockName ) ) {
return [];
}
return [
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js
index c913a689d54dc..3a0b501f9271a 100644
--- a/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/page-panels/index.js
@@ -37,7 +37,7 @@ export default function PagePanels() {
record: template,
} = useEditedEntityRecord();
- const { setHasPageContentLock } = useDispatch( editSiteStore );
+ const { setHasPageContentFocus } = useDispatch( editSiteStore );
const blockContext = useMemo(
() => ( { ...context, postType: null, postId: null } ),
@@ -78,7 +78,7 @@ export default function PagePanels() {
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/settings-header/index.js b/packages/edit-site/src/components/sidebar-edit-mode/settings-header/index.js
index b11d9acb2314f..b1fdb69a5ba9e 100644
--- a/packages/edit-site/src/components/sidebar-edit-mode/settings-header/index.js
+++ b/packages/edit-site/src/components/sidebar-edit-mode/settings-header/index.js
@@ -19,8 +19,8 @@ import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from '../constants';
import { store as editSiteStore } from '../../../store';
const SettingsHeader = ( { sidebarName } ) => {
- const hasPageContentLock = useSelect( ( select ) =>
- select( editSiteStore ).hasPageContentLock()
+ const hasPageContentFocus = useSelect( ( select ) =>
+ select( editSiteStore ).hasPageContentFocus()
);
const { enableComplementaryArea } = useDispatch( interfaceStore );
@@ -30,7 +30,7 @@ const SettingsHeader = ( { sidebarName } ) => {
enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );
let templateAriaLabel;
- if ( hasPageContentLock ) {
+ if ( hasPageContentFocus ) {
templateAriaLabel =
sidebarName === SIDEBAR_TEMPLATE
? // translators: ARIA label for the Template sidebar tab, selected.
@@ -60,10 +60,10 @@ const SettingsHeader = ( { sidebarName } ) => {
) }
aria-label={ templateAriaLabel }
data-label={
- hasPageContentLock ? __( 'Page' ) : __( 'Template' )
+ hasPageContentFocus ? __( 'Page' ) : __( 'Template' )
}
>
- { hasPageContentLock ? __( 'Page' ) : __( 'Template' ) }
+ { hasPageContentFocus ? __( 'Page' ) : __( 'Template' ) }
diff --git a/packages/edit-site/src/store/actions.js b/packages/edit-site/src/store/actions.js
index 67fbec4811db4..0e4e1ff00770f 100644
--- a/packages/edit-site/src/store/actions.js
+++ b/packages/edit-site/src/store/actions.js
@@ -532,19 +532,20 @@ export const switchEditorMode =
};
/**
- * Sets whether or not the editor is locked so that only page content can be
- * edited.
+ * Sets whether or not the editor allows only page content to be edited.
*
- * @param {boolean} hasPageContentLock True to enable lock, false to disable.
+ * @param {boolean} hasPageContentFocus True to allow only page content to be
+ * edited, false to allow template to be
+ * edited.
*/
-export const setHasPageContentLock =
- ( hasPageContentLock ) =>
+export const setHasPageContentFocus =
+ ( hasPageContentFocus ) =>
( { dispatch, registry } ) => {
- if ( hasPageContentLock ) {
+ if ( hasPageContentFocus ) {
registry.dispatch( blockEditorStore ).clearSelectedBlock();
}
dispatch( {
- type: 'SET_HAS_PAGE_CONTENT_LOCK',
- hasPageContentLock,
+ type: 'SET_HAS_PAGE_CONTENT_FOCUS',
+ hasPageContentFocus,
} );
};
diff --git a/packages/edit-site/src/store/reducer.js b/packages/edit-site/src/store/reducer.js
index a003ee958894e..4b4689e26c561 100644
--- a/packages/edit-site/src/store/reducer.js
+++ b/packages/edit-site/src/store/reducer.js
@@ -158,19 +158,20 @@ function editorCanvasContainerView( state = undefined, action ) {
}
/**
- * Reducer used to track whether the page content is locked.
+ * Reducer used to track whether the editor allows only page content to be
+ * edited.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
-export function hasPageContentLock( state = false, action ) {
+export function hasPageContentFocus( state = false, action ) {
switch ( action.type ) {
case 'SET_EDITED_POST':
return !! action.context?.postId;
- case 'SET_HAS_PAGE_CONTENT_LOCK':
- return action.hasPageContentLock;
+ case 'SET_HAS_PAGE_CONTENT_FOCUS':
+ return action.hasPageContentFocus;
}
return state;
@@ -185,5 +186,5 @@ export default combineReducers( {
saveViewPanel,
canvasMode,
editorCanvasContainerView,
- hasPageContentLock,
+ hasPageContentFocus,
} );
diff --git a/packages/edit-site/src/store/selectors.js b/packages/edit-site/src/store/selectors.js
index 16b6dc588ea26..3d27e1184bce7 100644
--- a/packages/edit-site/src/store/selectors.js
+++ b/packages/edit-site/src/store/selectors.js
@@ -336,12 +336,12 @@ export function isPage( state ) {
}
/**
- * Whether or not the editor is locked so that only page content can be edited.
+ * Whether or not the editor allows only page content to be edited.
*
* @param {Object} state Global application state.
*
- * @return {boolean} Whether or not the editor is locked.
+ * @return {boolean} Whether or not focus is on editing page content.
*/
-export function hasPageContentLock( state ) {
- return isPage( state ) ? state.hasPageContentLock : false;
+export function hasPageContentFocus( state ) {
+ return isPage( state ) ? state.hasPageContentFocus : false;
}
diff --git a/packages/edit-site/src/store/test/actions.js b/packages/edit-site/src/store/test/actions.js
index cca479e277662..8ce914b00b208 100644
--- a/packages/edit-site/src/store/test/actions.js
+++ b/packages/edit-site/src/store/test/actions.js
@@ -13,7 +13,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
* Internal dependencies
*/
import { store as editSiteStore } from '..';
-import { setHasPageContentLock } from '../actions';
+import { setHasPageContentFocus } from '../actions';
const ENTITY_TYPES = {
wp_template: {
@@ -217,18 +217,18 @@ describe( 'actions', () => {
} );
} );
- describe( 'setHasPageContentLock', () => {
+ describe( 'setHasPageContentFocus', () => {
it( 'toggles the page content lock on', () => {
const dispatch = jest.fn();
const clearSelectedBlock = jest.fn();
const registry = {
dispatch: () => ( { clearSelectedBlock } ),
};
- setHasPageContentLock( true )( { dispatch, registry } );
+ setHasPageContentFocus( true )( { dispatch, registry } );
expect( clearSelectedBlock ).toHaveBeenCalled();
expect( dispatch ).toHaveBeenCalledWith( {
- type: 'SET_HAS_PAGE_CONTENT_LOCK',
- hasPageContentLock: true,
+ type: 'SET_HAS_PAGE_CONTENT_FOCUS',
+ hasPageContentFocus: true,
} );
} );
@@ -238,11 +238,11 @@ describe( 'actions', () => {
const registry = {
dispatch: () => ( { clearSelectedBlock } ),
};
- setHasPageContentLock( false )( { dispatch, registry } );
+ setHasPageContentFocus( false )( { dispatch, registry } );
expect( clearSelectedBlock ).not.toHaveBeenCalled();
expect( dispatch ).toHaveBeenCalledWith( {
- type: 'SET_HAS_PAGE_CONTENT_LOCK',
- hasPageContentLock: false,
+ type: 'SET_HAS_PAGE_CONTENT_FOCUS',
+ hasPageContentFocus: false,
} );
} );
} );
diff --git a/packages/edit-site/src/store/test/reducer.js b/packages/edit-site/src/store/test/reducer.js
index 1ddc6bfb6fa7b..9ab7f8e3964f8 100644
--- a/packages/edit-site/src/store/test/reducer.js
+++ b/packages/edit-site/src/store/test/reducer.js
@@ -11,7 +11,7 @@ import {
editedPost,
blockInserterPanel,
listViewPanel,
- hasPageContentLock,
+ hasPageContentFocus,
} from '../reducer';
import { setIsInserterOpened, setIsListViewOpened } from '../actions';
@@ -137,14 +137,14 @@ describe( 'state', () => {
} );
} );
- describe( 'hasPageContentLocked()', () => {
+ describe( 'hasPageContentFocus()', () => {
it( 'defaults to false', () => {
- expect( hasPageContentLock( undefined, {} ) ).toBe( false );
+ expect( hasPageContentFocus( undefined, {} ) ).toBe( false );
} );
it( 'becomes false when editing a template', () => {
expect(
- hasPageContentLock( true, {
+ hasPageContentFocus( true, {
type: 'SET_EDITED_POST',
postType: 'wp_template',
} )
@@ -153,7 +153,7 @@ describe( 'state', () => {
it( 'becomes true when editing a page', () => {
expect(
- hasPageContentLock( false, {
+ hasPageContentFocus( false, {
type: 'SET_EDITED_POST',
postType: 'wp_template',
context: {
@@ -166,15 +166,15 @@ describe( 'state', () => {
it( 'can be set', () => {
expect(
- hasPageContentLock( false, {
- type: 'SET_HAS_PAGE_CONTENT_LOCK',
- hasPageContentLock: true,
+ hasPageContentFocus( false, {
+ type: 'SET_HAS_PAGE_CONTENT_FOCUS',
+ hasPageContentFocus: true,
} )
).toBe( true );
expect(
- hasPageContentLock( true, {
- type: 'SET_HAS_PAGE_CONTENT_LOCK',
- hasPageContentLock: false,
+ hasPageContentFocus( true, {
+ type: 'SET_HAS_PAGE_CONTENT_FOCUS',
+ hasPageContentFocus: false,
} )
).toBe( false );
} );
diff --git a/packages/edit-site/src/store/test/selectors.js b/packages/edit-site/src/store/test/selectors.js
index d9ed31411ffcc..ac4778f03c7b5 100644
--- a/packages/edit-site/src/store/test/selectors.js
+++ b/packages/edit-site/src/store/test/selectors.js
@@ -16,7 +16,7 @@ import {
isListViewOpened,
__unstableGetPreference,
isPage,
- hasPageContentLock,
+ hasPageContentFocus,
} from '../selectors';
describe( 'selectors', () => {
@@ -169,16 +169,16 @@ describe( 'selectors', () => {
} );
} );
- describe( 'hasPageContentLock', () => {
+ describe( 'hasPageContentFocus', () => {
it( 'returns true if locked and the edited post type is a page', () => {
const state = {
editedPost: {
postType: 'wp_template',
context: { postType: 'page', postId: 123 },
},
- hasPageContentLock: true,
+ hasPageContentFocus: true,
};
- expect( hasPageContentLock( state ) ).toBe( true );
+ expect( hasPageContentFocus( state ) ).toBe( true );
} );
it( 'returns false if not locked and the edited post type is a page', () => {
@@ -187,9 +187,9 @@ describe( 'selectors', () => {
postType: 'wp_template',
context: { postType: 'page', postId: 123 },
},
- hasPageContentLock: false,
+ hasPageContentFocus: false,
};
- expect( hasPageContentLock( state ) ).toBe( false );
+ expect( hasPageContentFocus( state ) ).toBe( false );
} );
it( 'returns false if locked and the edited post type is a template', () => {
@@ -197,9 +197,9 @@ describe( 'selectors', () => {
editedPost: {
postType: 'wp_template',
},
- hasPageContentLock: true,
+ hasPageContentFocus: true,
};
- expect( hasPageContentLock( state ) ).toBe( false );
+ expect( hasPageContentFocus( state ) ).toBe( false );
} );
} );
} );