W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2011

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

From: Ehsan Akhgari <ehsan@mozilla.com>
Date: Wed, 18 May 2011 15:22:43 -0400
Message-ID: <4DD41C83.3000404@mozilla.com>
On 11-05-18 2:46 PM, Aryeh Gregor wrote:
>> Also, we should be preserving inline styles.
>> We should copy all attributes and have a blacklist of uncopyable attributes.
>> ID is the only one I can think of off the top of my head that needs
>> blacklisting.
>
> accesskey, itemid, and name (on<a>) seem potentially problematic too.
>   It's also possible that custom attributes, data-* or otherwise, might
> be issues, depending on how they're used.  I guess in that case it's
> better to duplicate it and let authors figure out the consequences if
> it's wrong, than to destroy the info about what attributes it
> originally had.

I agree.

> So probably it's okay to just blacklist id and<a name>.

What about itemid and accesskey?  (There may be other examples that I'm 
forgetting right now).

>> IMO, WebKit's behavior here is wrong. When you hit enter not in a block
>> Opera's behavior here seems right to me. If I understand correctly here's
>> what Opera does:
>> enter without a parent block: wrap everything in two block elements as
>> defined by the opera-defaultblock execCommand.
>> enter with a parent block: split the parent block
>> shift+enter: insert a BR
>> enter inside a header: breaks out of the header and inserts a block as per
>> the opera-defaultblock execCommand (this is just legacy we're stuck with
>> from IE5+)
>
> There's more magic than that.  For instance, if you're in an<li>  and
> hit Enter twice, all browsers will create a new<li>  on the first
> Enter and then destroy it and move you outside the list on the second
> Enter.

Yes.  Overall, this seems like a pretty sane basis on top of which we 
can build the algorithm.

Cheers,
Ehsan
Received on Wednesday, 18 May 2011 12:22:43 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:33 UTC