From e27d24d61dbf1dec0fa95afffc164fca192a99c2 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 23 May 2024 11:24:00 +0100 Subject: [PATCH 1/5] Editor: Move the resizing of the editor to the EditorCanvas component --- .../src/components/block-canvas/style.scss | 5 - .../components/block-editor/editor-canvas.js | 11 +- .../block-editor/site-editor-canvas.js | 75 +---- .../src/components/block-editor/style.scss | 94 ------ .../src/components/editor-canvas/index.js | 274 +++++++++++------- .../editor-canvas}/resizable-editor.js | 3 +- .../editor-canvas}/resize-handle.js | 8 +- .../src/components/editor-canvas/style.scss | 65 +++++ packages/editor/src/style.scss | 1 + 9 files changed, 253 insertions(+), 283 deletions(-) rename packages/{edit-site/src/components/block-editor => editor/src/components/editor-canvas}/resizable-editor.js (94%) rename packages/{edit-site/src/components/block-editor => editor/src/components/editor-canvas}/resize-handle.js (87%) create mode 100644 packages/editor/src/components/editor-canvas/style.scss diff --git a/packages/block-editor/src/components/block-canvas/style.scss b/packages/block-editor/src/components/block-canvas/style.scss index 6ec97bfb38853c..525c79be53504b 100644 --- a/packages/block-editor/src/components/block-canvas/style.scss +++ b/packages/block-editor/src/components/block-canvas/style.scss @@ -4,8 +4,3 @@ iframe[name="editor-canvas"] { display: block; background-color: $gray-300; } - - -iframe[name="editor-canvas"].has-editor-padding { - padding: $grid-unit-30 $grid-unit-30 0; -} diff --git a/packages/edit-site/src/components/block-editor/editor-canvas.js b/packages/edit-site/src/components/block-editor/editor-canvas.js index 4f5237b7fdf92e..f81626e78ed790 100644 --- a/packages/edit-site/src/components/block-editor/editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/editor-canvas.js @@ -28,7 +28,7 @@ import { const { EditorCanvas: EditorCanvasRoot } = unlock( editorPrivateApis ); -function EditorCanvas( { enableResizing, settings, children, ...props } ) { +function EditorCanvas( { settings, children } ) { const { hasBlocks, isFocusMode, @@ -109,11 +109,7 @@ function EditorCanvas( { enableResizing, settings, children, ...props } ) { // Forming a "block formatting context" to prevent margin collapsing. // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context - css: `.is-root-container{display:flow-root;${ - // Some themes will have `min-height: 100vh` for the root container, - // which isn't a requirement in auto resize mode. - enableResizing ? 'min-height:0!important;' : '' - }}body{position:relative; ${ + css: `body{position:relative; ${ canvasMode === 'view' ? `min-height: 100vh; ${ currentPostIsTrashed ? '' : 'cursor: pointer;' @@ -122,7 +118,7 @@ function EditorCanvas( { enableResizing, settings, children, ...props } ) { }}}`, }, ], - [ settings.styles, enableResizing, canvasMode, currentPostIsTrashed ] + [ settings.styles, canvasMode, currentPostIsTrashed ] ); return ( @@ -136,7 +132,6 @@ function EditorCanvas( { enableResizing, settings, children, ...props } ) { className: clsx( 'edit-site-visual-editor__editor-canvas', { 'is-focused': isFocused && canvasMode === 'view', } ), - ...props, ...( canvasMode === 'view' ? viewModeIframeProps : {} ), } } > diff --git a/packages/edit-site/src/components/block-editor/site-editor-canvas.js b/packages/edit-site/src/components/block-editor/site-editor-canvas.js index 9a74652b53cabb..a7b7b2c8cc4232 100644 --- a/packages/edit-site/src/components/block-editor/site-editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/site-editor-canvas.js @@ -6,98 +6,43 @@ import clsx from 'clsx'; * WordPress dependencies */ import { useSelect } from '@wordpress/data'; -import { useViewportMatch, useResizeObserver } from '@wordpress/compose'; -import { store as blockEditorStore } from '@wordpress/block-editor'; /** * Internal dependencies */ -import ResizableEditor from './resizable-editor'; import EditorCanvas from './editor-canvas'; import EditorCanvasContainer from '../editor-canvas-container'; import useSiteEditorSettings from './use-site-editor-settings'; import { store as editSiteStore } from '../../store'; -import { - FOCUSABLE_ENTITIES, - NAVIGATION_POST_TYPE, - TEMPLATE_POST_TYPE, -} from '../../utils/constants'; import { unlock } from '../../lock-unlock'; -import { privateApis as routerPrivateApis } from '@wordpress/router'; - -const { useLocation } = unlock( routerPrivateApis ); export default function SiteEditorCanvas() { - const location = useLocation(); - const { templateType, isFocusableEntity, isViewMode, isZoomOutMode } = - useSelect( ( select ) => { - const { getEditedPostType, getCanvasMode } = unlock( - select( editSiteStore ) - ); - const { __unstableGetEditorMode } = select( blockEditorStore ); - const _templateType = getEditedPostType(); + const { isViewMode } = useSelect( ( select ) => { + const { getCanvasMode } = unlock( select( editSiteStore ) ); - return { - templateType: _templateType, - isFocusableEntity: FOCUSABLE_ENTITIES.includes( _templateType ), - isViewMode: getCanvasMode() === 'view', - isZoomOutMode: __unstableGetEditorMode() === 'zoom-out', - }; - }, [] ); - const isFocusMode = location.params.focusMode || isFocusableEntity; - const [ resizeObserver, sizes ] = useResizeObserver(); + return { + isViewMode: getCanvasMode() === 'view', + }; + }, [] ); const settings = useSiteEditorSettings(); - const isMobileViewport = useViewportMatch( 'small', '<' ); - const enableResizing = - isFocusMode && - ! isViewMode && - // Disable resizing in mobile viewport. - ! isMobileViewport && - // Dsiable resizing in zoomed-out mode. - ! isZoomOutMode && - // Disable resizing when editing a template in focus mode. - templateType !== TEMPLATE_POST_TYPE; - - const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; - const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; - const forceFullHeight = isNavigationFocusMode; - return ( { ( [ editorCanvasView ] ) => editorCanvasView ? ( -
+
{ editorCanvasView }
) : (
- - - { - // Avoid resize listeners when not needed, - // these will trigger unnecessary re-renders - // when animating the iframe width. - enableResizing && resizeObserver - } - - +
) } diff --git a/packages/edit-site/src/components/block-editor/style.scss b/packages/edit-site/src/components/block-editor/style.scss index e3d68109d8b490..801ccc78e396ca 100644 --- a/packages/edit-site/src/components/block-editor/style.scss +++ b/packages/edit-site/src/components/block-editor/style.scss @@ -40,98 +40,4 @@ outline-offset: calc(-2 * var(--wp-admin-border-width-focus)); } } - - - &.is-focus-mode { - .edit-site-layout.is-full-canvas & { - padding: $grid-unit-30; - } - - .edit-site-visual-editor__editor-canvas { - max-height: 100%; - } - - // To hide the horizontal scrollbar and show the drag handle on the - // left and right of the container. - .components-resizable-box__container { - overflow: visible; - } - } - - & > .components-resizable-box__container { - margin: 0 auto; - } -} - -.resizable-editor__drag-handle { - position: absolute; - top: 0; - bottom: 0; - padding: 0; - margin: auto 0; - width: $grid-unit-15; - appearance: none; - cursor: ew-resize; - outline: none; - background: none; - border-radius: $radius-block-ui; - border: 0; - - &.is-variation-default { - height: 100px; - } - - &.is-variation-separator { - height: 100%; - width: $grid-unit-30; - right: 0; - - &::after { - width: 2px; - border-radius: 0; - background: transparent; - left: 50%; - transform: translateX(-1px); - right: 0; - transition: all ease 0.2s; - transition-delay: 0.1s; - @include reduce-motion; - } - } - - &::after { - position: absolute; - top: $grid-unit-20; - left: $grid-unit-05; - right: 0; - bottom: $grid-unit-20; - content: ""; - width: $grid-unit-05; - background-color: rgba($gray-700, 0.4); - border-radius: $radius-block-ui; - } - - &.is-left { - // Subtract half of the handle width to properly center. - left: -$grid-unit-20 - math.div($grid-unit-05, 2); - } - - &.is-right { - // Subtract half of the handle width to properly center. - right: -$grid-unit-20 - math.div($grid-unit-05, 2); - } - - &:hover, - &:focus, - &:active { - opacity: 1; - &::after { - background-color: var(--wp-admin-theme-color); - } - } - - &.is-variation-separator:focus::after { - border-radius: $radius-block-ui; - box-shadow: inset 0 0 0 2px var(--wp-admin-theme-color); - } } diff --git a/packages/editor/src/components/editor-canvas/index.js b/packages/editor/src/components/editor-canvas/index.js index 37f03fc4a1dab7..9430d6475dda4e 100644 --- a/packages/editor/src/components/editor-canvas/index.js +++ b/packages/editor/src/components/editor-canvas/index.js @@ -20,7 +20,11 @@ import { useEffect, useRef, useMemo } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { parse } from '@wordpress/blocks'; import { store as coreStore } from '@wordpress/core-data'; -import { useMergeRefs } from '@wordpress/compose'; +import { + useMergeRefs, + useViewportMatch, + useResizeObserver, +} from '@wordpress/compose'; /** * Internal dependencies @@ -29,7 +33,14 @@ import PostTitle from '../post-title'; import { store as editorStore } from '../../store'; import { unlock } from '../../lock-unlock'; import EditTemplateBlocksNotification from './edit-template-blocks-notification'; +import ResizableEditor from './resizable-editor'; import useSelectNearestEditableBlock from '../../hooks/use-select-nearest-editable-block'; +import { + NAVIGATION_POST_TYPE, + PATTERN_POST_TYPE, + TEMPLATE_PART_POST_TYPE, + TEMPLATE_POST_TYPE, +} from '../../store/constants'; const { LayoutStyle, @@ -44,10 +55,10 @@ const { * and they don't apply the layout styles. */ const DESIGN_POST_TYPES = [ - 'wp_block', - 'wp_template', - 'wp_navigation', - 'wp_template_part', + PATTERN_POST_TYPE, + TEMPLATE_POST_TYPE, + NAVIGATION_POST_TYPE, + TEMPLATE_PART_POST_TYPE, ]; /** @@ -94,8 +105,9 @@ function EditorCanvas( { disableIframe = false, iframeProps, contentRef, - children, } ) { + const [ resizeObserver, sizes ] = useResizeObserver(); + const isMobileViewport = useViewportMatch( 'small', '<' ); const { renderingMode, postContentAttributes, @@ -103,8 +115,10 @@ function EditorCanvas( { wrapperBlockName, wrapperUniqueId, deviceType, - showEditorPadding, + isFocusedEntity, isDesignPostType, + postType, + isPreview, } = useSelect( ( select ) => { const { getCurrentPostId, @@ -120,7 +134,7 @@ function EditorCanvas( { const _renderingMode = getRenderingMode(); let _wrapperBlockName; - if ( postTypeSlug === 'wp_block' ) { + if ( postTypeSlug === PATTERN_POST_TYPE ) { _wrapperBlockName = 'core/block'; } else if ( _renderingMode === 'post-only' ) { _wrapperBlockName = 'core/post-content'; @@ -128,13 +142,13 @@ function EditorCanvas( { const editorSettings = getEditorSettings(); const supportsTemplateMode = editorSettings.supportsTemplateMode; - const postType = getPostType( postTypeSlug ); + const postTypeObject = getPostType( postTypeSlug ); const canEditTemplate = canUser( 'create', 'templates' ); const currentTemplateId = getCurrentTemplateId(); const template = currentTemplateId ? getEditedEntityRecord( 'postType', - 'wp_template', + TEMPLATE_POST_TYPE, currentTemplateId ) : undefined; @@ -146,14 +160,17 @@ function EditorCanvas( { // Post template fetch returns a 404 on classic themes, which // messes with e2e tests, so check it's a block theme first. editedPostTemplate: - postType?.viewable && supportsTemplateMode && canEditTemplate + postTypeObject?.viewable && + supportsTemplateMode && + canEditTemplate ? template : undefined, wrapperBlockName: _wrapperBlockName, wrapperUniqueId: getCurrentPostId(), deviceType: getDeviceType(), - showEditorPadding: - !! editorSettings.onNavigateToPreviousEntityRecord, + isFocusedEntity: !! editorSettings.onNavigateToPreviousEntityRecord, + postType: postTypeSlug, + isPreview: editorSettings.__unstableIsPreviewMode, }; }, [] ); const { isCleanNewPost } = useSelect( editorStore ); @@ -293,7 +310,6 @@ function EditorCanvas( { blockListLayout?.type === 'default' && ! hasPostContentAtRootLevel ? fallbackLayout : blockListLayout; - const observeTypingRef = useTypingObserver(); const titleRef = useRef(); useEffect( () => { @@ -330,102 +346,152 @@ function EditorCanvas( { } : {}; + const forceFullHeight = postType === NAVIGATION_POST_TYPE; + const enableResizing = + [ + NAVIGATION_POST_TYPE, + TEMPLATE_PART_POST_TYPE, + PATTERN_POST_TYPE, + ].includes( postType ) && + // Disable in previews / view mode. + ! isPreview && + // Disable resizing in mobile viewport. + ! isMobileViewport && + // Dsiable resizing in zoomed-out mode. + ! isZoomOutMode; + + const iframeStyles = useMemo( () => { + return [ + ...styles, + { + css: `.is-root-container{display:flow-root;${ + // Some themes will have `min-height: 100vh` for the root container, + // which isn't a requirement in auto resize mode. + enableResizing ? 'min-height:0!important;' : '' + }}`, + }, + ]; + }, [ styles, enableResizing ] ); + return ( - - { themeSupportsLayout && - ! themeHasDisabledLayoutStyles && - renderingMode === 'post-only' && - ! isDesignPostType && ( - <> - - - { align && } - { postContentLayoutStyles && ( - - ) } - - ) } - { renderingMode === 'post-only' && ! isDesignPostType && ( -
+ - -
- ) } - - + + + { align && } + { postContentLayoutStyles && ( + + ) } + + ) } + { renderingMode === 'post-only' && ! isDesignPostType && ( +
+ +
) } - layout={ blockListLayout } - dropZoneElement={ - // When iframed, pass in the html element of the iframe to - // ensure the drop zone extends to the edges of the iframe. - disableIframe - ? localRef.current - : localRef.current?.parentNode - } - renderAppender={ renderAppender } - __unstableDisableDropZone={ - // In template preview mode, disable drop zones at the root of the template. - renderingMode === 'template-locked' ? true : false + + + { renderingMode === 'template-locked' && ( + + ) } + + { + // Avoid resize listeners when not needed, + // these will trigger unnecessary re-renders + // when animating the iframe width. + enableResizing && resizeObserver } - /> - { renderingMode === 'template-locked' && ( - - ) } -
- { children } -
+ + +
); } diff --git a/packages/edit-site/src/components/block-editor/resizable-editor.js b/packages/editor/src/components/editor-canvas/resizable-editor.js similarity index 94% rename from packages/edit-site/src/components/block-editor/resizable-editor.js rename to packages/editor/src/components/editor-canvas/resizable-editor.js index eda5848cff2063..32b332161e22b3 100644 --- a/packages/edit-site/src/components/block-editor/resizable-editor.js +++ b/packages/editor/src/components/editor-canvas/resizable-editor.js @@ -22,7 +22,7 @@ const HANDLE_STYLES_OVERRIDE = { left: undefined, }; -function ResizableEditor( { enableResizing, height, children } ) { +function ResizableEditor( { className, enableResizing, height, children } ) { const [ width, setWidth ] = useState( '100%' ); const resizableRef = useRef(); const resizeWidthBy = useCallback( ( deltaPixels ) => { @@ -32,6 +32,7 @@ function ResizableEditor( { enableResizing, height, children } ) { }, [] ); return ( { resizableRef.current = api?.resizable; } } diff --git a/packages/edit-site/src/components/block-editor/resize-handle.js b/packages/editor/src/components/editor-canvas/resize-handle.js similarity index 87% rename from packages/edit-site/src/components/block-editor/resize-handle.js rename to packages/editor/src/components/editor-canvas/resize-handle.js index 04198b2140fd2c..bb9167eccb8379 100644 --- a/packages/edit-site/src/components/block-editor/resize-handle.js +++ b/packages/editor/src/components/editor-canvas/resize-handle.js @@ -11,11 +11,7 @@ import { const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels. -export default function ResizeHandle( { - variation = 'default', - direction, - resizeWidthBy, -} ) { +export default function ResizeHandle( { direction, resizeWidthBy } ) { function handleKeyDown( event ) { const { keyCode } = event; @@ -45,7 +41,7 @@ export default function ResizeHandle( { <> Date: Thu, 23 May 2024 12:16:57 +0100 Subject: [PATCH 2/5] Fix build --- .../editor-canvas-container/index.js | 8 +++- .../src/components/editor-canvas/index.js | 2 +- .../src/components/editor-canvas/style.scss | 47 ------------------- .../index.js} | 0 .../resize-handle.js | 2 +- .../components/resizable-editor/style.scss | 46 ++++++++++++++++++ packages/editor/src/private-apis.js | 2 + packages/editor/src/style.scss | 1 + 8 files changed, 57 insertions(+), 51 deletions(-) rename packages/editor/src/components/{editor-canvas/resizable-editor.js => resizable-editor/index.js} (100%) rename packages/editor/src/components/{editor-canvas => resizable-editor}/resize-handle.js (95%) create mode 100644 packages/editor/src/components/resizable-editor/style.scss diff --git a/packages/edit-site/src/components/editor-canvas-container/index.js b/packages/edit-site/src/components/editor-canvas-container/index.js index 0e9f7c3086ad7f..eca03ae8435659 100644 --- a/packages/edit-site/src/components/editor-canvas-container/index.js +++ b/packages/edit-site/src/components/editor-canvas-container/index.js @@ -13,14 +13,18 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { closeSmall } from '@wordpress/icons'; import { useFocusOnMount, useFocusReturn } from '@wordpress/compose'; import { store as preferencesStore } from '@wordpress/preferences'; -import { store as editorStore } from '@wordpress/editor'; +import { + store as editorStore, + privateApis as editorPrivateApis, +} from '@wordpress/editor'; /** * Internal dependencies */ import { unlock } from '../../lock-unlock'; import { store as editSiteStore } from '../../store'; -import ResizableEditor from '../block-editor/resizable-editor'; + +const { ResizableEditor } = unlock( editorPrivateApis ); /** * Returns a translated string for the title of the editor canvas container. diff --git a/packages/editor/src/components/editor-canvas/index.js b/packages/editor/src/components/editor-canvas/index.js index 9430d6475dda4e..1fd0cb4262831d 100644 --- a/packages/editor/src/components/editor-canvas/index.js +++ b/packages/editor/src/components/editor-canvas/index.js @@ -33,7 +33,7 @@ import PostTitle from '../post-title'; import { store as editorStore } from '../../store'; import { unlock } from '../../lock-unlock'; import EditTemplateBlocksNotification from './edit-template-blocks-notification'; -import ResizableEditor from './resizable-editor'; +import ResizableEditor from '../resizable-editor'; import useSelectNearestEditableBlock from '../../hooks/use-select-nearest-editable-block'; import { NAVIGATION_POST_TYPE, diff --git a/packages/editor/src/components/editor-canvas/style.scss b/packages/editor/src/components/editor-canvas/style.scss index 1cf030a1115cfa..e9c4b844b85d82 100644 --- a/packages/editor/src/components/editor-canvas/style.scss +++ b/packages/editor/src/components/editor-canvas/style.scss @@ -16,50 +16,3 @@ padding: $grid-unit-30 $grid-unit-30 0; } } - -.editor-canvas__resize-handle { - position: absolute; - top: 0; - bottom: 0; - padding: 0; - margin: auto 0; - width: $grid-unit-15; - appearance: none; - cursor: ew-resize; - outline: none; - background: none; - border-radius: $radius-block-ui; - border: 0; - height: 100px; - - &::after { - position: absolute; - top: $grid-unit-20; - left: $grid-unit-05; - right: 0; - bottom: $grid-unit-20; - content: ""; - width: $grid-unit-05; - background-color: rgba($gray-700, 0.4); - border-radius: $radius-block-ui; - } - - &.is-left { - // Subtract half of the handle width to properly center. - left: -$grid-unit-20 - math.div($grid-unit-05, 2); - } - - &.is-right { - // Subtract half of the handle width to properly center. - right: -$grid-unit-20 - math.div($grid-unit-05, 2); - } - - &:hover, - &:focus, - &:active { - opacity: 1; - &::after { - background-color: var(--wp-admin-theme-color); - } - } -} diff --git a/packages/editor/src/components/editor-canvas/resizable-editor.js b/packages/editor/src/components/resizable-editor/index.js similarity index 100% rename from packages/editor/src/components/editor-canvas/resizable-editor.js rename to packages/editor/src/components/resizable-editor/index.js diff --git a/packages/editor/src/components/editor-canvas/resize-handle.js b/packages/editor/src/components/resizable-editor/resize-handle.js similarity index 95% rename from packages/editor/src/components/editor-canvas/resize-handle.js rename to packages/editor/src/components/resizable-editor/resize-handle.js index bb9167eccb8379..7825a939553dc1 100644 --- a/packages/editor/src/components/editor-canvas/resize-handle.js +++ b/packages/editor/src/components/resizable-editor/resize-handle.js @@ -41,7 +41,7 @@ export default function ResizeHandle( { direction, resizeWidthBy } ) { <> Date: Thu, 23 May 2024 12:45:49 +0100 Subject: [PATCH 3/5] Fix canvas height --- .../src/components/iframe/content.scss | 4 ++++ .../src/components/visual-editor/index.js | 18 ++++++++++++++---- .../components/block-editor/editor-canvas.js | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/iframe/content.scss b/packages/block-editor/src/components/iframe/content.scss index 62a57030f1be11..165cf70d24a710 100644 --- a/packages/block-editor/src/components/iframe/content.scss +++ b/packages/block-editor/src/components/iframe/content.scss @@ -1,3 +1,7 @@ +.block-editor-iframe__body { + position: relative; +} + .block-editor-iframe__container { width: 100%; height: 100%; diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index c1e13d79f29411..43ee2458ceba24 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -25,6 +25,12 @@ import { usePaddingAppender } from './use-padding-appender'; const { EditorCanvas } = unlock( editorPrivateApis ); const isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false; +const DESIGN_POST_TYPES = [ + 'wp_template', + 'wp_template_part', + 'wp_block', + 'wp_navigation', +]; export default function VisualEditor( { styles } ) { const { @@ -34,12 +40,15 @@ export default function VisualEditor( { styles } ) { hasV3BlocksOnly, isEditingTemplate, isZoomedOutView, + postType, } = useSelect( ( select ) => { const { isFeatureActive } = select( editPostStore ); - const { getEditorSettings, getRenderingMode } = select( editorStore ); + const { getEditorSettings, getRenderingMode, getCurrentPostType } = + select( editorStore ); const { getBlockTypes } = select( blocksStore ); const { __unstableGetEditorMode } = select( blockEditorStore ); const editorSettings = getEditorSettings(); + const _postType = getCurrentPostType(); return { isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ), renderingMode: getRenderingMode(), @@ -47,9 +56,9 @@ export default function VisualEditor( { styles } ) { hasV3BlocksOnly: getBlockTypes().every( ( type ) => { return type.apiVersion >= 3; } ), - isEditingTemplate: - select( editorStore ).getCurrentPostType() === 'wp_template', + isEditingTemplate: _postType === 'wp_template', isZoomedOutView: __unstableGetEditorMode() === 'zoom-out', + postType: _postType, }; }, [] ); const hasMetaBoxes = useSelect( @@ -66,7 +75,8 @@ export default function VisualEditor( { styles } ) { if ( ! isZoomedOutView && ! hasMetaBoxes && - renderingMode === 'post-only' + renderingMode === 'post-only' && + ! DESIGN_POST_TYPES.includes( postType ) ) { paddingBottom = '40vh'; } diff --git a/packages/edit-site/src/components/block-editor/editor-canvas.js b/packages/edit-site/src/components/block-editor/editor-canvas.js index f81626e78ed790..383125b1615de2 100644 --- a/packages/edit-site/src/components/block-editor/editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/editor-canvas.js @@ -109,7 +109,7 @@ function EditorCanvas( { settings, children } ) { // Forming a "block formatting context" to prevent margin collapsing. // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context - css: `body{position:relative; ${ + css: `body{${ canvasMode === 'view' ? `min-height: 100vh; ${ currentPostIsTrashed ? '' : 'cursor: pointer;' From f801285564285566df60877161bde18908202594 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 23 May 2024 13:23:22 +0100 Subject: [PATCH 4/5] Fix stylebook --- .../editor-canvas-container/index.js | 40 ++++++++++--------- .../editor-canvas-container/style.scss | 8 ++++ .../src/components/editor-canvas/style.scss | 7 ---- .../src/components/resizable-editor/index.js | 9 ++++- .../resizable-editor/resize-handle.js | 2 +- .../components/resizable-editor/style.scss | 9 ++++- 6 files changed, 46 insertions(+), 29 deletions(-) diff --git a/packages/edit-site/src/components/editor-canvas-container/index.js b/packages/edit-site/src/components/editor-canvas-container/index.js index eca03ae8435659..ca5bc3a0b34f45 100644 --- a/packages/edit-site/src/components/editor-canvas-container/index.js +++ b/packages/edit-site/src/components/editor-canvas-container/index.js @@ -124,25 +124,27 @@ function EditorCanvasContainer( { return ( - - { /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ } -
- { shouldShowCloseButton && ( -
-
+
+ + { /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ } +
+ { shouldShowCloseButton && ( +
+
+
); } diff --git a/packages/edit-site/src/components/editor-canvas-container/style.scss b/packages/edit-site/src/components/editor-canvas-container/style.scss index acc0e0872f0b42..0aca5f8045ce8a 100644 --- a/packages/edit-site/src/components/editor-canvas-container/style.scss +++ b/packages/edit-site/src/components/editor-canvas-container/style.scss @@ -1,4 +1,12 @@ .edit-site-editor-canvas-container { + height: 100%; + + .edit-site-layout.is-full-canvas & { + padding: $grid-unit-30 $grid-unit-30 0; + } +} + +.edit-site-editor-canvas-container__section { background: $white; // Fallback color, overridden by JavaScript. border-radius: $radius-block-ui; bottom: 0; diff --git a/packages/editor/src/components/editor-canvas/style.scss b/packages/editor/src/components/editor-canvas/style.scss index e9c4b844b85d82..3e9d12cc190247 100644 --- a/packages/editor/src/components/editor-canvas/style.scss +++ b/packages/editor/src/components/editor-canvas/style.scss @@ -3,13 +3,6 @@ &.is-resizable { max-height: 100%; - - // To hide the horizontal scrollbar and show the drag handle on the - // left and right of the container. - .components-resizable-box__container { - overflow: visible; - margin: 0 auto; - } } &.has-padding { diff --git a/packages/editor/src/components/resizable-editor/index.js b/packages/editor/src/components/resizable-editor/index.js index 32b332161e22b3..7d8e26049389a7 100644 --- a/packages/editor/src/components/resizable-editor/index.js +++ b/packages/editor/src/components/resizable-editor/index.js @@ -1,3 +1,8 @@ +/** + * External dependencies + */ +import clsx from 'clsx'; + /** * WordPress dependencies */ @@ -32,7 +37,9 @@ function ResizableEditor( { className, enableResizing, height, children } ) { }, [] ); return ( { resizableRef.current = api?.resizable; } } diff --git a/packages/editor/src/components/resizable-editor/resize-handle.js b/packages/editor/src/components/resizable-editor/resize-handle.js index 7825a939553dc1..dbba31f6f998ba 100644 --- a/packages/editor/src/components/resizable-editor/resize-handle.js +++ b/packages/editor/src/components/resizable-editor/resize-handle.js @@ -41,7 +41,7 @@ export default function ResizeHandle( { direction, resizeWidthBy } ) { <> Date: Thu, 23 May 2024 15:00:45 +0100 Subject: [PATCH 5/5] Fix linting --- .../src/components/block-editor/site-editor-canvas.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/block-editor/site-editor-canvas.js b/packages/edit-site/src/components/block-editor/site-editor-canvas.js index a7b7b2c8cc4232..df63e3fde09aa5 100644 --- a/packages/edit-site/src/components/block-editor/site-editor-canvas.js +++ b/packages/edit-site/src/components/block-editor/site-editor-canvas.js @@ -40,9 +40,7 @@ export default function SiteEditorCanvas() { 'is-view-mode': isViewMode, } ) } > - + ) }