I have a div with contenteditable=true
set in order to allow inline editing (for RTE purposes).
Im aware different browsers handle the enter keypress differently, FF inserts <br>
and IE inserts <p>
The issue I am experiencing is when entering text across various lines.
e.g for the text:
line 1
line 2
line 3
line 4
In FF, when entering the above then switching contenteditable=false
, the line formatting remains as expected.
However, when editing in IE with multiple lines of text, then setting contenteditable=false
, any blank lines are collapsed. e.g:
line 1
line 2
line 3
line 4
If I then reset contenteditable=true
, these collapsed lines are restored.
I am guessing it has something to do with the use of <p>
by IE, any ideas how I can prevent the lines from being collapsed when contenteditable=false
?
tags around newline content, which then stops block commands using execcommand from working on a line by line basis (i.e. centering text will center all text, not the current line). It seems when adding a new line with contenteditable=true, IE inserts
tags, collapsing the section. I wrote a routine to manually add them back into empty
tags to maintain the newline
– SW4 May 17 '12 at 16:08