Because of how Editorial workflows work I had to do a bit of hackery to make it work. The idea is to find the starting position of the word just before the current selection. My first version looped through every single word up till the selection but that was unusably slow on large documents. So this version only loops through every word in the 50 letters leading up to the selection. A hack, but it works really well.