Firefox breaks new lines with <br>, Chrome and Safari are breaking with <div>...</div> and Internet Explorer and Opera are using paragraphs <p>...</p> for new lines.
I am looking for a method to force each browser to create only paragraphs, when breaking to a new line.
I know ckeditor supports this function, but how can i realize it simply in my custom editor?
For me was solution to add document.execCommand('formatBlock', false, 'p'); into a keypress event in the contenteditable div. For example:
element.addEventListener('keypress', function(ev){
if(ev.keyCode == '13')
document.execCommand('formatBlock', false, 'p');
}, false);
Hope it'll help someone. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With