From bc1a948de72e492b3ec416864107616f18dbe526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Tue, 14 Feb 2023 20:08:48 +0200 Subject: [PATCH 1/2] Post editor: revert iframed editor for WP core only --- lib/compat/wordpress-6.2/script-loader.php | 2 ++ packages/edit-post/src/components/visual-editor/index.js | 6 +++++- .../src/components/provider/use-block-editor-settings.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index 149a6a18e1450..36a66cf10121d 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -165,6 +165,8 @@ function( $settings ) { // We must override what core is passing now. $settings['__unstableResolvedAssets'] = gutenberg_resolve_assets_override(); $settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme(); + // As the name suggests, this shouldn't be backported to core. + $settings['__unstableIsGutenbergPlugin'] = IS_GUTENBERG_PLUGIN; return $settings; }, 100 diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index 21760ccfb40dd..abf496ac960eb 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -110,6 +110,7 @@ export default function VisualEditor( { styles } ) { wrapperBlockName, wrapperUniqueId, isBlockBasedTheme, + isGutenbergPlugin, } = useSelect( ( select ) => { const { isFeatureActive, @@ -148,6 +149,7 @@ export default function VisualEditor( { styles } ) { wrapperBlockName: _wrapperBlockName, wrapperUniqueId: getCurrentPostId(), isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme, + isGutenbergPlugin: editorSettings.__unstableIsGutenbergPlugin, }; }, [] ); const { isCleanNewPost } = useSelect( editorStore ); @@ -339,7 +341,9 @@ export default function VisualEditor( { styles } ) { > Date: Wed, 15 Feb 2023 09:57:40 +0200 Subject: [PATCH 2/2] Use env var --- lib/compat/wordpress-6.2/script-loader.php | 2 -- packages/edit-post/src/components/visual-editor/index.js | 4 ++-- .../src/components/provider/use-block-editor-settings.js | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-6.2/script-loader.php b/lib/compat/wordpress-6.2/script-loader.php index 36a66cf10121d..149a6a18e1450 100644 --- a/lib/compat/wordpress-6.2/script-loader.php +++ b/lib/compat/wordpress-6.2/script-loader.php @@ -165,8 +165,6 @@ function( $settings ) { // We must override what core is passing now. $settings['__unstableResolvedAssets'] = gutenberg_resolve_assets_override(); $settings['__unstableIsBlockBasedTheme'] = wp_is_block_theme(); - // As the name suggests, this shouldn't be backported to core. - $settings['__unstableIsGutenbergPlugin'] = IS_GUTENBERG_PLUGIN; return $settings; }, 100 diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index abf496ac960eb..263dc8044e3f2 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -44,6 +44,8 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editPostStore } from '../../store'; +const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false; + function MaybeIframe( { children, contentRef, shouldIframe, styles, style } ) { const ref = useMouseMoveTypingReset(); @@ -110,7 +112,6 @@ export default function VisualEditor( { styles } ) { wrapperBlockName, wrapperUniqueId, isBlockBasedTheme, - isGutenbergPlugin, } = useSelect( ( select ) => { const { isFeatureActive, @@ -149,7 +150,6 @@ export default function VisualEditor( { styles } ) { wrapperBlockName: _wrapperBlockName, wrapperUniqueId: getCurrentPostId(), isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme, - isGutenbergPlugin: editorSettings.__unstableIsGutenbergPlugin, }; }, [] ); const { isCleanNewPost } = useSelect( editorStore ); diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js index 1ef0cedcb8e80..4c5c431e5915f 100644 --- a/packages/editor/src/components/provider/use-block-editor-settings.js +++ b/packages/editor/src/components/provider/use-block-editor-settings.js @@ -74,7 +74,6 @@ const BLOCK_EDITOR_SETTINGS = [ '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', - '__unstableIsGutenbergPlugin', ]; /**