From c424cafaf3309a582fc028d656477d4a3612f6cf Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Mon, 24 May 2021 17:01:21 +1000 Subject: [PATCH] Prepare for adding the Widgets block editor to Core (#32136) --- packages/block-library/src/index.js | 6 ++---- packages/customize-widgets/src/index.js | 6 +----- .../fixtures/blocks/core__legacy-widget.html | 1 + .../fixtures/blocks/core__legacy-widget.json | 18 ++++++++++++++++++ .../blocks/core__legacy-widget.parsed.json | 16 ++++++++++++++++ .../blocks/core__legacy-widget.serialized.html | 1 + packages/edit-widgets/src/index.js | 6 +----- 7 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 packages/e2e-tests/fixtures/blocks/core__legacy-widget.html create mode 100644 packages/e2e-tests/fixtures/blocks/core__legacy-widget.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__legacy-widget.parsed.json create mode 100644 packages/e2e-tests/fixtures/blocks/core__legacy-widget.serialized.html diff --git a/packages/block-library/src/index.js b/packages/block-library/src/index.js index 6f0ebe50e8fe61..b0e36ae6dba9e7 100644 --- a/packages/block-library/src/index.js +++ b/packages/block-library/src/index.js @@ -148,6 +148,7 @@ export const __experimentalGetCoreBlocks = () => [ mediaText, latestComments, latestPosts, + legacyWidget, missing, more, nextpage, @@ -229,15 +230,12 @@ export const registerCoreBlocks = ( */ export const __experimentalRegisterExperimentalCoreBlocks = process.env.GUTENBERG_PHASE === 2 - ? ( { enableLegacyWidgetBlock, enableFSEBlocks } = {} ) => { + ? ( { enableFSEBlocks } = {} ) => { [ navigation, navigationLink, homeLink, - // Register Legacy Widget block. - ...( enableLegacyWidgetBlock ? [ legacyWidget ] : [] ), - // Register Full Site Editing Blocks. ...( enableFSEBlocks ? [ diff --git a/packages/customize-widgets/src/index.js b/packages/customize-widgets/src/index.js index 76af7c7fe660ff..25e99df5391c8a 100644 --- a/packages/customize-widgets/src/index.js +++ b/packages/customize-widgets/src/index.js @@ -31,11 +31,7 @@ export function initialize( editorName, blockEditorSettings ) { ); registerCoreBlocks( coreBlocks ); - if ( process.env.GUTENBERG_PHASE === 2 ) { - __experimentalRegisterExperimentalCoreBlocks( { - enableLegacyWidgetBlock: true, - } ); - } + __experimentalRegisterExperimentalCoreBlocks(); registerLegacyWidgetVariations( blockEditorSettings ); diff --git a/packages/e2e-tests/fixtures/blocks/core__legacy-widget.html b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.html new file mode 100644 index 00000000000000..293a884c37414f --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.html @@ -0,0 +1 @@ + diff --git a/packages/e2e-tests/fixtures/blocks/core__legacy-widget.json b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.json new file mode 100644 index 00000000000000..fc919a1597d6ca --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.json @@ -0,0 +1,18 @@ +[ + { + "clientId": "_clientId_0", + "name": "core/legacy-widget", + "isValid": true, + "attributes": { + "id": null, + "idBase": "search", + "instance": { + "encoded": "YTowOnt9", + "hash": "b9b82f721929717273108125217fbcd9", + "raw": {} + } + }, + "innerBlocks": [], + "originalContent": "" + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__legacy-widget.parsed.json b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.parsed.json new file mode 100644 index 00000000000000..e97d26c0f43b22 --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.parsed.json @@ -0,0 +1,16 @@ +[ + { + "blockName": "core/legacy-widget", + "attrs": { + "idBase": "search", + "instance": { + "encoded": "YTowOnt9", + "hash": "b9b82f721929717273108125217fbcd9", + "raw": {} + } + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/packages/e2e-tests/fixtures/blocks/core__legacy-widget.serialized.html b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.serialized.html new file mode 100644 index 00000000000000..293a884c37414f --- /dev/null +++ b/packages/e2e-tests/fixtures/blocks/core__legacy-widget.serialized.html @@ -0,0 +1 @@ + diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index d96c5d552f9aff..4605bb56346f2f 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -33,11 +33,7 @@ export function initialize( id, settings ) { ( block ) => ! [ 'core/more' ].includes( block.name ) ); registerCoreBlocks( coreBlocks ); - if ( process.env.GUTENBERG_PHASE === 2 ) { - __experimentalRegisterExperimentalCoreBlocks( { - enableLegacyWidgetBlock: true, - } ); - } + __experimentalRegisterExperimentalCoreBlocks(); registerLegacyWidgetVariations( settings ); registerBlock( widgetArea ); settings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>