From bc428d92afcdbaa5a1dee51cad054ce67516cddd Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Tue, 6 Jul 2021 15:49:00 +0100 Subject: [PATCH] Switch to using innerblocks --- packages/block-library/src/pattern/edit.js | 20 +++++++++----------- packages/block-library/src/pattern/index.js | 8 ++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/pattern/edit.js b/packages/block-library/src/pattern/edit.js index 9020bf81fc2fac..2eb540851f7160 100644 --- a/packages/block-library/src/pattern/edit.js +++ b/packages/block-library/src/pattern/edit.js @@ -1,23 +1,21 @@ /** * WordPress dependencies */ -import { useSelect } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { store as blockEditorStore, - BlockList, - BlockEditorProvider, + InnerBlocks, } from '@wordpress/block-editor'; -const PatternEdit = ( { attributes } ) => { +const PatternEdit = ( { attributes, clientId } ) => { const selectedPattern = useSelect( ( select ) => - select( blockEditorStore ).__experimentalGetParsedPattern( attributes.slug ) - ); - - return ( - - - + select( blockEditorStore ).__experimentalGetParsedPattern( + attributes.slug + ) ); + const { replaceInnerBlocks } = useDispatch( blockEditorStore ); + replaceInnerBlocks( clientId, selectedPattern.blocks ); + return ; }; export default PatternEdit; diff --git a/packages/block-library/src/pattern/index.js b/packages/block-library/src/pattern/index.js index 5ab74fdd0c967a..e5e2404f4897ba 100644 --- a/packages/block-library/src/pattern/index.js +++ b/packages/block-library/src/pattern/index.js @@ -1,3 +1,8 @@ +/** + * WordPress dependencies + */ +import { InnerBlocks } from '@wordpress/block-editor'; + /** * Internal dependencies */ @@ -9,4 +14,7 @@ export { metadata, name }; export const settings = { edit: PatternEdit, + save: () => { + return ; + }, };