JSFiddle - React, Tailwind, and code Playground

by Florian Gropp

HTML

<div id="wp-content-editor-container" class="wp-editor-container">
  <textarea class="wp-editor-area" rows="10" tabindex="1" cols="40" name="content" id="content">
        &lt;a title="This is a hyperlink" href="http://domain.com/directory"&gt;This is a hyperlink&lt;/a&gt;
        &lt;a title="This is another hyperlink" href="http://google.com/directory"&gt;This is another hyperlink&lt;/a&gt;        
    </textarea>
</div>

JavaScript

var url = 'domain.com';
var append = '?parameter ';

$(".wp-editor-area").each(function() {
  $(this).text(urlify($(this).text()));
});

function urlify(text) {
  var urlRegex = /(\b(https?|ftp|file):\/\/[domain.com][-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
  return text.replace(urlRegex, function(url) {
    return url + append;
  })
}