@ckeditor/ckeditor5-emoji 0.0.0-nightly-20250217.0 → 0.0.1
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/LICENSE.md +5 -16
- package/README.md +3 -30
- package/package.json +5 -58
- package/CHANGELOG.md +0 -4
- package/build/emoji.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/ckeditor5-metadata.json +0 -45
- package/dist/index-content.css +0 -4
- package/dist/index-editor.css +0 -111
- package/dist/index.css +0 -143
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -1698
- package/dist/index.js.map +0 -1
- package/dist/translations/af.d.ts +0 -8
- package/dist/translations/af.js +0 -5
- package/dist/translations/af.umd.js +0 -11
- package/dist/translations/ar.d.ts +0 -8
- package/dist/translations/ar.js +0 -5
- package/dist/translations/ar.umd.js +0 -11
- package/dist/translations/ast.d.ts +0 -8
- package/dist/translations/ast.js +0 -5
- package/dist/translations/ast.umd.js +0 -11
- package/dist/translations/az.d.ts +0 -8
- package/dist/translations/az.js +0 -5
- package/dist/translations/az.umd.js +0 -11
- package/dist/translations/bg.d.ts +0 -8
- package/dist/translations/bg.js +0 -5
- package/dist/translations/bg.umd.js +0 -11
- package/dist/translations/bn.d.ts +0 -8
- package/dist/translations/bn.js +0 -5
- package/dist/translations/bn.umd.js +0 -11
- package/dist/translations/bs.d.ts +0 -8
- package/dist/translations/bs.js +0 -5
- package/dist/translations/bs.umd.js +0 -11
- package/dist/translations/ca.d.ts +0 -8
- package/dist/translations/ca.js +0 -5
- package/dist/translations/ca.umd.js +0 -11
- package/dist/translations/cs.d.ts +0 -8
- package/dist/translations/cs.js +0 -5
- package/dist/translations/cs.umd.js +0 -11
- package/dist/translations/da.d.ts +0 -8
- package/dist/translations/da.js +0 -5
- package/dist/translations/da.umd.js +0 -11
- package/dist/translations/de-ch.d.ts +0 -8
- package/dist/translations/de-ch.js +0 -5
- package/dist/translations/de-ch.umd.js +0 -11
- package/dist/translations/de.d.ts +0 -8
- package/dist/translations/de.js +0 -5
- package/dist/translations/de.umd.js +0 -11
- package/dist/translations/el.d.ts +0 -8
- package/dist/translations/el.js +0 -5
- package/dist/translations/el.umd.js +0 -11
- package/dist/translations/en-au.d.ts +0 -8
- package/dist/translations/en-au.js +0 -5
- package/dist/translations/en-au.umd.js +0 -11
- package/dist/translations/en-gb.d.ts +0 -8
- package/dist/translations/en-gb.js +0 -5
- package/dist/translations/en-gb.umd.js +0 -11
- package/dist/translations/en.d.ts +0 -8
- package/dist/translations/en.js +0 -5
- package/dist/translations/en.umd.js +0 -11
- package/dist/translations/eo.d.ts +0 -8
- package/dist/translations/eo.js +0 -5
- package/dist/translations/eo.umd.js +0 -11
- package/dist/translations/es-co.d.ts +0 -8
- package/dist/translations/es-co.js +0 -5
- package/dist/translations/es-co.umd.js +0 -11
- package/dist/translations/es.d.ts +0 -8
- package/dist/translations/es.js +0 -5
- package/dist/translations/es.umd.js +0 -11
- package/dist/translations/et.d.ts +0 -8
- package/dist/translations/et.js +0 -5
- package/dist/translations/et.umd.js +0 -11
- package/dist/translations/eu.d.ts +0 -8
- package/dist/translations/eu.js +0 -5
- package/dist/translations/eu.umd.js +0 -11
- package/dist/translations/fa.d.ts +0 -8
- package/dist/translations/fa.js +0 -5
- package/dist/translations/fa.umd.js +0 -11
- package/dist/translations/fi.d.ts +0 -8
- package/dist/translations/fi.js +0 -5
- package/dist/translations/fi.umd.js +0 -11
- package/dist/translations/fr.d.ts +0 -8
- package/dist/translations/fr.js +0 -5
- package/dist/translations/fr.umd.js +0 -11
- package/dist/translations/gl.d.ts +0 -8
- package/dist/translations/gl.js +0 -5
- package/dist/translations/gl.umd.js +0 -11
- package/dist/translations/gu.d.ts +0 -8
- package/dist/translations/gu.js +0 -5
- package/dist/translations/gu.umd.js +0 -11
- package/dist/translations/he.d.ts +0 -8
- package/dist/translations/he.js +0 -5
- package/dist/translations/he.umd.js +0 -11
- package/dist/translations/hi.d.ts +0 -8
- package/dist/translations/hi.js +0 -5
- package/dist/translations/hi.umd.js +0 -11
- package/dist/translations/hr.d.ts +0 -8
- package/dist/translations/hr.js +0 -5
- package/dist/translations/hr.umd.js +0 -11
- package/dist/translations/hu.d.ts +0 -8
- package/dist/translations/hu.js +0 -5
- package/dist/translations/hu.umd.js +0 -11
- package/dist/translations/hy.d.ts +0 -8
- package/dist/translations/hy.js +0 -5
- package/dist/translations/hy.umd.js +0 -11
- package/dist/translations/id.d.ts +0 -8
- package/dist/translations/id.js +0 -5
- package/dist/translations/id.umd.js +0 -11
- package/dist/translations/it.d.ts +0 -8
- package/dist/translations/it.js +0 -5
- package/dist/translations/it.umd.js +0 -11
- package/dist/translations/ja.d.ts +0 -8
- package/dist/translations/ja.js +0 -5
- package/dist/translations/ja.umd.js +0 -11
- package/dist/translations/jv.d.ts +0 -8
- package/dist/translations/jv.js +0 -5
- package/dist/translations/jv.umd.js +0 -11
- package/dist/translations/kk.d.ts +0 -8
- package/dist/translations/kk.js +0 -5
- package/dist/translations/kk.umd.js +0 -11
- package/dist/translations/km.d.ts +0 -8
- package/dist/translations/km.js +0 -5
- package/dist/translations/km.umd.js +0 -11
- package/dist/translations/kn.d.ts +0 -8
- package/dist/translations/kn.js +0 -5
- package/dist/translations/kn.umd.js +0 -11
- package/dist/translations/ko.d.ts +0 -8
- package/dist/translations/ko.js +0 -5
- package/dist/translations/ko.umd.js +0 -11
- package/dist/translations/ku.d.ts +0 -8
- package/dist/translations/ku.js +0 -5
- package/dist/translations/ku.umd.js +0 -11
- package/dist/translations/lt.d.ts +0 -8
- package/dist/translations/lt.js +0 -5
- package/dist/translations/lt.umd.js +0 -11
- package/dist/translations/lv.d.ts +0 -8
- package/dist/translations/lv.js +0 -5
- package/dist/translations/lv.umd.js +0 -11
- package/dist/translations/ms.d.ts +0 -8
- package/dist/translations/ms.js +0 -5
- package/dist/translations/ms.umd.js +0 -11
- package/dist/translations/nb.d.ts +0 -8
- package/dist/translations/nb.js +0 -5
- package/dist/translations/nb.umd.js +0 -11
- package/dist/translations/ne.d.ts +0 -8
- package/dist/translations/ne.js +0 -5
- package/dist/translations/ne.umd.js +0 -11
- package/dist/translations/nl.d.ts +0 -8
- package/dist/translations/nl.js +0 -5
- package/dist/translations/nl.umd.js +0 -11
- package/dist/translations/no.d.ts +0 -8
- package/dist/translations/no.js +0 -5
- package/dist/translations/no.umd.js +0 -11
- package/dist/translations/oc.d.ts +0 -8
- package/dist/translations/oc.js +0 -5
- package/dist/translations/oc.umd.js +0 -11
- package/dist/translations/pl.d.ts +0 -8
- package/dist/translations/pl.js +0 -5
- package/dist/translations/pl.umd.js +0 -11
- package/dist/translations/pt-br.d.ts +0 -8
- package/dist/translations/pt-br.js +0 -5
- package/dist/translations/pt-br.umd.js +0 -11
- package/dist/translations/pt.d.ts +0 -8
- package/dist/translations/pt.js +0 -5
- package/dist/translations/pt.umd.js +0 -11
- package/dist/translations/ro.d.ts +0 -8
- package/dist/translations/ro.js +0 -5
- package/dist/translations/ro.umd.js +0 -11
- package/dist/translations/ru.d.ts +0 -8
- package/dist/translations/ru.js +0 -5
- package/dist/translations/ru.umd.js +0 -11
- package/dist/translations/si.d.ts +0 -8
- package/dist/translations/si.js +0 -5
- package/dist/translations/si.umd.js +0 -11
- package/dist/translations/sk.d.ts +0 -8
- package/dist/translations/sk.js +0 -5
- package/dist/translations/sk.umd.js +0 -11
- package/dist/translations/sl.d.ts +0 -8
- package/dist/translations/sl.js +0 -5
- package/dist/translations/sl.umd.js +0 -11
- package/dist/translations/sq.d.ts +0 -8
- package/dist/translations/sq.js +0 -5
- package/dist/translations/sq.umd.js +0 -11
- package/dist/translations/sr-latn.d.ts +0 -8
- package/dist/translations/sr-latn.js +0 -5
- package/dist/translations/sr-latn.umd.js +0 -11
- package/dist/translations/sr.d.ts +0 -8
- package/dist/translations/sr.js +0 -5
- package/dist/translations/sr.umd.js +0 -11
- package/dist/translations/sv.d.ts +0 -8
- package/dist/translations/sv.js +0 -5
- package/dist/translations/sv.umd.js +0 -11
- package/dist/translations/th.d.ts +0 -8
- package/dist/translations/th.js +0 -5
- package/dist/translations/th.umd.js +0 -11
- package/dist/translations/ti.d.ts +0 -8
- package/dist/translations/ti.js +0 -5
- package/dist/translations/ti.umd.js +0 -11
- package/dist/translations/tk.d.ts +0 -8
- package/dist/translations/tk.js +0 -5
- package/dist/translations/tk.umd.js +0 -11
- package/dist/translations/tr.d.ts +0 -8
- package/dist/translations/tr.js +0 -5
- package/dist/translations/tr.umd.js +0 -11
- package/dist/translations/tt.d.ts +0 -8
- package/dist/translations/tt.js +0 -5
- package/dist/translations/tt.umd.js +0 -11
- package/dist/translations/ug.d.ts +0 -8
- package/dist/translations/ug.js +0 -5
- package/dist/translations/ug.umd.js +0 -11
- package/dist/translations/uk.d.ts +0 -8
- package/dist/translations/uk.js +0 -5
- package/dist/translations/uk.umd.js +0 -11
- package/dist/translations/ur.d.ts +0 -8
- package/dist/translations/ur.js +0 -5
- package/dist/translations/ur.umd.js +0 -11
- package/dist/translations/uz.d.ts +0 -8
- package/dist/translations/uz.js +0 -5
- package/dist/translations/uz.umd.js +0 -11
- package/dist/translations/vi.d.ts +0 -8
- package/dist/translations/vi.js +0 -5
- package/dist/translations/vi.umd.js +0 -11
- package/dist/translations/zh-cn.d.ts +0 -8
- package/dist/translations/zh-cn.js +0 -5
- package/dist/translations/zh-cn.umd.js +0 -11
- package/dist/translations/zh.d.ts +0 -8
- package/dist/translations/zh.js +0 -5
- package/dist/translations/zh.umd.js +0 -11
- package/lang/contexts.json +0 -24
- package/lang/translations/af.po +0 -100
- package/lang/translations/ar.po +0 -100
- package/lang/translations/ast.po +0 -100
- package/lang/translations/az.po +0 -100
- package/lang/translations/bg.po +0 -100
- package/lang/translations/bn.po +0 -100
- package/lang/translations/bs.po +0 -100
- package/lang/translations/ca.po +0 -100
- package/lang/translations/cs.po +0 -100
- package/lang/translations/da.po +0 -100
- package/lang/translations/de-ch.po +0 -100
- package/lang/translations/de.po +0 -100
- package/lang/translations/el.po +0 -100
- package/lang/translations/en-au.po +0 -100
- package/lang/translations/en-gb.po +0 -100
- package/lang/translations/en.po +0 -100
- package/lang/translations/eo.po +0 -100
- package/lang/translations/es-co.po +0 -100
- package/lang/translations/es.po +0 -100
- package/lang/translations/et.po +0 -100
- package/lang/translations/eu.po +0 -100
- package/lang/translations/fa.po +0 -100
- package/lang/translations/fi.po +0 -100
- package/lang/translations/fr.po +0 -100
- package/lang/translations/gl.po +0 -100
- package/lang/translations/gu.po +0 -100
- package/lang/translations/he.po +0 -100
- package/lang/translations/hi.po +0 -100
- package/lang/translations/hr.po +0 -100
- package/lang/translations/hu.po +0 -100
- package/lang/translations/hy.po +0 -100
- package/lang/translations/id.po +0 -100
- package/lang/translations/it.po +0 -100
- package/lang/translations/ja.po +0 -100
- package/lang/translations/jv.po +0 -100
- package/lang/translations/kk.po +0 -100
- package/lang/translations/km.po +0 -100
- package/lang/translations/kn.po +0 -100
- package/lang/translations/ko.po +0 -100
- package/lang/translations/ku.po +0 -100
- package/lang/translations/lt.po +0 -100
- package/lang/translations/lv.po +0 -100
- package/lang/translations/ms.po +0 -100
- package/lang/translations/nb.po +0 -100
- package/lang/translations/ne.po +0 -100
- package/lang/translations/nl.po +0 -100
- package/lang/translations/no.po +0 -100
- package/lang/translations/oc.po +0 -100
- package/lang/translations/pl.po +0 -100
- package/lang/translations/pt-br.po +0 -100
- package/lang/translations/pt.po +0 -100
- package/lang/translations/ro.po +0 -100
- package/lang/translations/ru.po +0 -100
- package/lang/translations/si.po +0 -100
- package/lang/translations/sk.po +0 -100
- package/lang/translations/sl.po +0 -100
- package/lang/translations/sq.po +0 -100
- package/lang/translations/sr-latn.po +0 -100
- package/lang/translations/sr.po +0 -100
- package/lang/translations/sv.po +0 -100
- package/lang/translations/th.po +0 -100
- package/lang/translations/ti.po +0 -100
- package/lang/translations/tk.po +0 -100
- package/lang/translations/tr.po +0 -100
- package/lang/translations/tt.po +0 -100
- package/lang/translations/ug.po +0 -100
- package/lang/translations/uk.po +0 -100
- package/lang/translations/ur.po +0 -100
- package/lang/translations/uz.po +0 -100
- package/lang/translations/vi.po +0 -100
- package/lang/translations/zh-cn.po +0 -100
- package/lang/translations/zh.po +0 -100
- package/src/augmentation.d.ts +0 -25
- package/src/augmentation.js +0 -5
- package/src/emoji.d.ts +0 -32
- package/src/emoji.js +0 -38
- package/src/emojicommand.d.ts +0 -24
- package/src/emojicommand.js +0 -33
- package/src/emojiconfig.d.ts +0 -98
- package/src/emojiconfig.js +0 -5
- package/src/emojimention.d.ts +0 -75
- package/src/emojimention.js +0 -210
- package/src/emojipicker.d.ts +0 -97
- package/src/emojipicker.js +0 -255
- package/src/emojirepository.d.ts +0 -169
- package/src/emojirepository.js +0 -290
- package/src/emojiutils.d.ts +0 -58
- package/src/emojiutils.js +0 -141
- package/src/index.d.ts +0 -15
- package/src/index.js +0 -14
- package/src/ui/emojicategoriesview.d.ts +0 -68
- package/src/ui/emojicategoriesview.js +0 -131
- package/src/ui/emojigridview.d.ts +0 -140
- package/src/ui/emojigridview.js +0 -183
- package/src/ui/emojipickerview.d.ts +0 -91
- package/src/ui/emojipickerview.js +0 -173
- package/src/ui/emojisearchview.d.ts +0 -51
- package/src/ui/emojisearchview.js +0 -89
- package/src/ui/emojitoneview.d.ts +0 -46
- package/src/ui/emojitoneview.js +0 -89
- package/src/utils/isemojisupported.d.ts +0 -11
- package/src/utils/isemojisupported.js +0 -68
- package/theme/emojicategories.css +0 -29
- package/theme/emojigrid.css +0 -55
- package/theme/emojipicker.css +0 -32
- package/theme/emojitone.css +0 -21
package/src/emojirepository.d.ts
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { type Editor, Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import EmojiUtils from './emojiutils.js';
|
|
7
|
-
import type { SkinToneId } from './emojiconfig.js';
|
|
8
|
-
/**
|
|
9
|
-
* The emoji repository plugin.
|
|
10
|
-
*
|
|
11
|
-
* Loads the emoji repository from URL during plugin initialization and provides utility methods to search it.
|
|
12
|
-
*/
|
|
13
|
-
export default class EmojiRepository extends Plugin {
|
|
14
|
-
/**
|
|
15
|
-
* A callback to resolve the {@link #_repositoryPromise} to control the return value of this promise.
|
|
16
|
-
*/
|
|
17
|
-
private _repositoryPromiseResolveCallback;
|
|
18
|
-
/**
|
|
19
|
-
* An instance of the [Fuse.js](https://www.fusejs.io/) library.
|
|
20
|
-
*/
|
|
21
|
-
private _fuseSearch;
|
|
22
|
-
/**
|
|
23
|
-
* The resolved URL from which the emoji repository is downloaded.
|
|
24
|
-
*/
|
|
25
|
-
private readonly _url;
|
|
26
|
-
/**
|
|
27
|
-
* A promise resolved after downloading the emoji collection.
|
|
28
|
-
* The promise resolves with `true` when the repository is successfully downloaded or `false` otherwise.
|
|
29
|
-
*/
|
|
30
|
-
private readonly _repositoryPromise;
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
static get requires(): readonly [typeof EmojiUtils];
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
static get pluginName(): "EmojiRepository";
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
static get isOfficialPlugin(): true;
|
|
43
|
-
/**
|
|
44
|
-
* @inheritDoc
|
|
45
|
-
*/
|
|
46
|
-
constructor(editor: Editor);
|
|
47
|
-
/**
|
|
48
|
-
* @inheritDoc
|
|
49
|
-
*/
|
|
50
|
-
init(): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Returns an array of emoji entries that match the search query.
|
|
53
|
-
* If the emoji repository is not loaded, the [Fuse.js](https://www.fusejs.io/) instance is not created,
|
|
54
|
-
* hence this method returns an empty array.
|
|
55
|
-
*
|
|
56
|
-
* @param searchQuery A search query to match emoji.
|
|
57
|
-
* @returns An array of emoji entries that match the search query.
|
|
58
|
-
*/
|
|
59
|
-
getEmojiByQuery(searchQuery: string): Array<EmojiEntry>;
|
|
60
|
-
/**
|
|
61
|
-
* Groups all emojis by categories.
|
|
62
|
-
* If the emoji repository is not loaded, it returns an empty array.
|
|
63
|
-
*
|
|
64
|
-
* @returns An array of emoji entries grouped by categories.
|
|
65
|
-
*/
|
|
66
|
-
getEmojiCategories(): Array<EmojiCategory>;
|
|
67
|
-
/**
|
|
68
|
-
* Returns an array of available skin tones.
|
|
69
|
-
*/
|
|
70
|
-
getSkinTones(): Array<SkinTone>;
|
|
71
|
-
/**
|
|
72
|
-
* Indicates whether the emoji repository has been successfully downloaded and the plugin is operational.
|
|
73
|
-
*/
|
|
74
|
-
isReady(): Promise<boolean>;
|
|
75
|
-
/**
|
|
76
|
-
* Returns the URL from which the emoji repository is downloaded. If the URL is not provided
|
|
77
|
-
* in the configuration, the default URL is used with the version from the configuration.
|
|
78
|
-
*
|
|
79
|
-
* If both the URL and version are provided, a warning is logged.
|
|
80
|
-
*/
|
|
81
|
-
private _getUrl;
|
|
82
|
-
/**
|
|
83
|
-
* Warn users on self-hosted installations that this plugin uses a CDN to fetch the emoji repository.
|
|
84
|
-
*/
|
|
85
|
-
private _warnAboutCdnUse;
|
|
86
|
-
/**
|
|
87
|
-
* Returns the emoji repository in a configured version if it is a non-empty array. Returns `null` otherwise.
|
|
88
|
-
*/
|
|
89
|
-
private _getItems;
|
|
90
|
-
/**
|
|
91
|
-
* Loads the emoji repository. If the repository is already loaded, it returns the cached result.
|
|
92
|
-
* Otherwise, it fetches the repository from the URL and adds it to the cache.
|
|
93
|
-
*/
|
|
94
|
-
private _loadAndCacheEmoji;
|
|
95
|
-
/**
|
|
96
|
-
* Normalizes the raw data fetched from CDN. By normalization, we meant:
|
|
97
|
-
*
|
|
98
|
-
* * Filter out unsupported emoji (these that will not render correctly),
|
|
99
|
-
* * Prepare skin tone variants if an emoji defines them.
|
|
100
|
-
*/
|
|
101
|
-
private _normalizeEmoji;
|
|
102
|
-
/**
|
|
103
|
-
* Versioned emoji repository.
|
|
104
|
-
*/
|
|
105
|
-
private static _results;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Represents a single group of the emoji category, e.g., "Smileys & Expressions".
|
|
109
|
-
*/
|
|
110
|
-
export type EmojiCategory = {
|
|
111
|
-
/**
|
|
112
|
-
* A name of the category.
|
|
113
|
-
*/
|
|
114
|
-
title: string;
|
|
115
|
-
/**
|
|
116
|
-
* An example emoji representing items belonging to the category.
|
|
117
|
-
*/
|
|
118
|
-
icon: string;
|
|
119
|
-
/**
|
|
120
|
-
* Group id used to assign {@link #items}.
|
|
121
|
-
*/
|
|
122
|
-
groupId: number;
|
|
123
|
-
/**
|
|
124
|
-
* An array of emojis.
|
|
125
|
-
*/
|
|
126
|
-
items: Array<EmojiEntry>;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Represents a single item fetched from the CDN.
|
|
130
|
-
*/
|
|
131
|
-
export type EmojiCdnResource = {
|
|
132
|
-
annotation: string;
|
|
133
|
-
emoji: string;
|
|
134
|
-
group: number;
|
|
135
|
-
order: number;
|
|
136
|
-
version: number;
|
|
137
|
-
emoticon?: string;
|
|
138
|
-
shortcodes?: Array<string>;
|
|
139
|
-
skins?: Array<{
|
|
140
|
-
emoji: string;
|
|
141
|
-
tone: number;
|
|
142
|
-
version: number;
|
|
143
|
-
}>;
|
|
144
|
-
tags?: Array<string>;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Represents a single emoji item used by the emoji feature.
|
|
148
|
-
*/
|
|
149
|
-
export type EmojiEntry = Omit<EmojiCdnResource, 'skins'> & {
|
|
150
|
-
skins: EmojiMap;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Represents mapping between a skin tone and its corresponding emoji.
|
|
154
|
-
*
|
|
155
|
-
* The `default` key is always present. Additional values are assigned only if an emoji supports skin tones.
|
|
156
|
-
*/
|
|
157
|
-
export type EmojiMap = {
|
|
158
|
-
[K in Exclude<SkinToneId, 'default'>]?: string;
|
|
159
|
-
} & {
|
|
160
|
-
default: string;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* Represents an emoji skin tone variant.
|
|
164
|
-
*/
|
|
165
|
-
export type SkinTone = {
|
|
166
|
-
id: SkinToneId;
|
|
167
|
-
icon: string;
|
|
168
|
-
tooltip: string;
|
|
169
|
-
};
|
package/src/emojirepository.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module emoji/emojirepository
|
|
7
|
-
*/
|
|
8
|
-
import Fuse from 'fuse.js';
|
|
9
|
-
import { groupBy } from 'lodash-es';
|
|
10
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
11
|
-
import { logWarning, version as editorVersion } from 'ckeditor5/src/utils.js';
|
|
12
|
-
import EmojiUtils from './emojiutils.js';
|
|
13
|
-
// An endpoint from which the emoji data will be downloaded during plugin initialization.
|
|
14
|
-
// The `{version}` placeholder is replaced with the value from editor config.
|
|
15
|
-
const DEFAULT_EMOJI_DATABASE_URL = 'https://cdn.ckeditor.com/ckeditor5/data/emoji/{version}/en.json';
|
|
16
|
-
const DEFAULT_EMOJI_VERSION = 16;
|
|
17
|
-
/**
|
|
18
|
-
* The emoji repository plugin.
|
|
19
|
-
*
|
|
20
|
-
* Loads the emoji repository from URL during plugin initialization and provides utility methods to search it.
|
|
21
|
-
*/
|
|
22
|
-
class EmojiRepository extends Plugin {
|
|
23
|
-
/**
|
|
24
|
-
* @inheritDoc
|
|
25
|
-
*/
|
|
26
|
-
static get requires() {
|
|
27
|
-
return [EmojiUtils];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @inheritDoc
|
|
31
|
-
*/
|
|
32
|
-
static get pluginName() {
|
|
33
|
-
return 'EmojiRepository';
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @inheritDoc
|
|
37
|
-
*/
|
|
38
|
-
static get isOfficialPlugin() {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
constructor(editor) {
|
|
45
|
-
super(editor);
|
|
46
|
-
editor.config.define('emoji', {
|
|
47
|
-
version: undefined,
|
|
48
|
-
skinTone: 'default',
|
|
49
|
-
definitionsUrl: undefined
|
|
50
|
-
});
|
|
51
|
-
this._url = this._getUrl();
|
|
52
|
-
this._repositoryPromise = new Promise(resolve => {
|
|
53
|
-
this._repositoryPromiseResolveCallback = resolve;
|
|
54
|
-
});
|
|
55
|
-
this._fuseSearch = null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @inheritDoc
|
|
59
|
-
*/
|
|
60
|
-
async init() {
|
|
61
|
-
this._warnAboutCdnUse();
|
|
62
|
-
await this._loadAndCacheEmoji();
|
|
63
|
-
const items = this._getItems();
|
|
64
|
-
// Skip plugin initialization if the emoji repository is not available.
|
|
65
|
-
// The initialization of other dependent plugins, such as `EmojiMention` and `EmojiPicker`, is prevented as well.
|
|
66
|
-
if (!items) {
|
|
67
|
-
return this._repositoryPromiseResolveCallback(false);
|
|
68
|
-
}
|
|
69
|
-
// Create instance of the Fuse.js library with configured weighted search keys and disabled fuzzy search.
|
|
70
|
-
this._fuseSearch = new Fuse(items, {
|
|
71
|
-
keys: [
|
|
72
|
-
{ name: 'emoticon', weight: 5 },
|
|
73
|
-
{ name: 'annotation', weight: 3 },
|
|
74
|
-
{ name: 'tags', weight: 1 }
|
|
75
|
-
],
|
|
76
|
-
minMatchCharLength: 2,
|
|
77
|
-
threshold: 0,
|
|
78
|
-
ignoreLocation: true
|
|
79
|
-
});
|
|
80
|
-
return this._repositoryPromiseResolveCallback(true);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Returns an array of emoji entries that match the search query.
|
|
84
|
-
* If the emoji repository is not loaded, the [Fuse.js](https://www.fusejs.io/) instance is not created,
|
|
85
|
-
* hence this method returns an empty array.
|
|
86
|
-
*
|
|
87
|
-
* @param searchQuery A search query to match emoji.
|
|
88
|
-
* @returns An array of emoji entries that match the search query.
|
|
89
|
-
*/
|
|
90
|
-
getEmojiByQuery(searchQuery) {
|
|
91
|
-
if (!this._fuseSearch) {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
const searchQueryTokens = searchQuery.split(/\s/).filter(Boolean);
|
|
95
|
-
// Perform the search only if there is at least two non-white characters next to each other.
|
|
96
|
-
const shouldSearch = searchQueryTokens.some(token => token.length >= 2);
|
|
97
|
-
if (!shouldSearch) {
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
return this._fuseSearch
|
|
101
|
-
.search({
|
|
102
|
-
'$or': [
|
|
103
|
-
{
|
|
104
|
-
emoticon: searchQuery
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
'$and': searchQueryTokens.map(token => ({ annotation: token }))
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
'$and': searchQueryTokens.map(token => ({ tags: token }))
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
})
|
|
114
|
-
.map(result => result.item);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Groups all emojis by categories.
|
|
118
|
-
* If the emoji repository is not loaded, it returns an empty array.
|
|
119
|
-
*
|
|
120
|
-
* @returns An array of emoji entries grouped by categories.
|
|
121
|
-
*/
|
|
122
|
-
getEmojiCategories() {
|
|
123
|
-
const repository = this._getItems();
|
|
124
|
-
if (!repository) {
|
|
125
|
-
return [];
|
|
126
|
-
}
|
|
127
|
-
const { t } = this.editor.locale;
|
|
128
|
-
const categories = [
|
|
129
|
-
{ title: t('Smileys & Expressions'), icon: '😀', groupId: 0 },
|
|
130
|
-
{ title: t('Gestures & People'), icon: '👋', groupId: 1 },
|
|
131
|
-
{ title: t('Animals & Nature'), icon: '🐻', groupId: 3 },
|
|
132
|
-
{ title: t('Food & Drinks'), icon: '🍎', groupId: 4 },
|
|
133
|
-
{ title: t('Travel & Places'), icon: '🚘', groupId: 5 },
|
|
134
|
-
{ title: t('Activities'), icon: '🏀', groupId: 6 },
|
|
135
|
-
{ title: t('Objects'), icon: '💡', groupId: 7 },
|
|
136
|
-
{ title: t('Symbols'), icon: '🟢', groupId: 8 },
|
|
137
|
-
{ title: t('Flags'), icon: '🏁', groupId: 9 }
|
|
138
|
-
];
|
|
139
|
-
const groups = groupBy(repository, 'group');
|
|
140
|
-
return categories.map(category => {
|
|
141
|
-
return {
|
|
142
|
-
...category,
|
|
143
|
-
items: groups[category.groupId]
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Returns an array of available skin tones.
|
|
149
|
-
*/
|
|
150
|
-
getSkinTones() {
|
|
151
|
-
const { t } = this.editor.locale;
|
|
152
|
-
return [
|
|
153
|
-
{ id: 'default', icon: '👋', tooltip: t('Default skin tone') },
|
|
154
|
-
{ id: 'light', icon: '👋🏻', tooltip: t('Light skin tone') },
|
|
155
|
-
{ id: 'medium-light', icon: '👋🏼', tooltip: t('Medium Light skin tone') },
|
|
156
|
-
{ id: 'medium', icon: '👋🏽', tooltip: t('Medium skin tone') },
|
|
157
|
-
{ id: 'medium-dark', icon: '👋🏾', tooltip: t('Medium Dark skin tone') },
|
|
158
|
-
{ id: 'dark', icon: '👋🏿', tooltip: t('Dark skin tone') }
|
|
159
|
-
];
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Indicates whether the emoji repository has been successfully downloaded and the plugin is operational.
|
|
163
|
-
*/
|
|
164
|
-
isReady() {
|
|
165
|
-
return this._repositoryPromise;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Returns the URL from which the emoji repository is downloaded. If the URL is not provided
|
|
169
|
-
* in the configuration, the default URL is used with the version from the configuration.
|
|
170
|
-
*
|
|
171
|
-
* If both the URL and version are provided, a warning is logged.
|
|
172
|
-
*/
|
|
173
|
-
_getUrl() {
|
|
174
|
-
const { definitionsUrl, version } = this.editor.config.get('emoji');
|
|
175
|
-
if (!definitionsUrl || definitionsUrl === 'cdn') {
|
|
176
|
-
// URL was not provided or is set to 'cdn', so we use the default CDN URL.
|
|
177
|
-
const urlVersion = version || DEFAULT_EMOJI_VERSION;
|
|
178
|
-
const url = new URL(DEFAULT_EMOJI_DATABASE_URL.replace('{version}', urlVersion.toString()));
|
|
179
|
-
url.searchParams.set('editorVersion', editorVersion);
|
|
180
|
-
return url;
|
|
181
|
-
}
|
|
182
|
-
if (version) {
|
|
183
|
-
/**
|
|
184
|
-
* Both {@link module:emoji/emojiconfig~EmojiConfig#definitionsUrl `emoji.definitionsUrl`} and
|
|
185
|
-
* {@link module:emoji/emojiconfig~EmojiConfig#version `emoji.version`} configuration options
|
|
186
|
-
* are set. Only the `emoji.definitionsUrl` option will be used.
|
|
187
|
-
*
|
|
188
|
-
* The `emoji.version` option will be ignored and should be removed from the configuration.
|
|
189
|
-
*
|
|
190
|
-
* @error emoji-repository-redundant-version
|
|
191
|
-
*/
|
|
192
|
-
logWarning('emoji-repository-redundant-version');
|
|
193
|
-
}
|
|
194
|
-
return new URL(definitionsUrl);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Warn users on self-hosted installations that this plugin uses a CDN to fetch the emoji repository.
|
|
198
|
-
*/
|
|
199
|
-
_warnAboutCdnUse() {
|
|
200
|
-
const editor = this.editor;
|
|
201
|
-
const config = editor.config.get('emoji');
|
|
202
|
-
const licenseKey = editor.config.get('licenseKey');
|
|
203
|
-
const distributionChannel = window[Symbol.for('cke distribution')];
|
|
204
|
-
if (licenseKey === 'GPL') {
|
|
205
|
-
// Don't warn GPL users.
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (distributionChannel === 'cloud') {
|
|
209
|
-
// Don't warn cloud users, because they already use our CDN.
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
if (config && config.definitionsUrl) {
|
|
213
|
-
// Don't warn users who have configured their own definitions URL.
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* By default, the Emoji plugin fetches the emoji repository from CKEditor 5 CDN. To avoid this,
|
|
218
|
-
* you can use the {@link module:emoji/emojiconfig~EmojiConfig#definitionsUrl `emoji.definitionsUrl`}
|
|
219
|
-
* configuration option to provide a URL to your own emoji repository.
|
|
220
|
-
*
|
|
221
|
-
* If you only want to suppress this warning, set this configuration option to `cdn`.
|
|
222
|
-
*
|
|
223
|
-
* @error emoji-repository-cdn-use
|
|
224
|
-
*/
|
|
225
|
-
logWarning('emoji-repository-cdn-use');
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Returns the emoji repository in a configured version if it is a non-empty array. Returns `null` otherwise.
|
|
229
|
-
*/
|
|
230
|
-
_getItems() {
|
|
231
|
-
const repository = EmojiRepository._results[this._url.href];
|
|
232
|
-
return repository && repository.length ? repository : null;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Loads the emoji repository. If the repository is already loaded, it returns the cached result.
|
|
236
|
-
* Otherwise, it fetches the repository from the URL and adds it to the cache.
|
|
237
|
-
*/
|
|
238
|
-
async _loadAndCacheEmoji() {
|
|
239
|
-
if (EmojiRepository._results[this._url.href]) {
|
|
240
|
-
// The repository has already been downloaded.
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const result = await fetch(this._url, { cache: 'force-cache' })
|
|
244
|
-
.then(response => {
|
|
245
|
-
if (!response.ok) {
|
|
246
|
-
return [];
|
|
247
|
-
}
|
|
248
|
-
return response.json();
|
|
249
|
-
})
|
|
250
|
-
.catch(() => {
|
|
251
|
-
return [];
|
|
252
|
-
});
|
|
253
|
-
if (!result.length) {
|
|
254
|
-
/**
|
|
255
|
-
* Unable to load the emoji repository from the URL.
|
|
256
|
-
*
|
|
257
|
-
* If the URL works properly and there is no disruption of communication, please check your
|
|
258
|
-
* {@glink getting-started/setup/csp Content Security Policy (CSP)} setting and make sure
|
|
259
|
-
* the URL connection is allowed by the editor.
|
|
260
|
-
*
|
|
261
|
-
* @error emoji-repository-load-failed
|
|
262
|
-
*/
|
|
263
|
-
logWarning('emoji-repository-load-failed');
|
|
264
|
-
}
|
|
265
|
-
EmojiRepository._results[this._url.href] = this._normalizeEmoji(result);
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Normalizes the raw data fetched from CDN. By normalization, we meant:
|
|
269
|
-
*
|
|
270
|
-
* * Filter out unsupported emoji (these that will not render correctly),
|
|
271
|
-
* * Prepare skin tone variants if an emoji defines them.
|
|
272
|
-
*/
|
|
273
|
-
_normalizeEmoji(data) {
|
|
274
|
-
const emojiUtils = this.editor.plugins.get('EmojiUtils');
|
|
275
|
-
const emojiSupportedVersionByOs = emojiUtils.getEmojiSupportedVersionByOs();
|
|
276
|
-
const container = emojiUtils.createEmojiWidthTestingContainer();
|
|
277
|
-
document.body.appendChild(container);
|
|
278
|
-
const results = data
|
|
279
|
-
.filter(item => emojiUtils.isEmojiCategoryAllowed(item))
|
|
280
|
-
.filter(item => emojiUtils.isEmojiSupported(item, emojiSupportedVersionByOs, container))
|
|
281
|
-
.map(item => emojiUtils.normalizeEmojiSkinTone(item));
|
|
282
|
-
container.remove();
|
|
283
|
-
return results;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Versioned emoji repository.
|
|
288
|
-
*/
|
|
289
|
-
EmojiRepository._results = {};
|
|
290
|
-
export default EmojiRepository;
|
package/src/emojiutils.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import type { EmojiCdnResource, EmojiEntry } from './emojirepository.js';
|
|
7
|
-
/**
|
|
8
|
-
* The Emoji utilities plugin.
|
|
9
|
-
*/
|
|
10
|
-
export default class EmojiUtils extends Plugin {
|
|
11
|
-
/**
|
|
12
|
-
* @inheritDoc
|
|
13
|
-
*/
|
|
14
|
-
static get pluginName(): "EmojiUtils";
|
|
15
|
-
/**
|
|
16
|
-
* @inheritDoc
|
|
17
|
-
*/
|
|
18
|
-
static get isOfficialPlugin(): true;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the emoji is supported by verifying the emoji version supported by the system first.
|
|
21
|
-
* Then checks if emoji contains a zero width joiner (ZWJ), and if yes, then checks if it is supported by the system.
|
|
22
|
-
*/
|
|
23
|
-
isEmojiSupported(item: EmojiCdnResource, emojiSupportedVersionByOs: number, container: HTMLDivElement): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Checks the supported emoji version by the OS, by sampling some representatives from different emoji releases.
|
|
26
|
-
*/
|
|
27
|
-
getEmojiSupportedVersionByOs(): number;
|
|
28
|
-
/**
|
|
29
|
-
* Check for ZWJ (zero width joiner) character.
|
|
30
|
-
*/
|
|
31
|
-
hasZwj(emoji: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Checks whether the emoji is supported in the operating system.
|
|
34
|
-
*/
|
|
35
|
-
isEmojiZwjSupported(item: EmojiCdnResource, container: HTMLDivElement): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Returns the width of the provided node.
|
|
38
|
-
*/
|
|
39
|
-
getNodeWidth(container: HTMLDivElement, node: string): number;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a div for emoji width testing purposes.
|
|
42
|
-
*/
|
|
43
|
-
createEmojiWidthTestingContainer(): HTMLDivElement;
|
|
44
|
-
/**
|
|
45
|
-
* Adds default skin tone property to each emoji. If emoji defines other skin tones, they are added as well.
|
|
46
|
-
*/
|
|
47
|
-
normalizeEmojiSkinTone(item: EmojiCdnResource): EmojiEntry;
|
|
48
|
-
/**
|
|
49
|
-
* Checks whether the emoji belongs to a group that is allowed.
|
|
50
|
-
*/
|
|
51
|
-
isEmojiCategoryAllowed(item: EmojiCdnResource): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* A function used to determine if emoji is supported by detecting pixels.
|
|
54
|
-
*
|
|
55
|
-
* Referenced for unit testing purposes. Kept in a separate file because of licensing.
|
|
56
|
-
*/
|
|
57
|
-
private static _isEmojiSupported;
|
|
58
|
-
}
|
package/src/emojiutils.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
6
|
-
import isEmojiSupported from './utils/isemojisupported.js';
|
|
7
|
-
/**
|
|
8
|
-
* @module emoji/emojiutils
|
|
9
|
-
*/
|
|
10
|
-
const SKIN_TONE_MAP = {
|
|
11
|
-
0: 'default',
|
|
12
|
-
1: 'light',
|
|
13
|
-
2: 'medium-light',
|
|
14
|
-
3: 'medium',
|
|
15
|
-
4: 'medium-dark',
|
|
16
|
-
5: 'dark'
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* A map representing an emoji and its release version.
|
|
20
|
-
* It's used to identify a user's minimal supported emoji level.
|
|
21
|
-
*/
|
|
22
|
-
const EMOJI_SUPPORT_LEVEL = {
|
|
23
|
-
'': 16,
|
|
24
|
-
'🫨': 15.1 // Shaking head. Although the version of emoji is 15, it is used to detect versions 15 and 15.1.
|
|
25
|
-
};
|
|
26
|
-
const BASELINE_EMOJI_WIDTH = 24;
|
|
27
|
-
/**
|
|
28
|
-
* The Emoji utilities plugin.
|
|
29
|
-
*/
|
|
30
|
-
class EmojiUtils extends Plugin {
|
|
31
|
-
/**
|
|
32
|
-
* @inheritDoc
|
|
33
|
-
*/
|
|
34
|
-
static get pluginName() {
|
|
35
|
-
return 'EmojiUtils';
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @inheritDoc
|
|
39
|
-
*/
|
|
40
|
-
static get isOfficialPlugin() {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Checks if the emoji is supported by verifying the emoji version supported by the system first.
|
|
45
|
-
* Then checks if emoji contains a zero width joiner (ZWJ), and if yes, then checks if it is supported by the system.
|
|
46
|
-
*/
|
|
47
|
-
isEmojiSupported(item, emojiSupportedVersionByOs, container) {
|
|
48
|
-
const isEmojiVersionSupported = item.version <= emojiSupportedVersionByOs;
|
|
49
|
-
if (!isEmojiVersionSupported) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
if (!this.hasZwj(item.emoji)) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
return this.isEmojiZwjSupported(item, container);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Checks the supported emoji version by the OS, by sampling some representatives from different emoji releases.
|
|
59
|
-
*/
|
|
60
|
-
getEmojiSupportedVersionByOs() {
|
|
61
|
-
return Object.entries(EMOJI_SUPPORT_LEVEL)
|
|
62
|
-
.reduce((currentVersion, [emoji, newVersion]) => {
|
|
63
|
-
if (newVersion > currentVersion && EmojiUtils._isEmojiSupported(emoji)) {
|
|
64
|
-
return newVersion;
|
|
65
|
-
}
|
|
66
|
-
return currentVersion;
|
|
67
|
-
}, 0);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Check for ZWJ (zero width joiner) character.
|
|
71
|
-
*/
|
|
72
|
-
hasZwj(emoji) {
|
|
73
|
-
return emoji.includes('\u200d');
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Checks whether the emoji is supported in the operating system.
|
|
77
|
-
*/
|
|
78
|
-
isEmojiZwjSupported(item, container) {
|
|
79
|
-
const emojiWidth = this.getNodeWidth(container, item.emoji);
|
|
80
|
-
// On Windows, some supported emoji are ~50% bigger than the baseline emoji, but what we really want to guard
|
|
81
|
-
// against are the ones that are 2x the size, because those are truly broken (person with red hair = person with
|
|
82
|
-
// floating red wig, black cat = cat with black square, polar bear = bear with snowflake, etc.)
|
|
83
|
-
// So here we set the threshold at 1.8 times the size of the baseline emoji.
|
|
84
|
-
return emojiWidth < BASELINE_EMOJI_WIDTH * 1.8;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns the width of the provided node.
|
|
88
|
-
*/
|
|
89
|
-
getNodeWidth(container, node) {
|
|
90
|
-
const span = document.createElement('span');
|
|
91
|
-
span.textContent = node;
|
|
92
|
-
container.appendChild(span);
|
|
93
|
-
const nodeWidth = span.offsetWidth;
|
|
94
|
-
container.removeChild(span);
|
|
95
|
-
return nodeWidth;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Creates a div for emoji width testing purposes.
|
|
99
|
-
*/
|
|
100
|
-
createEmojiWidthTestingContainer() {
|
|
101
|
-
const container = document.createElement('div');
|
|
102
|
-
container.setAttribute('aria-hidden', 'true');
|
|
103
|
-
container.style.position = 'absolute';
|
|
104
|
-
container.style.left = '-9999px';
|
|
105
|
-
container.style.whiteSpace = 'nowrap';
|
|
106
|
-
container.style.fontSize = BASELINE_EMOJI_WIDTH + 'px';
|
|
107
|
-
return container;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Adds default skin tone property to each emoji. If emoji defines other skin tones, they are added as well.
|
|
111
|
-
*/
|
|
112
|
-
normalizeEmojiSkinTone(item) {
|
|
113
|
-
const entry = {
|
|
114
|
-
...item,
|
|
115
|
-
skins: {
|
|
116
|
-
default: item.emoji
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
if (item.skins) {
|
|
120
|
-
item.skins.forEach(skin => {
|
|
121
|
-
const skinTone = SKIN_TONE_MAP[skin.tone];
|
|
122
|
-
entry.skins[skinTone] = skin.emoji;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return entry;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Checks whether the emoji belongs to a group that is allowed.
|
|
129
|
-
*/
|
|
130
|
-
isEmojiCategoryAllowed(item) {
|
|
131
|
-
// Category group=2 contains skin tones only, which we do not want to render.
|
|
132
|
-
return item.group !== 2;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* A function used to determine if emoji is supported by detecting pixels.
|
|
137
|
-
*
|
|
138
|
-
* Referenced for unit testing purposes. Kept in a separate file because of licensing.
|
|
139
|
-
*/
|
|
140
|
-
EmojiUtils._isEmojiSupported = isEmojiSupported;
|
|
141
|
-
export default EmojiUtils;
|
package/src/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module emoji
|
|
7
|
-
*/
|
|
8
|
-
export { default as Emoji } from './emoji.js';
|
|
9
|
-
export { default as EmojiMention } from './emojimention.js';
|
|
10
|
-
export { default as EmojiPicker } from './emojipicker.js';
|
|
11
|
-
export { default as EmojiRepository } from './emojirepository.js';
|
|
12
|
-
export { default as EmojiUtils } from './emojiutils.js';
|
|
13
|
-
export { default as EmojiCommand } from './emojicommand.js';
|
|
14
|
-
export type { EmojiConfig } from './emojiconfig.js';
|
|
15
|
-
import './augmentation.js';
|
package/src/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module emoji
|
|
7
|
-
*/
|
|
8
|
-
export { default as Emoji } from './emoji.js';
|
|
9
|
-
export { default as EmojiMention } from './emojimention.js';
|
|
10
|
-
export { default as EmojiPicker } from './emojipicker.js';
|
|
11
|
-
export { default as EmojiRepository } from './emojirepository.js';
|
|
12
|
-
export { default as EmojiUtils } from './emojiutils.js';
|
|
13
|
-
export { default as EmojiCommand } from './emojicommand.js';
|
|
14
|
-
import './augmentation.js';
|