JSFiddle - React, Tailwind, and code Playground

HTML

<textarea id="texto">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</textarea>

CSS

#texto {
    width: 300px;
    height: 300px;
}

JavaScript

(function ($, undefined) {
    $.fn.getCursorPosition = function() {
        var el = $(this).get(0);
        var pos = 0;
        if('selectionStart' in el) {
            pos = el.selectionStart;
        } else if('selection' in document) {
            el.focus();
            var Sel = document.selection.createRange();
            var SelLength = document.selection.createRange().text.length;
            Sel.moveStart('character', -el.value.length);
            pos = Sel.text.length - SelLength;
        }
        return pos;
    }
})(jQuery);

var incorporaciones = [
    "Caca y culo",
    "Pis",
    "A zurrarte la sardina",
    "Zurdir mierda con un látigo",
    "Muñecos de mierda y comerles la cabeza",
    "Se baja las bragas a pedos",
    "Polo de pipi",
    "Pedo",
    "Ojete moreno"
]

function getIncorporacion() {
    var index = Math.floor(Math.random() * incorporaciones.length);
    return incorporaciones[index];
}

$("#texto").click(function() {
    var $this = $(this);
    var texto = $this.text();
    var pos = $this.getCursorPosition();
    
    var incorporacion = getIncorporacion();
    //alert(incorporacion);
    
    // incorporar texto
    texto = texto.substring(0,pos) + incorporacion + texto.substring(pos);
    $this.text(texto);
    
})