JSFiddle - React, Tailwind, and code Playground

HTML

<div class="conttext">How hard can it be to achieve this here and now. Will it be difficult or can it be done with great simplicity</div>

<div class="format bold">test</div>

CSS

.highlight {
    color:#888;
}

JavaScript

$(document).ready(function(){
    $("body").keypress(function(){
       var highlight = window.getSelection();
       
        var spn = '<span class="highlight">' + highlight + '</span>';
        $('.conttext').html($('.conttext').html().replace(highlight, spn));   
    });
});