-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathlibrary.js
59 lines (54 loc) · 1.37 KB
/
library.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
54
55
56
57
58
59
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import InserterMenu from './menu';
import { store as blockEditorStore } from '../../store';
const noop = () => {};
function InserterLibrary(
{
rootClientId,
clientId,
isAppender,
showInserterHelpPanel,
showMostUsedBlocks = false,
__experimentalInsertionIndex,
__experimentalFilterValue,
initialInserterTab,
onSelect = noop,
shouldFocusBlock = false,
},
ref
) {
const { destinationRootClientId } = useSelect(
( select ) => {
const { getBlockRootClientId } = select( blockEditorStore );
const _rootClientId =
rootClientId || getBlockRootClientId( clientId ) || undefined;
return {
destinationRootClientId: _rootClientId,
};
},
[ clientId, rootClientId ]
);
return (
<InserterMenu
onSelect={ onSelect }
rootClientId={ destinationRootClientId }
clientId={ clientId }
isAppender={ isAppender }
showInserterHelpPanel={ showInserterHelpPanel }
showMostUsedBlocks={ showMostUsedBlocks }
initialInserterTab={ initialInserterTab }
__experimentalInsertionIndex={ __experimentalInsertionIndex }
__experimentalFilterValue={ __experimentalFilterValue }
shouldFocusBlock={ shouldFocusBlock }
ref={ ref }
/>
);
}
export default forwardRef( InserterLibrary );