на примере кода от
Nexus,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style>
p {
min-height: 20px;
background: red;
color: white;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelector("#article").addEventListener("keydown", function(event) {
const paragraphs = this.querySelectorAll('p');
if(event.code == 'Backspace' && paragraphs.length == 1 && !paragraphs[0].textContent.length) event.preventDefault();
})
});
</script>
</head>
<body>
<article id="article" contenteditable="true">
<p class="paragraph">some..</p>
</article>
</body>
</html>