Skip to content

Commit

Permalink
Revert "Don't force iframe editor when gutenberg plugin and block the…
Browse files Browse the repository at this point in the history
…me are enabled (#65372)" (#65402)

This reverts commit 99fefd7.

Co-authored-by: t-hamano <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
4 people authored Sep 17, 2024
1 parent 2943dd3 commit c114b25
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,33 @@ 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 { 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',
};
},
[]
);
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 || isEditingTemplate || isZoomOutMode;
return (
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
isEditingTemplate ||
isZoomOutMode
);
}

0 comments on commit c114b25

Please sign in to comment.