Re: [w3c/editing] Should execCommand dispatch beforeinput or not? (#200)

It seems that there are two points of view:

- If setting `.value` on a textarea doesn't fire beforeinput, then `execCommand()` shouldn't, either. (@masayuki-nakano)
- If `execCommand()` fires `input`, then it should also fire `beforeinput`. (@rniwa)

Assuming we understand "input" as "user input", then perhaps we should only fire `beforeinput` or `input` events when the user does something. `execCommand()` can be called by a script without the user's knowledge, so it's not always user input.

However, if `execCommand()` were to dispatch `beforeinput`, there should be a way to distinguish the input from direct keyboard input. Here's a use case from my project:

Suppose I want to convert `-` to `–` (endash) whenever the user inputs `-` (regular dash). To achieve this, I listen for `beforeinput`.

But I also want to have a toolbar button that types `-` (regular dash) using `execCommand('insertText')`. I **don't** want to autoconvert the dash when the user clicks the `-` button, because the whole point of the button is to allow the user to type a regular dash.

If the button-triggered `execCommand()` call fires a `beforeinput` event, then I would need some way to recognize that the event was initiated by the button.


PS. It's true that advanced, full-featured editors don't use execCommand, but sometimes you just want a text box with basic formatting buttons (bold/italic etc.). I use a textbox like that on www.typeit.org.

-- 
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/200#issuecomment-558949339

Received on Wednesday, 27 November 2019 06:26:35 UTC