@wordpress/block-editor
Version:
53 lines (46 loc) • 1.12 kB
JavaScript
/**
* External dependencies
*/
import { noop } from 'lodash';
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import InserterMenu from './menu';
import { store as blockEditorStore } from '../../store';
function InserterLibrary( {
rootClientId,
clientId,
isAppender,
showInserterHelpPanel,
showMostUsedBlocks = false,
__experimentalInsertionIndex,
onSelect = noop,
shouldFocusBlock = false,
} ) {
const destinationRootClientId = useSelect(
( select ) => {
const { getBlockRootClientId } = select( blockEditorStore );
return (
rootClientId || getBlockRootClientId( clientId ) || undefined
);
},
[ clientId, rootClientId ]
);
return (
<InserterMenu
onSelect={ onSelect }
rootClientId={ destinationRootClientId }
clientId={ clientId }
isAppender={ isAppender }
showInserterHelpPanel={ showInserterHelpPanel }
showMostUsedBlocks={ showMostUsedBlocks }
__experimentalInsertionIndex={ __experimentalInsertionIndex }
shouldFocusBlock={ shouldFocusBlock }
/>
);
}
export default InserterLibrary;