Skip to content

Commit

Permalink
more simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 12, 2023
1 parent a229bd8 commit b446ac2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ import {

const { EditorCanvas: EditorCanvasRoot } = unlock( editorPrivateApis );

function EditorCanvas( {
enableResizing,
settings,
children,
contentRef,
...props
} ) {
function EditorCanvas( { enableResizing, settings, children, ...props } ) {
const { hasBlocks, isFocusMode, templateType, canvasMode, isZoomOutMode } =
useSelect( ( select ) => {
const { getBlockCount, __unstableGetEditorMode } =
Expand Down Expand Up @@ -107,7 +101,6 @@ function EditorCanvas( {

return (
<EditorCanvasRoot
ref={ contentRef }
className={ classnames( 'edit-site-editor-canvas__block-list', {
'is-navigation-block': isTemplateTypeNavigation,
} ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { useRef } from '@wordpress/element';
import { useViewportMatch, useResizeObserver } from '@wordpress/compose';

/**
Expand Down Expand Up @@ -50,7 +49,6 @@ export default function SiteEditorCanvas() {
// Disable resizing in mobile viewport.
! isMobileViewport;

const contentRef = useRef();
const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE;
const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode;
const forceFullHeight = isNavigationFocusMode;
Expand Down Expand Up @@ -81,7 +79,6 @@ export default function SiteEditorCanvas() {
<EditorCanvas
enableResizing={ enableResizing }
settings={ settings }
contentRef={ contentRef }
>
{ resizeObserver }
</EditorCanvas>
Expand Down
28 changes: 12 additions & 16 deletions packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
privateApis as blockEditorPrivateApis,
__experimentalUseResizeCanvas as useResizeCanvas,
} from '@wordpress/block-editor';
import { useEffect, useRef, useMemo, forwardRef } from '@wordpress/element';
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';
Expand Down Expand Up @@ -72,19 +72,16 @@ function checkForPostContentAtRootLevel( blocks ) {
return false;
}

function EditorCanvas(
{
// Ideally as we unify post and site editors, we won't need these props.
autoFocus,
className,
renderAppender,
styles,
disableIframe = false,
iframeProps,
children,
},
ref
) {
function EditorCanvas( {
// Ideally as we unify post and site editors, we won't need these props.
autoFocus,
className,
renderAppender,
styles,
disableIframe = false,
iframeProps,
children,
} ) {
const {
renderingMode,
postContentAttributes,
Expand Down Expand Up @@ -288,7 +285,6 @@ function EditorCanvas(
const typewriterRef = useTypewriter();
const contentRef = useMergeRefs(
[
ref,
localRef,
renderingMode === 'post-only' ? typewriterRef : undefined,
].filter( ( r ) => !! r )
Expand Down Expand Up @@ -379,4 +375,4 @@ function EditorCanvas(
);
}

export default forwardRef( EditorCanvas );
export default EditorCanvas;

0 comments on commit b446ac2

Please sign in to comment.