@ckeditor/ckeditor5-emoji 48.2.0 → 48.3.0-alpha.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.
@@ -1,108 +1,108 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
2
+ * @license Copyright (c) 2003-2026, 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
5
  /**
6
- * @module emoji/emojipicker
7
- */
8
- import { ContextualBalloon, Dialog } from '@ckeditor/ckeditor5-ui';
9
- import { Plugin } from '@ckeditor/ckeditor5-core';
10
- import { Typing } from '@ckeditor/ckeditor5-typing';
11
- import { EmojiRepository } from './emojirepository.js';
12
- import { EmojiPickerView } from './ui/emojipickerview.js';
13
- import { EmojiPickerFormView } from './ui/emojipickerformview.js';
14
- import type { EmojiSkinToneId } from './emojiconfig.js';
15
- import '../theme/emojipicker.css';
6
+ * @module emoji/emojipicker
7
+ */
8
+ import { ContextualBalloon, Dialog } from "@ckeditor/ckeditor5-ui";
9
+ import { Plugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
10
+ import { Typing } from "@ckeditor/ckeditor5-typing";
11
+ import { EmojiRepository } from "./emojirepository.js";
12
+ import { EmojiPickerView } from "./ui/emojipickerview.js";
13
+ import { EmojiPickerFormView } from "./ui/emojipickerformview.js";
14
+ import type { EmojiSkinToneId } from "./emojiconfig.js";
15
+ import "../theme/emojipicker.css";
16
16
  /**
17
- * The emoji picker plugin.
18
- *
19
- * Introduces the `'emoji'` dropdown.
20
- */
17
+ * The emoji picker plugin.
18
+ *
19
+ * Introduces the `'emoji'` dropdown.
20
+ */
21
21
  export declare class EmojiPicker extends Plugin {
22
- /**
23
- * The actions view displayed inside the balloon.
24
- */
25
- emojiPickerView: EmojiPickerView | undefined;
26
- /**
27
- * The form view displayed inside the balloon.
28
- */
29
- emojiPickerFormView: EmojiPickerFormView | undefined;
30
- /**
31
- * The contextual balloon plugin instance.
32
- */
33
- balloonPlugin: ContextualBalloon;
34
- /**
35
- * An instance of the {@link module:emoji/emojirepository~EmojiRepository} plugin.
36
- */
37
- emojiRepositoryPlugin: EmojiRepository;
38
- /**
39
- * @inheritDoc
40
- */
41
- static get requires(): readonly [typeof EmojiRepository, typeof ContextualBalloon, typeof Dialog, typeof Typing];
42
- /**
43
- * @inheritDoc
44
- */
45
- static get pluginName(): "EmojiPicker";
46
- /**
47
- * @inheritDoc
48
- */
49
- static get isOfficialPlugin(): true;
50
- /**
51
- * @inheritDoc
52
- */
53
- init(): Promise<void>;
54
- /**
55
- * @inheritDoc
56
- */
57
- destroy(): void;
58
- /**
59
- * Represents an active skin tone. Its value depends on the emoji UI plugin.
60
- *
61
- * Before opening the UI for the first time, the returned value is read from the editor configuration.
62
- * Otherwise, it reflects the user's intention.
63
- */
64
- get skinTone(): EmojiSkinToneId;
65
- /**
66
- * Displays the balloon with the emoji picker.
67
- *
68
- * @param [searchValue=''] A default query used to filer the grid when opening the UI.
69
- */
70
- showUI(searchValue?: string): void;
71
- /**
72
- * Creates a button for toolbar and menu bar that will show the emoji dialog.
73
- */
74
- private _createButton;
75
- /**
76
- * Creates an instance of the `EmojiPickerView` class that represents an emoji balloon.
77
- */
78
- private _createEmojiPickerView;
79
- /**
80
- * Creates an instance of the `EmojiPickerFormView` class that represents a balloon with the emoji picker.
81
- */
82
- private _createEmojiPickerFormView;
83
- /**
84
- * Hides the balloon with the emoji picker.
85
- *
86
- * @param updateFocus Whether to focus the editor after closing the emoji picker.
87
- */
88
- private _hideUI;
89
- /**
90
- * Registers converters.
91
- */
92
- private _setupConversion;
93
- /**
94
- * Returns positioning options for the {@link #balloonPlugin}. They control the way the balloon is attached
95
- * to the target element or selection.
96
- */
97
- private _getBalloonPositionData;
98
- /**
99
- * Displays a fake visual selection when the contextual balloon is displayed.
100
- *
101
- * This adds an 'emoji-picker' marker into the document that is rendered as a highlight on selected text fragment.
102
- */
103
- private _showFakeVisualSelection;
104
- /**
105
- * Hides the fake visual selection.
106
- */
107
- private _hideFakeVisualSelection;
22
+ /**
23
+ * The actions view displayed inside the balloon.
24
+ */
25
+ emojiPickerView: EmojiPickerView | undefined;
26
+ /**
27
+ * The form view displayed inside the balloon.
28
+ */
29
+ emojiPickerFormView: EmojiPickerFormView | undefined;
30
+ /**
31
+ * The contextual balloon plugin instance.
32
+ */
33
+ balloonPlugin: ContextualBalloon;
34
+ /**
35
+ * An instance of the {@link module:emoji/emojirepository~EmojiRepository} plugin.
36
+ */
37
+ emojiRepositoryPlugin: EmojiRepository;
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ static get requires(): PluginDependenciesOf<[EmojiRepository, ContextualBalloon, Dialog, Typing]>;
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ static get pluginName(): "EmojiPicker";
46
+ /**
47
+ * @inheritDoc
48
+ */
49
+ static override get isOfficialPlugin(): true;
50
+ /**
51
+ * @inheritDoc
52
+ */
53
+ init(): void;
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ override destroy(): void;
58
+ /**
59
+ * Represents an active skin tone. Its value depends on the emoji UI plugin.
60
+ *
61
+ * Before opening the UI for the first time, the returned value is read from the editor configuration.
62
+ * Otherwise, it reflects the user's intention.
63
+ */
64
+ get skinTone(): EmojiSkinToneId;
65
+ /**
66
+ * Displays the balloon with the emoji picker.
67
+ *
68
+ * @param [searchValue=''] A default query used to filer the grid when opening the UI.
69
+ */
70
+ showUI(searchValue?: string): void;
71
+ /**
72
+ * Creates a button for toolbar and menu bar that will show the emoji dialog.
73
+ */
74
+ private _createButton;
75
+ /**
76
+ * Creates an instance of the `EmojiPickerView` class that represents an emoji balloon.
77
+ */
78
+ private _createEmojiPickerView;
79
+ /**
80
+ * Creates an instance of the `EmojiPickerFormView` class that represents a balloon with the emoji picker.
81
+ */
82
+ private _createEmojiPickerFormView;
83
+ /**
84
+ * Hides the balloon with the emoji picker.
85
+ *
86
+ * @param updateFocus Whether to focus the editor after closing the emoji picker.
87
+ */
88
+ private _hideUI;
89
+ /**
90
+ * Registers converters.
91
+ */
92
+ private _setupConversion;
93
+ /**
94
+ * Returns positioning options for the balloon plugin. They control the way the balloon is attached
95
+ * to the target element or selection.
96
+ */
97
+ private _getBalloonPositionData;
98
+ /**
99
+ * Displays a fake visual selection when the contextual balloon is displayed.
100
+ *
101
+ * This adds an 'emoji-picker' marker into the document that is rendered as a highlight on selected text fragment.
102
+ */
103
+ private _showFakeVisualSelection;
104
+ /**
105
+ * Hides the fake visual selection.
106
+ */
107
+ private _hideFakeVisualSelection;
108
108
  }
@@ -1,177 +1,172 @@
1
1
  /**
2
- * @license Copyright (c) 2003-2026, 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 '@ckeditor/ckeditor5-core';
6
- import { EmojiUtils } from './emojiutils.js';
7
- import type { EmojiSkinToneId } from './emojiconfig.js';
2
+ * @license Copyright (c) 2003-2026, 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, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
6
+ import { EmojiUtils } from "./emojiutils.js";
7
+ import type { EmojiSkinToneId } from "./emojiconfig.js";
8
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
- */
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
13
  export declare 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
- * Emoji repository in a configured version.
20
- */
21
- private _items;
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 this method returns an empty array.
54
- *
55
- * @param searchQuery A search query to match emoji.
56
- * @returns An array of emoji entries that match the search query.
57
- */
58
- getEmojiByQuery(searchQuery: string): Array<EmojiEntry>;
59
- /**
60
- * Groups all emojis by categories.
61
- * If the emoji repository is not loaded, it returns an empty array.
62
- *
63
- * @returns An array of emoji entries grouped by categories.
64
- */
65
- getEmojiCategories(): Array<EmojiCategory>;
66
- /**
67
- * Returns an array of available skin tones.
68
- */
69
- getSkinTones(): Array<EmojiSkinTone>;
70
- /**
71
- * Indicates whether the emoji repository has been successfully downloaded and the plugin is operational.
72
- */
73
- isReady(): Promise<boolean>;
74
- /**
75
- * Returns the URL from which the emoji repository is downloaded. If the URL is not provided
76
- * in the configuration, the default URL is used with the version from the configuration.
77
- *
78
- * If both the URL and version are provided, a warning is logged.
79
- */
80
- private _getUrl;
81
- /**
82
- * Warn users on self-hosted installations that this plugin uses a CDN to fetch the emoji repository.
83
- */
84
- private _warnAboutCdnUse;
85
- /**
86
- * Returns the emoji repository in a configured version if it is a non-empty array. Returns `null` otherwise.
87
- */
88
- private _getItems;
89
- /**
90
- * Loads the emoji repository. If the repository is already loaded, it returns the cached result.
91
- * Otherwise, it fetches the repository from the URL and adds it to the cache.
92
- */
93
- private _loadAndCacheEmoji;
94
- /**
95
- * Normalizes the raw data fetched from CDN. By normalization, we meant:
96
- *
97
- * * Filter out unsupported emoji (these that will not render correctly),
98
- * * Prepare skin tone variants if an emoji defines them.
99
- */
100
- private _normalizeEmoji;
101
- /**
102
- * Versioned emoji repository.
103
- */
104
- private static _results;
14
+ /**
15
+ * Whether the emoji repository has been successfully loaded.
16
+ *
17
+ * - `null` – the repository is still being loaded (initial state).
18
+ * - `true` – the repository has been loaded successfully.
19
+ * - `false` – the repository failed to load (e.g. network error or empty response).
20
+ */
21
+ isRepositoryReady: boolean | null;
22
+ /**
23
+ * The resolved URL from which the emoji repository is downloaded.
24
+ */
25
+ private readonly _url;
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get requires(): PluginDependenciesOf<[EmojiUtils]>;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ static get pluginName(): "EmojiRepository";
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ static override get isOfficialPlugin(): true;
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ constructor(editor: Editor);
42
+ /**
43
+ * @inheritDoc
44
+ */
45
+ init(): void;
46
+ /**
47
+ * Calls `callback` once the repository finishes loading, passing the result as the argument.
48
+ *
49
+ * @param callback Receives `true` when the repository loaded successfully, `false` on failure.
50
+ * Note: if the editor is destroyed before loading completes, the callback may never be called.
51
+ * Use {@link #isReady} instead if you need a guaranteed resolution in all cases.
52
+ */
53
+ onReady(callback: (isReady: boolean) => void): void;
54
+ /**
55
+ * Returns an array of emoji entries that match the search query.
56
+ * If the emoji repository is not loaded this method returns an empty array.
57
+ *
58
+ * @param searchQuery A search query to match emoji.
59
+ * @returns An array of emoji entries that match the search query.
60
+ */
61
+ getEmojiByQuery(searchQuery: string): Array<EmojiEntry>;
62
+ /**
63
+ * Groups all emojis by categories.
64
+ * If the emoji repository is not loaded, it returns an empty array.
65
+ *
66
+ * @returns An array of emoji entries grouped by categories.
67
+ */
68
+ getEmojiCategories(): Array<EmojiCategory>;
69
+ /**
70
+ * Returns an array of available skin tones.
71
+ */
72
+ getSkinTones(): Array<EmojiSkinTone>;
73
+ /**
74
+ * Returns a promise that resolves once the repository finishes loading.
75
+ *
76
+ * Resolves with `true` if the repository loaded successfully, or `false` if loading failed.
77
+ * Rejects if the editor was destroyed before loading completed.
78
+ */
79
+ isReady(): Promise<boolean>;
80
+ /**
81
+ * Returns the URL from which the emoji repository is downloaded. If the URL is not provided
82
+ * in the configuration, the default URL is used with the version from the configuration.
83
+ *
84
+ * If both the URL and version are provided, a warning is logged.
85
+ */
86
+ private _getUrl;
87
+ /**
88
+ * Warn users on self-hosted installations that this plugin uses a CDN to fetch the emoji repository.
89
+ */
90
+ private _warnAboutCdnUse;
91
+ /**
92
+ * Returns the normalised emoji repository for this editor instance if it is
93
+ * a non-empty array, or `null` otherwise.
94
+ */
95
+ private _getItems;
96
+ /**
97
+ * Normalizes the raw data fetched from CDN. By normalization, we meant:
98
+ *
99
+ * * Filter out unsupported emoji (these that will not render correctly),
100
+ * * Prepare skin tone variants if an emoji defines them.
101
+ */
102
+ private _normalizeEmoji;
103
+ /**
104
+ * Cache key segments that distinguish the transformation result for this editor instance.
105
+ */
106
+ private get _cacheKeys();
107
+ /**
108
+ * Process-global cache that stores fetched emojis.
109
+ */
110
+ private static _cache;
105
111
  }
