-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
index.js
53 lines (45 loc) · 1.33 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* WordPress dependencies
*/
import { useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
/**
* Internal dependencies
*/
import withRegistryProvider from './with-registry-provider';
import useBlockSync from './use-block-sync';
import { store as blockEditorStore } from '../../store';
import { BlockRefsProvider } from './block-refs-provider';
import { unlock } from '../../lock-unlock';
/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
export const ExperimentalBlockEditorProvider = withRegistryProvider(
( props ) => {
const { children, settings, stripExperimentalSettings = false } = props;
const { __experimentalUpdateSettings } = unlock(
useDispatch( blockEditorStore )
);
useEffect( () => {
__experimentalUpdateSettings(
{
...settings,
__internalIsInitialized: true,
},
stripExperimentalSettings
);
}, [ settings ] );
// Syncs the entity provider with changes in the block-editor store.
useBlockSync( props );
return <BlockRefsProvider>{ children }</BlockRefsProvider>;
}
);
export const BlockEditorProvider = ( props ) => {
return (
<ExperimentalBlockEditorProvider
{ ...props }
stripExperimentalSettings={ true }
>
{ props.children }
</ExperimentalBlockEditorProvider>
);
};
export default BlockEditorProvider;