JSFiddle - React, Tailwind, and code Playground
HTML
<div class="cancelEnter" contenteditable="true">入力時に点滅する縦棒(カーソル)が常に先頭に来てしまう。</div>
CSS
div {background:#efefef;border:1px solid #333;padding:10px;}
JavaScript
$(document).on("input keydown keyup keypress change",".cancelEnter", function(e){
// 改行の入力を禁止
if (e.which == 13) {
return false;
}
// 改行のペーストを禁止
var txt = $(this).text();
var replace2 = txt.replace(/<("[^"]*"|'[^']*'|[^'">])*>/g,'');
$(this).text(replace2);
})