106
112
  /**
107
- * Represents a single group of the emoji category, e.g., "Smileys & Expressions".
108
- */
113
+ * Represents a single group of the emoji category, e.g., "Smileys & Expressions".
114
+ */
109
115
  export type EmojiCategory = {
110
- /**
111
- * A name of the category.
112
- */
113
- title: string;
114
- /**
115
- * An example emoji representing items belonging to the category.
116
- */
117
- icon: string;
118
- /**
119
- * Group id used to assign {@link #items}.
120
- */
121
- groupId: number;
122
- /**
123
- * An array of emojis.
124
- */
125
- items: Array<EmojiEntry>;
116
+ /**
117
+ * A name of the category.
118
+ */
119
+ title: string;
120
+ /**
121
+ * An example emoji representing items belonging to the category.
122
+ */
123
+ icon: string;
124
+ /**
125
+ * Group id used to assign {@link #items}.
126
+ */
127
+ groupId: number;
128
+ /**
129
+ * An array of emojis.
130
+ */
131
+ items: Array<EmojiEntry>;
126
132
  };
127
133
  /**
128
- * Represents a single item fetched from the CDN.
129
- */
134
+ * Represents a single item fetched from the CDN.
135
+ */
130
136
  export type EmojiCdnResource = {
131
- annotation: string;
132
- emoji: string;
133
- group: number;
134
- order: number;
135
- version: number;
136
- emoticon?: string;
137
- shortcodes?: Array<string>;
138
- skins?: Array<{
139
- emoji: string;
140
- tone: number;
141
- version: number;
142
- }>;
143
- tags?: Array<string>;
137
+ annotation: string;
138
+ emoji: string;
139
+ group: number;
140
+ order: number;
141
+ version: number;
142
+ emoticon?: string;
143
+ shortcodes?: Array<string>;
144
+ skins?: Array<{
145
+ emoji: string;
146
+ tone: number;
147
+ version: number;
148
+ }>;
149
+ tags?: Array<string>;
144
150
  };
145
151
  /**
146
- * Represents a single emoji item used by the Emoji feature.
147
- */
148
- export type EmojiEntry = Omit<EmojiCdnResource, 'skins'> & {
149
- skins: EmojiMap;
152
+ * Represents a single emoji item used by the Emoji feature.
153
+ */
154
+ export type EmojiEntry = Omit<EmojiCdnResource, "skins"> & {
155
+ skins: EmojiMap;
150
156
  };
151
157
  /**
152
- * Represents mapping between a skin tone and its corresponding emoji.
153
- *
154
- * The `default` key is always present. Additional values are assigned only if an emoji supports skin tones.
155
- */
156
- export type EmojiMap = {
157
- [K in Exclude<EmojiSkinToneId, 'default'>]?: string;
158
- } & {
159
- default: string;
158
+ * Represents mapping between a skin tone and its corresponding emoji.
159
+ *
160
+ * The `default` key is always present. Additional values are assigned only if an emoji supports skin tones.
161
+ */
162
+ export type EmojiMap = { [K in Exclude<EmojiSkinToneId, "default">]?: string } & {
163
+ default: string;
160
164
  };
161
165
  /**
162
- * Represents an emoji skin tone variant.
163
- */
166
+ * Represents an emoji skin tone variant.
167
+ */
164
168
  export type EmojiSkinTone = {
165
- id: EmojiSkinToneId;
166
- icon: string;
167
- tooltip: string;
169
+ id: EmojiSkinToneId;
170
+ icon: string;
171
+ tooltip: string;
168
172
  };
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
- */