@ckeditor/ckeditor5-special-characters 42.0.2 → 43.0.0-alpha.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.
Files changed (221) hide show
  1. package/CHANGELOG.md +1 -27
  2. package/build/special-characters.js +2 -2
  3. package/build/translations/ar.js +1 -1
  4. package/build/translations/az.js +1 -1
  5. package/build/translations/bg.js +1 -1
  6. package/build/translations/bn.js +1 -1
  7. package/build/translations/ca.js +1 -1
  8. package/build/translations/cs.js +1 -1
  9. package/build/translations/da.js +1 -1
  10. package/build/translations/de.js +1 -1
  11. package/build/translations/el.js +1 -1
  12. package/build/translations/en-au.js +1 -1
  13. package/build/translations/es.js +1 -1
  14. package/build/translations/et.js +1 -1
  15. package/build/translations/fa.js +1 -1
  16. package/build/translations/fi.js +1 -1
  17. package/build/translations/fr.js +1 -1
  18. package/build/translations/gl.js +1 -1
  19. package/build/translations/he.js +1 -1
  20. package/build/translations/hi.js +1 -1
  21. package/build/translations/hr.js +1 -1
  22. package/build/translations/hu.js +1 -1
  23. package/build/translations/id.js +1 -1
  24. package/build/translations/it.js +1 -1
  25. package/build/translations/ja.js +1 -1
  26. package/build/translations/ko.js +1 -1
  27. package/build/translations/lt.js +1 -1
  28. package/build/translations/lv.js +1 -1
  29. package/build/translations/ms.js +1 -1
  30. package/build/translations/nl.js +1 -1
  31. package/build/translations/no.js +1 -1
  32. package/build/translations/pl.js +1 -1
  33. package/build/translations/pt-br.js +1 -1
  34. package/build/translations/pt.js +1 -1
  35. package/build/translations/ro.js +1 -1
  36. package/build/translations/ru.js +1 -1
  37. package/build/translations/sk.js +1 -1
  38. package/build/translations/sq.js +1 -1
  39. package/build/translations/sr-latn.js +1 -1
  40. package/build/translations/sr.js +1 -1
  41. package/build/translations/sv.js +1 -1
  42. package/build/translations/th.js +1 -1
  43. package/build/translations/ti.js +1 -1
  44. package/build/translations/tk.js +1 -1
  45. package/build/translations/tr.js +1 -1
  46. package/build/translations/uk.js +1 -1
  47. package/build/translations/ur.js +1 -1
  48. package/build/translations/uz.js +1 -1
  49. package/build/translations/vi.js +1 -1
  50. package/build/translations/zh-cn.js +1 -1
  51. package/build/translations/zh.js +1 -1
  52. package/dist/index-editor.css +77 -1
  53. package/dist/index.css +96 -0
  54. package/dist/index.css.map +1 -1
  55. package/dist/index.js +155 -137
  56. package/dist/index.js.map +1 -1
  57. package/dist/specialcharacters.d.ts +8 -2
  58. package/dist/translations/ar.js +1 -1
  59. package/dist/translations/ar.umd.js +1 -1
  60. package/dist/translations/az.js +1 -1
  61. package/dist/translations/az.umd.js +1 -1
  62. package/dist/translations/bg.js +1 -1
  63. package/dist/translations/bg.umd.js +1 -1
  64. package/dist/translations/bn.js +1 -1
  65. package/dist/translations/bn.umd.js +1 -1
  66. package/dist/translations/ca.js +1 -1
  67. package/dist/translations/ca.umd.js +1 -1
  68. package/dist/translations/cs.js +1 -1
  69. package/dist/translations/cs.umd.js +1 -1
  70. package/dist/translations/da.js +1 -1
  71. package/dist/translations/da.umd.js +1 -1
  72. package/dist/translations/de.js +1 -1
  73. package/dist/translations/de.umd.js +1 -1
  74. package/dist/translations/el.js +1 -1
  75. package/dist/translations/el.umd.js +1 -1
  76. package/dist/translations/en-au.js +1 -1
  77. package/dist/translations/en-au.umd.js +1 -1
  78. package/dist/translations/en.js +1 -1
  79. package/dist/translations/en.umd.js +1 -1
  80. package/dist/translations/es.js +1 -1
  81. package/dist/translations/es.umd.js +1 -1
  82. package/dist/translations/et.js +1 -1
  83. package/dist/translations/et.umd.js +1 -1
  84. package/dist/translations/fa.js +1 -1
  85. package/dist/translations/fa.umd.js +1 -1
  86. package/dist/translations/fi.js +1 -1
  87. package/dist/translations/fi.umd.js +1 -1
  88. package/dist/translations/fr.js +1 -1
  89. package/dist/translations/fr.umd.js +1 -1
  90. package/dist/translations/gl.js +1 -1
  91. package/dist/translations/gl.umd.js +1 -1
  92. package/dist/translations/he.js +1 -1
  93. package/dist/translations/he.umd.js +1 -1
  94. package/dist/translations/hi.js +1 -1
  95. package/dist/translations/hi.umd.js +1 -1
  96. package/dist/translations/hr.js +1 -1
  97. package/dist/translations/hr.umd.js +1 -1
  98. package/dist/translations/hu.js +1 -1
  99. package/dist/translations/hu.umd.js +1 -1
  100. package/dist/translations/id.js +1 -1
  101. package/dist/translations/id.umd.js +1 -1
  102. package/dist/translations/it.js +1 -1
  103. package/dist/translations/it.umd.js +1 -1
  104. package/dist/translations/ja.js +1 -1
  105. package/dist/translations/ja.umd.js +1 -1
  106. package/dist/translations/ko.js +1 -1
  107. package/dist/translations/ko.umd.js +1 -1
  108. package/dist/translations/lt.js +1 -1
  109. package/dist/translations/lt.umd.js +1 -1
  110. package/dist/translations/lv.js +1 -1
  111. package/dist/translations/lv.umd.js +1 -1
  112. package/dist/translations/ms.js +1 -1
  113. package/dist/translations/ms.umd.js +1 -1
  114. package/dist/translations/nl.js +1 -1
  115. package/dist/translations/nl.umd.js +1 -1
  116. package/dist/translations/no.js +1 -1
  117. package/dist/translations/no.umd.js +1 -1
  118. package/dist/translations/pl.js +1 -1
  119. package/dist/translations/pl.umd.js +1 -1
  120. package/dist/translations/pt-br.js +1 -1
  121. package/dist/translations/pt-br.umd.js +1 -1
  122. package/dist/translations/pt.js +1 -1
  123. package/dist/translations/pt.umd.js +1 -1
  124. package/dist/translations/ro.js +1 -1
  125. package/dist/translations/ro.umd.js +1 -1
  126. package/dist/translations/ru.js +1 -1
  127. package/dist/translations/ru.umd.js +1 -1
  128. package/dist/translations/sk.js +1 -1
  129. package/dist/translations/sk.umd.js +1 -1
  130. package/dist/translations/sq.js +1 -1
  131. package/dist/translations/sq.umd.js +1 -1
  132. package/dist/translations/sr-latn.js +1 -1
  133. package/dist/translations/sr-latn.umd.js +1 -1
  134. package/dist/translations/sr.js +1 -1
  135. package/dist/translations/sr.umd.js +1 -1
  136. package/dist/translations/sv.js +1 -1
  137. package/dist/translations/sv.umd.js +1 -1
  138. package/dist/translations/th.js +1 -1
  139. package/dist/translations/th.umd.js +1 -1
  140. package/dist/translations/ti.js +1 -1
  141. package/dist/translations/ti.umd.js +1 -1
  142. package/dist/translations/tk.js +1 -1
  143. package/dist/translations/tk.umd.js +1 -1
  144. package/dist/translations/tr.js +1 -1
  145. package/dist/translations/tr.umd.js +1 -1
  146. package/dist/translations/uk.js +1 -1
  147. package/dist/translations/uk.umd.js +1 -1
  148. package/dist/translations/ur.js +1 -1
  149. package/dist/translations/ur.umd.js +1 -1
  150. package/dist/translations/uz.js +1 -1
  151. package/dist/translations/uz.umd.js +1 -1
  152. package/dist/translations/vi.js +1 -1
  153. package/dist/translations/vi.umd.js +1 -1
  154. package/dist/translations/zh-cn.js +1 -1
  155. package/dist/translations/zh-cn.umd.js +1 -1
  156. package/dist/translations/zh.js +1 -1
  157. package/dist/translations/zh.umd.js +1 -1
  158. package/dist/ui/specialcharacterscategoriesview.d.ts +45 -0
  159. package/dist/ui/specialcharactersview.d.ts +4 -4
  160. package/lang/contexts.json +2 -2
  161. package/lang/translations/ar.po +4 -4
  162. package/lang/translations/az.po +4 -4
  163. package/lang/translations/bg.po +4 -4
  164. package/lang/translations/bn.po +4 -4
  165. package/lang/translations/ca.po +4 -4
  166. package/lang/translations/cs.po +4 -4
  167. package/lang/translations/da.po +4 -4
  168. package/lang/translations/de.po +4 -4
  169. package/lang/translations/el.po +4 -4
  170. package/lang/translations/en-au.po +4 -4
  171. package/lang/translations/en.po +4 -4
  172. package/lang/translations/es.po +4 -4
  173. package/lang/translations/et.po +4 -4
  174. package/lang/translations/fa.po +4 -4
  175. package/lang/translations/fi.po +4 -4
  176. package/lang/translations/fr.po +4 -4
  177. package/lang/translations/gl.po +4 -4
  178. package/lang/translations/he.po +4 -4
  179. package/lang/translations/hi.po +4 -4
  180. package/lang/translations/hr.po +4 -4
  181. package/lang/translations/hu.po +4 -4
  182. package/lang/translations/id.po +4 -4
  183. package/lang/translations/it.po +4 -4
  184. package/lang/translations/ja.po +4 -4
  185. package/lang/translations/ko.po +4 -4
  186. package/lang/translations/lt.po +4 -4
  187. package/lang/translations/lv.po +4 -4
  188. package/lang/translations/ms.po +4 -4
  189. package/lang/translations/nl.po +4 -4
  190. package/lang/translations/no.po +4 -4
  191. package/lang/translations/pl.po +4 -4
  192. package/lang/translations/pt-br.po +4 -4
  193. package/lang/translations/pt.po +4 -4
  194. package/lang/translations/ro.po +4 -4
  195. package/lang/translations/ru.po +4 -4
  196. package/lang/translations/sk.po +4 -4
  197. package/lang/translations/sq.po +4 -4
  198. package/lang/translations/sr-latn.po +4 -4
  199. package/lang/translations/sr.po +4 -4
  200. package/lang/translations/sv.po +4 -4
  201. package/lang/translations/th.po +4 -4
  202. package/lang/translations/ti.po +4 -4
  203. package/lang/translations/tk.po +4 -4
  204. package/lang/translations/tr.po +4 -4
  205. package/lang/translations/uk.po +4 -4
  206. package/lang/translations/ur.po +4 -4
  207. package/lang/translations/uz.po +4 -4
  208. package/lang/translations/vi.po +4 -4
  209. package/lang/translations/zh-cn.po +4 -4
  210. package/lang/translations/zh.po +4 -4
  211. package/package.json +6 -6
  212. package/src/specialcharacters.d.ts +8 -2
  213. package/src/specialcharacters.js +60 -38
  214. package/src/ui/specialcharacterscategoriesview.d.ts +41 -0
  215. package/src/ui/specialcharacterscategoriesview.js +94 -0
  216. package/src/ui/specialcharactersview.d.ts +4 -4
  217. package/src/ui/specialcharactersview.js +6 -6
  218. package/theme/specialcharacters.css +81 -0
  219. package/dist/ui/specialcharactersnavigationview.d.ts +0 -63
  220. package/src/ui/specialcharactersnavigationview.d.ts +0 -59
  221. package/src/ui/specialcharactersnavigationview.js +0 -95
package/dist/index.js CHANGED
@@ -4,97 +4,8 @@
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, addKeyboardHandlingForGrid, ButtonView, FocusCycler } from '@ckeditor/ckeditor5-ui/dist/index.js';
8
- import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
9
-
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
- }
32
- /**
33
- * Returns the name of the character group currently selected in the {@link #groupDropdownView}.
34
- */ get currentGroupName() {
35
- return this.groupDropdownView.value;
36
- }
37
- /**
38
- * Focuses the character categories dropdown.
39
- */ focus() {
40
- this.groupDropdownView.focus();
41
- }
42
- /**
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) {
47
- const locale = this.locale;
48
- const t = locale.t;
49
- const dropdown = createDropdown(locale);
50
- const groupDefinitions = this._getCharacterGroupListItemDefinitions(dropdown, groupNames);
51
- const accessibleLabel = t('Character categories');
52
- dropdown.set('value', groupDefinitions.first.model.name);
53
- dropdown.buttonView.bind('label').to(dropdown, 'value', (value)=>groupNames.get(value));
54
- dropdown.buttonView.set({
55
- isOn: false,
56
- withText: true,
57
- tooltip: accessibleLabel,
58
- class: [
59
- 'ck-dropdown__button_label-width_auto'
60
- ],
61
- ariaLabel: accessibleLabel,
62
- ariaLabelledBy: undefined
63
- });
64
- dropdown.on('execute', (evt)=>{
65
- dropdown.value = evt.source.name;
66
- });
67
- dropdown.delegate('execute').to(this);
68
- addListToDropdown(dropdown, groupDefinitions, {
69
- ariaLabel: accessibleLabel,
70
- role: 'menu'
71
- });
72
- return dropdown;
73
- }
74
- /**
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) {
81
- const groupDefs = new Collection();
82
- for (const [name, label] of groupNames){
83
- const model = new ViewModel({
84
- name,
85
- label,
86
- withText: true,
87
- role: 'menuitemradio'
88
- });
89
- model.bind('isOn').to(dropdown, 'value', (value)=>value === model.name);
90
- groupDefs.add({
91
- type: 'button',
92
- model
93
- });
94
- }
95
- return groupDefs;
96
- }
97
- }
7
+ import { View, addKeyboardHandlingForGrid, ButtonView, FocusCycler, LabeledFieldView, createLabeledDropdown, ViewModel, addListToDropdown, Dialog, MenuBarMenuListItemButtonView, DialogViewPosition } from '@ckeditor/ckeditor5-ui/dist/index.js';
8
+ import { FocusTracker, KeystrokeHandler, global, Collection, CKEditorError } from '@ckeditor/ckeditor5-utils/dist/index.js';
98
9
 
99
10
  /**
100
11
  * A grid of character tiles. It allows browsing special characters and selecting the character to
@@ -309,8 +220,8 @@ import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } fro
309
220
  * Helps cycling over focusable {@link #items} in the view.
310
221
  */ _focusCycler;
