JSFiddle - React, Tailwind, and code Playground
HTML
<div id="editor" contenteditable>
Something something <span class="misspelled">mispeled</span>
</div>
CSS
.misspelled {
color: red;
cursor: default;
text-decoration: underline;
}
JavaScript
var editor = document.getElementById("editor");
editor.addEventListener("contextmenu", function(event) {
var misspelling = event.target;
while (misspelling && misspelling.className != "misspelled") {
misspelling = misspelling.parentNode;
}
if (misspelling) {
// Show your suggestions menu
// misspelling is <span class="mispelled">abc</span>
console.log("Show suggestions for " + misspelling.innerHTML, misspelling);
event.preventDefault();
}
});