@ckeditor/ckeditor5-emoji 44.3.0-alpha.4 β†’ 44.3.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-emoji",
3
- "version": "44.3.0-alpha.4",
3
+ "version": "44.3.0-alpha.6",
4
4
  "description": "Emoji feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,12 +13,12 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "@ckeditor/ckeditor5-core": "44.3.0-alpha.4",
17
- "@ckeditor/ckeditor5-mention": "44.3.0-alpha.4",
18
- "@ckeditor/ckeditor5-typing": "44.3.0-alpha.4",
19
- "@ckeditor/ckeditor5-ui": "44.3.0-alpha.4",
20
- "@ckeditor/ckeditor5-utils": "44.3.0-alpha.4",
21
- "ckeditor5": "44.3.0-alpha.4",
16
+ "@ckeditor/ckeditor5-core": "44.3.0-alpha.6",
17
+ "@ckeditor/ckeditor5-mention": "44.3.0-alpha.6",
18
+ "@ckeditor/ckeditor5-typing": "44.3.0-alpha.6",
19
+ "@ckeditor/ckeditor5-ui": "44.3.0-alpha.6",
20
+ "@ckeditor/ckeditor5-utils": "44.3.0-alpha.6",
21
+ "ckeditor5": "44.3.0-alpha.6",
22
22
  "fuzzysort": "3.1.0",
23
23
  "lodash-es": "4.17.21"
24
24
  },
@@ -93,6 +93,17 @@ export interface EmojiConfig {
93
93
  * option is provided, `version` is ignored as the defined URL takes precedence over the `version`.
94
94
  */
95
95
  version?: EmojiVersion;
96
+ /**
97
+ * The availability of the emoji depends on the operating system. Different systems will have different Unicode support.
98
+ *
99
+ * By default, the feature tries to filter out emojis not supported by your operating system.
100
+ * This means that instead of previewing an emoji, the feature renders a black square.
101
+ *
102
+ * If you customize the {@glink features/emoji#emoji-availability-and-appearance emoji availability and appearance}, it is
103
+ * highly recommended to disable the filtering mechanism because it uses a font built into your system
104
+ * instead of the provided custom font.
105
+ */
106
+ useCustomFont?: boolean;
96
107
  }
97
108
  export type SkinToneId = 'default' | 'light' | 'medium-light' | 'medium' | 'medium-dark' | 'dark';
98
109
  export type EmojiVersion = 15 | 16;
@@ -166,3 +166,12 @@ export type SkinTone = {
166
166
  icon: string;
167
167
  tooltip: string;
168
168
  };
