Skip to content

Commit

Permalink
Post Editor: Always force iframe in pattern editor (#65887)
Browse files Browse the repository at this point in the history
* Post Editor: Always force iframe in pattern editor

* Aggregate conditions into useShouldIframe hook

* Revert "Aggregate conditions into useShouldIframe hook"

This reverts commit 5da8433.

* Aggregate conditions into useShouldIframe hook

* Add device type check to useShouldIframe check

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: stokesman <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent 484c960 commit e36a382
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 11 additions & 5 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export function useShouldIframe() {
const {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
isEditingTemplateOrPattern,
isZoomOutMode,
deviceType,
} = useSelect( ( select ) => {
const { getEditorSettings, getCurrentPostType } = select( editorStore );
const { getEditorSettings, getCurrentPostType, getDeviceType } =
select( editorStore );
const { isZoomOut } = unlock( select( blockEditorStore ) );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
Expand All @@ -29,15 +31,19 @@ export function useShouldIframe() {
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
isEditingTemplateOrPattern: [ 'wp_template', 'wp_block' ].includes(
getCurrentPostType()
),
isZoomOutMode: isZoomOut(),
deviceType: getDeviceType(),
};
}, [] );

return (
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
isEditingTemplate ||
isZoomOutMode
isEditingTemplateOrPattern ||
isZoomOutMode ||
[ 'Tablet', 'Mobile' ].includes( deviceType )
);
}
6 changes: 2 additions & 4 deletions packages/editor/src/components/visual-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,6 @@ function VisualEditor( {
! isMobileViewport &&
// Dsiable resizing in zoomed-out mode.
! isZoomedOut;
const shouldIframe =
! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType );

const iframeStyles = useMemo( () => {
return [
Expand All @@ -377,7 +375,7 @@ function VisualEditor( {
{
'has-padding': isFocusedEntity || enableResizing,
'is-resizable': enableResizing,
'is-iframed': shouldIframe,
'is-iframed': ! disableIframe,
}
) }
>
Expand All @@ -388,7 +386,7 @@ function VisualEditor( {
}
>
<BlockCanvas
shouldIframe={ shouldIframe }
shouldIframe={ ! disableIframe }
contentRef={ contentRef }
styles={ iframeStyles }
height="100%"
Expand Down

0 comments on commit e36a382

Please sign in to comment.