Created
February 13, 2019 08:31
-
-
Save dongsik-yoo/ad62107da60a5a618f86300ff222c5e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// unwrap text nodes | |
wrappers.forEach(span => { | |
if (span.parentElement) { | |
const textNode = span.firstChild; | |
span.removeChild(textNode); | |
span.parentElement.insertBefore(textNode, span); | |
span.parentElement.removeChild(span); | |
} | |
}); | |
// keep the cursor | |
if (range) { | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} | |
paragraph.normalize(); | |
nextParagraph.normalize(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment