I am working on a custom text editor using a contenteditable div with basic formatting functionalities. I am using the command document.execCommand("superscript", false, undefined); to do superscript functionality, for example EXAMPLETEST. what command can i use to turn this back to normal text.
Ps. clicking the initial command again does not work
I have tried document.execCommand("superscript", false, undefined); and also document.execCommand("removeFormat", false, undefined); both dont work to toggle it off.
superscript is a toggle function, it will only work if text is not there
so to get text to normal we will have to use the command again but making sure text is there, so there is a way to check if text is there in selection by using
document.queryCommandState()methodusing removeFormat is not best option as it will remove all formatting
did that help ?