JSFiddle - React, Tailwind, and code Playground
by praveen_jegan
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">
<input id="editor" type='text'>
JavaScript
$(document).ready(function () {
var $editor = $('#editor');
var $clipboard = $('<input type="text" />').insertAfter($editor);
$editor.on('paste', function () {
var $self = $(this);
setTimeout(function () {
var $content = $self.val();
$clipboard.val($content);
}, 100);
});
});
if (window.clipboardData) {
$('#editor').bind('paste', function (e) {
var clipped = window.clipboardData.getData('Text');
clipped = clipped.replace(/(\r\n|\n|\r)/gm, " "); //replace newlines with spaces
$(this).val(clipped);
return false; //cancel the pasting event
});
}