[whatwg] Pressing Enter in contenteditable: <p> or <br> or <div>?

On 11-05-13 1:48 PM, Ryosuke Niwa wrote:
> On Fri, May 13, 2011 at 10:26 AM, Aryeh Gregor<Simetrical+w3c at gmail.com>wrote:
> Note that br and div affect UBA differently so we must consider what
> bidirectional text users want as well.
>
> For example, if we had<div dir="rtl">hello</div>, and inserted br as in
> <div dir="rtl">hello<br></div>, then we preserve the RTL directionality.  If
> we insert div on the other hand,<div dir="rtl">hello</div><div></div>, then
> new paragraph will have the containing block's direction.
>
> This will be a tricky issue when people want to mix LTR/RTL paragraphs in
> the same editable region.

This is a very good point.  I know that <p> constitutes a UBA paragraph. 
  Does the same apply to <div> as well?

> I strongly feel that we should default to div for the backward
> compatibility.  And this is the preferred paragraph separator in many Google
> products as far as I know because div allows developers to easy apply style,
> add class, etc... to a paragraph.  And there seems to be a long history of
> browsers inserting inserting p/div on Enter and inserting br on Shift+Enter
> (on Windows), and changing that behavior will confuse users who are used to
> this behavior.

I agree that we should use br for Shift+Enter, but I'm not sure if I 
agree with your rationale on using div for Enter.  Backwards 
compatibility is not a strong argument if you consider Gecko for 
example.  And I'm not sure if we need to comply with what Google web 
properties expect.  The result of the final spec is going to be 
different to what each browser implements today, so web apps might need 
to change anyway.  Furthermore, such web products would not work 
correctly in Gecko if the code is expecting divs today.

Cheers,
Ehsan

Received on Friday, 13 May 2011 15:35:20 UTC