-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Editor: Move the template focus modes to the editor store #56472
Conversation
@@ -133,6 +132,7 @@ export default function Editor( { listViewToggleElement, isLoading } ) { | |||
: undefined, | |||
editorMode: getEditorMode(), | |||
canvasMode: getCanvasMode(), | |||
renderingMode: getRenderingMode(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have so many modes: canvasMode, editorMode, renderingMode. To be honest, I don't like that and I'm not sure how to better name this. I'm opening to changing the name. Could be contentMode
or focusMode
or contentFocusMode
or something. I'm not sure, but I know that focusMode already exists for something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two modes that use "focus" as far as I know:
- "Spotlight mode" in preferences (
focusMode
variable) - Focus mode is also used to describe how the editor behaves for navigation, patterns etc with resize handles. It's not a great name I think, well, it left me scratching my head at least. Reference: Resizable editor (with drag handles) in Site Editor #55122 (comment)
Yeah, the challenge for managing this state is that most, if not all, of these modes are not mutually exclusive - there are various combinations.
An editor could be in "zoom-out" mode (__unstableGetEditorMode
) and "template-only" (renderingMode
), is-outline-mode
(postType === 'wp_template').
Then canvas mode, navigation/edit mode and whatever else.
Size Change: +855 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
@@ -1241,6 +1253,19 @@ _Related_ | |||
|
|||
- selectBlock in core/block-editor store. | |||
|
|||
### setRenderingMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renderingMode
is as good a name as any. I appreciate how you've combined pageContentFocusType
values 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, it's a nice way of combining things! I wonder if it'd be worth making it a tiny bit more specific and using something like blockRenderingMode
? Mostly I'm trying to think how can the name hint that this mode is about which blocks are displayed (and their locked status) 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer slightly renderingMode over blockRenderingMode because blockRenderingMode feels like "block specific" while here we're just actually focusing on one entity over another for both content (blocks) but also things like sidebars, headers...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Sounds reasonable to me 🙂
I've only smoke tested so far in the post and site editors: ✅ No regression in page editing in the site editor, including switching template preview on/off, swapping templates, template locking/flipping between template and page editing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only had a chance to smoke test this a bit today, but I like the overall direction, too! Feels nicer to group together into a particular mode in the editor store 👍
One other quick thought: if we have a finite list of modes, is it worth using constants for the strings rather than hard-coding all
or template-only
, etc when calling setRenderingMode
? Or does that get a bit awkward since each package would need to add their consts?
Happy to give this a more detailed test next week if it hasn't been merged by then 🙂
@@ -1241,6 +1253,19 @@ _Related_ | |||
|
|||
- selectBlock in core/block-editor store. | |||
|
|||
### setRenderingMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, it's a nice way of combining things! I wonder if it'd be worth making it a tiny bit more specific and using something like blockRenderingMode
? Mostly I'm trying to think how can the name hint that this mode is about which blocks are displayed (and their locked status) 🤔
What I don't like is that the package need to export these constants. I'm not strongly opinionated here and would be ok if added later though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't spot and regression and the code looks good. He have lot's of modes 😅 .. Thank you!
Related #52632
What?
This PR is a refactoring PR that moves the "template mode / page focus" modes state from the edit-site store to the editor store. The idea is that by moving the state and the components to the editor-store, we will be able to implement the same modes in the post editor as well.
The current PR only moves the "state" and doesn't touch the component. It should not have any impact on the behavior of these different modes in the site editor.
Testing Instructions
Check things like: "editing page", "switching to templates", "editing template parts"... in the site editor.