311
222
  /**
312
- * An instance of the `SpecialCharactersNavigationView`.
313
- */ navigationView;
223
+ * An instance of the `SpecialCharactersCategoriesView`.
224
+ */ categoriesView;
314
225
  /**
315
226
  * An instance of the `CharacterGridView`.
316
227
  */ gridView;
@@ -319,9 +230,9 @@ import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } fro
319
230
  */ infoView;
320
231
  /**
321
232
  * Creates an instance of the `SpecialCharactersView`.
322
- */ constructor(locale, navigationView, gridView, infoView){
233
+ */ constructor(locale, categoriesView, gridView, infoView){
323
234
  super(locale);
324
- this.navigationView = navigationView;
235
+ this.categoriesView = categoriesView;
325
236
  this.gridView = gridView;
326
237
  this.infoView = infoView;
327
238
  this.items = this.createCollection();
@@ -339,7 +250,7 @@ import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } fro
339
250
  this.setTemplate({
340
251
  tag: 'div',
341
252
  children: [
342
- this.navigationView,
253
+ this.categoriesView,
343
254
  this.gridView,
344
255
  this.infoView
345
256
  ],
@@ -349,14 +260,14 @@ import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } fro
349
260
  tabindex: '-1'
350
261
  }
351
262
  });
352
- this.items.add(this.navigationView.groupDropdownView.buttonView);
263
+ this.items.add(this.categoriesView);
353
264
  this.items.add(this.gridView);
354
265
  }
355
266
  /**
356
267
  * @inheritDoc
357
268
  */ render() {
358
269
  super.render();
359
- this.focusTracker.add(this.navigationView.groupDropdownView.buttonView.element);
270
+ this.focusTracker.add(this.categoriesView.element);
360
271
  this.focusTracker.add(this.gridView.element);
361
272
  // Start listening for the keystrokes coming from #element.
362
273
  this.keystrokes.listenTo(this.element);
@@ -371,12 +282,97 @@ import { Collection, FocusTracker, KeystrokeHandler, global, CKEditorError } fro
371
282
  /**
372
283
  * Focuses the first focusable in {@link #items}.
373
284
  */ focus() {
374
- this.navigationView.focus();
285
+ this._focusCycler.focusFirst();
375
286
  }
376
287
  }
377
288
 
378
289
  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>";
379
290
 
291
+ /**
292
+ * A class representing the navigation part of the special characters UI. It is responsible
293
+ * for describing the feature and allowing the user to select a particular character group.
294
+ */ class SpecialCharactersCategoriesView extends View {
295
+ _groupNames;
296
+ _dropdownView;
297
+ /**
298
+ * Creates an instance of the {@link module:special-characters/ui/specialcharacterscategoriesview~SpecialCharactersCategoriesView}
299
+ * class.
300
+ *
301
+ * @param locale The localization services instance.
302
+ * @param groupNames The names of the character groups.
303
+ */ constructor(locale, groupNames){
304
+ super(locale);
305
+ this.set('currentGroupName', Array.from(groupNames.entries())[0][0]);
306
+ this._groupNames = groupNames;
307
+ this._dropdownView = new LabeledFieldView(locale, createLabeledDropdown);
308
+ this.setTemplate({
309
+ tag: 'div',
310
+ attributes: {
311
+ class: [
312
+ 'ck',
313
+ 'ck-character-categories'
314
+ ]
315
+ },
316
+ children: [
317
+ this._dropdownView
318
+ ]
319
+ });
320
+ }
321
+ /**
322
+ * @inheritDoc
323
+ */ render() {
324
+ super.render();
325
+ this._setupDropdown();
326
+ }
327
+ /**
328
+ * @inheritDoc
329
+ */ focus() {
330
+ this._dropdownView.focus();
331
+ }
332
+ /**
333
+ * Creates dropdown item list, sets up bindings and fills properties.
334
+ */ _setupDropdown() {
335
+ const items = new Collection();
336
+ for (const [name, label] of this._groupNames){
337
+ const item = {
338
+ type: 'button',
339
+ model: new ViewModel({
340
+ name,
341
+ label,
342
+ role: 'menuitemradio',
343
+ withText: true
344
+ })
345
+ };
346
+ item.model.bind('isOn').to(this, 'currentGroupName', (value)=>{
347
+ return value === name;
348
+ });
349
+ items.add(item);
350
+ }
351
+ const t = this.locale.t;
352
+ const accessibleLabel = t('Category');
353
+ this._dropdownView.set({
354
+ label: accessibleLabel,
355
+ isEmpty: false
356
+ });
357
+ this._dropdownView.fieldView.panelPosition = this.locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';
358
+ this._dropdownView.fieldView.buttonView.set({
359
+ withText: true,
360
+ tooltip: accessibleLabel,
361
+ ariaLabel: accessibleLabel,
362
+ ariaLabelledBy: undefined,
363
+ isOn: false
364
+ });
365
+ this._dropdownView.fieldView.buttonView.bind('label').to(this, 'currentGroupName', (value)=>this._groupNames.get(value));
366
+ this._dropdownView.fieldView.on('execute', ({ source })=>{
367
+ this.currentGroupName = source.name;
368
+ });
369
+ addListToDropdown(this._dropdownView.fieldView, items, {
370
+ ariaLabel: accessibleLabel,
371
+ role: 'menu'
372
+ });
373
+ }
374
+ }
375
+
380
376
  const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
381
377
  /**
382
378
  * The special characters feature.
@@ -396,7 +392,8 @@ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
396
392
  * @inheritDoc
397
393
  */ static get requires() {
398
394
  return [
399
- Typing
395
+ Typing,
396
+ Dialog
400
397
  ];
401
398
  }
402
399
  /**
@@ -417,37 +414,15 @@ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
417
414
  * @inheritDoc
418
415
  */ init() {
419
416
  const editor = this.editor;
420
- const t = editor.t;
421
- const inputCommand = editor.commands.get('insertText');
422
- // Add the `specialCharacters` dropdown button to feature components.
423
- editor.ui.componentFactory.add('specialCharacters', (locale)=>{
424
- const dropdownView = createDropdown(locale);
425
- let dropdownPanelContent;
426
- dropdownView.buttonView.set({
427
- label: t('Special characters'),
428
- icon: specialCharactersIcon,
417
+ editor.ui.componentFactory.add('specialCharacters', ()=>{
418
+ const button = this._createDialogButton(ButtonView);
419
+ button.set({
429
420
  tooltip: true
430
421
  });
431
- dropdownView.bind('isEnabled').to(inputCommand);
432
- // Insert a special character when a tile was clicked.
433
- dropdownView.on('execute', (evt, data)=>{
434
- editor.execute('insertText', {
435
- text: data.character
436
- });
437
- editor.editing.view.focus();
438
- });
439
- dropdownView.on('change:isOpen', ()=>{
440
- if (!dropdownPanelContent) {
441
- dropdownPanelContent = this._createDropdownPanelContent(locale, dropdownView);
442
- const specialCharactersView = new SpecialCharactersView(locale, dropdownPanelContent.navigationView, dropdownPanelContent.gridView, dropdownPanelContent.infoView);
443
- dropdownView.panelView.children.add(specialCharactersView);
444
- }
445
- dropdownPanelContent.infoView.set({
446
- character: null,
447
- name: null
448
- });
449
- });
450
- return dropdownView;
422
+ return button;
423
+ });
424
+ editor.ui.componentFactory.add('menuBar:specialCharacters', ()=>{
425
+ return this._createDialogButton(MenuBarMenuListItemButtonView);
451
426
  });
452
427
  }
453
428
  /**
@@ -539,8 +514,8 @@ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
539
514
  /**
540
515
  * Initializes the dropdown, used for lazy loading.
541
516
  *
542
- * @returns An object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
543
- */ _createDropdownPanelContent(locale, dropdownView) {
517
+ * @returns An object with `categoriesView`, `gridView` and `infoView` properties, containing UI parts.
518
+ */ _createDropdownPanelContent(locale) {
544
519
  const groupEntries = Array.from(this.getGroups()).map((name)=>[
545
520
  name,
546
521
  this._groups.get(name).label
@@ -554,10 +529,9 @@ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
554
529
  ],
555
530
  ...groupEntries
556
531
  ]);
557
- const navigationView = new SpecialCharactersNavigationView(locale, specialCharsGroups);
532
+ const categoriesView = new SpecialCharactersCategoriesView(locale, specialCharsGroups);
558
533
  const gridView = new CharacterGridView(locale);
559
534
  const infoView = new CharacterInfoView(locale);
560
- gridView.delegate('execute').to(dropdownView);
561
535
  gridView.on('tileHover', (evt, data)=>{
562
536
  infoView.set(data);
563
537
  });
@@ -565,17 +539,61 @@ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
565
539
  infoView.set(data);
566
540
  });
567
541
  // Update the grid of special characters when a user changed the character group.
568
- navigationView.on('execute', ()=>{
569
- this._updateGrid(navigationView.currentGroupName, gridView);
542
+ categoriesView.on('change:currentGroupName', (evt, propertyName, newValue)=>{
543
+ this._updateGrid(newValue, gridView);
570
544
  });
571
545
  // Set the initial content of the special characters grid.
572
- this._updateGrid(navigationView.currentGroupName, gridView);
546
+ this._updateGrid(categoriesView.currentGroupName, gridView);
573
547
  return {
574
- navigationView,
548
+ categoriesView,
575
549
  gridView,
576
550
  infoView
577
551
  };
578
552
  }
553
+ /**
554
+ * Creates a button for for menu bar that will show special characetrs dialog.
555
+ */ _createDialogButton(ButtonClass) {
556
+ const editor = this.editor;
557
+ const locale = editor.locale;
558
+ const buttonView = new ButtonClass(editor.locale);
559
+ const command = editor.commands.get('insertText');
560
+ const t = locale.t;
561
+ const dialogPlugin = this.editor.plugins.get('Dialog');
562
+ buttonView.set({
563
+ label: t('Special characters'),
564
+ icon: specialCharactersIcon
565
+ });
566
+ buttonView.bind('isOn').to(dialogPlugin, 'id', (id)=>id === 'specialCharacters');
567
+ buttonView.bind('isEnabled').to(command, 'isEnabled');
568
+ buttonView.on('execute', ()=>{
569
+ if (dialogPlugin.id === 'specialCharacters') {
570
+ dialogPlugin.hide();
571
+ return;
572
+ }
573
+ this._showDialog();
574
+ });
575
+ return buttonView;
576
+ }
577
+ _showDialog() {
578
+ const editor = this.editor;
579
+ const dialog = editor.plugins.get('Dialog');
580
+ const locale = editor.locale;
581
+ const t = locale.t;
582
+ const { categoriesView, gridView, infoView } = this._createDropdownPanelContent(locale);
583
+ const content = new SpecialCharactersView(locale, categoriesView, gridView, infoView);
584
+ gridView.on('execute', (evt, data)=>{
585
+ editor.execute('insertText', {
586
+ text: data.character
587
+ });
588
+ });
589
+ dialog.show({
590
+ id: 'specialCharacters',
591
+ title: t('Special characters'),
592
+ className: 'ck-special-characters',
593
+ content,
594
+ position: DialogViewPosition.EDITOR_TOP_SIDE
595
+ });
596
+ }
579
597
  }
580
598
 
581
599
  /**