How to get startIndex and endIndex from the selected block in gutenberg?

You can use these to get the start and end of the selection:

var startIndex = wp.data.select('core/block-editor').getSelectionStart();
var endIndex   = wp.data.select('core/block-editor').getSelectionEnd();