Make part of contentEditable unable to delete

Viewed 6721

I have a contentEditable Div, and I'd like to be able to "protect" portions of it from deletions.

For instance, I have this contentEditable DIV that has an img tag in it I'd like to never get deleted. But I need to maintain the text flow around the image as the user types.

http://jsfiddle.net/uk6DA/16/

Is there any way, using formatting of inner DIV's, or any other way. I have experimented with key events but so far only have had sporadic results.

3 Answers

Try having something like this, where you nest the editable section in a non-editable element-

<p> uneditable text 
<p contenteditable> editable text </p>
</p>
Related