I am developing an epub renderer app for iOS with highlights included as one of its features. I have the algorithm for highlight creation (based on text selections made by user), removal and tap-on-highlight detection that works very well. But to get even better behaviour I would like to restrict text selection on plain text selecting.
In other words, on iOS7 & iOS8 devices I can create selection blocks around html nodes, like this:
As you can see on the pic above, the text selection box goes until header's margins and it is not bound to the text only. I would like that UIWebView automatically transforms that kind of selections to "around-text-only" selection, like this:
The reason I need this restriction is because in the first case some adjacent html nodes can get included under selection (like empty paragraphs, etc), while in the second case I have plain text selection that I can easily handle with my algorithm.
Once again, I don't want to disable text selection, I just want to bind blue selection box to the plain text only.
So can I do something to get that transformation in UIWebView? Use some javascript method perhaps?