Chrome has started shipping edit context, a feature that allows JavaScript to intercept editing actions, including composition-based ones, in a way that isn’t as problematic as the old ‘just see how the DOM changes and hope for the best’ approach. Mozilla is considering the proposal but hasn’t put out a position yet. Apple is responding with deafening silence as usual.
I’m generally a bit wary of Blink-only APIs, but since this may help tame the endless mess of virtual keyboard behavior on Andoid, I built a proof-of-concept implementation that uses this feature, when available, to capture text input. The interface was surprisingly pleasant to use, and fits into CodeMirror rather well. My implementation is in this branch, and available as @codemirror/view 6.26.4-edit-context on npm (under a separate tag).
I would appreciate help testing this. I’m sure there will be new bugs, both in my integration and in Chrome itself (I already ran into a rather bad one in Chrome), but those can hopefully be found and worked out in the near future. Once I’m more confident this is solid, I’ll move it to the main branch, possibly, depending on how solid, behind an option.