Skip to content

Commit

Permalink
Editor: Move the edit template blocks notification to editor package (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Dec 8, 2023
1 parent 2e95c20 commit 8a702c3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
NAVIGATION_POST_TYPE,
} from '../../utils/constants';
import { unlock } from '../../lock-unlock';
import PageContentFocusNotifications from '../page-content-focus-notifications';

export default function SiteEditorCanvas() {
const { clearSelectedBlock } = useDispatch( blockEditorStore );
Expand Down Expand Up @@ -60,50 +59,46 @@ export default function SiteEditorCanvas() {
const forceFullHeight = isNavigationFocusMode;

return (
<>
<EditorCanvasContainer.Slot>
{ ( [ editorCanvasView ] ) =>
editorCanvasView ? (
<div className="edit-site-visual-editor is-focus-mode">
{ editorCanvasView }
</div>
) : (
<BlockTools
className={ classnames( 'edit-site-visual-editor', {
'is-focus-mode':
isFocusMode || !! editorCanvasView,
'is-view-mode': isViewMode,
} ) }
__unstableContentRef={ contentRef }
onClick={ ( event ) => {
// Clear selected block when clicking on the gray background.
if ( event.target === event.currentTarget ) {
clearSelectedBlock();
}
} }
<EditorCanvasContainer.Slot>
{ ( [ editorCanvasView ] ) =>
editorCanvasView ? (
<div className="edit-site-visual-editor is-focus-mode">
{ editorCanvasView }
</div>
) : (
<BlockTools
className={ classnames( 'edit-site-visual-editor', {
'is-focus-mode': isFocusMode || !! editorCanvasView,
'is-view-mode': isViewMode,
} ) }
__unstableContentRef={ contentRef }
onClick={ ( event ) => {
// Clear selected block when clicking on the gray background.
if ( event.target === event.currentTarget ) {
clearSelectedBlock();
}
} }
>
<BackButton />
<ResizableEditor
enableResizing={ enableResizing }
height={
sizes.height && ! forceFullHeight
? sizes.height
: '100%'
}
>
<BackButton />
<ResizableEditor
<EditorCanvas
enableResizing={ enableResizing }
height={
sizes.height && ! forceFullHeight
? sizes.height
: '100%'
}
settings={ settings }
contentRef={ contentRef }
>
<EditorCanvas
enableResizing={ enableResizing }
settings={ settings }
contentRef={ contentRef }
>
{ resizeObserver }
</EditorCanvas>
</ResizableEditor>
</BlockTools>
)
}
</EditorCanvasContainer.Slot>
<PageContentFocusNotifications contentRef={ contentRef } />
</>
{ resizeObserver }
</EditorCanvas>
</ResizableEditor>
</BlockTools>
)
}
</EditorCanvasContainer.Slot>
);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { useEffect, useState, useRef } from '@wordpress/element';
import { store as noticesStore } from '@wordpress/notices';
import { __ } from '@wordpress/i18n';
import { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';
import { store as editorStore } from '@wordpress/editor';

/**
* Internal dependencies
*/
import { store as editorStore } from '../../store';

/**
* Component that:
Expand All @@ -22,7 +26,7 @@ import { store as editorStore } from '@wordpress/editor';
* @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
* editor iframe canvas.
*/
export default function EditTemplateNotification( { contentRef } ) {
export default function EditTemplateBlocksNotification( { contentRef } ) {
const renderingMode = useSelect(
( select ) => select( editorStore ).getRenderingMode(),
[]
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/components/editor-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useMergeRefs } from '@wordpress/compose';
import PostTitle from '../post-title';
import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import EditTemplateBlocksNotification from './edit-template-blocks-notification';

const {
LayoutStyle,
Expand Down Expand Up @@ -361,6 +362,7 @@ function EditorCanvas(
}
renderAppender={ renderAppender }
/>
<EditTemplateBlocksNotification contentRef={ localRef } />
</RecursionProvider>
{ children }
</BlockCanvas>
Expand Down

1 comment on commit 8a702c3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 8a702c3.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7145116477
📝 Reported issues:

Please sign in to comment.