JSFiddle - React, Tailwind, and code Playground

by tomprogramming

HTML

<script src="https://raw.github.com/atheken/Rangy-Mirror/master/currentrelease/rangy-core.js"></script>
<div id="my-editor" contenteditable="true"></div>

CSS

[contenteditable=true] {
  border: 1px dashed red;
  margin:10px;
  padding:10px;
  width:180px;
  height:180px;
    font-family:arial, sans-serif;
}

JavaScript

jQuery("#my-editor").bind("paste", function(e){
    console.log("paste event");
    console.log(arguments);
    var data = e.originalEvent.clipboardData.getData('text/html');
    console.log(data);
    var regex = /Microsoft/ig;
    if (regex.test(data)){
        alert("You're pasting from a microsoft product, you're a bad person")             
        e.preventDefault();
        e.stopPropagation();
    }        
});