set initial blocks from the store
This commit is contained in:
parent
c296776121
commit
69914eea34
|
@ -43,7 +43,6 @@ type IframeEditorProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function IframeEditor( {
|
export function IframeEditor( {
|
||||||
initialBlocks = [],
|
|
||||||
onChange = () => {},
|
onChange = () => {},
|
||||||
onClose,
|
onClose,
|
||||||
onInput = () => {},
|
onInput = () => {},
|
||||||
|
@ -51,14 +50,23 @@ export function IframeEditor( {
|
||||||
showBackButton = false,
|
showBackButton = false,
|
||||||
}: IframeEditorProps ) {
|
}: IframeEditorProps ) {
|
||||||
const [ resizeObserver ] = useResizeObserver();
|
const [ resizeObserver ] = useResizeObserver();
|
||||||
const [ temporalBlocks, setTemporalBlocks ] =
|
const [ temporalBlocks, setTemporalBlocks ] = useState< BlockInstance[] >(
|
||||||
useState< BlockInstance[] >( initialBlocks );
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
// Pick the blocks from the store.
|
// Pick the blocks from the store.
|
||||||
const blocks: BlockInstance[] = useSelect( ( select ) => {
|
const blocks: BlockInstance[] = useSelect( ( select ) => {
|
||||||
return select( productEditorUiStore ).getModalEditorBlocks();
|
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 } =
|
const { setModalEditorBlocks: setBlocks, setModalEditorContentHasChanged } =
|
||||||
useDispatch( productEditorUiStore );
|
useDispatch( productEditorUiStore );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue