I wrote a function to wrap/unwrap a range in a special element. To wrap the range I use the range function range.surroundContents(element). To unwrap an element I replace the wrapped range by the actual range. Now in the function if I don’t turn track changes off the whole range is marked as added which I don’t want. If in the wrap/unwrap function I turn track changes off I lose all track changes I had in the actual range.
How do I wrap/unwrap a range in anew element without losing track changes?