I will try do describe the issue:
I'm using contenteditable to edit text in DIV. The standard for elements I need to have in that DIV is:
paragraph:
<p style="someStyles"><span style="someStyles">TEXT GOES HERE</span></p>
empty line:
<p style="someStyles"><span style="someStyles"><br></span></p>
Due to some user text manipulations like copy/paste standard is messed in that DIV like here (ex. of case):
<span style="someStyles">
<p style="someStyles">SOME TEXT HERE</p>
<p style="someStyles">SOME TEXT HERE</p>
</span>
Im looking for a solution that will take messed text elements and rearrange it to given standard I wrote about above, any suggestions ?
After rearranging elements it should look like this:
<p style="someStyles">
<span style="someStyles">SOME TEXT HERE</span>
<span style="someStyles">SOME TEXT HERE</span>
</p>
P.S - I want to make that rearrange function on keyup event while typing and only for whole p element that caret is on.