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

Confusing characters after transform emoji using text-transformation #3147

Closed
elszczepano opened this issue Jul 5, 2019 · 9 comments · Fixed by ckeditor/ckeditor5-utils#327
Assignees
Labels
package:typing type:bug This issue reports a buggy (incorrect) behavior.

Comments

@elszczepano
Copy link
Member

Steps to reproduce:

  1. Add custom text transformation e.g.:
typing: {
    transformations: {
        extra: [
	    { from: ':)', to: '🙂' },
	    { from: ':+1:', to: '👍' },
	    { from: ':tada:', to: '🎉' }
        ]
    }
}
  1. Type e.g :tada: and then push space a few times.

2019-07-05 09 44 34

@pjasiun
Copy link

pjasiun commented Jul 5, 2019

You need very specific content to reproduce it. You can reproduce it with:

far from the truth Even the studies that conducted amost half a century show that the language you speak has more effects on you then you realise.

One of the very first experiments conducted on this topic dates back to 1964.

But it enough to remove a letter (any letter) form the first sentence and the bug does not appear anymore. Magic.

@Mgsy
Copy link
Member

Mgsy commented Jul 5, 2019

It looks like it occurs when a paragraph contains 148 or more characters.

bug_cke5

@elszczepano
Copy link
Member Author

elszczepano commented Jul 5, 2019

And bug doesn't occur when you add an emoji in the middle of a paragraph. It also occurs for headings.

@pjasiun
Copy link

pjasiun commented Jul 5, 2019

Also, you need to add an emoji at the end of the first paragraph, after the bolded text. It does not occur when you add it in the middle of the paragraph.

@Reinmar
Copy link
Member

Reinmar commented Jul 8, 2019

If it starts to happen at 148 characters, my guess will be the diff() function. At some threshold, it starts to use the fastDiff() function and my guess is that it doesn't handle two-byte unicode characters too well.

@mlewand
Copy link
Contributor

mlewand commented Jul 8, 2019

BTW it's a cross-browser bug.

@oskarwrobel
Copy link
Contributor

oskarwrobel commented Aug 21, 2019

Looks like multi-byte characters may be a problem here. When the paragraph is long enough and you start to type after a multi-byte character (It doesn't have to be directly after but in the same paragraph) then a character before the selection is inserted instead of a character you type. This may explain this weird � character because it's only one byte from a multi-byte character.

@mlewand mlewand transferred this issue from ckeditor/ckeditor5-typing Oct 9, 2019
@mlewand mlewand added this to the next milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. package:typing labels Oct 9, 2019
@elszczepano
Copy link
Member Author

It may be somehow related. If you add a lot of emojis strange characters are shown (I've shown it in a comment for simplicity - it occurs in the main editor too). Also, the editor inserts content in the other place than a marker position.

Oct-18-2019 09-11-53

@farthinker
Copy link

I found a working solution:
mycolorway/ckeditor5-typing@90cfb1c
mycolorway/ckeditor5-utils@835ac1f

These two commits make sure both diff and fastDiff correctly handle two-byte characters and the results are correctly normalized.

@Reinmar Reinmar modified the milestones: next, iteration 31 Mar 18, 2020
@niegowski niegowski self-assigned this Mar 24, 2020
Reinmar added a commit to ckeditor/ckeditor5-utils that referenced this issue Mar 27, 2020
Fix: Fixed various cases with typing multi-byte unicode sequences (e.g. emojis). Closes ckeditor/ckeditor5#3147. Closes ckeditor/ckeditor5#6495.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:typing type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants