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

Block editor canvas: use focusMode instead of editorPadding #58527

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,5 @@ iframe[name="editor-canvas"] {
width: 100%;
height: 100%;
display: block;
}

iframe[name="editor-canvas"]:not(.has-editor-padding) {
background-color: $white;
}

iframe[name="editor-canvas"].has-editor-padding {
padding: $grid-unit-30 $grid-unit-30 0;
}
10 changes: 7 additions & 3 deletions packages/edit-post/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ export default function VisualEditor( { styles } ) {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
isEditingPattern,
} = useSelect( ( select ) => {
const { isFeatureActive } = select( editPostStore );
const { getEditorSettings, getRenderingMode } = select( editorStore );
const { getEditorSettings, getRenderingMode, getCurrentPostType } =
select( editorStore );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
const currentPostType = getCurrentPostType();

return {
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
Expand All @@ -44,8 +47,8 @@ export default function VisualEditor( { styles } ) {
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate:
select( editorStore ).getCurrentPostType() === 'wp_template',
isEditingPattern: currentPostType === 'wp_block',
isEditingTemplate: currentPostType === 'wp_template',
};
}, [] );
const hasMetaBoxes = useSelect(
Expand Down Expand Up @@ -83,6 +86,7 @@ export default function VisualEditor( { styles } ) {
<div
className={ classnames( 'edit-post-visual-editor', {
'has-inline-canvas': ! isToBeIframed,
'is-focus-mode': isEditingPattern || isEditingTemplate,
} ) }
>
<EditorCanvas
Expand Down
6 changes: 6 additions & 0 deletions packages/edit-post/src/components/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
// as align-items: stretch is inherited by default.Additionally due to older browser's flex height
// interpretation, any percentage value is likely going to cause issues, such as metaboxes overlapping.
// See also https://www.w3.org/TR/CSS22/visudet.html#the-height-property.

// Matches `.is-focus-mode` padding in
// packages/edit-site/src/components/block-editor/style.scss.
&.is-focus-mode {
padding: $grid-unit-30;
}
}

.edit-post-visual-editor__content-area {
Expand Down
8 changes: 0 additions & 8 deletions packages/edit-site/src/components/block-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,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 {
Copy link
Member Author

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 (?)

display: block;
width: 100%;
height: 100%;
background: $white;
}

.edit-site-visual-editor__editor-canvas {
&.is-focused {
outline: calc(2 * var(--wp-admin-border-width-focus)) solid var(--wp-admin-theme-color);
Expand Down
7 changes: 1 addition & 6 deletions packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ function EditorCanvas( {
wrapperBlockName,
wrapperUniqueId,
deviceType,
showEditorPadding,
isDesignPostType,
} = useSelect( ( select ) => {
const {
Expand Down Expand Up @@ -152,8 +151,6 @@ function EditorCanvas( {
wrapperBlockName: _wrapperBlockName,
wrapperUniqueId: getCurrentPostId(),
deviceType: getDeviceType(),
showEditorPadding:
!! editorSettings.onNavigateToPreviousEntityRecord,
};
}, [] );
const { isCleanNewPost } = useSelect( editorStore );
Expand Down Expand Up @@ -324,9 +321,7 @@ function EditorCanvas( {
styles={ styles }
height="100%"
iframeProps={ {
className: classnames( 'editor-canvas__iframe', {
'has-editor-padding': showEditorPadding,
} ),
className: 'editor-canvas__iframe',
...iframeProps,
style: {
...iframeProps?.style,
Expand Down
Loading