JSFiddle - React, Tailwind, and code Playground

HTML

<div id="lc">&nbsp;</div>
<iframe id="edit"></iframe>

CSS

#lc { background: #eeeeee; margin-bottom: 5px; width: 200px; border: 1px solid #bbbbbb; }
#edit { width: 200px; border: 1px solid #bbbbbb; }

JavaScript

document.getElementById('edit').contentWindow.document.designMode = "on";

$('#edit').keyup(function() {
    x = $(this).contents().children().split('\n');
    $('#lc').text(x.length); // This will be the line number
});