diff --git a/.eslintrc.js b/.eslintrc.js index aea3677db..d1fa0cd52 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -63,4 +63,7 @@ module.exports = { }, }, }, + globals: { + structuredClone: true, + }, }; diff --git a/src/config/Blocks/ListingOptions/index.js b/src/config/Blocks/ListingOptions/index.js index 82170be2b..2db918e35 100644 --- a/src/config/Blocks/ListingOptions/index.js +++ b/src/config/Blocks/ListingOptions/index.js @@ -1,7 +1,6 @@ export { addSchemaField, templatesOptions, - cloneBlock, } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils'; export addDefaultOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultOptions'; export addDefaultAdditionalOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultAdditionalOptions'; diff --git a/src/config/Blocks/ListingOptions/utils.js b/src/config/Blocks/ListingOptions/utils.js index fc4867bc4..6443b2e70 100644 --- a/src/config/Blocks/ListingOptions/utils.js +++ b/src/config/Blocks/ListingOptions/utils.js @@ -165,9 +165,3 @@ export const addLighthouseField = (schema, intl, position = 0) => { return pos; }; - -export const cloneBlock = (blockData) => { - const blockID = uuid(); - const clonedData = { ...blockData, block: blockID }; - return [blockID, clonedData]; -}; diff --git a/src/config/Blocks/blocks.js b/src/config/Blocks/blocks.js index 251e3a45b..09bd29757 100644 --- a/src/config/Blocks/blocks.js +++ b/src/config/Blocks/blocks.js @@ -69,7 +69,7 @@ import countDownSVG from 'design-comuni-plone-theme/icons/count-down.svg'; import CountDownBlockView from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/View'; import CountDownBlockEdit from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/Edit'; -import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions'; +import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks'; const italiaBlocks = { highlitedContent: { diff --git a/src/config/Blocks/listingVariations.js b/src/config/Blocks/listingVariations.js index 0b4ca77be..e6dbcc50c 100644 --- a/src/config/Blocks/listingVariations.js +++ b/src/config/Blocks/listingVariations.js @@ -61,10 +61,8 @@ import { addSmallBlockLinksTemplateOptions, } from 'design-comuni-plone-theme/config/Blocks/ListingOptions'; -import { - addLighthouseField, - cloneBlock, -} from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils'; +import { addLighthouseField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils'; +import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks'; const italiaListingVariations = [ { diff --git a/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx b/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx index 19a20152d..37a8bbe9c 100644 --- a/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx +++ b/src/customizations/volto/components/manage/Form/BlocksToolbar.jsx @@ -17,7 +17,7 @@ import { Icon } from '@plone/volto/components'; import { Plug } from '@plone/volto/components/manage/Pluggable'; import { load } from 'redux-localstorage-simple'; import { isEqual, omit, without } from 'lodash'; -import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions'; +import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks'; import { setBlocksClipboard, resetBlocksClipboard } from '@plone/volto/actions'; import config from '@plone/volto/registry'; diff --git a/src/helpers/blocks.js b/src/helpers/blocks.js new file mode 100644 index 000000000..36fc8061c --- /dev/null +++ b/src/helpers/blocks.js @@ -0,0 +1,8 @@ +import { v4 as uuid } from 'uuid'; + +export const cloneBlock = (blockData) => { + const blockID = uuid(); + const clonedData = structuredClone(blockData); + clonedData.block = blockID; + return [blockID, clonedData]; +};