Apply the appropriate style to any text being inserted, not just the text added by the program. This not only fixes the bug with default style not being used for the text entered by user, but also makes the code simpler. Closes #17523.