Skip to content

Commit db1b91f

Browse files
committed
Use ckeditors emoji picker instead of our own plugin
1 parent e87720a commit db1b91f

File tree

7 files changed

+19
-26
lines changed

7 files changed

+19
-26
lines changed

assets/ckeditor/emojis.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

assets/ckeditor/markdown_full.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ import {EditorWatchdog} from 'ckeditor5';
6363
import {TodoList} from 'ckeditor5';
6464

6565
import ExtendedMarkdown from "./plugins/extendedMarkdown.js";
66-
import SpecialCharactersEmoji from "./plugins/special_characters_emoji";
66+
import SpecialCharactersGreek from "./plugins/special_characters_emoji";
67+
import {Mention, Emoji} from "ckeditor5";
6768

6869
class Editor extends ClassicEditor {}
6970

@@ -117,9 +118,11 @@ Editor.builtinPlugins = [
117118
Underline,
118119
TodoList,
119120

121+
Mention, Emoji,
122+
120123
//Our own extensions
121124
ExtendedMarkdown,
122-
SpecialCharactersEmoji
125+
SpecialCharactersGreek
123126
];
124127

125128
// Editor configuration.
@@ -148,6 +151,7 @@ Editor.defaultConfig = {
148151
'indent',
149152
'|',
150153
'specialCharacters',
154+
"emoji",
151155
'horizontalLine',
152156
'|',
153157
'imageUpload',

assets/ckeditor/markdown_single_line.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import {Subscript} from 'ckeditor5';
2727
import {Superscript} from 'ckeditor5';
2828
import {Underline} from 'ckeditor5';
2929
import {EditorWatchdog} from 'ckeditor5';
30+
import {Mention, Emoji} from "ckeditor5";
3031

3132
import ExtendedMarkdownInline from "./plugins/extendedMarkdownInline";
3233
import SingleLinePlugin from "./plugins/singleLine";
33-
import SpecialCharactersEmoji from "./plugins/special_characters_emoji";
34+
import SpecialCharactersGreek from "./plugins/special_characters_emoji";
3435

3536
class Editor extends ClassicEditor {}
3637

@@ -62,7 +63,8 @@ Editor.builtinPlugins = [
6263

6364
ExtendedMarkdownInline,
6465
SingleLinePlugin,
65-
SpecialCharactersEmoji
66+
SpecialCharactersGreek,
67+
Mention, Emoji
6668
];
6769

6870
// Editor configuration.
@@ -81,6 +83,7 @@ Editor.defaultConfig = {
8183
'link',
8284
'code',
8385
'specialCharacters',
86+
'emoji',
8487
'|',
8588
'undo',
8689
'redo',

assets/ckeditor/plugins/special_characters_emoji.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,14 @@ import SpecialCharactersEssentials from 'ckeditor5';
2222

2323
import {Plugin} from 'ckeditor5';
2424

25-
const emoji = require('emoji.json');
26-
27-
export default class SpecialCharactersEmoji extends Plugin {
25+
export default class SpecialCharactersGreek extends Plugin {
2826

2927
init() {
3028
const editor = this.editor;
3129
const specialCharsPlugin = editor.plugins.get('SpecialCharacters');
3230

3331
//Add greek characters to special characters
3432
specialCharsPlugin.addItems('Greek', this.getGreek());
35-
36-
//Add Emojis to special characters
37-
specialCharsPlugin.addItems('Emoji', this.getEmojis());
3833
}
3934

4035
getGreek() {
@@ -96,14 +91,4 @@ export default class SpecialCharactersEmoji extends Plugin {
9691
{ title: 'san', character: 'Ϻ' },
9792
];
9893
}
99-
100-
getEmojis() {
101-
//Map our emoji data to the format the plugin expects
102-
return emoji.map(emoji => {
103-
return {
104-
title: emoji.name,
105-
character: emoji.char
106-
};
107-
});
108-
}
10994
}

assets/controllers/elements/ckeditor_controller.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ export default class extends Controller {
5252

5353
const language = document.body.dataset.locale ?? "en";
5454

55+
const emojiURL = new URL('../../ckeditor/emojis.json', import.meta.url).href;
56+
5557
const config = {
5658
language: language,
5759
licenseKey: "GPL",
60+
61+
emoji: {
62+
definitionsUrl: emojiURL
63+
}
5864
}
5965

6066
const watchdog = new EditorWatchdog();

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"datatables.net-responsive-bs5": "^3.0.0",
5959
"datatables.net-select-bs5": "^2.0.0",
6060
"dompurify": "^3.0.3",
61-
"emoji.json": "^15.0.0",
6261
"exports-loader": "^5.0.0",
6362
"json-formatter-js": "^2.3.4",
6463
"jszip": "^3.2.0",

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,11 +3682,6 @@ emoji-regex@^8.0.0:
36823682
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
36833683
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
36843684

3685-
emoji.json@^15.0.0:
3686-
version "15.1.0"
3687-
resolved "https://registry.yarnpkg.com/emoji.json/-/emoji.json-15.1.0.tgz#1a1bac02f95983c808601a74b0b367677e52db3b"
3688-
integrity sha512-GqE6SCE8rSc5Gyd+oh6s/pkoNSW/pULdgJTB6jd/sM87FWA/a1nmvFMdWBjvSA5vdomzDvZgy584KNgzdYJwDA==
3689-
36903685
emojis-list@^3.0.0:
36913686
version "3.0.0"
36923687
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"

0 commit comments

Comments
 (0)