Re: [w3c/editing] [beforeinput] Should we allow canceling the committed text from IME? (#128)

Thinking more about this, another way of dealing with this would be to let the user IME-construct the characters in place and just not send those changes to collaborators during construction and then handle your point 8 as the change event that will be distributed to collaborators.

This would then probably mean that one would A) cancel and remove half-constructed characters if a change arrives that will change the DOM surrounding the characters that are in construction. Or B) one could try to wait applying changes until the construction is done. Or C) a combination of both with a timer.

For example:

A) User 1 is currently constructing a number of characters in paragraph 1, when diff 1 form user 2 comes in that will turn the paragraph 1 into headline 1. IME is canceled and the already constructed characters are removed (by means of JavaScript). Diff 1 is applied.

B) User 1 is currently constructing a number of characters in paragraph 1, when diff 1 form user 2 comes in that will turn the paragraph 1 into headline 1. The JS editor waits until user 1 is done with the construction of characters within IME. The entire constructed character string insertion (point 8) is turned into a diff 2. The document is rolled back to the state before character insertions. Then first diff 1 is applied, thereafter application of diff 2 is attempted. if this application is successful, it is distributed to collaborators. If application of 2 proves impossible, it is given up upon.

C) Generally like B, but a timer is set when a new diff comes in and IME construction is taking place. If the construction of characters doesn't finish within X seconds, follow A.

This may still cause unexpected behavior -- for example it may not be clear to the person constructing characters why a particular incoming diff causes their construction to be interrupted -- but I think it should work.

In short: Yes @choniong, I think it would help a lot if we could make sure that 8 is cancelable. How would the JS know  an insertion event is 8? Just by listening to all insertText beforeinput events during IME and then waiting for the one which is cancelable, which then must be the last one within that IME construction? This is certainly possible, although it's not that self-explanatory.

> Also am I using deleteComposedCharacterBackward correctly? It seems a little bit weird to fire two beforeinput for one compositionupdate...

Yes, this looks correctly to me.


---
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/128#issuecomment-223749706

Received on Saturday, 4 June 2016 11:01:10 UTC