JSFiddle - React, Tailwind, and code Playground

HTML

<textarea onkeyup="charCountTextarea(&quot;type1&quot;,event,&quot;75&quot;,&quot;14&quot;)"
onblur="bubblesFocusOut(&quot;type1&quot;);callTextBlur();" onfocus="showBubbleButton(&quot;type1&quot;); callTextFocus(&quot;type1&quot;,event,&quot;75&quot;,&quot;14&quot;)"
style="word-wrap:break-word;" id="type1">Type Here</textarea>

JavaScript

var countLines = 0;
var myAra = Array();
myAra = "";
var str = "";
var newLines;

var countLine1 = 0,
  countLine2 = 0,
  countLine3 = 0,
  countLine4 = 0,
  countLine5 = 0;

var timer1, timer2;

function callTextFocus(textAreaId, e, limit, lineLen) {
  console.log("Call textt");
  timer1 = setInterval(function () {
    arrangeText(textAreaId, e, limit, lineLen);
    // Do something every 5 seconds
  }, 1);
}

function arrangeText(textAreaId, e, limit, lineLen) {
  var lineNos = $("#" + textAreaId).val().split("\n").length;
  var t = $("#" + textAreaId)[0];
  console.log("totl Lines zz: " + lineNos);
  if (lineNos == 1) {
    if ($("#" + textAreaId).val().split("\n")[0].length > lineLen) {
      insertTextAtCaret(document.getElementById(textAreaId), "\n");
    }
  } else if (lineNos == 2) {
    if ($("#" + textAreaId).val().split("\n")[1].length > lineLen) {
      insertTextAtCaret(document.getElementById(textAreaId), "\n");
    }
  } else if (lineNos == 3) {
    if ($("#" + textAreaId).val().split("\n")[2].length > lineLen) {
      insertTextAtCaret(document.getElementById(textAreaId), "\n");
    }
  } else if (lineNos == 4) {
    if ($("#" + textAreaId).val().split("\n")[3].length > lineLen) {
      insertTextAtCaret(document.getElementById(textAreaId), "\n");
    }
  } else if (lineNos == 5) {
    insertTextAtCaret(document.getElementById(textAreaId), "");
    $("#" + textAreaId).val().split("\n")[4][15] = "";
  }

}

function callTextBlur() {
  countLine1 = 0, countLine2 = 0, countLine3 = 0, countLine4 = 0, countLine5 = 0;
  clearInterval(timer1);
}

function charCountTextarea(textAreaId, e, limit, lineLen) {

  var code = e.charCode || e.keyCode;

  newLines = $("#" + textAreaId).val().split("\n").length;
  var t = $("#" + textAreaId)[0];
  var lineIndex = t.value.substr(0, t.selectionStart).split("\n").length - 1;


  if (lineIndex == 5 && $("#" + textAreaId).val().split("\n")[lineIndex].length > (lineLen + 2) && code != 8 && code != 46 && code != 33 &&...