how to make selected text stay surrounded by a span without breaking any Tag-element (javascript)
one exaple:
original text:
<p> a foo </p>
<p> another bar </p>
selected:
a fooer bar
anoth
I do not want break the html nesting structure:
<p> a fo<span>o </p>
<p> anoth</span>er bar </p>
I need something like this:
<p> a fo<span>o </span></p>
<p> <span>anoth</span>er bar </p>
It's not possible. Imagine this:
resulting in:
a foo
another bar
Now if a user selects only a portion, lets say:
a fo
oer baranoth
you break the html nesting structure:
This is impossible to achieve with only one tag.