- From: <bugzilla@jessica.w3.org>
- Date: Fri, 21 Feb 2014 12:09:59 +0000
- To: public-webapps@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24704 Aryeh Gregor <ayg@aryeh.name> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WORKSFORME --- Comment #2 from Aryeh Gregor <ayg@aryeh.name> --- The specification requires that hitting Enter (or equivalent) is the same as the insertParagraph command, and Shift-Enter (or equivalent) is the same as insertLineBreak: https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#additional-requirements The insertParagraph command is specified here, with a rough summary in green at the top: https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#the-insertparagraph-command The short story is: this has been discussed a lot, and there are three basic approaches taken by browser engines. The basic behavior that's currently specified (very simplified) is patterned after IE and Opera, and is: find the nearest ancestor that's a <div>/<p>/<li>/etc. and make a new one, if there is any; and if there isn't, make a new <p>. So for instance, if you have <ol><li>foo</ol> and you hit Enter in the middle, it becomes <ol><li>fo<li>o</ol> or such. Likewise <p>foo</p> will become <p>fo<p>o</p>, and so on. If you start off with an empty editing host, or break out of a list or such, it will use <p>, but this can be changed to <div> via the defaultParagraphSeparator command. This has been discussed a lot, multiple times, and I'm unlikely to change the spec to require <br> for Enter unless browser implementers want it, which is unlikely. A good thread to read if you're interested is: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-May/031577.html <br> for Enter is the Firefox behavior at the time of this writing, but I rejected it because it causes a lot of subtle headaches and bugs. Particularly, it doesn't actually always create a line break: HTML like foo<br><ol><li>bar</ol> displays identically to the same without the <br> -- try it and see. So you have to write lots of magic to figure out when you need to insert extra <br>s to make the <br> do what you want. Moreover, having each paragraph wrapped in its own tag is programmatically easier. Sometimes you want code that affects an entire paragraph, and if it's in a <p> it's very easy. With <br>s it's much more annoying. As far as your example of <p contenteditable> -- this sort of thing is not well-supported right now, either in the spec or in browsers. <span contenteditable> is even worse. A ton of work would have to be done to get this sort of thing to behave right, and it's not realistically worth it, so I suggest sticking with <div> for contenteditable for now. I hope this helps. As I said, this is very unlikely to change to what you requested, but if you have more questions *after* reading the mailing list thread I linked to, please feel free to reopen this bug. -- You are receiving this mail because: You are on the CC list for the bug.
Received on Friday, 21 February 2014 12:10:01 UTC