Re: [w3c/editing] Universal interface to modify content in a JS editor from unrelated JS code. (Issue #551)

GaurangTandon left a comment (w3c/editing#551)

I really appreciate your comprehensive response. I just want to quickly make a note specifically about execCommand: I see you're using `execCommand('insertHTML')`, which has no equivalent user action, so it is reasonable to expect that editors don't work well with it.

We should be testing `execCommand('paste')` instead, which is representative of a real user action (paste itself). `execCommand('paste')` (from an extension content script) dispatches 'paste' and 'input' events, just as a real user paste does, but not the `'beforeinput'` event (which needs to be dispatched manually).

I used Fable to fork and extend your test suite with the approach I suggested above. It passed on all six (non-EditContext) editors. Link: https://github.com/GaurangTandon/influence-text-editors (only tested on Chrome). It also does not leave any artifacts like nbsp. EditContext editor still needs the separate beforeinput route.

To be clear, any editor (not just the six above) that supports paste would (by definition) have to depend on at least one of three events: 'paste', 'beforeinput' or 'input' and in that order (as defined in the spec). In our own real world testing, this exact approach works in almost every real world editor, except those that specifically ignore a synthetic beforeinput event (hence the discussion in https://github.com/w3c/editing/issues/200#issuecomment-5951475331). 

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

Message ID: <w3c/editing/issues/551/6047609685@github.com>

Received on Wednesday, 7 October 2026 21:54:25 UTC