From 1cfdda666e70b08833c2919dad8d920b614fa3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Fern=C3=A1ndez=20de=20Alba?= Date: Mon, 9 Dec 2024 11:25:07 +0100 Subject: [PATCH] Fixed circular import error in dev with HMR in core Blocks shadow customizations (#6525) --- packages/volto/news/6525.bugfix | 1 + packages/volto/src/config/Blocks.jsx | 9 +++++++++ packages/volto/src/config/index.js | 20 ++++---------------- 3 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 packages/volto/news/6525.bugfix diff --git a/packages/volto/news/6525.bugfix b/packages/volto/news/6525.bugfix new file mode 100644 index 0000000000..39351c4afc --- /dev/null +++ b/packages/volto/news/6525.bugfix @@ -0,0 +1 @@ +Fixed circular import error in dev with HMR in core Blocks shadow customizations. @sneridagh diff --git a/packages/volto/src/config/Blocks.jsx b/packages/volto/src/config/Blocks.jsx index 573bdce903..0110a6616c 100644 --- a/packages/volto/src/config/Blocks.jsx +++ b/packages/volto/src/config/Blocks.jsx @@ -530,6 +530,15 @@ const requiredBlocks = ['title']; const initialBlocks = {}; const initialBlocksFocus = {}; //{Document:'title'} +export function installDefaultBlocks(config) { + config.blocks.requiredBlocks = requiredBlocks; + config.blocks.blocksConfig = blocksConfig; + config.blocks.groupBlocksOrder = groupBlocksOrder; + config.blocks.initialBlocks = initialBlocks; + config.blocks.initialBlocksFocus = initialBlocksFocus; + config.blocks.showEditBlocksInBabelView = false; +} + export { groupBlocksOrder, requiredBlocks, diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js index c689a84b73..cf912fbaf0 100644 --- a/packages/volto/src/config/index.js +++ b/packages/volto/src/config/index.js @@ -1,3 +1,4 @@ +import ConfigRegistry from '@plone/volto/registry'; import { parse as parseUrl } from 'url'; import { defaultWidget, widgetMapping } from './Widgets'; import { @@ -9,13 +10,6 @@ import { } from './Views'; import { nonContentRoutes } from './NonContentRoutes'; import { nonContentRoutesPublic } from './NonContentRoutesPublic'; -import { - groupBlocksOrder, - requiredBlocks, - blocksConfig, - initialBlocks, - initialBlocksFocus, -} from './Blocks'; import { loadables } from './Loadables'; import { workflowMapping } from './Workflows'; import slots from './slots'; @@ -31,8 +25,8 @@ import { import applyAddonConfiguration, { addonsInfo } from 'load-volto-addons'; -import ConfigRegistry from '@plone/volto/registry'; import { installDefaultComponents } from './Components'; +import { installDefaultBlocks } from './Blocks'; import { getSiteAsyncPropExtender } from '@plone/volto/helpers/Site'; import { registerValidators } from './validation'; @@ -206,14 +200,7 @@ let config = { errorViews, layoutViewsNamesMapping, }, - blocks: { - requiredBlocks, - blocksConfig, - groupBlocksOrder, - initialBlocks, - initialBlocksFocus, - showEditBlocksInBabelView: false, - }, + blocks: {}, addonRoutes: [], addonReducers: {}, components: {}, @@ -262,5 +249,6 @@ Object.entries(slots).forEach(([slotName, components]) => { registerValidators(ConfigRegistry); installDefaultComponents(ConfigRegistry); +installDefaultBlocks(ConfigRegistry); applyAddonConfiguration(ConfigRegistry);