JSFiddle - React, Tailwind, and code Playground

JavaScript

function download(data, filename, type) {
    var file = new Blob([data], {type: type});
    if (window.navigator.msSaveOrOpenBlob) // IE10+
        window.navigator.msSaveOrOpenBlob(file, filename);
    else { // Others
        var a = document.createElement("a"),
                url = URL.createObjectURL(file);
        a.href = url;
        a.download = filename;
        document.body.appendChild(a);
        a.click();
        console.log('1')
        setTimeout(function() {
            document.body.removeChild(a);
            window.URL.revokeObjectURL(url);  
            console.log('2')
        }, 0); 
    }
}

$('body').on('paste',function(e) {
	  console.log(e)
    e.preventDefault();
    var text = (e.originalEvent || e).clipboardData.getData('text/uri');
    //alert(text);
    download(text, 'paste.txt', 'txt')
    console.log(text)
});