I have a content-editable div that's being used like a text area element (I can't use an actual text area because I need rich text capabilities). When I copy and past multiple lines of text into it, the default behavior creates a mess of nested divs which makes it a lot harder to do things such as getting the actual text content of the div.
I found a solution for this problem here
editor.addEventListener("paste", function(e) {
// cancel paste
e.preventDefault();
// get text representation of clipboard
var text = (e.originalEvent || e).clipboardData.getData('text/plain');
// insert text manually
document.execCommand("insertHTML", false, text);
});
However, this uses the deprecated execCommand. Should I just use execCommand or is there am easy way to do this with supported code.