References and tutorials on developing rich text editors are rare and extremely difficult to find (I never found one till today). You should check out the open-source rich text editors and try to understand what they do in the sourcecode.
Before I forget, I also decided to make a tiny editor myself after your question with an API etc. (but release date is about two weeks from now ;) ) but before I started my own, I created a tutorial on how to do make a tiny editor (aka a rich text editor). You might want to check it out: