JSFiddle - React, Tailwind, and code Playground

by denislexic

HTML

<div class="editable" contentEditable="true" style="width:60%; height:100px; border:1px solid #cacaca; margin-top:10px; margin-left: 10px;"></div>

JavaScript

$(document).ready(function() {
    $("body").on("keyup", ".editable", function() {
        var $this = $(this),
            value = $this.html(),
            regex = /[^>]#\S+[^ ]/gim;
        value = value.replace(regex, "<span style='color:red'>$&</span>");
        $this.html(value);
    });

});