diff --git a/docs/reference-guides/block-api/block-templates.md b/docs/reference-guides/block-api/block-templates.md index babe693c542141..a16ad6ea2548d1 100644 --- a/docs/reference-guides/block-api/block-templates.md +++ b/docs/reference-guides/block-api/block-templates.md @@ -115,7 +115,7 @@ add_action( 'init', 'myplugin_register_template' ); _Options:_ -- `noContent` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children. +- `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children. - `all` — prevents all operations. It is not possible to insert new blocks, move existing blocks, or delete blocks. - `insert` — prevents inserting or removing blocks, but allows moving existing blocks. diff --git a/packages/block-editor/src/components/block-inspector/index.js b/packages/block-editor/src/components/block-inspector/index.js index 56b3096fee1497..3accd8ee6babd3 100644 --- a/packages/block-editor/src/components/block-inspector/index.js +++ b/packages/block-editor/src/components/block-inspector/index.js @@ -158,7 +158,7 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => { selectedBlockName: _selectedBlockName, blockType: _blockType, topLevelLockedBlock: - getTemplateLock( _selectedBlockClientId ) === 'noContent' + getTemplateLock( _selectedBlockClientId ) === 'contentOnly' ? _selectedBlockClientId : __unstableGetContentLockingParent( _selectedBlockClientId diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index a554069d97bb65..da0cfd9bda481e 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -118,7 +118,7 @@ function BlockListBlock( { ), hasContentLockedParent: _hasContentLockedParent, isContentLocking: - getTemplateLock( clientId ) === 'noContent' && + getTemplateLock( clientId ) === 'contentOnly' && ! _hasContentLockedParent, isTemporarilyEditingAsBlocks: __unstableGetTemporarilyEditingAsBlocks() === clientId, diff --git a/packages/block-editor/src/components/block-lock/use-block-lock.js b/packages/block-editor/src/components/block-lock/use-block-lock.js index d225557a5813ac..da6ccc4092096d 100644 --- a/packages/block-editor/src/components/block-lock/use-block-lock.js +++ b/packages/block-editor/src/components/block-lock/use-block-lock.js @@ -38,7 +38,7 @@ export default function useBlockLock( clientId ) { canMove, canRemove, canLock: canLockBlockType( getBlockName( clientId ) ), - isContentLocked: getTemplateLock( clientId ) === 'noContent', + isContentLocked: getTemplateLock( clientId ) === 'contentOnly', isLocked: ! canEdit || ! canMove || ! canRemove, }; }, diff --git a/packages/block-editor/src/components/inner-blocks/README.md b/packages/block-editor/src/components/inner-blocks/README.md index 73cc5bef95db83..ce4eacb5e09954 100644 --- a/packages/block-editor/src/components/inner-blocks/README.md +++ b/packages/block-editor/src/components/inner-blocks/README.md @@ -125,12 +125,12 @@ Template locking of `InnerBlocks` is similar to [Custom Post Type templates lock Template locking allows locking the `InnerBlocks` area for the current template. _Options:_ -- `noContent` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children. +- `contentOnly` — prevents all operations. Additionally, the block types that don't have content are hidden from the list view and can't gain focus within the block list. Unlike the other lock types, this is not overrideable by children. - `'all'` — prevents all operations. It is not possible to insert new blocks. Move existing blocks or delete them. - `'insert'` — prevents inserting or removing blocks, but allows moving existing ones. - `false` — prevents locking from being applied to an `InnerBlocks` area even if a parent block contains locking. ( Boolean ) -If locking is not set in an `InnerBlocks` area: the locking of the parent `InnerBlocks` area is used. Note that `noContent` can't be overriden: it's present, the `templateLock` value of any children is ignored. +If locking is not set in an `InnerBlocks` area: the locking of the parent `InnerBlocks` area is used. Note that `contentOnly` can't be overriden: it's present, the `templateLock` value of any children is ignored. If the block is a top level block: the locking of the Custom Post Type is used. diff --git a/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js b/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js index 8323f8f7ce4ffc..f25831f4974d1b 100644 --- a/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js +++ b/packages/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js @@ -19,7 +19,7 @@ import { store as blockEditorStore } from '../../store'; * This hook makes sure that a block's inner blocks stay in sync with the given * block "template". The template is a block hierarchy to which inner blocks must * conform. If the blocks get "out of sync" with the template and the template - * is meant to be locked (e.g. templateLock = "all" or templateLock = "noContent"), + * is meant to be locked (e.g. templateLock = "all" or templateLock = "contentOnly"), * then we replace the inner blocks with the correct value after synchronizing it with the template. * * @param {string} clientId The block client ID. @@ -52,11 +52,11 @@ export default function useInnerBlockTemplateSync( const existingTemplate = useRef( null ); useLayoutEffect( () => { // Only synchronize innerBlocks with template if innerBlocks are empty - // or a locking "all" or "noContent" exists directly on the block. + // or a locking "all" or "contentOnly" exists directly on the block. if ( innerBlocks.length === 0 || templateLock === 'all' || - templateLock === 'noContent' + templateLock === 'contentOnly' ) { const hasTemplateChanged = ! isEqual( template, diff --git a/packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js b/packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js index c8e2e3443ae15d..18b1b37748bd5e 100644 --- a/packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js +++ b/packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js @@ -69,7 +69,7 @@ export default function useNestedSettingsUpdate( const newSettings = { allowedBlocks: _allowedBlocks, templateLock: - templateLock === undefined || parentLock === 'noContent' + templateLock === undefined || parentLock === 'contentOnly' ? parentLock : templateLock, }; diff --git a/packages/block-editor/src/components/list-view/branch.js b/packages/block-editor/src/components/list-view/branch.js index 5600bca07d56d9..0c2b541f3199a1 100644 --- a/packages/block-editor/src/components/list-view/branch.js +++ b/packages/block-editor/src/components/list-view/branch.js @@ -99,7 +99,7 @@ function ListViewBranch( props ) { return !! ( parentId && select( blockEditorStore ).getTemplateLock( parentId ) === - 'noContent' + 'contentOnly' ); }, [ parentId ] diff --git a/packages/block-editor/src/components/use-block-drop-zone/index.js b/packages/block-editor/src/components/use-block-drop-zone/index.js index a8de937f7c960b..ac6a0ea3d1f670 100644 --- a/packages/block-editor/src/components/use-block-drop-zone/index.js +++ b/packages/block-editor/src/components/use-block-drop-zone/index.js @@ -101,7 +101,7 @@ export default function useBlockDropZone( { } = select( blockEditorStore ); const templateLock = getTemplateLock( targetRootClientId ); return ( - [ 'all', 'noContent' ].some( + [ 'all', 'contentOnly' ].some( ( lock ) => lock === templateLock ) || __unstableHasActiveBlockOverlayActive( targetRootClientId ) || diff --git a/packages/block-editor/src/hooks/content-lock-ui.js b/packages/block-editor/src/hooks/content-lock-ui.js index 98098cf583361c..b373c01422e995 100644 --- a/packages/block-editor/src/hooks/content-lock-ui.js +++ b/packages/block-editor/src/hooks/content-lock-ui.js @@ -72,7 +72,7 @@ export const withBlockControls = createHigherOrderComponent( __unstableSetTemporarilyEditingAsBlocks, } = useDispatch( blockEditorStore ); const isContentLocked = - ! isLockedByParent && templateLock === 'noContent'; + ! isLockedByParent && templateLock === 'contentOnly'; const { __unstableMarkNextChangeAsNotPersistent, updateBlockAttributes, @@ -81,11 +81,11 @@ export const withBlockControls = createHigherOrderComponent( const stopEditingAsBlock = useCallback( () => { __unstableMarkNextChangeAsNotPersistent(); updateBlockAttributes( props.clientId, { - templateLock: 'noContent', + templateLock: 'contentOnly', } ); updateBlockListSettings( props.clientId, { ...getBlockListSettings( props.clientId ), - templateLock: 'noContent', + templateLock: 'contentOnly', } ); updateSettings( { focusMode: focusModeToRevert.current } ); __unstableSetTemporarilyEditingAsBlocks(); diff --git a/packages/block-editor/src/store/selectors.js b/packages/block-editor/src/store/selectors.js index 07ffcc53bed395..9bbaf9aeef5343 100644 --- a/packages/block-editor/src/store/selectors.js +++ b/packages/block-editor/src/store/selectors.js @@ -2696,7 +2696,7 @@ export const __unstableGetContentLockingParent = createSelector( let result; while ( !! state.blocks.parents[ current ] ) { current = state.blocks.parents[ current ]; - if ( getTemplateLock( state, current ) === 'noContent' ) { + if ( getTemplateLock( state, current ) === 'contentOnly' ) { result = current; } } diff --git a/packages/block-library/src/column/block.json b/packages/block-library/src/column/block.json index 59472b4c124046..f6f7bc8d1f5cc9 100644 --- a/packages/block-library/src/column/block.json +++ b/packages/block-library/src/column/block.json @@ -19,7 +19,7 @@ }, "templateLock": { "type": [ "string", "boolean" ], - "enum": [ "all", "insert", "noContent", false ] + "enum": [ "all", "insert", "contentOnly", false ] } }, "supports": { diff --git a/packages/block-library/src/cover/block.json b/packages/block-library/src/cover/block.json index a7b495cfc3f8f6..1982ecc44853ea 100644 --- a/packages/block-library/src/cover/block.json +++ b/packages/block-library/src/cover/block.json @@ -73,7 +73,7 @@ }, "templateLock": { "type": [ "string", "boolean" ], - "enum": [ "all", "insert", "noContent", false ] + "enum": [ "all", "insert", "contentOnly", false ] } }, "usesContext": [ "postId", "postType" ], diff --git a/packages/block-library/src/group/block.json b/packages/block-library/src/group/block.json index 4e0f15c90d6e96..5e44488732703c 100644 --- a/packages/block-library/src/group/block.json +++ b/packages/block-library/src/group/block.json @@ -14,7 +14,7 @@ }, "templateLock": { "type": [ "string", "boolean" ], - "enum": [ "all", "insert", "noContent", false ] + "enum": [ "all", "insert", "contentOnly", false ] }, "layout": { "type": "object",