From 99fefd79c2644f65fb885fad82e0c11e7593eca0 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Tue, 17 Sep 2024 20:59:21 +0900 Subject: [PATCH] Don't force iframe editor when gutenberg plugin and block theme are enabled (#65372) Co-authored-by: t-hamano Co-authored-by: fabiankaegy Co-authored-by: stokesman --- .../components/layout/use-should-iframe.js | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/packages/edit-post/src/components/layout/use-should-iframe.js b/packages/edit-post/src/components/layout/use-should-iframe.js index e36a4773c4a1fd..9fed30c07b37e3 100644 --- a/packages/edit-post/src/components/layout/use-should-iframe.js +++ b/packages/edit-post/src/components/layout/use-should-iframe.js @@ -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; }