w3c / input-events

Input Events
https://w3c.github.io/input-events/
Other
23 stars 16 forks source link

Gather informations on content replaced by insertReplacementText or trigger a deleteByReplacement event? #133

Open Sharcoux opened 2 years ago

Sharcoux commented 2 years ago

Hi,

From everything I read so far, there is no way to get any information about what exactly happened when insertReplacementText event is triggered. We can easily know the new content that was added, but we have absolutely no way of knowing what was removed and where...

There are 2 ways that could solve this:

1. Provide extra data in the event: It could be considered that a replacement operation without information about what was replaced is kind of incomplete, and we could consider that this information is missing in the event itself

2. Trigger a deleteByReplacement event: Every operation that removes data from the editor triggers its own delete event but the replacement operation. Why is that?

In my opinion, only by listening to the events, a program should be able to tell exactly what happened to the editor without comparing the previous and the new content. That is exactly the logic behind event based programming. So, unless I'm missing something, there is something wrong here...

We are building a React rich text editor, and we succeeded to map all the changes made to the contentEditable component through input events (except the changes involved by insertReplacementText), into a custom model of ours, which make us able to add many features to the editor.