From 5f9c5fc4d6a3325dca4ebf2c9e9b1d78b0d3cac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Mon, 4 Dec 2023 18:59:51 -0300 Subject: [PATCH 01/26] description block uses inner blocks --- .../src/blocks/product-fields/description/edit.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx index 371dc3a1f0c..fb071805100 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx @@ -10,6 +10,7 @@ import { serialize, } from '@wordpress/blocks'; import { useSelect, useDispatch } from '@wordpress/data'; +import { useInnerBlocksProps } from '@wordpress/block-editor'; import { Button } from '@wordpress/components'; import { useWooBlockProps } from '@woocommerce/block-templates'; import { recordEvent } from '@woocommerce/tracks'; @@ -85,8 +86,18 @@ export function DescriptionBlockEdit( { setDescription( html ); }, [ modalEditorBlocks, setDescription, hasChanged ] ); + const innerBlockProps = useInnerBlocksProps( + {}, + { + templateLock: 'contentOnly', + allowedBlocks: [ 'woocommerce/product-summary-field' ], + } + ); + return (
+
+ - { !! description.length && ( ) } From ba52220f392def21fd6059a174f99d1e47245585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Fri, 1 Dec 2023 13:18:39 -0300 Subject: [PATCH 09/26] introduce _templateBlockId attr to Product block --- packages/js/product-editor/src/types.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/js/product-editor/src/types.ts b/packages/js/product-editor/src/types.ts index cbb19f729e5..0dd35cd4e71 100644 --- a/packages/js/product-editor/src/types.ts +++ b/packages/js/product-editor/src/types.ts @@ -1,7 +1,7 @@ /** * External dependencies */ -import { BlockEditProps } from '@wordpress/blocks'; +import { BlockAttributes, BlockEditProps } from '@wordpress/blocks'; export interface ProductEditorContext { postId: number; @@ -13,6 +13,11 @@ export interface ProductEditorContext { export interface ProductEditorBlockEditProps< T extends Record< string, any > > extends BlockEditProps< T > { readonly context: ProductEditorContext; + readonly name: string; +} + +export interface ProductEditorBlockAttributes extends BlockAttributes { + _templateBlockId?: string; } export interface Metadata< T > { From 25626b8df00a2c90b3ce68c417865220475ca59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Fri, 1 Dec 2023 13:19:27 -0300 Subject: [PATCH 10/26] fix TS issues --- .../withFullEditorToolbarButton.tsx | 101 +++++++++--------- .../product-fields/description/edit.tsx | 6 +- .../product-fields/description/types.ts | 20 ++++ 3 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 packages/js/product-editor/src/blocks/product-fields/description/types.ts diff --git a/packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx b/packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx index 35b751b1c0d..5f5df3c8993 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx @@ -13,59 +13,64 @@ import { useDispatch } from '@wordpress/data'; * Internal dependencies */ import { store } from '../../../../store/product-editor-ai'; +import type { + DescriptionBlockEditComponent, + DescriptionBlockEditProps, +} from '../types'; -/** - * Internal dependencies - */ -// import type { ProductEditorBlockEditProps } from '../../../types'; +const wooBlockwithFullEditorToolbarButton = + createHigherOrderComponent< DescriptionBlockEditComponent >( + ( BlockEdit: DescriptionBlockEditComponent ) => { + return ( props: DescriptionBlockEditProps ) => { + const { openModalEditor } = useDispatch( store ); -const wooBlockwithFullEditorToolbarButton = createHigherOrderComponent< - Record< string, unknown > ->( ( BlockEdit ) => { - return ( props ) => { - const { openModalEditor } = useDispatch( store ); + // Only extend summary field block instances + if ( props?.name !== 'woocommerce/product-summary-field' ) { + return ; + } - // Only extend summary field block instances - if ( props?.name !== 'woocommerce/product-summary-field' ) { - return ; - } + // Only add the `Full editor` button when the block is selected + if ( ! props?.isSelected ) { + return ; + } - // Only add the `Full editor` button when the block is selected - if ( ! props?.isSelected ) { - return ; - } + /* + * Extend the toolbar only to the sumary field block instance + * that has the `woocommerce/product-description-field__content` template block ID. + */ + if ( + props?.attributes?._templateBlockId !== + 'product-description__content' + ) { + return ; + } - /* - * Extend the toolbar only to the sumary field block instance - * that has the `woocommerce/product-description-field__content` template block ID. - */ - if ( - props?.attributes?._templateBlockId !== - 'product-description__content' - ) { - return ; - } + const blockControlProps = { group: 'other' }; - return ( - <> - - { - recordEvent( 'product_add_description_click' ); - openModalEditor(); - } } - > - { __( 'Full editor', 'woocommerce' ) } - - - - - ); - }; -}, 'wooBlockwithFullEditorToolbarButton' ); + return ( + <> + + { + recordEvent( + 'product_add_description_click' + ); + openModalEditor(); + } } + > + { __( 'Full editor', 'woocommerce' ) } + + + + + ); + }; + }, + 'wooBlockwithFullEditorToolbarButton' + ); export default wooBlockwithFullEditorToolbarButton; diff --git a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx index 5ba4cf86710..0b6d4a3dee9 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx @@ -2,7 +2,7 @@ * External dependencies */ import { createElement, useEffect } from '@wordpress/element'; -import { BlockAttributes, BlockInstance, serialize } from '@wordpress/blocks'; +import { BlockInstance, serialize } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { useWooBlockProps } from '@woocommerce/block-templates'; import { useEntityProp } from '@wordpress/core-data'; @@ -15,9 +15,9 @@ import { * Internal dependencies */ import { ContentPreview } from '../../../components/content-preview'; -import { ProductEditorBlockEditProps } from '../../../types'; import ModalEditorWelcomeGuide from '../../../components/modal-editor-welcome-guide'; import { store } from '../../../store/product-editor-ui'; +import type { DescriptionBlockEditComponent } from './types'; /** * Internal dependencies @@ -45,7 +45,7 @@ function clearDescriptionIfEmpty( blocks: BlockInstance[] ) { export function DescriptionBlockEdit( { attributes, -}: ProductEditorBlockEditProps< BlockAttributes > ) { +}: DescriptionBlockEditComponent ) { const blockProps = useWooBlockProps( attributes ); const [ description, setDescription ] = useEntityProp< string >( 'postType', diff --git a/packages/js/product-editor/src/blocks/product-fields/description/types.ts b/packages/js/product-editor/src/blocks/product-fields/description/types.ts new file mode 100644 index 00000000000..60719cb6d17 --- /dev/null +++ b/packages/js/product-editor/src/blocks/product-fields/description/types.ts @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +import { + // @ts-expect-error no exported member. + ComponentType, +} from '@wordpress/element'; +/** + * Internal dependencies + */ +import { + ProductEditorBlockAttributes, + ProductEditorBlockEditProps, +} from '../../../types'; + +export type DescriptionBlockEditProps = + ProductEditorBlockEditProps< ProductEditorBlockAttributes >; + +export type DescriptionBlockEditComponent = + ComponentType< DescriptionBlockEditProps >; From f573a0a4b4d52a03c539c5b27ef3edea83345864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Fri, 1 Dec 2023 13:21:17 -0300 Subject: [PATCH 11/26] use kebab-case to file names --- ...torToolbarButton.tsx => with-full-editor-toolbar-button.tsx} | 0 .../src/blocks/product-fields/description/index.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/js/product-editor/src/blocks/product-fields/description/components/{withFullEditorToolbarButton.tsx => with-full-editor-toolbar-button.tsx} (100%) diff --git a/packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx b/packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx similarity index 100% rename from packages/js/product-editor/src/blocks/product-fields/description/components/withFullEditorToolbarButton.tsx rename to packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx diff --git a/packages/js/product-editor/src/blocks/product-fields/description/index.ts b/packages/js/product-editor/src/blocks/product-fields/description/index.ts index 196ae99f4b1..59eda68e201 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/index.ts +++ b/packages/js/product-editor/src/blocks/product-fields/description/index.ts @@ -10,7 +10,7 @@ import { addFilter } from '@wordpress/hooks'; import blockConfiguration from './block.json'; import { DescriptionBlockEdit } from './edit'; import { registerProductEditorBlockType } from '../../../utils'; -import wooDescriptionBlockWithFullEditorButton from './components/withFullEditorToolbarButton'; +import wooDescriptionBlockWithFullEditorButton from './components/with-full-editor-toolbar-button'; const { name, ...metadata } = blockConfiguration; From beca44c12b03f6b83de11b7ab504f2d41551d9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Fri, 1 Dec 2023 16:02:29 -0300 Subject: [PATCH 12/26] react -> extract full editor toolbar button cpm --- .../components/full-editor-toolbar-button.tsx | 32 +++++++++++++++++++ .../with-full-editor-toolbar-button.tsx | 23 ++----------- 2 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx diff --git a/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx b/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx new file mode 100644 index 00000000000..583931d253d --- /dev/null +++ b/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx @@ -0,0 +1,32 @@ +/** + * External dependencies + */ +import { createElement } from '@wordpress/element'; +import { ToolbarButton } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; +import { recordEvent } from '@woocommerce/tracks'; +import { dispatch } from '@wordpress/data'; + +/** + * Internal dependencies + */ +import { store } from '../../../../store/product-editor-ui'; + +export default function FullEditorToolbarButton( { + label = __( 'Edit Product description', 'woocommerce' ), + text = __( 'Full editor', 'woocommerce' ), +} ) { + const { openModalEditor } = dispatch( store ); + + return ( + { + recordEvent( 'product_add_description_click' ); + openModalEditor(); + } } + > + { text } + + ); +} diff --git a/packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx b/packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx index 5f5df3c8993..4385e9d0842 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/components/with-full-editor-toolbar-button.tsx @@ -4,26 +4,20 @@ import { createElement, Fragment } from '@wordpress/element'; import { createHigherOrderComponent } from '@wordpress/compose'; import { BlockControls } from '@wordpress/block-editor'; -import { ToolbarButton } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; -import { recordEvent } from '@woocommerce/tracks'; -import { useDispatch } from '@wordpress/data'; /** * Internal dependencies */ -import { store } from '../../../../store/product-editor-ai'; import type { DescriptionBlockEditComponent, DescriptionBlockEditProps, } from '../types'; +import FullEditorToolbarButton from './full-editor-toolbar-button'; const wooBlockwithFullEditorToolbarButton = createHigherOrderComponent< DescriptionBlockEditComponent >( ( BlockEdit: DescriptionBlockEditComponent ) => { return ( props: DescriptionBlockEditProps ) => { - const { openModalEditor } = useDispatch( store ); - // Only extend summary field block instances if ( props?.name !== 'woocommerce/product-summary-field' ) { return ; @@ -50,20 +44,7 @@ const wooBlockwithFullEditorToolbarButton = return ( <> - { - recordEvent( - 'product_add_description_click' - ); - openModalEditor(); - } } - > - { __( 'Full editor', 'woocommerce' ) } - + From d336a1c508e86ca75a38b8f267a7ec34ee928cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Fri, 1 Dec 2023 16:16:59 -0300 Subject: [PATCH 13/26] show full editor toolbar button when blocks --- .../blocks/product-fields/description/block.json | 2 +- .../src/blocks/product-fields/description/edit.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/js/product-editor/src/blocks/product-fields/description/block.json b/packages/js/product-editor/src/blocks/product-fields/description/block.json index 8ecafe04e9a..3306eedfe1a 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/block.json +++ b/packages/js/product-editor/src/blocks/product-fields/description/block.json @@ -20,6 +20,6 @@ "reusable": false, "inserter": false, "lock": false, - "__experimentalToolbar": false + "__experimentalToolbar": true } } diff --git a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx index 0b6d4a3dee9..4d3e01be401 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx @@ -6,9 +6,11 @@ import { BlockInstance, serialize } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; import { useWooBlockProps } from '@woocommerce/block-templates'; import { useEntityProp } from '@wordpress/core-data'; +import { __ } from '@wordpress/i18n'; import { // @ts-expect-error no exported member. useInnerBlocksProps, + BlockControls, } from '@wordpress/block-editor'; /** @@ -18,6 +20,7 @@ import { ContentPreview } from '../../../components/content-preview'; import ModalEditorWelcomeGuide from '../../../components/modal-editor-welcome-guide'; import { store } from '../../../store/product-editor-ui'; import type { DescriptionBlockEditComponent } from './types'; +import FullEditorToolbarButton from './components/full-editor-toolbar-button'; /** * Internal dependencies @@ -89,7 +92,15 @@ export function DescriptionBlockEdit( { return (
-
+ { description.length && ( + + + + ) } + + { ! description.length &&
} { !! description.length && ( From b24ddef6c0a1f524c4dad2288dc86f1d64a99d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Mon, 4 Dec 2023 12:44:35 -0300 Subject: [PATCH 14/26] tweak description preview --- .../product-fields/description/edit.tsx | 13 +++++++- .../product-fields/description/editor.scss | 33 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 packages/js/product-editor/src/blocks/product-fields/description/editor.scss diff --git a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx index 4d3e01be401..6b3139953db 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx @@ -4,6 +4,7 @@ import { createElement, useEffect } from '@wordpress/element'; import { BlockInstance, serialize } from '@wordpress/blocks'; import { useSelect } from '@wordpress/data'; +import classNames from 'classnames'; import { useWooBlockProps } from '@woocommerce/block-templates'; import { useEntityProp } from '@wordpress/core-data'; import { __ } from '@wordpress/i18n'; @@ -49,7 +50,6 @@ function clearDescriptionIfEmpty( blocks: BlockInstance[] ) { export function DescriptionBlockEdit( { attributes, }: DescriptionBlockEditComponent ) { - const blockProps = useWooBlockProps( attributes ); const [ description, setDescription ] = useEntityProp< string >( 'postType', 'product', @@ -82,6 +82,10 @@ export function DescriptionBlockEdit( { setDescription( html ); }, [ modalEditorBlocks, setDescription, hasChanged ] ); + const blockProps = useWooBlockProps( attributes, { + className: classNames( { 'has-blocks': !! description.length } ), + } ); + const innerBlockProps = useInnerBlocksProps( {}, { @@ -102,6 +106,13 @@ export function DescriptionBlockEdit( { { ! description.length &&
} + { !! description.length && ( +
+ ) } + { !! description.length && ( ) } diff --git a/packages/js/product-editor/src/blocks/product-fields/description/editor.scss b/packages/js/product-editor/src/blocks/product-fields/description/editor.scss new file mode 100644 index 00000000000..fcc44d1658c --- /dev/null +++ b/packages/js/product-editor/src/blocks/product-fields/description/editor.scss @@ -0,0 +1,33 @@ + +.wp-block-woocommerce-product-description-field { + &.has-blocks { + min-height: 320px; + .wp-block-woocommerce-product-description-field__cover, + .woocommerce-content-preview { + min-height: 320px; + &:after { + display: none; + } + + .woocommerce-content-preview__iframe { + min-height: 320px; + } + } + } + + .woocommerce-content-preview { + position: absolute; + top: 0; + left: 0; + margin: 0; + z-index: 100; + } +} + +.wp-block-woocommerce-product-description-field__cover { + position: absolute; + width: 100%; + top: 0; + left: 0; + z-index: 200; +} From b7aeaecb3bab3abf162f516255dfeafe0448eec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 7 Dec 2023 11:53:31 -0300 Subject: [PATCH 15/26] load description styles --- packages/js/product-editor/src/blocks/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/js/product-editor/src/blocks/style.scss b/packages/js/product-editor/src/blocks/style.scss index 3697d625ab1..60bc70206c0 100644 --- a/packages/js/product-editor/src/blocks/style.scss +++ b/packages/js/product-editor/src/blocks/style.scss @@ -1,4 +1,5 @@ @import "product-fields/attributes/editor.scss"; +@import "product-fields/description/editor.scss"; @import "product-fields/downloads/editor.scss"; @import "product-fields/images/editor.scss"; @import "product-fields/inventory-email/editor.scss"; From 52c95d242c2b5567f475dc9cdd435e5a42320ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 7 Dec 2023 12:21:15 -0300 Subject: [PATCH 16/26] fix checking description is defined --- .../src/blocks/product-fields/description/edit.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx index 6b3139953db..5ba1accbdda 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/edit.tsx @@ -96,7 +96,7 @@ export function DescriptionBlockEdit( { return (
- { description.length && ( + { !! description.length && ( Date: Thu, 7 Dec 2023 12:21:44 -0300 Subject: [PATCH 17/26] parse and set iframe blocks when clicking on toolbar button --- .../components/full-editor-toolbar-button.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx b/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx index 583931d253d..348b497ae68 100644 --- a/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx +++ b/packages/js/product-editor/src/blocks/product-fields/description/components/full-editor-toolbar-button.tsx @@ -6,6 +6,8 @@ import { ToolbarButton } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { recordEvent } from '@woocommerce/tracks'; import { dispatch } from '@wordpress/data'; +import { useEntityProp } from '@wordpress/core-data'; +import { parse } from '@wordpress/blocks'; /** * Internal dependencies @@ -16,12 +18,18 @@ export default function FullEditorToolbarButton( { label = __( 'Edit Product description', 'woocommerce' ), text = __( 'Full editor', 'woocommerce' ), } ) { - const { openModalEditor } = dispatch( store ); + const { openModalEditor, setModalEditorBlocks } = dispatch( store ); + const [ description ] = useEntityProp< string >( + 'postType', + 'product', + 'description' + ); return ( { + setModalEditorBlocks( parse( description ) ); recordEvent( 'product_add_description_click' ); openModalEditor(); } } From 69914eea348c3406c3cae3be5c8a6e441c6d253d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 7 Dec 2023 12:29:30 -0300 Subject: [PATCH 18/26] set initial blocks from the store --- .../src/components/iframe-editor/iframe-editor.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/js/product-editor/src/components/iframe-editor/iframe-editor.tsx b/packages/js/product-editor/src/components/iframe-editor/iframe-editor.tsx index 2e68d8b8215..435c159bbb5 100644 --- a/packages/js/product-editor/src/components/iframe-editor/iframe-editor.tsx +++ b/packages/js/product-editor/src/components/iframe-editor/iframe-editor.tsx @@ -43,7 +43,6 @@ type IframeEditorProps = { }; export function IframeEditor( { - initialBlocks = [], onChange = () => {}, onClose, onInput = () => {}, @@ -51,14 +50,23 @@ export function IframeEditor( { showBackButton = false, }: IframeEditorProps ) { const [ resizeObserver ] = useResizeObserver(); - const [ temporalBlocks, setTemporalBlocks ] = - useState< BlockInstance[] >( initialBlocks ); + const [ temporalBlocks, setTemporalBlocks ] = useState< BlockInstance[] >( + [] + ); // Pick the blocks from the store. const blocks: BlockInstance[] = useSelect( ( select ) => { return select( productEditorUiStore ).getModalEditorBlocks(); }, [] ); + /* + * Set the initial blocks from the store. + * @todo: probably we can get rid of the initialBlocks prop. + */ + useEffect( () => { + setTemporalBlocks( blocks ); + }, [] ); // eslint-disable-line + const { setModalEditorBlocks: setBlocks, setModalEditorContentHasChanged } = useDispatch( productEditorUiStore ); From 74e2e166c0cc263940897ed63ec4cbdd514b658f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Thu, 7 Dec 2023 13:00:12 -0300 Subject: [PATCH 19/26] don't allow focusing to Preview component --- .../src/components/content-preview/content-preview.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/js/product-editor/src/components/content-preview/content-preview.tsx b/packages/js/product-editor/src/components/content-preview/content-preview.tsx index c2ab4ccce58..fac99210622 100644 --- a/packages/js/product-editor/src/components/content-preview/content-preview.tsx +++ b/packages/js/product-editor/src/components/content-preview/content-preview.tsx @@ -67,7 +67,10 @@ export function ContentPreview( { content }: ContentPreviewProps ) { return (
-