Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing options.updateWhenComposing #3664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Introducing options.updateWhenComposing #3664

wants to merge 1 commit into from

Conversation

mihailik
Copy link
Contributor

This option (defaulting to false) makes CodeMirror ignore composing events, switching off mobile keyboard suggestions and making mobile experience align closely with the desktop for highlighting and change handling.

The target use case of the option is rich code editing and IDEs. Those normally provide custom completions and rich contextual services, exceeding and often conflicting with mobile touch keyboard suggestions.

Hence an option to disable the platform composing smartness/substitutions.

The key downside is IME being disabled or severely handicapped when this option is set. Given that most programming languages tend to use with English and ASCII, lack of IME is seen as a reasonable tradeoff.

This option (defaulting to `false`) makes CodeMirror ignore composing events, which switches off mobile keyboard suggestions and makes mobile experience align closely with the desktop for highlighting and change handling.

The purpose of the option is rich code editing and IDEs, which provide custom completions and rich contextual services.

These IDE features tend to conflict with mobile touch keyboard suggestions.

The key downside is IME is disabled or severely handicapped when this option is enabled. Given that most programming languages tend to stick with English and ASCII, lack of IME is often a reasonable tradeoff.
@mihailik
Copy link
Contributor Author

See also discussion in #3655 [mobile] Colouring not picking changes until non-word characters

@mihailik
Copy link
Contributor Author

I've created a gist with a CodeMirror using this option and HTML mode:

Gist hosted with githack

Gist itself

URL shortener to quickly type on mobile:
http://tinyurl.com/updateWhenComposing

@marijnh
Copy link
Member

marijnh commented Nov 24, 2015

This seems to sort of work for the textarea inputStyle, but when using contenteditable it creates a mess of latin and Japanese characters when I try to use it with Japanese IME.

Also, in general, I'm rather hesistant to include such an accessibility-hostile feature in the core editor. Have you tried adding your own event handlers to somehow force composition to end as soon as it starts? That sounds like it would also be possible, and doesn't require changing the library.

@mihailik
Copy link
Contributor Author

IME is an expected downside, insignificant in the target use case: mobile code editing.

I am not aware of any accessibility issues. Both reading and writing should work just the same.

@mihailik
Copy link
Contributor Author

To put it into context, currently code editing on mobile with CodeMirror is a major pain. Because of autocorrection, lack of completion and #3653 (troubles with arrow keys).

Comparing to that, troubles with occasional ideographic in string literals/comments is very minor.

But you've mentioned composition refactoring you're planning. Would that bring back 'change' events during composition? Would you elaborate please?

Many thanks!

@marijnh
Copy link
Member

marijnh commented Nov 25, 2015

The rewrite will, if it works out the way I planned it, have the editor fire change events during composition.

In my test with your option, there we no occasional problems with IME, it was just completely broken -- inserting both the composed character and the latin variants next to each other. The code is written with the expectation that compose events are handled, and just disabling those handlers doesn't seem like it will do the right thing.

@mihailik
Copy link
Contributor Author

Sure, if a better solution is in the works let's close this one.

@marijnh
Copy link
Member

marijnh commented Nov 25, 2015

Well, the thing is, that other solution isn't something that is going to happen soon, since I have much other things to do and this isn't very high-priority. So waiting for it is likely to end with frustration.

@mihailik
Copy link
Contributor Author

Only a bit: I am keeping this option in my forked code, so it's fine in my app :-)

Or shall I try to implement that other solution?

I assume the crux of the plan is to tweak the line rendering. If composition is on (plus some extra checks), rendering will update existing elements in place, instead of recreating from scratch.

@marijnh
Copy link
Member

marijnh commented Nov 25, 2015

The plan is to just disable line re-rendering for the line that is being composed (since the entered characters will already show up), and force a composition end if something else (say, a script) tries to modify that line. In addition, we have to read the actual characters that are in the composition from the DOM, since the events often contain unhelpful or even plain bogus data, and immediately update the document on each compositionupdate. I expect it's going to a bit hairy to implement, but if you want to take a stab at it, that'd be very helpful.

@mihailik
Copy link
Contributor Author

Thanks, I shall stab indeed :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants