https://ckeditor5.github.io/ <- here editor
You can check the symptoms in the image below.

I use a chrome.
Possibly related to https://github.com/ckeditor/ckeditor5/issues/777. @Reinmar?
@bjrambo, could you check whether #748 describes the bug that you encounter as well? Because you didn't state what happens and what's the expected result and I can see on your screenshot that #748 occurs there as well, but perhaps you meant also some other issues,
@Reinmar Seems to be related but different. Japanese has problem at the beginning of line. Korean has problem at the end of line.
@Mgsy, could you take a look on this?
I can confirm this issue. As you can see on the screencast, the selection is always behind inserted character (except character at the beginning of the block) and probably that's why one character moves downwards after pressing Enter.

Update: This is editor's bug. In a plain contenteditable selection is also behind the character, but after pressing Enter it moves properly to the new line without any content.
I assume that in a plain contenteditable or in CKEditor 4 the selection stays after the underlined part of the content?
Also, does a similar issue occur if you start typing at the end of a non-empty line?
I assume that in a plain contenteditable or in CKEditor 4 the selection stays after the underlined part of the content?
I've made an update to my previous comment. In a plain contenteditable the selection stays behind inserted character, but after pressing Enter it behaves properly.
Also, does a similar issue occur if you start typing at the end of a non-empty line?
Yes, behaviour is the same.
This bug isn't reproducible in Firefox and Edge, I guess because of different typing method:

I have analysed this issue in a little more detail. I suspected it might be caused by the renderer and the fact that it rerenders selection during composition which may break it.
However, it seems the cause is totally different. First of all, the fact that caret is before the last character when composing in Hangul (Korean) is already reported as a bug in a Chrome bugtracker. However as it works correctly in plain _contenteditable_ (even though selection is before the last character - enter does not move it to the new line) it means that CKEditor behaves different in some way and breaks it.
The different behaviour is caused by our custom enter handling (Enter feature) which relays on the current selection when inserting new lines (in short). Now, when typing regular text like:
<p>Foo Ba{}r</p>
and when composing Hangul:
<p>Foo γ
γ
{}γ·</p>
the native selection (and its ranges) is exactly the same showing that selection is before the last character. So relying on the native selection we are unable to tell that for Hangul the enter behaviour should be different.
This means that enter behaviour is inconsistent and I have already reported it to a Chrome team. TBH, I didn't find any other way to distinguish the Hangul case from other cases so I'm not sure if there is any reasonable way to fix it for nowπ€
@f1ames
It does not seem to be a problem with Chrome. There is no problem in ckeditor4.
Please check the image on #1117
There is no problem in ckeditor4.
CKEditor 4 works completely differently than CKEditor 5 so this Chrome's bug isn't triggered there.
Is there any idea?
The Chrome team seems not to fix this problem and it takes long time already.
We can't write sentences without "Enter key" globally (especially Korean) and I want to use CKEditor5 in developing Korean sites.
@startong21
When entering characters in the editor, if the character you want to input is "enter", if the previous character is Korean, you have moved to the right and tried to "enter". However, unlike ckeditor version 4, we stopped the fix.
Please note that below is not a complete source code.
var ck5LastHan = false;
editor.editing.view.document.on( 'keydown', ( evt, data ) => {
var ck5pass = getKeyStatus(data.keyCode);
if(!ck5pass){
ck5LastHan = true;
}else{
ck5LastHan = false;
}
} );
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
editor.keystrokes.set( 'Enter', (data, stop ) => {
if(ck5LastHan)
{
//give up
}
}, { priority: 'high' } );
// korean char detect
function getKeyStatus(char_ASCII){
if (char_ASCII >= 48 && char_ASCII <= 57 )
return true;
else if ((char_ASCII>=65 && char_ASCII<=90) || (char_ASCII>=97 && char_ASCII<=122))
return true;
else if ((char_ASCII>=33 && char_ASCII<=47) || (char_ASCII>=58 && char_ASCII<=64)
|| (char_ASCII>=91 && char_ASCII<=96) || (char_ASCII>=123 && char_ASCII<=126))
return true;
else if (char_ASCII>=188 && char_ASCII<=190)
return true;
else if (char_ASCII>=8 && char_ASCII<=1)
return true;
return false;
}
// You will also need to add the source code above that works only with the Chrome browser.
Hello @startong21,
I have checked the 849263 issue on the latest Chrome (71.0.3578.80) on Windows and it still occurs there.
Please keep in mind that when checking this issue it is the matter of what is the state/ranges of native selection so it can't be simply checked by typing text, pressing enter and checking if last character was moved to the next line. This will work in native text fields and that's also what 849263 issue issue is about. You may take a look at the above comment https://github.com/ckeditor/ckeditor5/issues/777#issuecomment-394639005 for more technical explanation.
Hello @f1ames,
I don't have many knowledge about input method and contenteditable so I seem to talk about what it isn't easy or reasonable.
When I checked Chrome bugtracker, 653160 issue looks just caret position issue.
It means it's not functional but just design issue.
In other words, when Korean people type Korean, caret position looks strange (because the caret position is on the left and not right. some Korean says that the caret position should be on the right.), but it is just design issue. And functionally it is no problem.
But this is just Chrome style and other editors in Windows use the block design style, and you can see this in 653160 issue comment 5.
I'm not sure how I write the source code for this but how about to solve this problem like the following?
When you type the Enter key typing Korean, you move the caret to the right one step(or regarding as real caret position is right) and to new line.
And you may refer to a @Clouds101 comment for Korean character ASCII codes.
I think this can solve almost all cases of typing Korean and enter key problems.
@startong21
In ckeditor5, it is a code to check if the previous character is Korean when entering enter key.
if stop the event and enter the right key and enter key, it can be solved to some extent.
However, I did not know how to use ckeditor5's api, so I stopped modifying it in this way.
I hope this issue will be resolved with other useful ideas.
//see script console

chrome 71.0.3578.80
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>CKEditor 5 β Classic editor</title>
<script src="ckeditor/ckeditor.js"></script>
</head>
<body>
<h1>CKEditor5 Korea input test</h1>
<textarea name="content" id="editor"></textarea>
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script>
var ck5LastHan = false;
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
editor.keystrokes.set( 'Enter', (data, stop ) => {
if(ck5LastHan)
{
console.log("previous korean character");
//Stop the event and press the right key to enter the next enter key.
}
}, { priority: 'high' } );
editor.editing.view.document.on( 'keydown', ( evt, data ) => {
var ck5pass = getKeyStatus(data.keyCode);
if(!ck5pass){
ck5LastHan = true;
}else{
ck5LastHan = false;
}
} );
} )
.catch( error => {
console.error( error );
} );
function getKeyStatus(char_ASCII){
if (char_ASCII >= 48 && char_ASCII <= 57 )
return true;
else if ((char_ASCII>=65 && char_ASCII<=90) || (char_ASCII>=97 && char_ASCII<=122))
return true;
else if ((char_ASCII>=33 && char_ASCII<=47) || (char_ASCII>=58 && char_ASCII<=64)
|| (char_ASCII>=91 && char_ASCII<=96) || (char_ASCII>=123 && char_ASCII<=126))
return true;
else if (char_ASCII>=188 && char_ASCII<=190)
return true;
else if (char_ASCII>=8 && char_ASCII<=1)
return true;
return false;
}
</script>
</body>
</html>
@startong21 The issue is not a caret style/position itself but the inconsistency between caret position / native selection and the way Enter behaves in this cases. As described in #653160 and https://github.com/ckeditor/ckeditor5/issues/777#issuecomment-394639005 above:
When typing regular text like:
<p>Foo Ba{}r</p>and when composing Hangul:
<p>Foo γ γ {}γ·</p>the native selection (and its ranges) is exactly the same showing that selection is before the last character. So relying on the native selection we are unable to tell that for Hangul the enter behaviour should be different.
This means that enter behaviour is inconsistent and I have already reported it to a Chrome team.
@Clouds101 the solution may work but it will need some adjustments (still it is kind of hackish workaround). Imagine for example that someone typed Korean, then changed selection (moved caret somewhere) and then pressed Enter. So you cannot reasonably rely on only checking what was the last character typed when Enter is pressed. What could be done instead:
keydown and check if Korean character was inserted (store the result so other listeners may check it).In other words the special enter handler should only kick in when Enter is pressed directly (directly meaning that there were no other actions in-between) after typing Korean. Still I'm not 100% sure if you can reasonably handle all cases this way without breaking anything.
This issue is fixed in Chrome version 75 or later.
This issue is fixed in Chrome version 75 or later.
It's what the upstream comment also says - https://bugs.chromium.org/p/chromium/issues/detail?id=653160#c18. @Mgsy could you check if it solved the issue in the editor?
This issue has been fixed.
Most helpful comment
This issue has been fixed.