Re: [editing] nested contenteditable

On Sat, Jun 1, 2013 at 1:27 AM, Ojan Vafai <> wrote:
> The main use case I can think of for mixed editability is an image with a caption. If anyone has other use-cases, that would be helpful in reasoning about this.

A video with JavaScript controls comes to mind.  Any embedded widget, really.

> Looking at that, I think we should make it so that a selection can never cross an editing boundary. So, in the image caption example, put your cursor right before the uneditable div, then:
> 1. Right arrow should move your cursor into the caption text.
> 2. Shift+right arrow should select the whole uneditable div.
> And delete/backspace can just be defined as extending the selection one position and then removing the selected DOM. Relatedly, if you are at the beginning of the caption text and hit backspace, nothing happens because the backspace had nothing to select (i.e. selections are contained within their first contentEditable=true ancestor).

Delete/backspace are more complicated than just selecting one position
and removing.  For instance, backspacing at the beginning of a block
is complicated, and the spec says (following Word and OpenOffice) that
backspacing after a link should unlink it rather than delete the last
character.  (Browsers don't do the latter yet, but it's particularly
essential when autolinking is supported -- otherwise it's annoying to
unlink something that the browser helpfully linked it without asking

The rest of what you say sounds reasonable.

> As to the question of whether delete/backspace should select or remove non-editable elements, I'm not opposed to giving this a try in Chromium and seeing if users are confused by it, but I'm skeptical it will make sense to people.

I'm not sure either.  It's what the "behavior when typing in
contentEditable elements" document recommends for tables.  Maybe it
makes more sense to just delete it, and assume the user is clever
enough to undo if they didn't want it deleted.

Received on Monday, 10 June 2013 11:46:07 UTC