diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 9cb2f44d05eb9b..56365c87a268fd 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -314,21 +314,21 @@ export const registerCoreBlocks = ( * __experimentalRegisterExperimentalCoreBlocks( settings ); * ``` */ -export const __experimentalRegisterExperimentalCoreBlocks = process.env - .IS_GUTENBERG_PLUGIN - ? ( { enableFSEBlocks } = {} ) => { - const enabledExperiments = [ enableFSEBlocks ? 'fse' : null ]; - getAllBlocks() - .filter( ( { metadata } ) => - isBlockMetadataExperimental( metadata ) - ) - .filter( - ( { metadata: { __experimental } } ) => - __experimental === true || - enabledExperiments.includes( __experimental ) - ) - .forEach( ( { init } ) => init() ); - } - : undefined; +export const __experimentalRegisterExperimentalCoreBlocks = + globalThis.IS_GUTENBERG_PLUGIN + ? ( { enableFSEBlocks } = {} ) => { + const enabledExperiments = [ enableFSEBlocks ? 'fse' : null ]; + getAllBlocks() + .filter( ( { metadata } ) => + isBlockMetadataExperimental( metadata ) + ) + .filter( + ( { metadata: { __experimental } } ) => + __experimental === true || + enabledExperiments.includes( __experimental ) + ) + .forEach( ( { init } ) => init() ); + } + : undefined; export { privateApis } from './private-apis'; diff --git a/packages/blocks/src/api/parser/convert-legacy-block.js b/packages/blocks/src/api/parser/convert-legacy-block.js index c828a3f5db6c49..8396b98109792f 100644 --- a/packages/blocks/src/api/parser/convert-legacy-block.js +++ b/packages/blocks/src/api/parser/convert-legacy-block.js @@ -79,7 +79,7 @@ export function convertLegacyBlockNameAndAttributes( name, attributes ) { // The following code is only relevant for the Gutenberg plugin. // It's a stand-alone if statement for dead-code elimination. - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { // Convert pattern overrides added during experimental phase. // Only four blocks were supported initially. // These checks can be removed in WordPress 6.6. diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index 454250e8ad13c9..be4d12f0cb9ef6 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -396,7 +396,7 @@ export const editEntityRecord = }, {} ), }; if ( window.__experimentalEnableSync && entityConfig.syncConfig ) { - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { const objectId = entityConfig.getSyncObjectId( recordId ); getSyncProvider().update( entityConfig.syncObjectType + '--edit', diff --git a/packages/core-data/src/entities.js b/packages/core-data/src/entities.js index e91744110faf32..8d09402087cf90 100644 --- a/packages/core-data/src/entities.js +++ b/packages/core-data/src/entities.js @@ -485,7 +485,7 @@ export const getOrLoadEntitiesConfig = if ( configs?.length > 0 && hasConfig ) { if ( window.__experimentalEnableSync ) { - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { registerSyncConfigs( configs ); } } @@ -506,7 +506,7 @@ export const getOrLoadEntitiesConfig = configs = await loader.loadEntities(); if ( window.__experimentalEnableSync ) { - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { registerSyncConfigs( configs ); } } diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index 7de2c354ba2bf8..ea77f342e69ca7 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -81,7 +81,7 @@ export const getEntityRecord = entityConfig.syncConfig && ! query ) { - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { const objectId = entityConfig.getSyncObjectId( key ); // Loads the persisted document. diff --git a/packages/customize-widgets/src/index.js b/packages/customize-widgets/src/index.js index 5b438cac86f49b..9afda775a1701c 100644 --- a/packages/customize-widgets/src/index.js +++ b/packages/customize-widgets/src/index.js @@ -61,7 +61,7 @@ export function initialize( editorName, blockEditorSettings ) { } ); registerCoreBlocks( coreBlocks ); registerLegacyWidgetBlock(); - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS, } ); diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index 3bb50999c2a929..c1e13d79f29411 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -24,7 +24,7 @@ import { usePaddingAppender } from './use-padding-appender'; const { EditorCanvas } = unlock( editorPrivateApis ); -const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false; +const isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false; export default function VisualEditor( { styles } ) { const { diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 0a2d17a344e474..1e0b3fe7d4d6ff 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -80,7 +80,7 @@ export function initializeEditor( registerCoreBlocks(); registerLegacyWidgetBlock( { inserter: false } ); registerWidgetGroupBlock( { inserter: false } ); - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks, } ); diff --git a/packages/edit-site/src/index.js b/packages/edit-site/src/index.js index f42842f504e54d..41fc0a1985fded 100644 --- a/packages/edit-site/src/index.js +++ b/packages/edit-site/src/index.js @@ -42,7 +42,7 @@ export function initializeEditor( id, settings ) { dispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' ); registerLegacyWidgetBlock( { inserter: false } ); registerWidgetGroupBlock( { inserter: false } ); - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: true, } ); diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index eb87d22fefef9e..2374ec19dabd7b 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -73,7 +73,7 @@ export function initializeEditor( id, settings ) { dispatch( blocksStore ).reapplyBlockTypeFilters(); registerCoreBlocks( coreBlocks ); registerLegacyWidgetBlock(); - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS, } ); diff --git a/packages/editor/src/bindings/index.js b/packages/editor/src/bindings/index.js index ce77b87ebc7a5c..5824cdde022cc6 100644 --- a/packages/editor/src/bindings/index.js +++ b/packages/editor/src/bindings/index.js @@ -13,6 +13,6 @@ import postMeta from './post-meta'; const { registerBlockBindingsSource } = unlock( dispatch( blocksStore ) ); registerBlockBindingsSource( postMeta ); -if ( process.env.IS_GUTENBERG_PLUGIN ) { +if ( globalThis.IS_GUTENBERG_PLUGIN ) { registerBlockBindingsSource( patternOverrides ); } diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index 194dd338f49e61..88387f336c159a 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -1019,7 +1019,7 @@ export function usePostActions( postType, onActionPerformed ) { isTemplateOrTemplatePart && deleteTemplateAction, ! isTemplateOrTemplatePart && permanentlyDeletePostAction, postRevisionsAction, - process.env.IS_GUTENBERG_PLUGIN + globalThis.IS_GUTENBERG_PLUGIN ? ! isTemplateOrTemplatePart && ! isPattern && duplicatePostAction diff --git a/packages/interactivity-router/src/index.js b/packages/interactivity-router/src/index.js index 7e786700338f50..35baa8bced4bbc 100644 --- a/packages/interactivity-router/src/index.js +++ b/packages/interactivity-router/src/index.js @@ -58,7 +58,7 @@ const fetchPage = async ( url, { html } ) => { const regionsToVdom = async ( dom, { vdom } = {} ) => { const regions = {}; let head; - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { if ( navigationMode === 'fullPage' ) { head = await fetchHeadAssets( dom, headElements ); regions.body = vdom @@ -83,7 +83,7 @@ const regionsToVdom = async ( dom, { vdom } = {} ) => { // Render all interactive regions contained in the given page. const renderRegions = ( page ) => { batch( () => { - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { if ( navigationMode === 'fullPage' ) { // Once this code is tested and more mature, the head should be updated for region based navigation as well. updateHead( page.head ); @@ -139,7 +139,7 @@ window.addEventListener( 'popstate', async () => { // Initialize the router and cache the initial page using the initial vDOM. // Once this code is tested and more mature, the head should be updated for region based navigation as well. -if ( process.env.IS_GUTENBERG_PLUGIN ) { +if ( globalThis.IS_GUTENBERG_PLUGIN ) { if ( navigationMode === 'fullPage' ) { // Cache the scripts. Has to be called before fetching the assets. [].map.call( document.querySelectorAll( 'script[src]' ), ( script ) => { @@ -329,7 +329,7 @@ export const { state, actions } = store( 'core/router', { } ); // Add click and prefetch to all links. -if ( process.env.IS_GUTENBERG_PLUGIN ) { +if ( globalThis.IS_GUTENBERG_PLUGIN ) { if ( navigationMode === 'fullPage' ) { // Navigate on click. document.addEventListener( diff --git a/test/integration/full-content/full-content.test.js b/test/integration/full-content/full-content.test.js index f825de04771442..4522dd7b88e451 100644 --- a/test/integration/full-content/full-content.test.js +++ b/test/integration/full-content/full-content.test.js @@ -82,7 +82,7 @@ describe( 'full post content fixture', () => { formSubmissionNotification, ] ); - if ( process.env.IS_GUTENBERG_PLUGIN ) { + if ( globalThis.IS_GUTENBERG_PLUGIN ) { __experimentalRegisterExperimentalCoreBlocks( { enableFSEBlocks: true, } );