I have the following problem. Once I add a blockquote
in contenteditable
, by pressing Enter key it moves to a new line and adds another blockquote
element. It goes on forever, and I can’t escape the formatting. The desired functionality would be that of the unordered list. When you press the Enter key it adds a new empty <li>
element, but if you press Enter again, it escapes the formatting, removes the previously created <li>
and adds a <p>
.
Check out the demo: http://jsfiddle.net/wa9pM/
One hack I found was to create an empty <p>
under the blockquote
, before you create a blockquote
. But is there a way to break this formatting behaviour with JavaScript? No idea how I would check: if where the cursor is, it’s the end of the line and if it’s a blockquote and on Enter key press, don’t add a new blockquote
.
I’m using this code to generate a blockquote
in JS:
document.execCommand('formatBlock', false, 'blockquote');
`, it's being pressed on a blank line and should then break out of the ` – Lrdwhyt Feb 03 '13 at 00:12