JSFiddle - React, Tailwind, and code Playground

HTML

<div class="field" contenteditable="true"></div>
<button class="insert-image">Insert Image</button>

JavaScript

$(document).ready(function() {
    $(".insert-image").on('click', function(event) {
        event.preventDefault();
        var $img = $('.field img.custom');
        if(!$img.length){
            $img = $('<img class="custom" src="http://nuclearpixel.com/content/icons/2010-02-09_stellar_icons_from_space_from_2005/earth_128.png">')
             $('.field').append($img);
        }
       
        // not sure what to do here
    });
});