JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://rangy.googlecode.com/svn/trunk/currentrelease/rangy-core.js"></script>
<script src="http://rangy.googlecode.com/svn/trunk/currentrelease/rangy-cssclassapplier.js"></script>
<script src="http://rangy.googlecode.com/svn/trunk/currentrelease/rangy-selectionsaverestore.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Strip editable div markup</title>
</head>
<body>
Pasting without formating. Copy some CSS above. Magic, the formating is gone after pasting!
<div id="editableDiv" contentEditable="true">Editable text</div>
</body>

</html>

CSS

div {
border: 1px solid;
height: 50px;
width: 200px;
}

JavaScript

//var ctrl = false;

/*$('#editableDiv').keydown(function(e) {
    if(e.which == 17 || e.which == 91) {
        ctrl = true;
        return false;
    } 
    
    if(ctrl && e.which == 86) {
        cleanUp();
    } else {
        ctrl = false;        
    }
});*/


$(document).on('paste', '#editableDiv', function(e) {
    cleanUp();
});

savedSel = null;

function cleanUp() {
    savedSel = rangy.saveSelection(); //save range. It's done with inline html.
    
    var oldContent = $('#editableDiv').html(); //Save the current values. Because of the selectionSaveing, we have to use html()
    
    $('#editableDiv').empty(); //empty the div
    
    setTimeout(function() {//wait a little bit, so the text is pasted for sure.
        var newContent = $("#editableDiv").text(); //get the content again. now you got the pasted text. Use text() to get rid of the formatting ;)
        $('#editableDiv').html(oldContent); //Because rangy saves the selection with html, we have to put it back with html()
        rangy.restoreSelection(savedSel); //restore selection, so our cursor is on the correct position. It also removes the html wich was made for the selection saving.
        paste(newContent); //Some code to put some html to the current selection
    }, 100);
}

//IE 9 fix. IE9 doesn't know createContextualFragment,so we'll teach him.
if (typeof Range.prototype.createContextualFragment == "undefined") {
    Range.prototype.createContextualFragment = function(html) {
        var doc = this.startContainer.ownerDocument;
        var container = doc.createElement("div");
        container.innerHTML = html;
        var frag = doc.createDocumentFragment(), n;
        while ( (n = container.firstChild) ) {
            frag.appendChild(n);
        }
        return frag;
    };
}

function paste(html) {
    if (window.getSelection && window.getSelection().getRangeAt) {
        range = window.getSelection().getRangeAt(0);
        node = range.createContextualFragment(html);
       ...