Fix missing characters caused by concurrent editing

pull/1/head
yflory 6 years ago
parent 331197197a
commit 015449832c

@ -694,6 +694,18 @@ define([
the first such keypress will not be inserted into the P. */
inner.addEventListener('keydown', cursor.brFix);
/*
CkEditor emits a change event when it detects new content in the editable area.
Our problem is that this event is sent asynchronously and late after a keystroke.
The result is that between the keystroke and the change event, chainpad may
receive remote changes and so it can wipe the newly inserted content (because
chainpad work synchronously), and the merged text is missing a few characters.
To fix this, we have to call `framework.localChange` sooner. We can't listen for
the "keypress" event because it is trigger before the character is inserted.
The solution is the "input" event, triggered by the browser as soon as the
character is inserted.
*/
inner.addEventListener('input', framework.localChange);
editor.on('change', framework.localChange);
// export the typing tests to the window.

Loading…
Cancel
Save