@ckeditor/ckeditor5-special-characters 39.0.1 → 40.0.0

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.
Files changed (82) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/special-characters.js.map +1 -0
  4. package/build/translations/pt-br.js +1 -1
  5. package/lang/translations/ar.po +1 -0
  6. package/lang/translations/az.po +1 -0
  7. package/lang/translations/bg.po +1 -0
  8. package/lang/translations/bn.po +1 -0
  9. package/lang/translations/ca.po +1 -0
  10. package/lang/translations/cs.po +1 -0
  11. package/lang/translations/da.po +1 -0
  12. package/lang/translations/de.po +1 -0
  13. package/lang/translations/el.po +1 -0
  14. package/lang/translations/en-au.po +1 -0
  15. package/lang/translations/en.po +1 -0
  16. package/lang/translations/es.po +1 -0
  17. package/lang/translations/et.po +1 -0
  18. package/lang/translations/fa.po +1 -0
  19. package/lang/translations/fi.po +1 -0
  20. package/lang/translations/fr.po +1 -0
  21. package/lang/translations/gl.po +1 -0
  22. package/lang/translations/he.po +1 -0
  23. package/lang/translations/hi.po +1 -0
  24. package/lang/translations/hr.po +1 -0
  25. package/lang/translations/hu.po +1 -0
  26. package/lang/translations/id.po +1 -0
  27. package/lang/translations/it.po +1 -0
  28. package/lang/translations/ja.po +1 -0
  29. package/lang/translations/ko.po +1 -0
  30. package/lang/translations/lt.po +1 -0
  31. package/lang/translations/lv.po +1 -0
  32. package/lang/translations/ms.po +1 -0
  33. package/lang/translations/nl.po +1 -0
  34. package/lang/translations/no.po +1 -0
  35. package/lang/translations/pl.po +1 -0
  36. package/lang/translations/pt-br.po +42 -41
  37. package/lang/translations/pt.po +1 -0
  38. package/lang/translations/ro.po +1 -0
  39. package/lang/translations/ru.po +1 -0
  40. package/lang/translations/sk.po +1 -0
  41. package/lang/translations/sq.po +1 -0
  42. package/lang/translations/sr-latn.po +1 -0
  43. package/lang/translations/sr.po +1 -0
  44. package/lang/translations/sv.po +1 -0
  45. package/lang/translations/th.po +1 -0
  46. package/lang/translations/tk.po +1 -0
  47. package/lang/translations/tr.po +1 -0
  48. package/lang/translations/uk.po +1 -0
  49. package/lang/translations/ur.po +1 -0
  50. package/lang/translations/uz.po +1 -0
  51. package/lang/translations/vi.po +1 -0
  52. package/lang/translations/zh-cn.po +1 -0
  53. package/lang/translations/zh.po +1 -0
  54. package/package.json +2 -6
  55. package/src/augmentation.d.ts +24 -24
  56. package/src/augmentation.js +5 -5
  57. package/src/index.d.ts +16 -16
  58. package/src/index.js +15 -15
  59. package/src/specialcharacters.d.ts +96 -96
  60. package/src/specialcharacters.js +206 -206
  61. package/src/specialcharactersarrows.d.ts +30 -30
  62. package/src/specialcharactersarrows.js +60 -60
  63. package/src/specialcharactersconfig.d.ts +51 -51
  64. package/src/specialcharactersconfig.js +5 -5
  65. package/src/specialcharacterscurrency.d.ts +30 -30
  66. package/src/specialcharacterscurrency.js +74 -74
  67. package/src/specialcharactersessentials.d.ts +35 -35
  68. package/src/specialcharactersessentials.js +45 -45
  69. package/src/specialcharacterslatin.d.ts +30 -30
  70. package/src/specialcharacterslatin.js +166 -166
  71. package/src/specialcharactersmathematical.d.ts +30 -30
  72. package/src/specialcharactersmathematical.js +82 -82
  73. package/src/specialcharacterstext.d.ts +30 -30
  74. package/src/specialcharacterstext.js +65 -65
  75. package/src/ui/charactergridview.d.ts +94 -94
  76. package/src/ui/charactergridview.js +129 -129
  77. package/src/ui/characterinfoview.d.ts +35 -35
  78. package/src/ui/characterinfoview.js +71 -71
  79. package/src/ui/specialcharactersnavigationview.d.ts +59 -59
  80. package/src/ui/specialcharactersnavigationview.js +95 -95
  81. package/src/ui/specialcharactersview.d.ts +65 -65
  82. package/src/ui/specialcharactersview.js +78 -78
