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.
Would you be open to providing an option for this now, rather than later? It’s fine if it is still in its own special branch. We want to test this at Replit but we’d like to be able to restrict it to just our opt-in beta testers. It would also let us do a semi-graceful fallback if we detect errors.
I’ve published a 6.26.4-edit-context.1 that allows you do EditorView.EDIT_CONTEXT = false to disable use of edit context. This will not be a stable feature, just a kludge that exists as long as this is experimental.
@codemirror/view 6.28.0 ships with EditContext support. It would have been nice to get some more testing feedback, but I guess we’re now going to test in production.
I have been using codemirror in my day job, and I was stuck by this change for 2 days.
The problem is when I try to rename a file outside of codemirror, codemirror stealed the keyboard input.
I have debugged this issue for a long time, I attached event listeners to the rename input , keydown/keyup fires, but beforeinput/input not fired, because codemirror stealed the keyboard input
my current solution is to downgrade codemirror to v6.28.1.
is there an option to enable/disable EditorContext manually?