@ckeditor/ckeditor5-special-characters 41.4.1 → 42.0.0-alpha.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.
- package/README.md +6 -0
- package/dist/index.js +310 -183
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4,25 +4,46 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
|
|
6
6
|
import { Typing } from '@ckeditor/ckeditor5-typing/dist/index.js';
|
|
7
|
-
import { FormHeaderView, createDropdown, addListToDropdown, ViewModel, View,
|
|
7
|
+
import { FormHeaderView, createDropdown, addListToDropdown, ViewModel, View, addKeyboardHandlingForGrid, ButtonView, FocusCycler } from '@ckeditor/ckeditor5-ui/dist/index.js';
|
|
8
8
|
import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A class representing the navigation part of the special characters UI. It is responsible
|
|
12
|
+
* for describing the feature and allowing the user to select a particular character group.
|
|
13
|
+
*/ class SpecialCharactersNavigationView extends FormHeaderView {
|
|
14
|
+
/**
|
|
15
|
+
* A dropdown that allows selecting a group of special characters to be displayed.
|
|
16
|
+
*/ groupDropdownView;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an instance of the {@link module:special-characters/ui/specialcharactersnavigationview~SpecialCharactersNavigationView}
|
|
19
|
+
* class.
|
|
20
|
+
*
|
|
21
|
+
* @param locale The localization services instance.
|
|
22
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
23
|
+
*/ constructor(locale, groupNames){
|
|
24
|
+
super(locale);
|
|
25
|
+
const t = locale.t;
|
|
26
|
+
this.set('class', 'ck-special-characters-navigation');
|
|
27
|
+
this.groupDropdownView = this._createGroupDropdown(groupNames);
|
|
28
|
+
this.groupDropdownView.panelPosition = locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';
|
|
29
|
+
this.label = t('Special characters');
|
|
30
|
+
this.children.add(this.groupDropdownView);
|
|
31
|
+
}
|
|
11
32
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
* Returns the name of the character group currently selected in the {@link #groupDropdownView}.
|
|
34
|
+
*/ get currentGroupName() {
|
|
14
35
|
return this.groupDropdownView.value;
|
|
15
36
|
}
|
|
16
37
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
* Focuses the character categories dropdown.
|
|
39
|
+
*/ focus() {
|
|
19
40
|
this.groupDropdownView.focus();
|
|
20
41
|
}
|
|
21
42
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
* Returns a dropdown that allows selecting character groups.
|
|
44
|
+
*
|
|
45
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
46
|
+
*/ _createGroupDropdown(groupNames) {
|
|
26
47
|
const locale = this.locale;
|
|
27
48
|
const t = locale.t;
|
|
28
49
|
const dropdown = createDropdown(locale);
|
|
@@ -51,12 +72,12 @@ class SpecialCharactersNavigationView extends FormHeaderView {
|
|
|
51
72
|
return dropdown;
|
|
52
73
|
}
|
|
53
74
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
* Returns list item definitions to be used in the character group dropdown
|
|
76
|
+
* representing specific character groups.
|
|
77
|
+
*
|
|
78
|
+
* @param dropdown Dropdown view element
|
|
79
|
+
* @param groupNames The names of the character groups and their displayed labels.
|
|
80
|
+
*/ _getCharacterGroupListItemDefinitions(dropdown, groupNames) {
|
|
60
81
|
const groupDefs = new Collection();
|
|
61
82
|
for (const [name, label] of groupNames){
|
|
62
83
|
const model = new ViewModel({
|
|
@@ -73,30 +94,66 @@ class SpecialCharactersNavigationView extends FormHeaderView {
|
|
|
73
94
|
}
|
|
74
95
|
return groupDefs;
|
|
75
96
|
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A grid of character tiles. It allows browsing special characters and selecting the character to
|
|
101
|
+
* be inserted into the content.
|
|
102
|
+
*/ class CharacterGridView extends View {
|
|
103
|
+
/**
|
|
104
|
+
* A collection of the child tile views. Each tile represents a particular character.
|
|
105
|
+
*/ tiles;
|
|
76
106
|
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
107
|
+
* Tracks information about the DOM focus in the grid.
|
|
108
|
+
*/ focusTracker;
|
|
109
|
+
/**
|
|
110
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
111
|
+
*/ keystrokes;
|
|
112
|
+
/**
|
|
113
|
+
* Creates an instance of a character grid containing tiles representing special characters.
|
|
114
|
+
*
|
|
115
|
+
* @param locale The localization services instance.
|
|
116
|
+
*/ constructor(locale){
|
|
83
117
|
super(locale);
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
118
|
+
this.tiles = this.createCollection();
|
|
119
|
+
this.setTemplate({
|
|
120
|
+
tag: 'div',
|
|
121
|
+
children: [
|
|
122
|
+
{
|
|
123
|
+
tag: 'div',
|
|
124
|
+
attributes: {
|
|
125
|
+
class: [
|
|
126
|
+
'ck',
|
|
127
|
+
'ck-character-grid__tiles'
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
children: this.tiles
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
attributes: {
|
|
134
|
+
class: [
|
|
135
|
+
'ck',
|
|
136
|
+
'ck-character-grid'
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.focusTracker = new FocusTracker();
|
|
141
|
+
this.keystrokes = new KeystrokeHandler();
|
|
142
|
+
addKeyboardHandlingForGrid({
|
|
143
|
+
keystrokeHandler: this.keystrokes,
|
|
144
|
+
focusTracker: this.focusTracker,
|
|
145
|
+
gridItems: this.tiles,
|
|
146
|
+
numberOfColumns: ()=>global.window.getComputedStyle(this.element.firstChild) // Responsive .ck-character-grid__tiles
|
|
147
|
+
.getPropertyValue('grid-template-columns').split(' ').length,
|
|
148
|
+
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
|
|
149
|
+
});
|
|
90
150
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
class CharacterGridView extends View {
|
|
94
151
|
/**
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
152
|
+
* Creates a new tile for the grid.
|
|
153
|
+
*
|
|
154
|
+
* @param character A human-readable character displayed as the label (e.g. "ε").
|
|
155
|
+
* @param name The name of the character (e.g. "greek small letter epsilon").
|
|
156
|
+
*/ createTile(character, name) {
|
|
100
157
|
const tile = new ButtonView(this.locale);
|
|
101
158
|
tile.set({
|
|
102
159
|
label: character,
|
|
@@ -135,8 +192,8 @@ class CharacterGridView extends View {
|
|
|
135
192
|
return tile;
|
|
136
193
|
}
|
|
137
194
|
/**
|
|
138
|
-
|
|
139
|
-
|
|
195
|
+
* @inheritDoc
|
|
196
|
+
*/ render() {
|
|
140
197
|
super.render();
|
|
141
198
|
for (const item of this.tiles){
|
|
142
199
|
this.focusTracker.add(item.element);
|
|
@@ -156,58 +213,22 @@ class CharacterGridView extends View {
|
|
|
156
213
|
this.keystrokes.listenTo(this.element);
|
|
157
214
|
}
|
|
158
215
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
216
|
+
* @inheritDoc
|
|
217
|
+
*/ destroy() {
|
|
161
218
|
super.destroy();
|
|
162
219
|
this.keystrokes.destroy();
|
|
163
220
|
}
|
|
164
221
|
/**
|
|
165
|
-
|
|
166
|
-
|
|
222
|
+
* Focuses the first focusable in {@link ~CharacterGridView#tiles}.
|
|
223
|
+
*/ focus() {
|
|
167
224
|
this.tiles.first.focus();
|
|
168
225
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Creates an instance of a character grid containing tiles representing special characters.
|
|
171
|
-
*
|
|
172
|
-
* @param locale The localization services instance.
|
|
173
|
-
*/ constructor(locale){
|
|
174
|
-
super(locale);
|
|
175
|
-
this.tiles = this.createCollection();
|
|
176
|
-
this.setTemplate({
|
|
177
|
-
tag: 'div',
|
|
178
|
-
children: [
|
|
179
|
-
{
|
|
180
|
-
tag: 'div',
|
|
181
|
-
attributes: {
|
|
182
|
-
class: [
|
|
183
|
-
'ck',
|
|
184
|
-
'ck-character-grid__tiles'
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
children: this.tiles
|
|
188
|
-
}
|
|
189
|
-
],
|
|
190
|
-
attributes: {
|
|
191
|
-
class: [
|
|
192
|
-
'ck',
|
|
193
|
-
'ck-character-grid'
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
this.focusTracker = new FocusTracker();
|
|
198
|
-
this.keystrokes = new KeystrokeHandler();
|
|
199
|
-
addKeyboardHandlingForGrid({
|
|
200
|
-
keystrokeHandler: this.keystrokes,
|
|
201
|
-
focusTracker: this.focusTracker,
|
|
202
|
-
gridItems: this.tiles,
|
|
203
|
-
numberOfColumns: ()=>global.window.getComputedStyle(this.element.firstChild) // Responsive .ck-character-grid__tiles
|
|
204
|
-
.getPropertyValue('grid-template-columns').split(' ').length,
|
|
205
|
-
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
226
|
}
|
|
209
227
|
|
|
210
|
-
|
|
228
|
+
/**
|
|
229
|
+
* The view displaying detailed information about a special character glyph, e.g. upon
|
|
230
|
+
* hovering it with a mouse.
|
|
231
|
+
*/ class CharacterInfoView extends View {
|
|
211
232
|
constructor(locale){
|
|
212
233
|
super(locale);
|
|
213
234
|
const bind = this.bindTemplate;
|
|
@@ -268,31 +289,37 @@ class CharacterInfoView extends View {
|
|
|
268
289
|
return 'U+' + ('0000' + hexCode).slice(-4);
|
|
269
290
|
}
|
|
270
291
|
|
|
271
|
-
|
|
292
|
+
/**
|
|
293
|
+
* A view that glues pieces of the special characters dropdown panel together:
|
|
294
|
+
*
|
|
295
|
+
* * the navigation view (allows selecting the category),
|
|
296
|
+
* * the grid view (displays characters as a grid),
|
|
297
|
+
* * and the info view (displays detailed info about a specific character).
|
|
298
|
+
*/ class SpecialCharactersView extends View {
|
|
272
299
|
/**
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
super.render();
|
|
276
|
-
this.focusTracker.add(this.navigationView.groupDropdownView.buttonView.element);
|
|
277
|
-
this.focusTracker.add(this.gridView.element);
|
|
278
|
-
// Start listening for the keystrokes coming from #element.
|
|
279
|
-
this.keystrokes.listenTo(this.element);
|
|
280
|
-
}
|
|
300
|
+
* A collection of the focusable children of the view.
|
|
301
|
+
*/ items;
|
|
281
302
|
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
super.destroy();
|
|
285
|
-
this.focusTracker.destroy();
|
|
286
|
-
this.keystrokes.destroy();
|
|
287
|
-
}
|
|
303
|
+
* Tracks information about the DOM focus in the view.
|
|
304
|
+
*/ focusTracker;
|
|
288
305
|
/**
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
306
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
307
|
+
*/ keystrokes;
|
|
308
|
+
/**
|
|
309
|
+
* Helps cycling over focusable {@link #items} in the view.
|
|
310
|
+
*/ _focusCycler;
|
|
311
|
+
/**
|
|
312
|
+
* An instance of the `SpecialCharactersNavigationView`.
|
|
313
|
+
*/ navigationView;
|
|
293
314
|
/**
|
|
294
|
-
|
|
295
|
-
|
|
315
|
+
* An instance of the `CharacterGridView`.
|
|
316
|
+
*/ gridView;
|
|
317
|
+
/**
|
|
318
|
+
* An instance of the `CharacterInfoView`.
|
|
319
|
+
*/ infoView;
|
|
320
|
+
/**
|
|
321
|
+
* Creates an instance of the `SpecialCharactersView`.
|
|
322
|
+
*/ constructor(locale, navigationView, gridView, infoView){
|
|
296
323
|
super(locale);
|
|
297
324
|
this.navigationView = navigationView;
|
|
298
325
|
this.gridView = gridView;
|
|
@@ -325,27 +352,70 @@ class SpecialCharactersView extends View {
|
|
|
325
352
|
this.items.add(this.navigationView.groupDropdownView.buttonView);
|
|
326
353
|
this.items.add(this.gridView);
|
|
327
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* @inheritDoc
|
|
357
|
+
*/ render() {
|
|
358
|
+
super.render();
|
|
359
|
+
this.focusTracker.add(this.navigationView.groupDropdownView.buttonView.element);
|
|
360
|
+
this.focusTracker.add(this.gridView.element);
|
|
361
|
+
// Start listening for the keystrokes coming from #element.
|
|
362
|
+
this.keystrokes.listenTo(this.element);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* @inheritDoc
|
|
366
|
+
*/ destroy() {
|
|
367
|
+
super.destroy();
|
|
368
|
+
this.focusTracker.destroy();
|
|
369
|
+
this.keystrokes.destroy();
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Focuses the first focusable in {@link #items}.
|
|
373
|
+
*/ focus() {
|
|
374
|
+
this.navigationView.focus();
|
|
375
|
+
}
|
|
328
376
|
}
|
|
329
377
|
|
|
330
378
|
var specialCharactersIcon = "<svg viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M10 2.5a7.47 7.47 0 0 1 4.231 1.31 7.268 7.268 0 0 1 2.703 3.454 7.128 7.128 0 0 1 .199 4.353c-.39 1.436-1.475 2.72-2.633 3.677h2.013c0-.226.092-.443.254-.603a.876.876 0 0 1 1.229 0c.163.16.254.377.254.603v.853c0 .209-.078.41-.22.567a.873.873 0 0 1-.547.28l-.101.006h-4.695a.517.517 0 0 1-.516-.518v-1.265c0-.21.128-.398.317-.489a5.601 5.601 0 0 0 2.492-2.371 5.459 5.459 0 0 0 .552-3.693 5.53 5.53 0 0 0-1.955-3.2A5.71 5.71 0 0 0 10 4.206 5.708 5.708 0 0 0 6.419 5.46 5.527 5.527 0 0 0 4.46 8.663a5.457 5.457 0 0 0 .554 3.695 5.6 5.6 0 0 0 2.497 2.37.55.55 0 0 1 .317.49v1.264c0 .286-.23.518-.516.518H2.618a.877.877 0 0 1-.614-.25.845.845 0 0 1-.254-.603v-.853c0-.226.091-.443.254-.603a.876.876 0 0 1 1.228 0c.163.16.255.377.255.603h1.925c-1.158-.958-2.155-2.241-2.545-3.678a7.128 7.128 0 0 1 .199-4.352 7.268 7.268 0 0 1 2.703-3.455A7.475 7.475 0 0 1 10 2.5z\"/></svg>";
|
|
331
379
|
|
|
332
380
|
const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
|
|
333
|
-
|
|
381
|
+
/**
|
|
382
|
+
* The special characters feature.
|
|
383
|
+
*
|
|
384
|
+
* Introduces the `'specialCharacters'` dropdown.
|
|
385
|
+
*/ class SpecialCharacters extends Plugin {
|
|
334
386
|
/**
|
|
335
|
-
|
|
336
|
-
|
|
387
|
+
* Registered characters. A pair of a character name and its symbol.
|
|
388
|
+
*/ _characters;
|
|
389
|
+
/**
|
|
390
|
+
* Registered groups. Each group contains a displayed label and a collection with symbol names.
|
|
391
|
+
*/ _groups;
|
|
392
|
+
/**
|
|
393
|
+
* A label describing the "All" special characters category.
|
|
394
|
+
*/ _allSpecialCharactersGroupLabel;
|
|
395
|
+
/**
|
|
396
|
+
* @inheritDoc
|
|
397
|
+
*/ static get requires() {
|
|
337
398
|
return [
|
|
338
399
|
Typing
|
|
339
400
|
];
|
|
340
401
|
}
|
|
341
402
|
/**
|
|
342
|
-
|
|
343
|
-
|
|
403
|
+
* @inheritDoc
|
|
404
|
+
*/ static get pluginName() {
|
|
344
405
|
return 'SpecialCharacters';
|
|
345
406
|
}
|
|
346
407
|
/**
|
|
347
|
-
|
|
348
|
-
|
|
408
|
+
* @inheritDoc
|
|
409
|
+
*/ constructor(editor){
|
|
410
|
+
super(editor);
|
|
411
|
+
const t = editor.t;
|
|
412
|
+
this._characters = new Map();
|
|
413
|
+
this._groups = new Map();
|
|
414
|
+
this._allSpecialCharactersGroupLabel = t('All');
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* @inheritDoc
|
|
418
|
+
*/ init() {
|
|
349
419
|
const editor = this.editor;
|
|
350
420
|
const t = editor.t;
|
|
351
421
|
const inputCommand = editor.commands.get('insertText');
|
|
@@ -381,20 +451,20 @@ class SpecialCharacters extends Plugin {
|
|
|
381
451
|
});
|
|
382
452
|
}
|
|
383
453
|
/**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
454
|
+
* Adds a collection of special characters to the specified group. The title of a special character must be unique.
|
|
455
|
+
*
|
|
456
|
+
* **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
|
|
457
|
+
* characters category.
|
|
458
|
+
*/ addItems(groupName, items, options = {
|
|
389
459
|
label: groupName
|
|
390
460
|
}) {
|
|
391
461
|
if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
|
|
392
462
|
/**
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
463
|
+
* The name "All" for a special category group cannot be used because it is a special category that displays all
|
|
464
|
+
* available special characters.
|
|
465
|
+
*
|
|
466
|
+
* @error special-character-invalid-group-name
|
|
467
|
+
*/ throw new CKEditorError('special-character-invalid-group-name', null);
|
|
398
468
|
}
|
|
399
469
|
const group = this._getGroup(groupName, options.label);
|
|
400
470
|
for (const item of items){
|
|
@@ -403,17 +473,17 @@ class SpecialCharacters extends Plugin {
|
|
|
403
473
|
}
|
|
404
474
|
}
|
|
405
475
|
/**
|
|
406
|
-
|
|
407
|
-
|
|
476
|
+
* Returns special character groups in an order determined based on configuration and registration sequence.
|
|
477
|
+
*/ getGroups() {
|
|
408
478
|
const groups = Array.from(this._groups.keys());
|
|
409
479
|
const order = this.editor.config.get('specialCharacters.order') || [];
|
|
410
480
|
const invalidGroup = order.find((item)=>!groups.includes(item));
|
|
411
481
|
if (invalidGroup) {
|
|
412
482
|
/**
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
483
|
+
* One of the special character groups in the "specialCharacters.order" configuration doesn't exist.
|
|
484
|
+
*
|
|
485
|
+
* @error special-character-invalid-order-group-name
|
|
486
|
+
*/ throw new CKEditorError('special-character-invalid-order-group-name', null, {
|
|
417
487
|
invalidGroup
|
|
418
488
|
});
|
|
419
489
|
}
|
|
@@ -423,8 +493,8 @@ class SpecialCharacters extends Plugin {
|
|
|
423
493
|
]);
|
|
424
494
|
}
|
|
425
495
|
/**
|
|
426
|
-
|
|
427
|
-
|
|
496
|
+
* Returns a collection of special characters symbol names (titles).
|
|
497
|
+
*/ getCharactersForGroup(groupName) {
|
|
428
498
|
if (groupName === ALL_SPECIAL_CHARACTERS_GROUP) {
|
|
429
499
|
return new Set(this._characters.keys());
|
|
430
500
|
}
|
|
@@ -434,19 +504,19 @@ class SpecialCharacters extends Plugin {
|
|
|
434
504
|
}
|
|
435
505
|
}
|
|
436
506
|
/**
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
507
|
+
* Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
|
|
508
|
+
* is returned.
|
|
509
|
+
*
|
|
510
|
+
* @param title The title of a special character.
|
|
511
|
+
*/ getCharacter(title) {
|
|
442
512
|
return this._characters.get(title);
|
|
443
513
|
}
|
|
444
514
|
/**
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
515
|
+
* Returns a group of special characters. If the group with the specified name does not exist, it will be created.
|
|
516
|
+
*
|
|
517
|
+
* @param groupName The name of the group to create.
|
|
518
|
+
* @param label The label describing the new group.
|
|
519
|
+
*/ _getGroup(groupName, label) {
|
|
450
520
|
if (!this._groups.has(groupName)) {
|
|
451
521
|
this._groups.set(groupName, {
|
|
452
522
|
items: new Set(),
|
|
@@ -456,8 +526,8 @@ class SpecialCharacters extends Plugin {
|
|
|
456
526
|
return this._groups.get(groupName);
|
|
457
527
|
}
|
|
458
528
|
/**
|
|
459
|
-
|
|
460
|
-
|
|
529
|
+
* Updates the symbol grid depending on the currently selected character group.
|
|
530
|
+
*/ _updateGrid(currentGroupName, gridView) {
|
|
461
531
|
// Updating the grid starts with removing all tiles belonging to the old group.
|
|
462
532
|
gridView.tiles.clear();
|
|
463
533
|
const characterTitles = this.getCharactersForGroup(currentGroupName);
|
|
@@ -467,10 +537,10 @@ class SpecialCharacters extends Plugin {
|
|
|
467
537
|
}
|
|
468
538
|
}
|
|
469
539
|
/**
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
540
|
+
* Initializes the dropdown, used for lazy loading.
|
|
541
|
+
*
|
|
542
|
+
* @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
|
|
543
|
+
*/ _createDropdownPanelContent(locale, dropdownView) {
|
|
474
544
|
const groupEntries = Array.from(this.getGroups()).map((name)=>[
|
|
475
545
|
name,
|
|
476
546
|
this._groups.get(name).label
|
|
@@ -506,26 +576,28 @@ class SpecialCharacters extends Plugin {
|
|
|
506
576
|
infoView
|
|
507
577
|
};
|
|
508
578
|
}
|
|
509
|
-
/**
|
|
510
|
-
* @inheritDoc
|
|
511
|
-
*/ constructor(editor){
|
|
512
|
-
super(editor);
|
|
513
|
-
const t = editor.t;
|
|
514
|
-
this._characters = new Map();
|
|
515
|
-
this._groups = new Map();
|
|
516
|
-
this._allSpecialCharactersGroupLabel = t('All');
|
|
517
|
-
}
|
|
518
579
|
}
|
|
519
580
|
|
|
520
|
-
|
|
581
|
+
/**
|
|
582
|
+
* A plugin that provides special characters for the "Arrows" category.
|
|
583
|
+
*
|
|
584
|
+
* ```ts
|
|
585
|
+
* ClassicEditor
|
|
586
|
+
* .create( {
|
|
587
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersArrows ],
|
|
588
|
+
* } )
|
|
589
|
+
* .then( ... )
|
|
590
|
+
* .catch( ... );
|
|
591
|
+
* ```
|
|
592
|
+
*/ class SpecialCharactersArrows extends Plugin {
|
|
521
593
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
594
|
+
* @inheritDoc
|
|
595
|
+
*/ static get pluginName() {
|
|
524
596
|
return 'SpecialCharactersArrows';
|
|
525
597
|
}
|
|
526
598
|
/**
|
|
527
|
-
|
|
528
|
-
|
|
599
|
+
* @inheritDoc
|
|
600
|
+
*/ init() {
|
|
529
601
|
const editor = this.editor;
|
|
530
602
|
const t = editor.t;
|
|
531
603
|
const plugin = editor.plugins.get('SpecialCharacters');
|
|
@@ -624,15 +696,26 @@ class SpecialCharactersArrows extends Plugin {
|
|
|
624
696
|
}
|
|
625
697
|
}
|
|
626
698
|
|
|
627
|
-
|
|
699
|
+
/**
|
|
700
|
+
* A plugin that provides special characters for the "Text" category.
|
|
701
|
+
*
|
|
702
|
+
* ```ts
|
|
703
|
+
* ClassicEditor
|
|
704
|
+
* .create( {
|
|
705
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersText ],
|
|
706
|
+
* } )
|
|
707
|
+
* .then( ... )
|
|
708
|
+
* .catch( ... );
|
|
709
|
+
* ```
|
|
710
|
+
*/ class SpecialCharactersText extends Plugin {
|
|
628
711
|
/**
|
|
629
|
-
|
|
630
|
-
|
|
712
|
+
* @inheritDoc
|
|
713
|
+
*/ static get pluginName() {
|
|
631
714
|
return 'SpecialCharactersText';
|
|
632
715
|
}
|
|
633
716
|
/**
|
|
634
|
-
|
|
635
|
-
|
|
717
|
+
* @inheritDoc
|
|
718
|
+
*/ init() {
|
|
636
719
|
const editor = this.editor;
|
|
637
720
|
const t = editor.t;
|
|
638
721
|
const plugin = editor.plugins.get('SpecialCharacters');
|
|
@@ -751,15 +834,26 @@ class SpecialCharactersText extends Plugin {
|
|
|
751
834
|
}
|
|
752
835
|
}
|
|
753
836
|
|
|
754
|
-
|
|
837
|
+
/**
|
|
838
|
+
* A plugin that provides special characters for the "Mathematical" category.
|
|
839
|
+
*
|
|
840
|
+
* ```ts
|
|
841
|
+
* ClassicEditor
|
|
842
|
+
* .create( {
|
|
843
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersMathematical ],
|
|
844
|
+
* } )
|
|
845
|
+
* .then( ... )
|
|
846
|
+
* .catch( ... );
|
|
847
|
+
* ```
|
|
848
|
+
*/ class SpecialCharactersMathematical extends Plugin {
|
|
755
849
|
/**
|
|
756
|
-
|
|
757
|
-
|
|
850
|
+
* @inheritDoc
|
|
851
|
+
*/ static get pluginName() {
|
|
758
852
|
return 'SpecialCharactersMathematical';
|
|
759
853
|
}
|
|
760
854
|
/**
|
|
761
|
-
|
|
762
|
-
|
|
855
|
+
* @inheritDoc
|
|
856
|
+
*/ init() {
|
|
763
857
|
const editor = this.editor;
|
|
764
858
|
const t = editor.t;
|
|
765
859
|
const plugin = editor.plugins.get('SpecialCharacters');
|
|
@@ -946,15 +1040,26 @@ class SpecialCharactersMathematical extends Plugin {
|
|
|
946
1040
|
}
|
|
947
1041
|
}
|
|
948
1042
|
|
|
949
|
-
|
|
1043
|
+
/**
|
|
1044
|
+
* A plugin that provides special characters for the "Latin" category.
|
|
1045
|
+
*
|
|
1046
|
+
* ```ts
|
|
1047
|
+
* ClassicEditor
|
|
1048
|
+
* .create( {
|
|
1049
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersLatin ],
|
|
1050
|
+
* } )
|
|
1051
|
+
* .then( ... )
|
|
1052
|
+
* .catch( ... );
|
|
1053
|
+
* ```
|
|
1054
|
+
*/ class SpecialCharactersLatin extends Plugin {
|
|
950
1055
|
/**
|
|
951
|
-
|
|
952
|
-
|
|
1056
|
+
* @inheritDoc
|
|
1057
|
+
*/ static get pluginName() {
|
|
953
1058
|
return 'SpecialCharactersLatin';
|
|
954
1059
|
}
|
|
955
1060
|
/**
|
|
956
|
-
|
|
957
|
-
|
|
1061
|
+
* @inheritDoc
|
|
1062
|
+
*/ init() {
|
|
958
1063
|
const editor = this.editor;
|
|
959
1064
|
const t = editor.t;
|
|
960
1065
|
const plugin = editor.plugins.get('SpecialCharacters');
|
|
@@ -1477,15 +1582,26 @@ class SpecialCharactersLatin extends Plugin {
|
|
|
1477
1582
|
}
|
|
1478
1583
|
}
|
|
1479
1584
|
|
|
1480
|
-
|
|
1585
|
+
/**
|
|
1586
|
+
* A plugin that provides special characters for the "Currency" category.
|
|
1587
|
+
*
|
|
1588
|
+
* ```ts
|
|
1589
|
+
* ClassicEditor
|
|
1590
|
+
* .create( {
|
|
1591
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersCurrency ],
|
|
1592
|
+
* } )
|
|
1593
|
+
* .then( ... )
|
|
1594
|
+
* .catch( ... );
|
|
1595
|
+
* ```
|
|
1596
|
+
*/ class SpecialCharactersCurrency extends Plugin {
|
|
1481
1597
|
/**
|
|
1482
|
-
|
|
1483
|
-
|
|
1598
|
+
* @inheritDoc
|
|
1599
|
+
*/ static get pluginName() {
|
|
1484
1600
|
return 'SpecialCharactersCurrency';
|
|
1485
1601
|
}
|
|
1486
1602
|
/**
|
|
1487
|
-
|
|
1488
|
-
|
|
1603
|
+
* @inheritDoc
|
|
1604
|
+
*/ init() {
|
|
1489
1605
|
const editor = this.editor;
|
|
1490
1606
|
const t = editor.t;
|
|
1491
1607
|
const plugin = editor.plugins.get('SpecialCharacters');
|
|
@@ -1640,15 +1756,26 @@ class SpecialCharactersCurrency extends Plugin {
|
|
|
1640
1756
|
}
|
|
1641
1757
|
}
|
|
1642
1758
|
|
|
1643
|
-
|
|
1759
|
+
/**
|
|
1760
|
+
* A plugin combining a basic set of characters for the special characters plugin.
|
|
1761
|
+
*
|
|
1762
|
+
* ```ts
|
|
1763
|
+
* ClassicEditor
|
|
1764
|
+
* .create( {
|
|
1765
|
+
* plugins: [ ..., SpecialCharacters, SpecialCharactersEssentials ],
|
|
1766
|
+
* } )
|
|
1767
|
+
* .then( ... )
|
|
1768
|
+
* .catch( ... );
|
|
1769
|
+
* ```
|
|
1770
|
+
*/ class SpecialCharactersEssentials extends Plugin {
|
|
1644
1771
|
/**
|
|
1645
|
-
|
|
1646
|
-
|
|
1772
|
+
* @inheritDoc
|
|
1773
|
+
*/ static get pluginName() {
|
|
1647
1774
|
return 'SpecialCharactersEssentials';
|
|
1648
1775
|
}
|
|
1649
1776
|
/**
|
|
1650
|
-
|
|
1651
|
-
|
|
1777
|
+
* @inheritDoc
|
|
1778
|
+
*/ static get requires() {
|
|
1652
1779
|
return [
|
|
1653
1780
|
SpecialCharactersCurrency,
|
|
1654
1781
|
SpecialCharactersText,
|