-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Japanese input (IME) fails at the first character in a paragraph #748
Comments
I've found more accurate steps. When a paragraph includes only a
In that paragraph, Japanese input doesn't work properly. The condition I mentioned before is not enough to reproduce. |
Thanks for a detailed bug report. We're aware of problems with text composition and spent some time in the past researching this topic. Unfortunately, we haven't finished https://github.com/ckeditor/ckeditor5-typing/issues/4 and now it will need to wait. My guess here is that we remove the bogus br after the first character is inserted which may break the composition. The solution is the same as in other cases β to not render when composition takes place. But we need to figure out whether this is really a DOM structure change what breaks composition or just selection re-rendering. Perhaps it's the latter in which case we could remove the bogus br normally and only prevent selection rendering (as in ckeditor/ckeditor5-engine#861). |
Thanks you for quick response. I'll watch https://github.com/ckeditor/ckeditor5-typing/issues/4 and if something I can help you about the composition problem, I'll willingly take effort. |
OS: macOS 10.13.2 I made a quick investigation.
I found this is just selection re-rendering because https://github.com/ckeditor/ckeditor5-engine/blob/v1.0.0-alpha.2/src/view/renderer.js#L611 And why is it? The answer is two selections have different props.
I don't know why the two differs.Do you have any ideas about this? By the way, DOM Selection seems to show different behavior whether you access the HTML file via |
Yep... Working with local files is not a good idea. Random things may work slightly differently, sometimes for no good reasons.
It's hard to tell because:
Regarding "when exactly", does it happen right after typing the "m" letter? If so, then indeed one would expect that the DOM selection be after the typed "m" letter so on offset So you'd need to check these things. What exactly happens here: https://github.com/ckeditor/ckeditor5-engine/blob/v1.0.0-alpha.2/src/view/renderer.js#L198-L212 |
And regarding checking/debugging stuff in a safe way β a couple of tips:
|
Wow. That's surprising! I'll use JSON.stringify from today. |
Okay, I made a more precise exploration. patchhttps://github.com/tai2/ckeditor5-engine/commit/348c5d261696a840c32745a7625b7194e39dd797 steps
Expected result: "γ" logs
Note: keyCode 77 = KeyM What I did is really just to push 'm' then 'o'. |
For more concrete understanding, I made a screen capture. |
You might need to handle key code 229 properly. |
It's not about handling 229 button. We don't handle buttons because typing is about more than keydowns. In simple cases (American) there's indeed 1:1 mapping between keys and inserted letters, but in most other locations this gets tricky. E.g. in Polish Alt+A will insert "Δ ", in Spanish pressing ' and then A will insert "Γ‘" and different quotes characters will be inserted. And so on. The extreme here is the IME where the actual text, as you know, is being composed for a longer time, you have the entire widget with suggestions, ability to move left/right, change words, etc. Therefore, since information about keys is not sufficient, we let the browser insert text and, based on mutations, discover what was inserted into the editor. Using this information, we update the model. We need to apply there minimal changes through operations. So e.g. When the user has such a selection:
Then, we convert these changes to the view. The view is still in the Finally, we check whether we need to render anything. Since the user typed letter "f" and the browser inserted it into the DOM (which resulted in mutations from which we started), the DOM also contains Thanks to the fact that we don't touch the DOM if not needed we don't break the IME. At least β we shouldn't if everything worked fine. E.g., if typing "f" should start a composition, then if we would either change the selection or the DOM, even if the final structure and selection would be identical, the IME would be reset. |
I'll try to analyse your logs later on today. |
Thanks. Please tell me if you need more detailed logs. |
OK, this bit is enough:
The first rendering touches
Since
So, the One of these (removing the <p>[]m</p> This is corrected right after because the expected selection offset is === What you could check next is what exactly happens in |
Something differs. It doesn't seem to be touched. To make the situation clearer, I bring the logs after browser reload. patchhttps://github.com/tai2/ckeditor5-engine/commit/ebb906014665114302f16096536480b6a4c17a55 Reload browser
Focus to editor
Press m
|
DUP was reported in #795. |
There is a difference on DOM selection between English and Japanese mode. You can see the difference here: https://codepen.io/tai2/pen/qxdwMX After press m key: English Input Mode
anchor offset: 1 Japanse Input ModePlease note the underline indicating selection range
anchor offset: 0 This difference results in DOM selection retouching in Japanese environment. I dug the CKEditor5 code deeply and realized why this retouching is occurred. |
SummaryWhen users press m in Japanese IME, internal model becomes What happensinitial model:
ExtraI think, to fix this problem, MutationHandler. _handleTextNodeInsertion needs to take If you decided to pass
I hope this report helps you fix the problem. |
Nice analysis of this issue @tai2! One strange thing I noticed is that I'm not able to reproduce this issue in the exact same manner. While typing The thing I noticed while watching attached Also the fact which @tai2 mentioned that blocking selection resolves the issue:
does not solve the issue I my case, which may mean that these both are separate issues. In my case, blocking children rerendering during composition solves it. Anyway, if selection is the case in this one, it should be solved with https://github.com/ckeditor/ckeditor5-engine/issues/460 (if not there are also tickets for other cases like elements rerendering - see #802 (comment)). |
@f1ames Apple introduced completely different Japanese IME on 10.10 Yosemite. If you use 10.9 or former, it might behave different. I tried Google Japanese IME Hiragana mode and checked the problem is reproduced as well. |
I noticed the video, which was made by one of colleagues, was captured in Google Japanese environment. |
The situation I described above occurs only on Chrome. |
Thanks @tai2, I will take a look at Google Japanese IME. Btw. could you share any insight why some people prefer Google IME over native one? Is it more convenient, have more functionality or is it just a matter of pure preferences? As for software version I tested on: |
Because it provides cleverer word suggestions than others based on their machine learning. |
Hello @tai2, |
I tested v11.0.1 with some Japanese IME on macOS 10.13.6.
Excellent! |
@tai2 thank you for rechecking this issue. Great news! π |
It may be a regression. Could you report a new ticket? |
π Is this a bug report or feature request? (choose one)
π» Version of CKEditor
ver1.0.0-alpha.2, classic, balloon and inline build
π Steps to reproduce
In macOS environment:
β Expected result
Editor displays "γγ"
β Actual result
Editor displays "mγγ"
π Other details that might be useful
In Japanese, we use special input method for inputting our language. Other asian region like Chinese or Korea also uses their special methods.
Typically, we Japanese type some keystrokes which express Japanese pronunciation, then press space key some times to convert these keystrokes into proper Japanese characters.
The text was updated successfully, but these errors were encountered: