Skip to content

Commit

Permalink
Ensure section root is also contentOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Sep 6, 2024
1 parent 4f29dcd commit 613c95e
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ export default function ContentOnlyLockSections() {
? getClientIdsOfDescendants( sectionRootClientId )
: getClientIdsWithDescendants();
return {
sectionRootClientId,
sectionClientIds,
allClientIds,
};
}, [] );
const { sectionClientIds, allClientIds } = selected;
const { sectionClientIds, allClientIds, sectionRootClientId } = selected;
const { getBlockOrder, getBlockName } = useSelect( blockEditorStore );
const { __experimentalHasContentRoleAttribute } = useSelect( blocksStore );

Expand All @@ -52,12 +53,20 @@ export default function ContentOnlyLockSections() {
);

registry.batch( () => {
// 1. The section root should hide non-content controls.
setBlockEditingMode( sectionRootClientId, 'contentOnly' );

// 2. Each section should hide non-content controls.
for ( const clientId of sectionClientIds ) {
setBlockEditingMode( clientId, 'contentOnly' );
}

// 3. The children of the section should be disabled.
for ( const clientId of sectionChildrenClientIds ) {
setBlockEditingMode( clientId, 'disabled' );
}

// 4. ...except for the "content" blocks which should be content-only.
for ( const clientId of contentClientIds ) {
setBlockEditingMode( clientId, 'contentOnly' );
}
Expand All @@ -66,6 +75,7 @@ export default function ContentOnlyLockSections() {
return () => {
registry.batch( () => {
for ( const clientId of [
sectionRootClientId,
...sectionClientIds,
...sectionChildrenClientIds,
...contentClientIds,
Expand All @@ -80,6 +90,7 @@ export default function ContentOnlyLockSections() {
getBlockName,
getBlockOrder,
registry,
sectionRootClientId,
sectionClientIds,
setBlockEditingMode,
unsetBlockEditingMode,
Expand Down

0 comments on commit 613c95e

Please sign in to comment.