@enne9
You do not explain what it is you see, or how you say the HTML ends up which you should show us, after you enter some characters. I don't know what "new spans are added instead of inserting the actual content I enter using the keyboard" means.
If I try your code (Linux Qt 5.12.2), with color being red, what I see is: a red background on one space, with the cursor immediately to the right of that space. When I type characters they appear, but with the red background. Doubtless because it does not know whether your cursor "position" is after the but still before the </span> versus whether it is after the </span> .
If I append a <br /> to your HTML, "...> </span><br \>", the cursor starts at the line below and characters now typed do not have the red background.
You may have to explain exactly what happens to you and what you want/expect.