Creating your component with the text selection was a great way to have a deeper understanding of the subject.
As they say in the books, the carpenter had an exam - to make a stool.
So, I made a stool, it’s crooked, but you can sit on it. No ass gets hurt... probably

It cloud be worth considering making a component that can be multiline or not, depending on the value of a property.
What do you think?
Of course, this is the first thing that comes to mind.
My goal was to create a simple one-line editor that could be decorated however you wanted.
But, if you add multi-line, then the internal logic should be completely different, for example, the text will need to be stored in pieces in a doubly linked list.
And this is no longer a stool, but a large closet!