Re: [w3c/editing] beforeinput: Should we fire `replaceContent` during IME composition? (#122)

@choniong: it seems insertText (formerly insertCharacter) is separate from replaceContent because the insertText event is not cancelable during composition and because cE=typing will have a default action for insertText, but not for replaceContent.

> 1. Type "abc" in an input field (`insertText` should be fired for each letter)
> 2. Select "bc" (no `beforeinput` event)
> 3. Press "d" (`replaceContent` should be fired instead of `insertText`)

That may indeed sound a bit strange, but instead of just selecting one character, the selection could also span over a more complex piece of piece of the DOM. This means it would be difficult to handle the two correctly in JS if the two were merged in cE=typing. One would have to check:

- Whether the inserted content is plain text.
- Whether the selection is collapsed.

Only if both are true would there be a default action, otherwise no.

> Also I'm not sure why do we need `replaceContent` instead of using `insertText` with a `targetRanges`? (I could't find `replace*` in https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#Commands, they only got `insertText` I guess?)

Indeed, it seems not all the actions we need can necessarily be defined in terms of execCommand commands, and vice versa. This was just an idea that came out of the browser meeting. It hasn't been discussed or investigated much beyond that.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/editing/issues/122#issuecomment-209652647

Received on Wednesday, 13 April 2016 21:24:57 UTC