I built an in page editor like this a few years ago. I took a completely different approach however. I used jQuery to parse the entire page as XML and the used some dom navigation to work out path locations to the node I was on. There are jQuery libraries which will select nodes via xpath queries.
Then with some string functions I managed to break each node down into text runs (just wrapping spans around text blocks) so that I could apply styles to certain segments. Preserved the whole document in valid XHTML.
Just food for thought if you feel like making the editing functions even more granular.
Then with some string functions I managed to break each node down into text runs (just wrapping spans around text blocks) so that I could apply styles to certain segments. Preserved the whole document in valid XHTML.
Just food for thought if you feel like making the editing functions even more granular.