From fa72398e72adc7236d9224bc17a845d13f0545d5 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:49:44 +0100 Subject: [PATCH 1/7] Disable post-* and query* blocks --- packages/edit-widgets/src/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index f2e98fc62b5a2..22c17155be603 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -25,6 +25,8 @@ import './filters'; import * as widgetArea from './blocks/widget-area'; import Layout from './components/layout'; +const DISABLED_BLOCKS = [ 'core/more', 'core/freeform' ]; + /** * Initializes the block editor in the widgets screen. * @@ -32,9 +34,14 @@ import Layout from './components/layout'; * @param {Object} settings Block editor settings. */ export function initialize( id, settings ) { - const coreBlocks = __experimentalGetCoreBlocks().filter( - ( block ) => ! [ 'core/more', 'core/freeform' ].includes( block.name ) - ); + const coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => { + return ! ( + DISABLED_BLOCKS.includes( block.name ) || + block.name.startsWith( 'core/post-' ) || + block.name.startsWith( 'core/query' ) + ); + } ); + registerCoreBlocks( coreBlocks ); registerLegacyWidgetBlock(); if ( process.env.GUTENBERG_PHASE === 2 ) { From f022ad27d7952c4b26d710016786808f538c28d6 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:51:22 +0100 Subject: [PATCH 2/7] Disable remaining entity blocks and any experimental FSE blocks --- packages/edit-widgets/src/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index 22c17155be603..f83b1a7732756 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -26,6 +26,7 @@ import * as widgetArea from './blocks/widget-area'; import Layout from './components/layout'; const DISABLED_BLOCKS = [ 'core/more', 'core/freeform' ]; +const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; /** * Initializes the block editor in the widgets screen. @@ -37,15 +38,18 @@ export function initialize( id, settings ) { const coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => { return ! ( DISABLED_BLOCKS.includes( block.name ) || - block.name.startsWith( 'core/post-' ) || - block.name.startsWith( 'core/query' ) + block.name.startsWith( 'core/post' ) || + block.name.startsWith( 'core/query' ) || + block.name.startsWith( 'core/site' ) ); } ); registerCoreBlocks( coreBlocks ); registerLegacyWidgetBlock(); if ( process.env.GUTENBERG_PHASE === 2 ) { - __experimentalRegisterExperimentalCoreBlocks(); + __experimentalRegisterExperimentalCoreBlocks( { + enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS, + } ); } registerLegacyWidgetVariations( settings ); registerBlock( widgetArea ); From cc241f5f58e728705fa99babe3ab26b8acaedf98 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:52:13 +0100 Subject: [PATCH 3/7] Apply same disabling in the Customizer Widgets screen --- packages/customize-widgets/src/index.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/customize-widgets/src/index.js b/packages/customize-widgets/src/index.js index 475629450f860..da3554cf70d51 100644 --- a/packages/customize-widgets/src/index.js +++ b/packages/customize-widgets/src/index.js @@ -22,6 +22,9 @@ import './filters'; const { wp } = window; +const DISABLED_BLOCKS = [ 'core/more', 'core/freeform' ]; +const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; + /** * Initializes the widgets block editor in the customizer. * @@ -29,13 +32,20 @@ const { wp } = window; * @param {Object} blockEditorSettings Block editor settings. */ export function initialize( editorName, blockEditorSettings ) { - const coreBlocks = __experimentalGetCoreBlocks().filter( - ( block ) => ! [ 'core/more', 'core/freeform' ].includes( block.name ) - ); + const coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => { + return ! ( + DISABLED_BLOCKS.includes( block.name ) || + block.name.startsWith( 'core/post' ) || + block.name.startsWith( 'core/query' ) || + block.name.startsWith( 'core/site' ) + ); + } ); registerCoreBlocks( coreBlocks ); registerLegacyWidgetBlock(); if ( process.env.GUTENBERG_PHASE === 2 ) { - __experimentalRegisterExperimentalCoreBlocks(); + __experimentalRegisterExperimentalCoreBlocks( { + enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS, + } ); } registerLegacyWidgetVariations( blockEditorSettings ); From c17ed85450ada2065ec832844a82f37d6acaa1cb Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:53:04 +0100 Subject: [PATCH 4/7] Remove any registered reusable blocks from inserter --- packages/customize-widgets/src/index.js | 2 +- packages/edit-widgets/src/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/customize-widgets/src/index.js b/packages/customize-widgets/src/index.js index da3554cf70d51..bf3b8eef0c862 100644 --- a/packages/customize-widgets/src/index.js +++ b/packages/customize-widgets/src/index.js @@ -22,7 +22,7 @@ import './filters'; const { wp } = window; -const DISABLED_BLOCKS = [ 'core/more', 'core/freeform' ]; +const DISABLED_BLOCKS = [ 'core/more', 'core/block', 'core/freeform' ]; const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; /** diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index f83b1a7732756..6232d525b64e6 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -25,7 +25,7 @@ import './filters'; import * as widgetArea from './blocks/widget-area'; import Layout from './components/layout'; -const DISABLED_BLOCKS = [ 'core/more', 'core/freeform' ]; +const DISABLED_BLOCKS = [ 'core/more', 'core/freeform', 'core/block' ]; const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; /** From 850332cfa2a4deb780fd81e1fdd743f214e53697 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:53:44 +0100 Subject: [PATCH 5/7] Fully disable reusable blocks in Widgets Editor --- .../widget-areas-block-editor-provider/index.js | 8 ++++---- packages/edit-widgets/src/constants.js | 1 + packages/edit-widgets/src/index.js | 8 +++++++- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 packages/edit-widgets/src/constants.js diff --git a/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js b/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js index 3e772190ebcba..b9aeef8db1953 100644 --- a/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js +++ b/packages/edit-widgets/src/components/widget-areas-block-editor-provider/index.js @@ -24,6 +24,7 @@ import { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data'; import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils'; import useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area'; import { store as editWidgetsStore } from '../../store'; +import { ALLOW_REUSABLE_BLOCKS } from '../../constants'; export default function WidgetAreasBlockEditorProvider( { blockEditorSettings, @@ -43,10 +44,9 @@ export default function WidgetAreasBlockEditorProvider( { ), widgetAreas: select( editWidgetsStore ).getWidgetAreas(), widgets: select( editWidgetsStore ).getWidgets(), - reusableBlocks: select( coreStore ).getEntityRecords( - 'postType', - 'wp_block' - ), + reusableBlocks: ALLOW_REUSABLE_BLOCKS + ? select( coreStore ).getEntityRecords( 'postType', 'wp_block' ) + : [], isFixedToolbarActive: select( editWidgetsStore ).__unstableIsFeatureActive( 'fixedToolbar' ), diff --git a/packages/edit-widgets/src/constants.js b/packages/edit-widgets/src/constants.js new file mode 100644 index 0000000000000..22c010b2fc11a --- /dev/null +++ b/packages/edit-widgets/src/constants.js @@ -0,0 +1 @@ +export const ALLOW_REUSABLE_BLOCKS = false; diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index 6232d525b64e6..c0723a44f946c 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -24,8 +24,13 @@ import './store'; import './filters'; import * as widgetArea from './blocks/widget-area'; import Layout from './components/layout'; +import { ALLOW_REUSABLE_BLOCKS } from './constants'; -const DISABLED_BLOCKS = [ 'core/more', 'core/freeform', 'core/block' ]; +const DISABLED_BLOCKS = [ + 'core/more', + 'core/freeform', + ...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ), +]; const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; /** @@ -55,6 +60,7 @@ export function initialize( id, settings ) { registerBlock( widgetArea ); settings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) => fetchLinkSuggestions( search, searchOptions, settings ); + render( , document.getElementById( id ) From e34e0f5495dfb32ae0d2fb9d4a519f6e0598cc66 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:53:58 +0100 Subject: [PATCH 6/7] Fully disable reusable blocks in Widgets Editor --- packages/edit-widgets/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index c0723a44f946c..4f6ba497029c9 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -28,7 +28,7 @@ import { ALLOW_REUSABLE_BLOCKS } from './constants'; const DISABLED_BLOCKS = [ 'core/more', - 'core/freeform', + 'core/freeform', ...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ), ]; const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; From 57492c2a386d07a2b9b0eeb8a5193c8f01cb6a6e Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 22 Jun 2021 09:57:23 +0100 Subject: [PATCH 7/7] Improve constant usage --- packages/edit-widgets/src/constants.js | 1 + packages/edit-widgets/src/index.js | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/edit-widgets/src/constants.js b/packages/edit-widgets/src/constants.js index 22c010b2fc11a..c2ab518c5c9c4 100644 --- a/packages/edit-widgets/src/constants.js +++ b/packages/edit-widgets/src/constants.js @@ -1 +1,2 @@ export const ALLOW_REUSABLE_BLOCKS = false; +export const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; diff --git a/packages/edit-widgets/src/index.js b/packages/edit-widgets/src/index.js index 4f6ba497029c9..7ed910113e7e8 100644 --- a/packages/edit-widgets/src/index.js +++ b/packages/edit-widgets/src/index.js @@ -24,14 +24,16 @@ import './store'; import './filters'; import * as widgetArea from './blocks/widget-area'; import Layout from './components/layout'; -import { ALLOW_REUSABLE_BLOCKS } from './constants'; +import { + ALLOW_REUSABLE_BLOCKS, + ENABLE_EXPERIMENTAL_FSE_BLOCKS, +} from './constants'; -const DISABLED_BLOCKS = [ +const disabledBlocks = [ 'core/more', 'core/freeform', ...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ), ]; -const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; /** * Initializes the block editor in the widgets screen. @@ -42,7 +44,7 @@ const ENABLE_EXPERIMENTAL_FSE_BLOCKS = false; export function initialize( id, settings ) { const coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => { return ! ( - DISABLED_BLOCKS.includes( block.name ) || + disabledBlocks.includes( block.name ) || block.name.startsWith( 'core/post' ) || block.name.startsWith( 'core/query' ) || block.name.startsWith( 'core/site' )