Reputation: 2968
I create the simplest WYSIWYG editor, but in each browser generated other html code.
I use:
a.execCommand('useCSS', false, true);
a.execCommand('styleWithCSS', false, false);
For example:
Chrome generate unnecessary div when i use enter key...
IE generate <p>
tags when go to new line...
Firefox generate for me the best code, inserts old br:)
I must create styles for results, by it's too much differences.
Upvotes: 1
Views: 947
Reputation: 4314
The insertion of div's, p's, or br's when pressing enter/return is NOT controlled with the useCSS/styleWithCSS option. This option is only for styles. What happens when you press enter/return
is entirely browser-specific. To normalize the behavior, you can code a key-handler for the return key (code 13) where you insert a <br>
or \n
or whatever you like when enter
is pressed.
See the following questions to get started with writing a key handler for exactly this:
Make a <br> instead of <div></div> by pressing Enter on a contenteditable
Cross browser event handler must capture [ENTER]
Upvotes: 2