-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Block editor canvas iframe: play around with restricting max height of iframe #58484
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,13 @@ import { | |
|
|
||
| const { EditorCanvas: EditorCanvasRoot } = unlock( editorPrivateApis ); | ||
|
|
||
| function EditorCanvas( { enableResizing, settings, children, ...props } ) { | ||
| function EditorCanvas( { | ||
| enableResizing, | ||
| settings, | ||
| children, | ||
| containerHeight, | ||
| ...props | ||
| } ) { | ||
| const { hasBlocks, isFocusMode, templateType, canvasMode, isZoomOutMode } = | ||
| useSelect( ( select ) => { | ||
| const { getBlockCount, __unstableGetEditorMode } = | ||
|
|
@@ -109,13 +115,20 @@ function EditorCanvas( { enableResizing, settings, children, ...props } ) { | |
| iframeProps={ { | ||
| expand: isZoomOutMode, | ||
| scale: isZoomOutMode ? 0.45 : undefined, | ||
| frameSize: isZoomOutMode ? 100 : undefined, | ||
| frameSize: isZoomOutMode ? 50 : undefined, | ||
| className: classnames( | ||
| 'edit-site-visual-editor__editor-canvas', | ||
| { | ||
| 'is-focused': isFocused && canvasMode === 'view', | ||
| } | ||
| ), | ||
| maxHeight: | ||
| isZoomOutMode && containerHeight | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we wouldn't want to set a maxHeight in Right now I'm just testing in the site editor when browsing styles. |
||
| ? containerHeight | ||
| : undefined, | ||
| style: { | ||
| transition: isZoomOutMode ? 'none' : undefined, | ||
| }, | ||
| ...props, | ||
| ...( canvasMode === 'view' ? viewModeProps : {} ), | ||
| } } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,12 @@ import classnames from 'classnames'; | |
| * WordPress dependencies | ||
| */ | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { useViewportMatch, useResizeObserver } from '@wordpress/compose'; | ||
|
|
||
| import { | ||
| useViewportMatch, | ||
| useResizeObserver, | ||
| useRefEffect, | ||
| } from '@wordpress/compose'; | ||
| import { useState } from '@wordpress/element'; | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
|
|
@@ -59,12 +63,25 @@ export default function SiteEditorCanvas() { | |
| const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; | ||
| const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; | ||
| const forceFullHeight = isNavigationFocusMode; | ||
| const [ containerHeight, setContainerHeight ] = useState(); | ||
| const containerRef = useRefEffect( | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expect this is not ideal. It's a lot of faffery just to passing down the iframe container's height. Maybe we pass down the ref? 🤷🏻 |
||
| ( node ) => { | ||
| if ( ! node && ! node?.offsetHeight ) { | ||
| return; | ||
| } | ||
| setContainerHeight( node?.offsetHeight ); | ||
| }, | ||
| [ window.innerHeight ] | ||
| ); | ||
|
|
||
| return ( | ||
| <EditorCanvasContainer.Slot> | ||
| { ( [ editorCanvasView ] ) => | ||
| editorCanvasView ? ( | ||
| <div className="edit-site-visual-editor is-focus-mode"> | ||
| <div | ||
| className="edit-site-visual-editor is-focus-mode" | ||
| ref={ containerRef } | ||
| > | ||
| { editorCanvasView } | ||
| </div> | ||
| ) : ( | ||
|
|
@@ -73,6 +90,7 @@ export default function SiteEditorCanvas() { | |
| 'is-focus-mode': isFocusMode || !! editorCanvasView, | ||
| 'is-view-mode': isViewMode, | ||
| } ) } | ||
| ref={ containerRef } | ||
| > | ||
| <BackButton /> | ||
| <ResizableEditor | ||
|
|
@@ -86,6 +104,7 @@ export default function SiteEditorCanvas() { | |
| <EditorCanvas | ||
| enableResizing={ enableResizing } | ||
| settings={ settings } | ||
| containerHeight={ containerHeight } | ||
| > | ||
| { resizeObserver } | ||
| </EditorCanvas> | ||
|
|
||
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.
Scale the maxHeight.
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.
Wondering if we could get the container height using DOM API here instead 🤷🏻
Would save all the ref passing and other chicanery