Fix an image related selection issue

At the moment if user start a selection in text and then release the mouse on an
image. It loses the selection and just selects the image.
Merge pull request #396 from kevinlli/rangeSelectionFix

Fix an image related selection issue