JSFiddle - React, Tailwind, and code Playground

by tomprogramming

HTML

<div class="box1" contenteditable="true">
    <span class="level1">Text</span>
    <br>
        <span class="level1">Other Text</span>
</div>

CSS

.level1 {
    font-size:3em;
    color: white;
    font-family: Arial, Verdana, sans-serif;
}

.box1 {
    background-color: #0073ac;
    padding:20px;
}

JavaScript

document.execCommand("StyleWithCSS", true);

$("[contenteditable]").on("keypress", function(e){
    if (e.which === 13){
        document.execCommand("insertLineBreak");
        e.preventDefault();
        e.stopPropagation();
    }
});