import { ContentBlock } from 'draft-js' ; export type StrategyCallback = ( start : number , end : number ) => void ; export function findWithRegex ( regex , contentBlock , callback ) { const text = contentBlock . getText ( ) ; let matchArr ; let start ; while ( ( matchArr = regex . exec ( text ) ) !== null ) { if ( matchArr . index === regex . lastIndex ) { regex . lastIndex += 1 ; } start = matchArr . index ; callback ( start , start + matchArr [ 0 ] . length ) ; } }