@ckeditor/ckeditor5-emoji 44.2.0-alpha.3 → 44.2.0-alpha.4
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/build/emoji.js +1 -1
- package/dist/index.js +31 -19
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/emojimention.d.ts +10 -4
- package/src/emojimention.js +34 -21
- package/src/ui/emojipickerview.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-emoji",
|
|
3
|
-
"version": "44.2.0-alpha.
|
|
3
|
+
"version": "44.2.0-alpha.4",
|
|
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.2.0-alpha.
|
|
17
|
-
"@ckeditor/ckeditor5-mention": "44.2.0-alpha.
|
|
18
|
-
"@ckeditor/ckeditor5-typing": "44.2.0-alpha.
|
|
19
|
-
"@ckeditor/ckeditor5-ui": "44.2.0-alpha.
|
|
20
|
-
"@ckeditor/ckeditor5-utils": "44.2.0-alpha.
|
|
21
|
-
"ckeditor5": "44.2.0-alpha.
|
|
16
|
+
"@ckeditor/ckeditor5-core": "44.2.0-alpha.4",
|
|
17
|
+
"@ckeditor/ckeditor5-mention": "44.2.0-alpha.4",
|
|
18
|
+
"@ckeditor/ckeditor5-typing": "44.2.0-alpha.4",
|
|
19
|
+
"@ckeditor/ckeditor5-ui": "44.2.0-alpha.4",
|
|
20
|
+
"@ckeditor/ckeditor5-utils": "44.2.0-alpha.4",
|
|
21
|
+
"ckeditor5": "44.2.0-alpha.4",
|
|
22
22
|
"fuse.js": "7.0.0",
|
|
23
23
|
"lodash-es": "4.17.21"
|
|
24
24
|
},
|
package/src/emojimention.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export default class EmojiMention extends Plugin {
|
|
|
19
19
|
* An instance of the {@link module:emoji/emojirepository~EmojiRepository} plugin.
|
|
20
20
|
*/
|
|
21
21
|
private _emojiRepositoryPlugin;
|
|
22
|
+
/**
|
|
23
|
+
* A flag that informs if the {@link module:emoji/emojirepository~EmojiRepository} plugin is loaded correctly.
|
|
24
|
+
*/
|
|
25
|
+
private _isEmojiRepositoryAvailable;
|
|
22
26
|
/**
|
|
23
27
|
* Defines a number of displayed items in the auto complete dropdown.
|
|
24
28
|
*
|
|
@@ -45,14 +49,16 @@ export default class EmojiMention extends Plugin {
|
|
|
45
49
|
* @inheritDoc
|
|
46
50
|
*/
|
|
47
51
|
constructor(editor: Editor);
|
|
48
|
-
/**
|
|
49
|
-
* @inheritDoc
|
|
50
|
-
*/
|
|
51
|
-
init(): Promise<void>;
|
|
52
52
|
/**
|
|
53
53
|
* Initializes the configuration for emojis in the mention feature.
|
|
54
|
+
* If the marker used by emoji mention is already registered, it displays a warning.
|
|
55
|
+
* If emoji mention configuration is detected, it does not register it for a second time.
|
|
54
56
|
*/
|
|
55
57
|
private _setupMentionConfiguration;
|
|
58
|
+
/**
|
|
59
|
+
* @inheritDoc
|
|
60
|
+
*/
|
|
61
|
+
init(): Promise<void>;
|
|
56
62
|
/**
|
|
57
63
|
* Returns the `itemRenderer()` callback for mention config.
|
|
58
64
|
*/
|
package/src/emojimention.js
CHANGED
|
@@ -46,11 +46,21 @@ export default class EmojiMention extends Plugin {
|
|
|
46
46
|
});
|
|
47
47
|
this._emojiDropdownLimit = editor.config.get('emoji.dropdownLimit');
|
|
48
48
|
this._skinTone = editor.config.get('emoji.skinTone');
|
|
49
|
-
|
|
49
|
+
this._setupMentionConfiguration(editor);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Initializes the configuration for emojis in the mention feature.
|
|
53
|
+
* If the marker used by emoji mention is already registered, it displays a warning.
|
|
54
|
+
* If emoji mention configuration is detected, it does not register it for a second time.
|
|
55
|
+
*/
|
|
56
|
+
_setupMentionConfiguration(editor) {
|
|
50
57
|
const mergeFieldsPrefix = editor.config.get('mergeFields.prefix');
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
58
|
+
const mentionFeedsConfigs = editor.config.get('mention.feeds');
|
|
59
|
+
const isEmojiMarkerUsedByMergeFields = mergeFieldsPrefix ? mergeFieldsPrefix[0] === EMOJI_MENTION_MARKER : false;
|
|
60
|
+
const isEmojiMarkerUsedByMention = mentionFeedsConfigs
|
|
61
|
+
.filter(config => !config._isEmojiMarker)
|
|
62
|
+
.some(config => config.marker === EMOJI_MENTION_MARKER);
|
|
63
|
+
if (isEmojiMarkerUsedByMention || isEmojiMarkerUsedByMergeFields) {
|
|
54
64
|
/**
|
|
55
65
|
* The `marker` in the `emoji` config is already used by other plugin configuration.
|
|
56
66
|
*
|
|
@@ -60,26 +70,12 @@ export default class EmojiMention extends Plugin {
|
|
|
60
70
|
logWarning('emoji-config-marker-already-used', { marker: EMOJI_MENTION_MARKER });
|
|
61
71
|
return;
|
|
62
72
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @inheritDoc
|
|
67
|
-
*/
|
|
68
|
-
async init() {
|
|
69
|
-
const editor = this.editor;
|
|
70
|
-
this._emojiPickerPlugin = editor.plugins.has('EmojiPicker') ? editor.plugins.get('EmojiPicker') : null;
|
|
71
|
-
this._emojiRepositoryPlugin = editor.plugins.get('EmojiRepository');
|
|
72
|
-
// Skip overriding the `mention` command listener if the emoji repository is not ready.
|
|
73
|
-
if (!await this._emojiRepositoryPlugin.isReady()) {
|
|
73
|
+
const isEmojiConfigDefined = mentionFeedsConfigs.some(config => config._isEmojiMarker);
|
|
74
|
+
if (isEmojiConfigDefined) {
|
|
74
75
|
return;
|
|
75
76
|
}
|
|
76
|
-
editor.once('ready', this._overrideMentionExecuteListener.bind(this));
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Initializes the configuration for emojis in the mention feature.
|
|
80
|
-
*/
|
|
81
|
-
_setupMentionConfiguration(mentionFeedsConfigs) {
|
|
82
77
|
const emojiMentionFeedConfig = {
|
|
78
|
+
_isEmojiMarker: true,
|
|
83
79
|
marker: EMOJI_MENTION_MARKER,
|
|
84
80
|
dropdownLimit: this._emojiDropdownLimit,
|
|
85
81
|
itemRenderer: this._customItemRendererFactory(this.editor.t),
|
|
@@ -87,6 +83,19 @@ export default class EmojiMention extends Plugin {
|
|
|
87
83
|
};
|
|
88
84
|
this.editor.config.set('mention.feeds', [...mentionFeedsConfigs, emojiMentionFeedConfig]);
|
|
89
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @inheritDoc
|
|
88
|
+
*/
|
|
89
|
+
async init() {
|
|
90
|
+
const editor = this.editor;
|
|
91
|
+
this._emojiPickerPlugin = editor.plugins.has('EmojiPicker') ? editor.plugins.get('EmojiPicker') : null;
|
|
92
|
+
this._emojiRepositoryPlugin = editor.plugins.get('EmojiRepository');
|
|
93
|
+
this._isEmojiRepositoryAvailable = await this._emojiRepositoryPlugin.isReady();
|
|
94
|
+
// Override the `mention` command listener if the emoji repository is ready.
|
|
95
|
+
if (this._isEmojiRepositoryAvailable) {
|
|
96
|
+
editor.once('ready', this._overrideMentionExecuteListener.bind(this));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
90
99
|
/**
|
|
91
100
|
* Returns the `itemRenderer()` callback for mention config.
|
|
92
101
|
*/
|
|
@@ -167,6 +176,10 @@ export default class EmojiMention extends Plugin {
|
|
|
167
176
|
if (searchQuery.startsWith(' ')) {
|
|
168
177
|
return [];
|
|
169
178
|
}
|
|
179
|
+
// If the repository plugin is not available, return an empty feed to avoid confusion. See: #17842.
|
|
180
|
+
if (!this._isEmojiRepositoryAvailable) {
|
|
181
|
+
return [];
|
|
182
|
+
}
|
|
170
183
|
const emojis = this._emojiRepositoryPlugin.getEmojiByQuery(searchQuery)
|
|
171
184
|
.map(emoji => {
|
|
172
185
|
let text = emoji.skins[this._skinTone] || emoji.skins.default;
|
|
@@ -156,6 +156,7 @@ export default class EmojiPickerView extends View {
|
|
|
156
156
|
// Emit an update event to react to balloon dimensions changes.
|
|
157
157
|
this.searchView.on('search', () => {
|
|
158
158
|
this.fire('update');
|
|
159
|
+
this.gridView.element.scrollTo(0, 0);
|
|
159
160
|
});
|
|
160
161
|
// Update the grid of emojis when the selected category is changed.
|
|
161
162
|
this.categoriesView.on('change:categoryName', (ev, args, categoryName) => {
|