@wordpress/block-editor
Version:
32 lines (27 loc) • 708 B
JavaScript
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';
export default function useListViewClientIds( { blocks, rootClientId } ) {
return useSelect(
( select ) => {
const {
getDraggedBlockClientIds,
getSelectedBlockClientIds,
getEnabledClientIdsTree,
} = unlock( select( blockEditorStore ) );
return {
selectedClientIds: getSelectedBlockClientIds(),
draggedClientIds: getDraggedBlockClientIds(),
clientIdsTree:
blocks ?? getEnabledClientIdsTree( rootClientId ),
};
},
[ blocks, rootClientId ]
);
}