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

johanneswilm left a comment (w3c/editing#551)

Hey @GaurangTandon 

>  Regarding your "Working solutions", I do not believe we should rely on any existing behavior of the editors and attempt to build heuristics around those

That is, according to my research, what current browser extensions do though. I don't know about the one your company is working on, but common browser extensions that interact with editable elements usually contain a library of different editors and they then attempt at figuring out which ones it is and work somewhat differently. They also have a generic fallback in case they cannot determine which editor it is.

So the question is how can we get them to play nicely together. My proposal for this is  to add this: https://github.com/w3c/input-events/pull/185 . That will make it easier for JavaScript editor developers to allow extensions to connect with it. In those cases where JS editors want to actively prevent extensions from interfering with them, then they can also make sure to only listen to events with isTrusted set (none of the editors I looked at did this).

The `paste`-event is not quite as good as the `beforeinput` event as it has no target ranges.  The Wordgard-editor (v 0.5.2) is the one case where one even has to wait for 1 frame between setting the selection and making the paste. `execCommand` leaves random `&nbsp` in the target and should therefore be avoided at all costs. Additionally, it doesn't work with several modern editors (both `contenteditable`- and `EditContext`-based) as my research above has shown.

Luckily, the Wordgard-maintainer also agrees that it is an improvement to switch to the beforeinput event (same as the recommendation I propose to put into the Input event spec) and the change has landed here: https://code.haverbeke.berlin/wordgard/wordgard/commit/79931393d3025fcdd1a5b7482b79878a8d4712df

For the near future, the extensions probably still will ship with a large library of different websites and different scripts to enter here and there. But over time, with the bug fixes in Firefox and Safari and the recommendations in the spec advising editor developers on how to make their editors compatible with extensions, hopefully the interaction can get smoother.

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

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

Received on Wednesday, 7 October 2026 14:47:19 UTC