@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/emojimention.js
DELETED
|
@@ -1,210 +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/emojimention
|
|
7
|
-
*/
|
|
8
|
-
import { logWarning } from 'ckeditor5/src/utils.js';
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
-
import { Typing } from 'ckeditor5/src/typing.js';
|
|
11
|
-
import EmojiRepository from './emojirepository.js';
|
|
12
|
-
const EMOJI_MENTION_MARKER = ':';
|
|
13
|
-
const EMOJI_SHOW_ALL_OPTION_ID = ':__EMOJI_SHOW_ALL:';
|
|
14
|
-
const EMOJI_HINT_OPTION_ID = ':__EMOJI_HINT:';
|
|
15
|
-
/**
|
|
16
|
-
* The emoji mention plugin.
|
|
17
|
-
*
|
|
18
|
-
* Introduces the autocomplete of emojis while typing.
|
|
19
|
-
*/
|
|
20
|
-
export default class EmojiMention extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* @inheritDoc
|
|
23
|
-
*/
|
|
24
|
-
static get requires() {
|
|
25
|
-
return [EmojiRepository, Typing, 'Mention'];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @inheritDoc
|
|
29
|
-
*/
|
|
30
|
-
static get pluginName() {
|
|
31
|
-
return 'EmojiMention';
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get isOfficialPlugin() {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @inheritDoc
|
|
41
|
-
*/
|
|
42
|
-
constructor(editor) {
|
|
43
|
-
super(editor);
|
|
44
|
-
this.editor.config.define('emoji', {
|
|
45
|
-
dropdownLimit: 6
|
|
46
|
-
});
|
|
47
|
-
this._emojiDropdownLimit = editor.config.get('emoji.dropdownLimit');
|
|
48
|
-
this._skinTone = editor.config.get('emoji.skinTone');
|
|
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) {
|
|
57
|
-
const mergeFieldsPrefix = editor.config.get('mergeFields.prefix');
|
|
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) {
|
|
64
|
-
/**
|
|
65
|
-
* The `marker` in the `emoji` config is already used by other plugin configuration.
|
|
66
|
-
*
|
|
67
|
-
* @error emoji-config-marker-already-used
|
|
68
|
-
* @param {string} marker Used marker.
|
|
69
|
-
*/
|
|
70
|
-
logWarning('emoji-config-marker-already-used', { marker: EMOJI_MENTION_MARKER });
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const isEmojiConfigDefined = mentionFeedsConfigs.some(config => config._isEmojiMarker);
|
|
74
|
-
if (isEmojiConfigDefined) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const emojiMentionFeedConfig = {
|
|
78
|
-
_isEmojiMarker: true,
|
|
79
|
-
marker: EMOJI_MENTION_MARKER,
|
|
80
|
-
dropdownLimit: this._emojiDropdownLimit,
|
|
81
|
-
itemRenderer: this._customItemRendererFactory(this.editor.t),
|
|
82
|
-
feed: this._queryEmojiCallbackFactory()
|
|
83
|
-
};
|
|
84
|
-
this.editor.config.set('mention.feeds', [...mentionFeedsConfigs, emojiMentionFeedConfig]);
|
|
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
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Returns the `itemRenderer()` callback for mention config.
|
|
101
|
-
*/
|
|
102
|
-
_customItemRendererFactory(t) {
|
|
103
|
-
return (item) => {
|
|
104
|
-
const itemElement = document.createElement('button');
|
|
105
|
-
itemElement.classList.add('ck');
|
|
106
|
-
itemElement.classList.add('ck-button');
|
|
107
|
-
itemElement.classList.add('ck-button_with-text');
|
|
108
|
-
itemElement.id = `mention-list-item-id${item.id.slice(0, -1)}`;
|
|
109
|
-
itemElement.type = 'button';
|
|
110
|
-
itemElement.tabIndex = -1;
|
|
111
|
-
const labelElement = document.createElement('span');
|
|
112
|
-
labelElement.classList.add('ck');
|
|
113
|
-
labelElement.classList.add('ck-button__label');
|
|
114
|
-
itemElement.appendChild(labelElement);
|
|
115
|
-
if (item.id === EMOJI_HINT_OPTION_ID) {
|
|
116
|
-
itemElement.classList.add('ck-list-item-button');
|
|
117
|
-
itemElement.classList.add('ck-disabled');
|
|
118
|
-
labelElement.textContent = t('Keep on typing to see the emoji.');
|
|
119
|
-
}
|
|
120
|
-
else if (item.id === EMOJI_SHOW_ALL_OPTION_ID) {
|
|
121
|
-
labelElement.textContent = t('Show all emoji...');
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
labelElement.textContent = `${item.text} ${item.id}`;
|
|
125
|
-
}
|
|
126
|
-
return itemElement;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Overrides the default mention execute listener to insert an emoji as plain text instead.
|
|
131
|
-
*/
|
|
132
|
-
_overrideMentionExecuteListener() {
|
|
133
|
-
const editor = this.editor;
|
|
134
|
-
editor.commands.get('mention').on('execute', (event, data) => {
|
|
135
|
-
const eventData = data[0];
|
|
136
|
-
// Ignore non-emoji auto-complete actions.
|
|
137
|
-
if (eventData.marker !== EMOJI_MENTION_MARKER) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
// Do not propagate the event.
|
|
141
|
-
event.stop();
|
|
142
|
-
// Do nothing when executing after selecting a hint message.
|
|
143
|
-
if (eventData.mention.id === EMOJI_HINT_OPTION_ID) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
// Trigger the picker UI.
|
|
147
|
-
if (eventData.mention.id === EMOJI_SHOW_ALL_OPTION_ID) {
|
|
148
|
-
const text = [...eventData.range.getItems()]
|
|
149
|
-
.filter(item => item.is('$textProxy'))
|
|
150
|
-
.map(item => item.data)
|
|
151
|
-
.reduce((result, text) => result + text, '');
|
|
152
|
-
editor.model.change(writer => {
|
|
153
|
-
editor.model.deleteContent(writer.createSelection(eventData.range));
|
|
154
|
-
});
|
|
155
|
-
const emojiPickerPlugin = this.emojiPickerPlugin;
|
|
156
|
-
emojiPickerPlugin.showUI(text.slice(1));
|
|
157
|
-
setTimeout(() => {
|
|
158
|
-
emojiPickerPlugin.emojiPickerView.focus();
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
// Or insert the emoji to editor.
|
|
162
|
-
else {
|
|
163
|
-
editor.execute('insertText', {
|
|
164
|
-
text: eventData.mention.text,
|
|
165
|
-
range: eventData.range
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}, { priority: 'high' });
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Returns the `feed()` callback for mention config.
|
|
172
|
-
*/
|
|
173
|
-
_queryEmojiCallbackFactory() {
|
|
174
|
-
return (searchQuery) => {
|
|
175
|
-
// Do not show anything when a query starts with a space.
|
|
176
|
-
if (searchQuery.startsWith(' ')) {
|
|
177
|
-
return [];
|
|
178
|
-
}
|
|
179
|
-
// Do not show anything when a query starts with a marker character.
|
|
180
|
-
if (searchQuery.startsWith(EMOJI_MENTION_MARKER)) {
|
|
181
|
-
return [];
|
|
182
|
-
}
|
|
183
|
-
// If the repository plugin is not available, return an empty feed to avoid confusion. See: #17842.
|
|
184
|
-
if (!this._isEmojiRepositoryAvailable) {
|
|
185
|
-
return [];
|
|
186
|
-
}
|
|
187
|
-
const emojis = this.emojiRepositoryPlugin.getEmojiByQuery(searchQuery)
|
|
188
|
-
.map(emoji => {
|
|
189
|
-
let text = emoji.skins[this._skinTone] || emoji.skins.default;
|
|
190
|
-
if (this.emojiPickerPlugin) {
|
|
191
|
-
text = emoji.skins[this.emojiPickerPlugin.skinTone] || emoji.skins.default;
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
id: `:${emoji.annotation}:`,
|
|
195
|
-
text
|
|
196
|
-
};
|
|
197
|
-
});
|
|
198
|
-
if (!this.emojiPickerPlugin) {
|
|
199
|
-
return emojis.slice(0, this._emojiDropdownLimit);
|
|
200
|
-
}
|
|
201
|
-
const actionItem = {
|
|
202
|
-
id: searchQuery.length > 1 ? EMOJI_SHOW_ALL_OPTION_ID : EMOJI_HINT_OPTION_ID
|
|
203
|
-
};
|
|
204
|
-
return [
|
|
205
|
-
...emojis.slice(0, this._emojiDropdownLimit - 1),
|
|
206
|
-
actionItem
|
|
207
|
-
];
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
}
|
package/src/emojipicker.d.ts
DELETED
|
@@ -1,97 +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/emojipicker
|
|
7
|
-
*/
|
|
8
|
-
import { ContextualBalloon, Dialog } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
-
import { Typing } from 'ckeditor5/src/typing.js';
|
|
11
|
-
import EmojiRepository from './emojirepository.js';
|
|
12
|
-
import EmojiPickerView from './ui/emojipickerview.js';
|
|
13
|
-
import type { SkinToneId } from './emojiconfig.js';
|
|
14
|
-
import '../theme/emojipicker.css';
|
|
15
|
-
/**
|
|
16
|
-
* The emoji picker plugin.
|
|
17
|
-
*
|
|
18
|
-
* Introduces the `'emoji'` dropdown.
|
|
19
|
-
*/
|
|
20
|
-
export default class EmojiPicker extends Plugin {
|
|
21
|
-
/**
|
|
22
|
-
* The actions view displayed inside the balloon.
|
|
23
|
-
*/
|
|
24
|
-
emojiPickerView: EmojiPickerView | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* The contextual balloon plugin instance.
|
|
27
|
-
*/
|
|
28
|
-
balloonPlugin: ContextualBalloon;
|
|
29
|
-
/**
|
|
30
|
-
* An instance of the {@link module:emoji/emojirepository~EmojiRepository} plugin.
|
|
31
|
-
*/
|
|
32
|
-
emojiRepositoryPlugin: EmojiRepository;
|
|
33
|
-
/**
|
|
34
|
-
* @inheritDoc
|
|
35
|
-
*/
|
|
36
|
-
static get requires(): readonly [typeof EmojiRepository, typeof ContextualBalloon, typeof Dialog, typeof Typing];
|
|
37
|
-
/**
|
|
38
|
-
* @inheritDoc
|
|
39
|
-
*/
|
|
40
|
-
static get pluginName(): "EmojiPicker";
|
|
41
|
-
/**
|
|
42
|
-
* @inheritDoc
|
|
43
|
-
*/
|
|
44
|
-
static get isOfficialPlugin(): true;
|
|
45
|
-
/**
|
|
46
|
-
* @inheritDoc
|
|
47
|
-
*/
|
|
48
|
-
init(): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* @inheritDoc
|
|
51
|
-
*/
|
|
52
|
-
destroy(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Represents an active skin tone. Its value depends on the emoji UI plugin.
|
|
55
|
-
*
|
|
56
|
-
* Before opening the UI for the first time, the returned value is read from the editor configuration.
|
|
57
|
-
* Otherwise, it reflects the user's intention.
|
|
58
|
-
*/
|
|
59
|
-
get skinTone(): SkinToneId;
|
|
60
|
-
/**
|
|
61
|
-
* Displays the balloon with the emoji picker.
|
|
62
|
-
*
|
|
63
|
-
* @param [searchValue=''] A default query used to filer the grid when opening the UI.
|
|
64
|
-
*/
|
|
65
|
-
showUI(searchValue?: string): void;
|
|
66
|
-
/**
|
|
67
|
-
* Creates a button for toolbar and menu bar that will show the emoji dialog.
|
|
68
|
-
*/
|
|
69
|
-
private _createButton;
|
|
70
|
-
/**
|
|
71
|
-
* Creates an instance of the `EmojiPickerView` class that represents an emoji balloon.
|
|
72
|
-
*/
|
|
73
|
-
private _createEmojiPickerView;
|
|
74
|
-
/**
|
|
75
|
-
* Hides the balloon with the emoji picker.
|
|
76
|
-
*/
|
|
77
|
-
private _hideUI;
|
|
78
|
-
/**
|
|
79
|
-
* Registers converters.
|
|
80
|
-
*/
|
|
81
|
-
private _setupConversion;
|
|
82
|
-
/**
|
|
83
|
-
* Returns positioning options for the {@link #balloonPlugin}. They control the way the balloon is attached
|
|
84
|
-
* to the target element or selection.
|
|
85
|
-
*/
|
|
86
|
-
private _getBalloonPositionData;
|
|
87
|
-
/**
|
|
88
|
-
* Displays a fake visual selection when the contextual balloon is displayed.
|
|
89
|
-
*
|
|
90
|
-
* This adds an 'emoji-picker' marker into the document that is rendered as a highlight on selected text fragment.
|
|
91
|
-
*/
|
|
92
|
-
private _showFakeVisualSelection;
|
|
93
|
-
/**
|
|
94
|
-
* Hides the fake visual selection.
|
|
95
|
-
*/
|
|
96
|
-
private _hideFakeVisualSelection;
|
|
97
|
-
}
|
package/src/emojipicker.js
DELETED
|
@@ -1,255 +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/emojipicker
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, clickOutsideHandler, ContextualBalloon, Dialog, MenuBarMenuListItemButtonView } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { icons, Plugin } from 'ckeditor5/src/core.js';
|
|
10
|
-
import { Typing } from 'ckeditor5/src/typing.js';
|
|
11
|
-
import EmojiCommand from './emojicommand.js';
|
|
12
|
-
import EmojiRepository from './emojirepository.js';
|
|
13
|
-
import EmojiPickerView from './ui/emojipickerview.js';
|
|
14
|
-
import '../theme/emojipicker.css';
|
|
15
|
-
const VISUAL_SELECTION_MARKER_NAME = 'emoji-picker';
|
|
16
|
-
/**
|
|
17
|
-
* The emoji picker plugin.
|
|
18
|
-
*
|
|
19
|
-
* Introduces the `'emoji'` dropdown.
|
|
20
|
-
*/
|
|
21
|
-
export default class EmojiPicker extends Plugin {
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
static get requires() {
|
|
26
|
-
return [EmojiRepository, ContextualBalloon, Dialog, Typing];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @inheritDoc
|
|
30
|
-
*/
|
|
31
|
-
static get pluginName() {
|
|
32
|
-
return 'EmojiPicker';
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @inheritDoc
|
|
36
|
-
*/
|
|
37
|
-
static get isOfficialPlugin() {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @inheritDoc
|
|
42
|
-
*/
|
|
43
|
-
async init() {
|
|
44
|
-
const editor = this.editor;
|
|
45
|
-
this.balloonPlugin = editor.plugins.get('ContextualBalloon');
|
|
46
|
-
this.emojiRepositoryPlugin = editor.plugins.get('EmojiRepository');
|
|
47
|
-
// Skip registering a button in the toolbar and list item in the menu bar if the emoji repository is not ready.
|
|
48
|
-
if (!await this.emojiRepositoryPlugin.isReady()) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const command = new EmojiCommand(editor);
|
|
52
|
-
editor.commands.add('emoji', command);
|
|
53
|
-
editor.ui.componentFactory.add('emoji', () => {
|
|
54
|
-
const button = this._createButton(ButtonView, command);
|
|
55
|
-
button.set({
|
|
56
|
-
tooltip: true
|
|
57
|
-
});
|
|
58
|
-
return button;
|
|
59
|
-
});
|
|
60
|
-
editor.ui.componentFactory.add('menuBar:emoji', () => {
|
|
61
|
-
return this._createButton(MenuBarMenuListItemButtonView, command);
|
|
62
|
-
});
|
|
63
|
-
this._setupConversion();
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* @inheritDoc
|
|
67
|
-
*/
|
|
68
|
-
destroy() {
|
|
69
|
-
super.destroy();
|
|
70
|
-
if (this.emojiPickerView) {
|
|
71
|
-
this.emojiPickerView.destroy();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Represents an active skin tone. Its value depends on the emoji UI plugin.
|
|
76
|
-
*
|
|
77
|
-
* Before opening the UI for the first time, the returned value is read from the editor configuration.
|
|
78
|
-
* Otherwise, it reflects the user's intention.
|
|
79
|
-
*/
|
|
80
|
-
get skinTone() {
|
|
81
|
-
if (!this.emojiPickerView) {
|
|
82
|
-
return this.editor.config.get('emoji.skinTone');
|
|
83
|
-
}
|
|
84
|
-
return this.emojiPickerView.gridView.skinTone;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Displays the balloon with the emoji picker.
|
|
88
|
-
*
|
|
89
|
-
* @param [searchValue=''] A default query used to filer the grid when opening the UI.
|
|
90
|
-
*/
|
|
91
|
-
showUI(searchValue = '') {
|
|
92
|
-
// Show visual selection on a text when the contextual balloon is displayed.
|
|
93
|
-
// See #17654.
|
|
94
|
-
this._showFakeVisualSelection();
|
|
95
|
-
if (!this.emojiPickerView) {
|
|
96
|
-
this.emojiPickerView = this._createEmojiPickerView();
|
|
97
|
-
}
|
|
98
|
-
if (searchValue) {
|
|
99
|
-
this.emojiPickerView.searchView.setInputValue(searchValue);
|
|
100
|
-
}
|
|
101
|
-
this.emojiPickerView.searchView.search(searchValue);
|
|
102
|
-
if (!this.balloonPlugin.hasView(this.emojiPickerView)) {
|
|
103
|
-
this.balloonPlugin.add({
|
|
104
|
-
view: this.emojiPickerView,
|
|
105
|
-
position: this._getBalloonPositionData()
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
this.emojiPickerView.focus();
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Creates a button for toolbar and menu bar that will show the emoji dialog.
|
|
112
|
-
*/
|
|
113
|
-
_createButton(ViewClass, command) {
|
|
114
|
-
const buttonView = new ViewClass(this.editor.locale);
|
|
115
|
-
const t = this.editor.locale.t;
|
|
116
|
-
buttonView.bind('isEnabled').to(command, 'isEnabled');
|
|
117
|
-
buttonView.set({
|
|
118
|
-
label: t('Emoji'),
|
|
119
|
-
icon: icons.emoji,
|
|
120
|
-
isToggleable: true
|
|
121
|
-
});
|
|
122
|
-
buttonView.on('execute', () => {
|
|
123
|
-
this.showUI();
|
|
124
|
-
});
|
|
125
|
-
return buttonView;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Creates an instance of the `EmojiPickerView` class that represents an emoji balloon.
|
|
129
|
-
*/
|
|
130
|
-
_createEmojiPickerView() {
|
|
131
|
-
const emojiPickerView = new EmojiPickerView(this.editor.locale, {
|
|
132
|
-
emojiCategories: this.emojiRepositoryPlugin.getEmojiCategories(),
|
|
133
|
-
skinTone: this.editor.config.get('emoji.skinTone'),
|
|
134
|
-
skinTones: this.emojiRepositoryPlugin.getSkinTones(),
|
|
135
|
-
getEmojiByQuery: (query) => {
|
|
136
|
-
return this.emojiRepositoryPlugin.getEmojiByQuery(query);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
// Insert an emoji on a tile click.
|
|
140
|
-
this.listenTo(emojiPickerView.gridView, 'execute', (evt, data) => {
|
|
141
|
-
const editor = this.editor;
|
|
142
|
-
const textToInsert = data.emoji;
|
|
143
|
-
this._hideUI();
|
|
144
|
-
editor.execute('insertText', { text: textToInsert });
|
|
145
|
-
});
|
|
146
|
-
// Update the balloon position when layout is changed.
|
|
147
|
-
this.listenTo(emojiPickerView, 'update', () => {
|
|
148
|
-
if (this.balloonPlugin.visibleView === emojiPickerView) {
|
|
149
|
-
this.balloonPlugin.updatePosition();
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
// Close the panel on `Esc` key press when the **actions have focus**.
|
|
153
|
-
emojiPickerView.keystrokes.set('Esc', (data, cancel) => {
|
|
154
|
-
this._hideUI();
|
|
155
|
-
cancel();
|
|
156
|
-
});
|
|
157
|
-
// Close the dialog when clicking outside of it.
|
|
158
|
-
clickOutsideHandler({
|
|
159
|
-
emitter: emojiPickerView,
|
|
160
|
-
contextElements: [this.balloonPlugin.view.element],
|
|
161
|
-
callback: () => this._hideUI(),
|
|
162
|
-
activator: () => this.balloonPlugin.visibleView === emojiPickerView
|
|
163
|
-
});
|
|
164
|
-
return emojiPickerView;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Hides the balloon with the emoji picker.
|
|
168
|
-
*/
|
|
169
|
-
_hideUI() {
|
|
170
|
-
this.balloonPlugin.remove(this.emojiPickerView);
|
|
171
|
-
this.emojiPickerView.searchView.setInputValue('');
|
|
172
|
-
this.editor.editing.view.focus();
|
|
173
|
-
this._hideFakeVisualSelection();
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Registers converters.
|
|
177
|
-
*/
|
|
178
|
-
_setupConversion() {
|
|
179
|
-
const editor = this.editor;
|
|
180
|
-
// Renders a fake visual selection marker on an expanded selection.
|
|
181
|
-
editor.conversion.for('editingDowncast').markerToHighlight({
|
|
182
|
-
model: VISUAL_SELECTION_MARKER_NAME,
|
|
183
|
-
view: {
|
|
184
|
-
classes: ['ck-fake-emoji-selection']
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
// Renders a fake visual selection marker on a collapsed selection.
|
|
188
|
-
editor.conversion.for('editingDowncast').markerToElement({
|
|
189
|
-
model: VISUAL_SELECTION_MARKER_NAME,
|
|
190
|
-
view: (data, { writer }) => {
|
|
191
|
-
if (!data.markerRange.isCollapsed) {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
const markerElement = writer.createUIElement('span');
|
|
195
|
-
writer.addClass(['ck-fake-emoji-selection', 'ck-fake-emoji-selection_collapsed'], markerElement);
|
|
196
|
-
return markerElement;
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Returns positioning options for the {@link #balloonPlugin}. They control the way the balloon is attached
|
|
202
|
-
* to the target element or selection.
|
|
203
|
-
*/
|
|
204
|
-
_getBalloonPositionData() {
|
|
205
|
-
const view = this.editor.editing.view;
|
|
206
|
-
const viewDocument = view.document;
|
|
207
|
-
// Set a target position by converting view selection range to DOM.
|
|
208
|
-
const target = () => view.domConverter.viewRangeToDom(viewDocument.selection.getFirstRange());
|
|
209
|
-
return {
|
|
210
|
-
target
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Displays a fake visual selection when the contextual balloon is displayed.
|
|
215
|
-
*
|
|
216
|
-
* This adds an 'emoji-picker' marker into the document that is rendered as a highlight on selected text fragment.
|
|
217
|
-
*/
|
|
218
|
-
_showFakeVisualSelection() {
|
|
219
|
-
const model = this.editor.model;
|
|
220
|
-
model.change(writer => {
|
|
221
|
-
const range = model.document.selection.getFirstRange();
|
|
222
|
-
if (model.markers.has(VISUAL_SELECTION_MARKER_NAME)) {
|
|
223
|
-
writer.updateMarker(VISUAL_SELECTION_MARKER_NAME, { range });
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
if (range.start.isAtEnd) {
|
|
227
|
-
const startPosition = range.start.getLastMatchingPosition(({ item }) => !model.schema.isContent(item), { boundaries: range });
|
|
228
|
-
writer.addMarker(VISUAL_SELECTION_MARKER_NAME, {
|
|
229
|
-
usingOperation: false,
|
|
230
|
-
affectsData: false,
|
|
231
|
-
range: writer.createRange(startPosition, range.end)
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
writer.addMarker(VISUAL_SELECTION_MARKER_NAME, {
|
|
236
|
-
usingOperation: false,
|
|
237
|
-
affectsData: false,
|
|
238
|
-
range
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Hides the fake visual selection.
|
|
246
|
-
*/
|
|
247
|
-
_hideFakeVisualSelection() {
|
|
248
|
-
const model = this.editor.model;
|
|
249
|
-
if (model.markers.has(VISUAL_SELECTION_MARKER_NAME)) {
|
|
250
|
-
model.change(writer => {
|
|
251
|
-
writer.removeMarker(VISUAL_SELECTION_MARKER_NAME);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|