Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sections contentOnly in Zoom Out #65396

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,7 @@ export const getBlockEditingMode = createRegistrySelector(
if ( clientId === null ) {
clientId = '';
}

// In zoom-out mode, override the behavior set by
// __unstableSetBlockEditingMode to only allow editing the top-level
// sections.
Expand All @@ -2943,9 +2944,13 @@ export const getBlockEditingMode = createRegistrySelector(
state,
sectionRootClientId
);
if ( ! sectionsClientIds?.includes( clientId ) ) {
return 'disabled';

// Sections are always contentOnly.
if ( sectionsClientIds?.includes( clientId ) ) {
return 'contentOnly';
}
Comment on lines +2949 to 2951
Copy link
Contributor

@talldan talldan Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it might set the section to contentOnly block editing mode, the inner content blocks don't seem to be editable when I tested it.

contentOnly block editing mode is different to contentOnly template lock. The block editing mode only affects the current client id and not the inner blocks of the current client id.

To make the content blocks contentOnly I think you'll need to use __experimentalHasContentRoleAttribute like the code a few lines below this to determine whether a block is a content block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding you correctly (please say if I'm not) then that is exactly what I want to happen in this PR.

In "zoom out" the intent is that only the sections themselves are editable (for now) and not the inner blocks.

If other efforts around content only don't land, then we might want to adjust zoom out behaviour to do what you suggest.

Let me know if thats confusing or something seems off.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok, I have the wrong end of the stick then. I thought the goal would be to make content editable in zoom out. I guess the advantage of using contentOnly in the way this PR does it to reduce the number of inspector controls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's right.

In the future we anticipate making all the "content" blocks editable but for now we are sticking with only being able to select top level "sections".

....to reduce the number of inspector controls?

Yes that's the idea. If you select a section you shouldn't be overwhelmed with layout options on the section.


return 'disabled';
}

const blockEditingMode = state.blockEditingModes.get( clientId );
Expand Down
Loading