JSFiddle - React, Tailwind, and code Playground

by Kai

HTML

<div id="myDiv" contentEditable="true"></div>

CSS

#myDiv {
    width: 250px;
    height: 100px;
    border: 1px solid #000;
    font-family: 'Verdana';
}

JavaScript

/* Vanilla JS

var div = document.getElementById('myDiv');

div.addEventListener('keyup', function () {
    this.innerHTML = stripFont(this.innerHTML);
});

function stripFont (html) {
    var re = ;
    return html.replace(re, '');
}

*/

$('#myDiv').bind('keyup', function () {
    var $this = $(this);
    
    $this[0].innerHTML = $this[0].innerHTML.replace(/(font-family:\s?[\"\'A-Z0-9\s]+);/ig, '');
});