Skip to content

Commit

Permalink
Don't force iframe editor when gutenberg plugin and block theme are e…
Browse files Browse the repository at this point in the history
…nabled (#65372)

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: stokesman <[email protected]>
  • Loading branch information
4 people committed Sep 17, 2024
1 parent afbb659 commit 99fefd7
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,22 @@ import { useSelect } from '@wordpress/data';
import { store as blocksStore } from '@wordpress/blocks';
import { store as blockEditorStore } from '@wordpress/block-editor';

const isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;

export function useShouldIframe() {
const {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
isZoomOutMode,
} = useSelect( ( select ) => {
const { getEditorSettings, getCurrentPostType } = select( editorStore );
const { __unstableGetEditorMode } = select( blockEditorStore );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
return {
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
};
}, [] );

return (
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
isEditingTemplate ||
isZoomOutMode
const { hasV3BlocksOnly, isEditingTemplate, isZoomOutMode } = useSelect(
( select ) => {
const { getCurrentPostType } = select( editorStore );
const { __unstableGetEditorMode } = select( blockEditorStore );
const { getBlockTypes } = select( blocksStore );
return {
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
};
},
[]
);

return hasV3BlocksOnly || isEditingTemplate || isZoomOutMode;
}

0 comments on commit 99fefd7

Please sign in to comment.