Skip to content

Commit

Permalink
Remove subregistry as it's baked in now
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Mar 29, 2019
1 parent 086ae8f commit 158d62e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
4 changes: 0 additions & 4 deletions packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ The default editor settings

Undocumented declaration.

<a name="storeConfig" href="#storeConfig">#</a> **storeConfig**

Internal dependencies

<a name="URLInput" href="#URLInput">#</a> **URLInput**

Undocumented declaration.
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '@wordpress/viewport';
/**
* Internal dependencies
*/
export { storeConfig } from './store';
import './store';
import './hooks';

export * from './components';
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-widgets/src/components/layout/style.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.edit-widgets-layout__content {
height: 100%;
min-height: 100%;
background: $light-gray-300;
padding: 30px 0;

Expand Down
43 changes: 10 additions & 33 deletions packages/edit-widgets/src/components/widget-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,28 @@ import { Panel, PanelBody } from '@wordpress/components';
import {
BlockEditorProvider,
BlockList,
storeConfig,
} from '@wordpress/block-editor';
import { useState, useEffect } from '@wordpress/element';
import {
RegistryProvider,
withRegistry,
createRegistry,
plugins,
} from '@wordpress/data';
import { useState } from '@wordpress/element';

function WidgetArea( { title, initialOpen, registry } ) {
// Disable reason, this rule conflicts with the React hooks rule (no conditionals)
// eslint-disable-next-line @wordpress/no-unused-vars-before-return
function WidgetArea( { title, initialOpen } ) {
const [ blocks, updateBlocks ] = useState( [] );
const [ subRegistry, updateRegistry ] = useState( null );
useEffect( () => {
// TODO: This behavior should be embedded in the BlockEditorProvider
const newRegistry = createRegistry( {}, registry );
newRegistry.use( plugins.controls );
newRegistry.registerStore( 'core/block-editor', storeConfig );
updateRegistry( newRegistry );
}, [ registry ] );

if ( ! subRegistry ) {
return null;
}

return (
<Panel>
<PanelBody
title={ title }
initialOpen={ initialOpen }
>
<RegistryProvider value={ subRegistry }>
<BlockEditorProvider
value={ blocks }
onInput={ updateBlocks }
onChange={ updateBlocks }
>
<BlockList />
</BlockEditorProvider>
</RegistryProvider>
<BlockEditorProvider
value={ blocks }
onInput={ updateBlocks }
onChange={ updateBlocks }
>
<BlockList />
</BlockEditorProvider>
</PanelBody>
</Panel>
);
}

export default withRegistry( WidgetArea );
export default WidgetArea;

0 comments on commit 158d62e

Please sign in to comment.