169
+ /**
170
+ * Unable to load the emoji repository from the URL.
171
+ *
172
+ * If the URL works properly and there is no disruption of communication, please check your
173
+ * {@glink getting-started/setup/csp Content Security Policy (CSP)} setting and make sure
174
+ * the URL connection is allowed by the editor.
175
+ *
176
+ * @error emoji-repository-load-failed
177
+ */
@@ -46,7 +46,8 @@ class EmojiRepository extends Plugin {
46
46
  editor.config.define('emoji', {
47
47
  version: undefined,
48
48
  skinTone: 'default',
49
- definitionsUrl: undefined
49
+ definitionsUrl: undefined,
50
+ useCustomFont: false
50
51
  });
51
52
  this._url = this._getUrl();
52
53
  this._repositoryPromise = new Promise(resolve => {
@@ -62,6 +63,15 @@ class EmojiRepository extends Plugin {
62
63
  await this._loadAndCacheEmoji();
63
64
  this._items = this._getItems();
64
65
  if (!this._items) {
66
+ /**
67
+ * Unable to identify the available emoji to display.
68
+ *
69
+ * See the {@glink features/emoji#troubleshooting troubleshooting} section in the {@glink features/emoji Emoji feature} guide
70
+ * for more details.
71
+ *
72
+ * @error emoji-repository-empty
73
+ */
74
+ logWarning('emoji-repository-empty');
65
75
  return this._repositoryPromiseResolveCallback(false);
66
76
  }
67
77
  return this._repositoryPromiseResolveCallback(true);
@@ -116,14 +126,14 @@ class EmojiRepository extends Plugin {
116
126
  }
117
127
  const { t } = this.editor.locale;
118
128
  const categories = [
119
- { title: t('Smileys & Expressions'), icon: 'πŸ˜€', groupId: 0 },
129
+ { title: t('Smileys & Expressions'), icon: 'πŸ˜„', groupId: 0 },
120
130
  { title: t('Gestures & People'), icon: 'πŸ‘‹', groupId: 1 },
121
131
  { title: t('Animals & Nature'), icon: '🐻', groupId: 3 },
122
132
  { title: t('Food & Drinks'), icon: '🍎', groupId: 4 },
123
133
  { title: t('Travel & Places'), icon: '🚘', groupId: 5 },
124
134
  { title: t('Activities'), icon: 'πŸ€', groupId: 6 },
125
135
  { title: t('Objects'), icon: 'πŸ’‘', groupId: 7 },
126
- { title: t('Symbols'), icon: '🟒', groupId: 8 },
136
+ { title: t('Symbols'), icon: 'πŸ”΅', groupId: 8 },
127
137
  { title: t('Flags'), icon: '🏁', groupId: 9 }
128
138
  ];
129
139
  const groups = groupBy(repository, 'group');
@@ -242,18 +252,6 @@ class EmojiRepository extends Plugin {
242
252
  .catch(() => {
243
253
  return [];
244
254
  });
245
- if (!result.length) {
246
- /**
247
- * Unable to load the emoji repository from the URL.
248
- *
249
- * If the URL works properly and there is no disruption of communication, please check your
250
- * {@glink getting-started/setup/csp Content Security Policy (CSP)} setting and make sure
251
- * the URL connection is allowed by the editor.
252
- *
253
- * @error emoji-repository-load-failed
254
- */
255
- logWarning('emoji-repository-load-failed');
256
- }
257
255
  EmojiRepository._results[this._url.href] = this._normalizeEmoji(result);
258
256
  }
259
257
  /**
@@ -263,12 +261,18 @@ class EmojiRepository extends Plugin {
263
261
  * * Prepare skin tone variants if an emoji defines them.
264
262
  */
265
263
  _normalizeEmoji(data) {
266
- const emojiUtils = this.editor.plugins.get('EmojiUtils');
264
+ const editor = this.editor;
265
+ const useCustomFont = editor.config.get('emoji.useCustomFont');
266
+ const emojiUtils = editor.plugins.get('EmojiUtils');
267
+ const insertableEmoji = data.filter(item => emojiUtils.isEmojiCategoryAllowed(item));
268
+ // When using a custom font, the feature does not filter any emoji.
269
+ if (useCustomFont) {
270
+ return insertableEmoji.map(item => emojiUtils.normalizeEmojiSkinTone(item));
271
+ }
267
272
  const emojiSupportedVersionByOs = emojiUtils.getEmojiSupportedVersionByOs();
268
273
  const container = emojiUtils.createEmojiWidthTestingContainer();
269
274
  document.body.appendChild(container);
270
- const results = data
271
- .filter(item => emojiUtils.isEmojiCategoryAllowed(item))
275
+ const results = insertableEmoji
272
276
  .filter(item => emojiUtils.isEmojiSupported(item, emojiSupportedVersionByOs, container))
273
277
  .map(item => emojiUtils.normalizeEmojiSkinTone(item));
274
278
  container.remove();
@@ -280,3 +284,12 @@ class EmojiRepository extends Plugin {
280
284
  */
281
285
  EmojiRepository._results = {};
282
286
  export default EmojiRepository;
287
+ /**
288
+ * Unable to load the emoji repository from the URL.
289
+ *
290
+ * If the URL works properly and there is no disruption of communication, please check your
291
+ * {@glink getting-started/setup/csp Content Security Policy (CSP)} setting and make sure
292
+ * the URL connection is allowed by the editor.
293
+ *
294
+ * @error emoji-repository-load-failed
295
+ */
package/src/emojiutils.js CHANGED
@@ -18,10 +18,22 @@ const SKIN_TONE_MAP = {
18
18
  /**
19
19
  * A map representing an emoji and its release version.
20
20
  * It's used to identify a user's minimal supported emoji level.
21
+ * We skip versions with older patches, such as 15.0 instead of 15.1 etc.
21
22
  */
22
23
  const EMOJI_SUPPORT_LEVEL = {
23
24
  '🫩': 16,
24
- '🫨': 15.1 // Shaking head. Although the version of emoji is 15, it is used to detect versions 15 and 15.1.
25
+ '🫨': 15.1,
26
+ '🫠': 14,
27
+ 'πŸ˜Άβ€πŸŒ«οΈ': 13.1,
28
+ 'πŸ§‘β€πŸ’»': 12.1,
29
+ 'πŸ₯°': 11,
30
+ 'πŸ€ͺ': 5,
31
+ 'βš•οΈ': 4,
32
+ '🀣': 3,
33
+ 'πŸ‘‹πŸ½': 2,
34
+ 'πŸ˜€': 1,
35
+ '😐': 0.7,
36
+ 'πŸ˜‚': 0.6 // Face with Tears of Joy.
25
37
  };
26
38
  const BASELINE_EMOJI_WIDTH = 24;
27
39
  /**
@@ -58,13 +70,12 @@ class EmojiUtils extends Plugin {
58
70
  * Checks the supported emoji version by the OS, by sampling some representatives from different emoji releases.
59
71
  */
60
72
  getEmojiSupportedVersionByOs() {
61
- return Object.entries(EMOJI_SUPPORT_LEVEL)
62
- .reduce((currentVersion, [emoji, newVersion]) => {
63
- if (newVersion > currentVersion && EmojiUtils._isEmojiSupported(emoji)) {
64
- return newVersion;
73
+ for (const [emoji, emojiVersion] of Object.entries(EMOJI_SUPPORT_LEVEL)) {
74
+ if (EmojiUtils._isEmojiSupported(emoji)) {
75
+ return emojiVersion;
65
76
  }
66
- return currentVersion;
67
- }, 0);
77
+ }
78
+ return 0;
68
79
  }
69
80
  /**
70
81
  * Check for ZWJ (zero width joiner) character.