fix a lot of little text-selection and toolbar issues
Namely switch to iterating over every position in a slection and
checking if there is a mark, and then updating the mark if neccessary
instead of toggling it.
Also add a specific case for handling links since they aren't inclusive
of the last position