The previous accepted solution is not working any longer.
I ended up coding a simple function which wraps the range
into a styled container adding the bar that is needed before the cursor.
I wrote this example where easy to see the two colors 'blue' and 'orange' set in the css, so they can be quickly modified.