Bug 31678

Summary: contentEditable doesn't wrap elements around content until after the first line
Product: WebKit Reporter: Tim McConnell <timmc>
Component: HTML EditingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: ap, ayg, enrica, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
URL: http://www.mozilla.org/editor/midasdemo/

Tim McConnell
Reported 2009-11-19 12:16:23 PST
For a new contentEditable region, only the second line will be wrapped in a container element (e.g. div or p). Repro steps: 1) Navigate to http://www.mozilla.org/editor/midasdemo/ 2) Click into the CE region and type a line 3) Hit enter and type another line 4) Click "View HTML Source" Actual: You will see that the first line is not contained in the relevant line element. Expected: The first line, like the second line, has been wrapped in the editor's line element. Problem: Because content is not uniformly wrapped, operations that should apply to the current line/block will fail on the first line. Any attempt to walk the DOM to find the parent will reach the contentEditable root.
Attachments
Aryeh Gregor
Comment 1 2011-08-19 09:08:35 PDT
I specced IE/Opera's behavior, which is to wrap every line in a <p>, including the current one as soon as the user hits enter: http://aryeh.name/spec/editing/editing.html#the-insertparagraph-command The relevant case is "If container is not editable or not in the same editing host as node or is not a single-line container:". This basically wraps the current line in a <p>, although admittedly that's unlikely to be clear on a casual read. I specced it this way because I agree that it's useful for every line to have a wrapper, so that they can be handled consistently.
Note You need to log in before you can comment on or make changes to this bug.