The simplest approach is really very simple, but doing it all from scratch just means a lot of work.
Here is the idea: don't use a "regular" text box. You can make any block HTML element, such as div or paragraph, typeable, by using the attribute
contenteditable
. And other HTML content (tags with formatting attributes, such as classes, font colors, etc) could be added via commands modifying
innerHTML
of any element. I already answered this question, with rudimentary code samples:
http://www.codeproject.com/Answers/682802/How-can-i-insert-different-letters-with-different#answer1[
^],
http://www.codeproject.com/Answers/684812/changing-the-style-of-every-character-within-any-c#answer1[
^].
—SA