-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block editor canvas: use focusMode instead of editorPadding #58527
Conversation
Size Change: -31 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
44bc6ee
to
de12144
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
de12144
to
63e4b3f
Compare
@@ -27,14 +27,6 @@ | |||
// Centralize the editor horizontally (flex-direction is column). | |||
align-items: center; | |||
|
|||
// Controls height of editor and editor canvas container (style book, global styles revisions previews etc.) | |||
iframe { |
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.
The styles are the same across editors so I centralized them in packages/block-editor/src/components/block-canvas/style.scss.
If there's any reason to have bespoke styles I guess they can be overwritten in the site or post editor packages (?)
background-color: $white; | ||
} | ||
|
||
iframe[name="editor-canvas"].has-editor-padding { | ||
padding: $grid-unit-60 $grid-unit-60 0; |
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.
Removed bottom padding to match what the style editor already has:
padding: $grid-unit-60; |
iframeProps={ { | ||
style: { | ||
background: isEditingPattern | ||
? 'transparent' |
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.
This is the magic that removes the background and only highlights the pattern being edited. This is current behaviour in trunk.
To be effective however, it relies on the pattern having a background of its own.
2024-02-02.10.38.08.mp4
cc @glendaviesnz for confirmation
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.
Actually I'm thinking we ditch the transparent background.
… of whether it has "padding". Because the background of the visual editor is $gray-900, we use a border to mimic existing padding.
…-focus-mode between site and post editors. By "harmonize", I mean use the same approach by driving the padding via a classname `is-focus-mode` on the edit-${site/post}-layout element, not centralize the code. The latter is difficult because the site editor has "modes", such as edit and view, which also affect the styles. Reverts first attempt and now tries to harmonize the editor canvas is-focus-mode between site and post editors. By "harmonize", I mean use the same approach by driving the padding via a classname `is-focus-mode` on the edit-${site/post}-layout element, not centralize the code. The latter is difficult because the site editor has "modes", such as edit and view, which also affect the styles.
ca21493
to
a798e23
Compare
Closing this PR as the original bug has been addressed. There's still an outstanding disunity in the way we determine "focus mode" across the editors, and therefore the padding. In the site editor, it's partly set according to whether the currently-edited template is in the FOCUSABLE_ENTITIES array. This PR in its current state attempts to steer things in the latter direction.
In the post editor however, a I think it should and can be harmonized still, with a tendency towards detecting |
What?
Follow up to #57631
This PR ensures that the iframe background is always white regardless of whether it has "padding".
Why?
Normally, the iframe has a white background.
When editing a template in the post editor, the iframe receives a classname of
.has-editor-padding
- this class is excluded from receiving the white background via thenot()
selector.Here's the post editor in trunk:
2024-02-01.12.22.46.mp4
How?
This PR tries to harmonize the editor canvas
.is-focus-mode
between site and post editors.By "harmonize", I mean use the same approach by driving the padding via a classname
is-focus-mode
on the edit-${site/post}-layout element, not centralize the code.The latter is difficult because the site editor has "modes", such as edit and view, which also affect the styles.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Post editor editing post template
Post editor editing original synched pattern
Site editor editing page template