package/src/index.js CHANGED
@@ -1,15 +1,15 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module special-characters
7
- */
8
- export { default as SpecialCharacters } from './specialcharacters';
9
- export { default as SpecialCharactersArrows } from './specialcharactersarrows';
10
- export { default as SpecialCharactersText } from './specialcharacterstext';
11
- export { default as SpecialCharactersMathematical } from './specialcharactersmathematical';
12
- export { default as SpecialCharactersLatin } from './specialcharacterslatin';
13
- export { default as SpecialCharactersEssentials } from './specialcharactersessentials';
14
- export { default as SpecialCharactersCurrency } from './specialcharacterscurrency';
15
- import './augmentation';
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module special-characters
7
+ */
8
+ export { default as SpecialCharacters } from './specialcharacters';
9
+ export { default as SpecialCharactersArrows } from './specialcharactersarrows';
10
+ export { default as SpecialCharactersText } from './specialcharacterstext';
11
+ export { default as SpecialCharactersMathematical } from './specialcharactersmathematical';
12
+ export { default as SpecialCharactersLatin } from './specialcharacterslatin';
13
+ export { default as SpecialCharactersEssentials } from './specialcharactersessentials';
14
+ export { default as SpecialCharactersCurrency } from './specialcharacterscurrency';
15
+ import './augmentation';
@@ -1,96 +1,96 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module special-characters/specialcharacters
7
- */
8
- import { Plugin, type Editor } from 'ckeditor5/src/core';
9
- import { Typing } from 'ckeditor5/src/typing';
10
- import '../theme/specialcharacters.css';
11
- /**
12
- * The special characters feature.
13
- *
14
- * Introduces the `'specialCharacters'` dropdown.
15
- */
16
- export default class SpecialCharacters extends Plugin {
17
- /**
18
- * Registered characters. A pair of a character name and its symbol.
19
- */
20
- private _characters;
21
- /**
22
- * Registered groups. Each group contains a displayed label and a collection with symbol names.
23
- */
24
- private _groups;
25
- /**
26
- * A label describing the "All" special characters category.
27
- */
28
- private _allSpecialCharactersGroupLabel;
29
- /**
30
- * @inheritDoc
31
- */
32
- static get requires(): readonly [typeof Typing];
33
- /**
34
- * @inheritDoc
35
- */
36
- static get pluginName(): "SpecialCharacters";
37
- /**
38
- * @inheritDoc
39
- */
40
- constructor(editor: Editor);
41
- /**
42
- * @inheritDoc
43
- */
44
- init(): void;
45
- /**
46
- * Adds a collection of special characters to the specified group. The title of a special character must be unique.
47
- *
48
- * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
49
- * characters category.
50
- */
51
- addItems(groupName: string, items: Array<SpecialCharacterDefinition>, options?: {
52
- label: string;
53
- }): void;
54
- /**
55
- * Returns special character groups in an order determined based on configuration and registration sequence.
56
- */
57
- getGroups(): Set<string>;
58
- /**
59
- * Returns a collection of special characters symbol names (titles).
60
- */
61
- getCharactersForGroup(groupName: string): Set<string> | undefined;
62
- /**
63
- * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
64
- * is returned.
65
- *
66
- * @param title The title of a special character.
67
- */
68
- getCharacter(title: string): string | undefined;
69
- /**
70
- * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
71
- *
72
- * @param groupName The name of the group to create.
73
- * @param label The label describing the new group.
74
- */
75
- private _getGroup;
76
- /**
77
- * Updates the symbol grid depending on the currently selected character group.
78
- */
79
- private _updateGrid;
80
- /**
81
- * Initializes the dropdown, used for lazy loading.
82
- *
83
- * @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
84
- */
85
- private _createDropdownPanelContent;
86
- }
87
- export interface SpecialCharacterDefinition {
88
- /**
89
- * A unique name of the character (e.g. "greek small letter epsilon").
90
- */
91
- title: string;
92
- /**
93
- * A human-readable character displayed as the label (e.g. "ε").
94
- */
95
- character: string;
96
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module special-characters/specialcharacters
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core';
9
+ import { Typing } from 'ckeditor5/src/typing';
10
+ import '../theme/specialcharacters.css';
11
+ /**
12
+ * The special characters feature.
13
+ *
14
+ * Introduces the `'specialCharacters'` dropdown.
15
+ */
16
+ export default class SpecialCharacters extends Plugin {
17
+ /**
18
+ * Registered characters. A pair of a character name and its symbol.
19
+ */
20
+ private _characters;
21
+ /**
22
+ * Registered groups. Each group contains a displayed label and a collection with symbol names.
23
+ */
24
+ private _groups;
25
+ /**
26
+ * A label describing the "All" special characters category.
27
+ */
28
+ private _allSpecialCharactersGroupLabel;
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ static get requires(): readonly [typeof Typing];
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ static get pluginName(): "SpecialCharacters";
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ constructor(editor: Editor);
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ init(): void;
45
+ /**
46
+ * Adds a collection of special characters to the specified group. The title of a special character must be unique.
47
+ *
48
+ * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
49
+ * characters category.
50
+ */
51
+ addItems(groupName: string, items: Array<SpecialCharacterDefinition>, options?: {
52
+ label: string;
53
+ }): void;
54
+ /**
55
+ * Returns special character groups in an order determined based on configuration and registration sequence.
56
+ */
57
+ getGroups(): Set<string>;
58
+ /**
59
+ * Returns a collection of special characters symbol names (titles).
60
+ */
61
+ getCharactersForGroup(groupName: string): Set<string> | undefined;
62
+ /**
63
+ * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
64
+ * is returned.
65
+ *
66
+ * @param title The title of a special character.
67
+ */
68
+ getCharacter(title: string): string | undefined;
69
+ /**
70
+ * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
71
+ *
72
+ * @param groupName The name of the group to create.
73
+ * @param label The label describing the new group.
74
+ */
75
+ private _getGroup;
76
+ /**
77
+ * Updates the symbol grid depending on the currently selected character group.
78
+ */
79
+ private _updateGrid;
80
+ /**
81
+ * Initializes the dropdown, used for lazy loading.
82
+ *
83
+ * @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
84
+ */
85
+ private _createDropdownPanelContent;
86
+ }
87
+ export interface SpecialCharacterDefinition {
88
+ /**
89
+ * A unique name of the character (e.g. "greek small letter epsilon").
90
+ */
91
+ title: string;
92
+ /**
93
+ * A human-readable character displayed as the label (e.g. "ε").
94
+ */
95
+ character: string;
96
+ }
@@ -1,206 +1,206 @@
1
- /**
2
- * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @module special-characters/specialcharacters
7
- */
8
- import { Plugin } from 'ckeditor5/src/core';
9
- import { Typing } from 'ckeditor5/src/typing';
10
- import { createDropdown } from 'ckeditor5/src/ui';
11
- import { CKEditorError } from 'ckeditor5/src/utils';
12
- import SpecialCharactersNavigationView from './ui/specialcharactersnavigationview';
13
- import CharacterGridView from './ui/charactergridview';
14
- import CharacterInfoView from './ui/characterinfoview';
15
- import SpecialCharactersView from './ui/specialcharactersview';
16
- import specialCharactersIcon from '../theme/icons/specialcharacters.svg';
17
- import '../theme/specialcharacters.css';
18
- const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
19
- /**
20
- * The special characters feature.
21
- *
22
- * Introduces the `'specialCharacters'` dropdown.
23
- */
24
- export default class SpecialCharacters extends Plugin {
25
- /**
26
- * @inheritDoc
27
- */
28
- static get requires() {
29
- return [Typing];
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- static get pluginName() {
35
- return 'SpecialCharacters';
36
- }
37
- /**
38
- * @inheritDoc
39
- */
40
- constructor(editor) {
41
- super(editor);
42
- const t = editor.t;
43
- this._characters = new Map();
44
- this._groups = new Map();
45
- this._allSpecialCharactersGroupLabel = t('All');
46
- }
47
- /**
48
- * @inheritDoc
49
- */
50
- init() {
51
- const editor = this.editor;
52
- const t = editor.t;
53
- const inputCommand = editor.commands.get('insertText');
54
- // Add the `specialCharacters` dropdown button to feature components.
55
- editor.ui.componentFactory.add('specialCharacters', locale => {
56
- const dropdownView = createDropdown(locale);
57
- let dropdownPanelContent;
58
- dropdownView.buttonView.set({
59
- label: t('Special characters'),
60
- icon: specialCharactersIcon,
61
- tooltip: true
62
- });
63
- dropdownView.bind('isEnabled').to(inputCommand);
64
- // Insert a special character when a tile was clicked.
65
- dropdownView.on('execute', (evt, data) => {
66
- editor.execute('insertText', { text: data.character });
67
- editor.editing.view.focus();
68
- });
69
- dropdownView.on('change:isOpen', () => {
70
- if (!dropdownPanelContent) {
71
- dropdownPanelContent = this._createDropdownPanelContent(locale, dropdownView);
72
- const specialCharactersView = new SpecialCharactersView(locale, dropdownPanelContent.navigationView, dropdownPanelContent.gridView, dropdownPanelContent.infoView);
73
- dropdownView.panelView.children.add(specialCharactersView);
74
- }
75
- dropdownPanelContent.infoView.set({
76
- character: null,
77
- name: null
78
- });
79
- });
80
- return dropdownView;
81
- });
82
- }
83
- /**
84
- * Adds a collection of special characters to the specified group. The title of a special character must be unique.
85
- *
86
- * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
87
- * characters category.
88
- */
89
- addItems(groupName, items, options = { label: groupName }) {
90
- if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
91
- /**
92
- * The name "All" for a special category group cannot be used because it is a special category that displays all
93
- * available special characters.
94
- *
95
- * @error special-character-invalid-group-name
96
- */
97
- throw new CKEditorError('special-character-invalid-group-name', null);
98
- }
99
- const group = this._getGroup(groupName, options.label);
100
- for (const item of items) {
101
- group.items.add(item.title);
102
- this._characters.set(item.title, item.character);
103
- }
104
- }
105
- /**
106
- * Returns special character groups in an order determined based on configuration and registration sequence.
107
- */
108
- getGroups() {
109
- const groups = Array.from(this._groups.keys());
110
- const order = this.editor.config.get('specialCharacters.order') || [];
111
- const invalidGroup = order.find(item => !groups.includes(item));
112
- if (invalidGroup) {
113
- /**
114
- * One of the special character groups in the "specialCharacters.order" configuration doesn't exist.
115
- *
116
- * @error special-character-invalid-order-group-name
117
- */
118
- throw new CKEditorError('special-character-invalid-order-group-name', null, { invalidGroup });
119
- }
120
- return new Set([
121
- ...order,
122
- ...groups
123
- ]);
124
- }
125
- /**
126
- * Returns a collection of special characters symbol names (titles).
127
- */
128
- getCharactersForGroup(groupName) {
129
- if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
130
- return new Set(this._characters.keys());
131
- }
132
- const group = this._groups.get(groupName);
133
- if (group) {
134
- return group.items;
135
- }
136
- }
137
- /**
138
- * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
139
- * is returned.
140
- *
141
- * @param title The title of a special character.
142
- */
143
- getCharacter(title) {
144
- return this._characters.get(title);
145
- }
146
- /**
147
- * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
148
- *
149
- * @param groupName The name of the group to create.
150
- * @param label The label describing the new group.
151
- */
152
- _getGroup(groupName, label) {
153
- if (!this._groups.has(groupName)) {
154
- this._groups.set(groupName, {
155
- items: new Set(),
156
- label
157
- });
158
- }
159
- return this._groups.get(groupName);
160
- }
161
- /**
162
- * Updates the symbol grid depending on the currently selected character group.
163
- */
164
- _updateGrid(currentGroupName, gridView) {
165
- // Updating the grid starts with removing all tiles belonging to the old group.
166
- gridView.tiles.clear();
167
- const characterTitles = this.getCharactersForGroup(currentGroupName);
168
- for (const title of characterTitles) {
169
- const character = this.getCharacter(title);
170
- gridView.tiles.add(gridView.createTile(character, title));
171
- }
172
- }
173
- /**
174
- * Initializes the dropdown, used for lazy loading.
175
- *
176
- * @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
177
- */
178
- _createDropdownPanelContent(locale, dropdownView) {
179
- const groupEntries = Array
180
- .from(this.getGroups())
181
- .map(name => ([name, this._groups.get(name).label]));
182
- // The map contains a name of category (an identifier) and its label (a translational string).
183
- const specialCharsGroups = new Map([
184
- // Add a special group that shows all available special characters.
185
- [ALL_SPECIAL_CHARACTERS_GROUP, this._allSpecialCharactersGroupLabel],
186
- ...groupEntries
187
- ]);
188
- const navigationView = new SpecialCharactersNavigationView(locale, specialCharsGroups);
189
- const gridView = new CharacterGridView(locale);
190
- const infoView = new CharacterInfoView(locale);
191
- gridView.delegate('execute').to(dropdownView);
192
- gridView.on('tileHover', (evt, data) => {
193
- infoView.set(data);
194
- });
195
- gridView.on('tileFocus', (evt, data) => {
196
- infoView.set(data);
197
- });
198
- // Update the grid of special characters when a user changed the character group.
199
- navigationView.on('execute', () => {
200
- this._updateGrid(navigationView.currentGroupName, gridView);
201
- });
202
- // Set the initial content of the special characters grid.
203
- this._updateGrid(navigationView.currentGroupName, gridView);
204
- return { navigationView, gridView, infoView };
205
- }
206
- }
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module special-characters/specialcharacters
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core';
9
+ import { Typing } from 'ckeditor5/src/typing';
10
+ import { createDropdown } from 'ckeditor5/src/ui';
11
+ import { CKEditorError } from 'ckeditor5/src/utils';
12
+ import SpecialCharactersNavigationView from './ui/specialcharactersnavigationview';
13
+ import CharacterGridView from './ui/charactergridview';
14
+ import CharacterInfoView from './ui/characterinfoview';
15
+ import SpecialCharactersView from './ui/specialcharactersview';
16
+ import specialCharactersIcon from '../theme/icons/specialcharacters.svg';
17
+ import '../theme/specialcharacters.css';
18
+ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
19
+ /**
20
+ * The special characters feature.
21
+ *
22
+ * Introduces the `'specialCharacters'` dropdown.
23
+ */
24
+ export default class SpecialCharacters extends Plugin {
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get requires() {
29
+ return [Typing];
30
+ }
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get pluginName() {
35
+ return 'SpecialCharacters';
36
+ }
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ constructor(editor) {
41
+ super(editor);
42
+ const t = editor.t;
43
+ this._characters = new Map();
44
+ this._groups = new Map();
45
+ this._allSpecialCharactersGroupLabel = t('All');
46
+ }
47
+ /**
48
+ * @inheritDoc
49
+ */
50
+ init() {
51
+ const editor = this.editor;
52
+ const t = editor.t;
53
+ const inputCommand = editor.commands.get('insertText');
54
+ // Add the `specialCharacters` dropdown button to feature components.
55
+ editor.ui.componentFactory.add('specialCharacters', locale => {
56
+ const dropdownView = createDropdown(locale);
57
+ let dropdownPanelContent;
58
+ dropdownView.buttonView.set({
59
+ label: t('Special characters'),
60
+ icon: specialCharactersIcon,
61
+ tooltip: true
62
+ });
63
+ dropdownView.bind('isEnabled').to(inputCommand);
64
+ // Insert a special character when a tile was clicked.
65
+ dropdownView.on('execute', (evt, data) => {
66
+ editor.execute('insertText', { text: data.character });
67
+ editor.editing.view.focus();
68
+ });
69
+ dropdownView.on('change:isOpen', () => {
70
+ if (!dropdownPanelContent) {
71
+ dropdownPanelContent = this._createDropdownPanelContent(locale, dropdownView);
72
+ const specialCharactersView = new SpecialCharactersView(locale, dropdownPanelContent.navigationView, dropdownPanelContent.gridView, dropdownPanelContent.infoView);
73
+ dropdownView.panelView.children.add(specialCharactersView);
74
+ }
75
+ dropdownPanelContent.infoView.set({
76
+ character: null,
77
+ name: null
78
+ });
79
+ });
80
+ return dropdownView;
81
+ });
82
+ }
83
+ /**
84
+ * Adds a collection of special characters to the specified group. The title of a special character must be unique.
85
+ *
86
+ * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
87
+ * characters category.
88
+ */
89
+ addItems(groupName, items, options = { label: groupName }) {
90
+ if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
91
+ /**
92
+ * The name "All" for a special category group cannot be used because it is a special category that displays all
93
+ * available special characters.
94
+ *
95
+ * @error special-character-invalid-group-name
96
+ */
97
+ throw new CKEditorError('special-character-invalid-group-name', null);
98
+ }
99
+ const group = this._getGroup(groupName, options.label);
100
+ for (const item of items) {
101
+ group.items.add(item.title);
102
+ this._characters.set(item.title, item.character);
103
+ }
104
+ }
105
+ /**
106
+ * Returns special character groups in an order determined based on configuration and registration sequence.
107
+ */
108
+ getGroups() {
109
+ const groups = Array.from(this._groups.keys());
110
+ const order = this.editor.config.get('specialCharacters.order') || [];
111
+ const invalidGroup = order.find(item => !groups.includes(item));
112
+ if (invalidGroup) {
113
+ /**
114
+ * One of the special character groups in the "specialCharacters.order" configuration doesn't exist.
115
+ *
116
+ * @error special-character-invalid-order-group-name
117
+ */
118
+ throw new CKEditorError('special-character-invalid-order-group-name', null, { invalidGroup });
119
+ }
120
+ return new Set([
121
+ ...order,
122
+ ...groups
123
+ ]);
124
+ }
125
+ /**
126
+ * Returns a collection of special characters symbol names (titles).
127
+ */
128
+ getCharactersForGroup(groupName) {
129
+ if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
130
+ return new Set(this._characters.keys());
131
+ }
132
+ const group = this._groups.get(groupName);
133
+ if (group) {
134
+ return group.items;
135
+ }
136
+ }
137
+ /**
138
+ * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
139
+ * is returned.
140
+ *
141
+ * @param title The title of a special character.
142
+ */
143
+ getCharacter(title) {
144
+ return this._characters.get(title);
145
+ }
146
+ /**
147
+ * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
148
+ *
149
+ * @param groupName The name of the group to create.
150
+ * @param label The label describing the new group.
151
+ */
152
+ _getGroup(groupName, label) {
153
+ if (!this._groups.has(groupName)) {
154
+ this._groups.set(groupName, {
155
+ items: new Set(),
156
+ label
157
+ });
158
+ }
159
+ return this._groups.get(groupName);
160
+ }
161
+ /**
162
+ * Updates the symbol grid depending on the currently selected character group.
163
+ */
164
+ _updateGrid(currentGroupName, gridView) {
165
+ // Updating the grid starts with removing all tiles belonging to the old group.
166
+ gridView.tiles.clear();
167
+ const characterTitles = this.getCharactersForGroup(currentGroupName);
168
+ for (const title of characterTitles) {
169
+ const character = this.getCharacter(title);
170
+ gridView.tiles.add(gridView.createTile(character, title));
171
+ }
172
+ }
173
+ /**
174
+ * Initializes the dropdown, used for lazy loading.
175
+ *
176
+ * @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
177
+ */
178
+ _createDropdownPanelContent(locale, dropdownView) {
179
+ const groupEntries = Array
180
+ .from(this.getGroups())
181
+ .map(name => ([name, this._groups.get(name).label]));
182
+ // The map contains a name of category (an identifier) and its label (a translational string).
183
+ const specialCharsGroups = new Map([
184
+ // Add a special group that shows all available special characters.
185
+ [ALL_SPECIAL_CHARACTERS_GROUP, this._allSpecialCharactersGroupLabel],
186
+ ...groupEntries
187
+ ]);
188
+ const navigationView = new SpecialCharactersNavigationView(locale, specialCharsGroups);
189
+ const gridView = new CharacterGridView(locale);
190
+ const infoView = new CharacterInfoView(locale);
191
+ gridView.delegate('execute').to(dropdownView);
192
+ gridView.on('tileHover', (evt, data) => {
193
+ infoView.set(data);
194
+ });
195
+ gridView.on('tileFocus', (evt, data) => {
196
+ infoView.set(data);
197
+ });
198
+ // Update the grid of special characters when a user changed the character group.
199
+ navigationView.on('execute', () => {
200
+ this._updateGrid(navigationView.currentGroupName, gridView);
201
+ });
202
+ // Set the initial content of the special characters grid.
203
+ this._updateGrid(navigationView.currentGroupName, gridView);
204
+ return { navigationView, gridView, infoView };
205
+ }
206
+ }