JSFiddle - React, Tailwind, and code Playground

HTML

<div class="text" contenteditable="true" style="overflow-y: auto;height: 100px;max-height: 100px;border: 1px solid black;">
    	function escapeHtml(string) {
	    var entityMap = {"&": "&amp;", "<": "&lt;", ">": "&gt;", '"': '&quot;', "'": '&#39;', "/": '&#x2F;'};
	    return String(string).replace(/[&<>"'\/]/g, function (s) {
	        return entityMap[s];
	    });
	}

	function stringMsg(msg) {
	    var replacedText, replacePattern1, replacePattern2, replacePattern3;

	    //URLs starting with http://, https://, or ftp://
	    replacePattern1 = /(\b(https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim;
	    replacedText = msg.replace(replacePattern1, '<a href="$1" class="link" target="_blank">$1</a>');

	    //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
	    replacePattern2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim;
	    replacedText = replacedText.replace(replacePattern2, '$1<a href="http://$2" class="link" target="_blank">$2</a>');

	    //Change email addresses to mailto:: links.
	    replacePattern3 = /(([a-zA-Z0-9\-\_\.])+@[a-zA-Z\_]+?(\.[a-zA-Z]{2,6})+)/gim;
	    replacedText = replacedText.replace(replacePattern3, '<a href="mailto:$1">$1</a>');

	    return replacedText;
	}
</div>
<div class="response"></div>
<button>CLICK</button>

JavaScript

$(function(){
$('button').click(function(){
    var input = $('div').text();
    $('.response').text(input);
    
    $.ajax({
        type: 'POST',
        url: 'sys/teste.php',
        data: 'acao='+input,
        success: function(html){}
    });
});
  });