-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Asynchronous load of emoji list #2049
Conversation
plugins/emoji/plugin.js
Outdated
@@ -158,3 +174,34 @@ | |||
* @cfg {Number} [emoji_minChars = 2] | |||
* @member CKEDITOR.config | |||
*/ | |||
|
|||
/** | |||
* Address to json file containing emoji list. File is downloaded through {@link CKEDITOR.ajax#load} method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON is an acronym should be uppercased.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
There isn't any error handling. When emojis fail to load, then editor will throw new error for every try to insert emoji. In case of failing to load emojis file, plugin should shutdown gracefully.
-
Listening to
instanceReady
event to bind all listeners fails when editor is ready before emojis are loaded (e.g. super lag on server-side). If editor is already ready, just create emoji autocomplete and init it. -
There is also very weird bug connected with undo
- Open emoji sample.
- Click into the editor.
Expected result:
Nothing happens.
Actual result:
Wild undo step appears. After applying it, preinserted emoji is changed back into text.
What's even weirder, clicking inside the editor after undoing causes redo step to disappear…
plugins/emoji/plugin.js
Outdated
|
||
/** | ||
* Address to json file containing emoji list. File is downloaded through {@link CKEDITOR.ajax#load} method | ||
* and url address is processed by {@link CKEDITOR#getUrl}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL is also an acronym ;)
25e5355
to
781de6d
Compare
… graceful shutdown in case of emoji loading error.
I've rebase branch to contain change introduced in #2032 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no tests for case when editor is loaded faster than file with emojis. There is also no test for failed loading of emojis.
I'm also not sure about current undo integration. If there's a situation when user already started typing and then emojis are loaded, selection jumps to the beginning of the editor and emoji substitution is recorded as extra undo step.
Issue reported by @Comandeer is valid. What's more imagine a case when CKEditor makes few snapshots before the Instead let's make a tough decision and drop the feature which replaced valid emoji tokens in the content, at paste, drop, etc. Ideally I'd like to keep this feature at To sum it up:
|
…us but not convert emoji during paste data to editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also some issues with support for particular emojis in IEs. Forcing OS emoji font (Segoe UI Emoji) should be a proper fix for this. However I'm not sure if it's present on systems older than Windows 10.
The other issue is support for Linux as this system AFAIR does not have any built-in font with emoji support.
|
||
if ( !match ) { | ||
return null; | ||
if ( editor.status !== 'ready' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this if
needed now, when substitution is removed and initialisation just creates autocomplete instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it's required because of this bug: #2114
Inlining this function cause random error, where plugin might be not initialised during loading stage (depend how fast json will be loaded). Error was clearly visible in Firefox browser.
return elementsPath.contains( forbiddenScope ) ? false : true; | ||
} else { | ||
return true; | ||
function initPlugin() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove the if
mentioned above, then this function could be inlined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related to previous comment :)
}, | ||
|
||
// #2036 | ||
'test custom emoji list is loadd': function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: loadd → load
'test invalid emoji list': function() { | ||
var editor = this.editors.classic2; | ||
emojiTools.runAfterInstanceReady( editor, null, function( editor ) { | ||
assert.isUndefined( editor._.emoji, 'There are created emoji private data, so emoji was loaded what is wrong for this case.' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem like good assertion message.
…ading to support emoji in IE, correct test to run on supported environments only.
Font injection for IE browser in divarea editor is extracted here: #2121 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running tests/plugins/emoji/basic
there are several errors in the console:
plugin.js:689 Uncaught TypeError: Cannot read property 'getClientRects' of undefined
at View.getViewPosition (plugin.js:689)
at View.updatePosition (plugin.js:910)
at Autocomplete.onChange (plugin.js:418)
at Autocomplete.<anonymous> (plugin.js:267)
at CKEDITOR.dom.window.listenerFirer (event.js:144)
at CKEDITOR.dom.window.CKEDITOR.event.fire (event.js:290)
at domobject.js:46
I also slightly updated sample (Firefox had some styling issues) and fixed typo in tests, which disabled ignoring.
I correct those tests. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated API docs, LGTM now!
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
What changes did you make?
Close #2036