I'm currently working on a text editor, but I'm facing an issue with the remove underline functionality that doesn't seem to be working as expected. For reference, you can check out a working code example here: jsfiddle
Below is the part of the code that's causing the problem:
else if (tag == "u") {
sell = window.getSelection().getRangeAt(0);
if (selectionIsUnderlined()) {
node = range.createContextualFragment("<font style='text-decoration: none !important'>" + sell + "</font>");
} else {
node = range.createContextualFragment("<u>" + sell + "</u>");
}
range.deleteContents();
}
Any suggestions or ideas on how to fix this?