From fb3e161176f5c66f9c1afe5bec739a24b20b269e Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Tue, 17 Sep 2024 22:16:27 +0900 Subject: [PATCH] Revert "Don't force iframe editor when gutenberg plugin and block theme are enabled (#65372)" This reverts commit 99fefd79c2644f65fb885fad82e0c11e7593eca0. --- .../components/layout/use-should-iframe.js | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 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 9fed30c07b37e..e36a4773c4a1f 100644 --- a/packages/edit-post/src/components/layout/use-should-iframe.js +++ b/packages/edit-post/src/components/layout/use-should-iframe.js @@ -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 + ); }