@ckeditor/ckeditor5-special-characters 0.0.0-internal-20241017.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 (313) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +17 -0
  3. package/README.md +27 -0
  4. package/build/special-characters.js +5 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/az.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/bn.js +1 -0
  9. package/build/translations/ca.js +1 -0
  10. package/build/translations/cs.js +1 -0
  11. package/build/translations/da.js +1 -0
  12. package/build/translations/de.js +1 -0
  13. package/build/translations/el.js +1 -0
  14. package/build/translations/en-au.js +1 -0
  15. package/build/translations/es.js +1 -0
  16. package/build/translations/et.js +1 -0
  17. package/build/translations/fa.js +1 -0
  18. package/build/translations/fi.js +1 -0
  19. package/build/translations/fr.js +1 -0
  20. package/build/translations/gl.js +1 -0
  21. package/build/translations/he.js +1 -0
  22. package/build/translations/hi.js +1 -0
  23. package/build/translations/hr.js +1 -0
  24. package/build/translations/hu.js +1 -0
  25. package/build/translations/id.js +1 -0
  26. package/build/translations/it.js +1 -0
  27. package/build/translations/ja.js +1 -0
  28. package/build/translations/ko.js +1 -0
  29. package/build/translations/lt.js +1 -0
  30. package/build/translations/lv.js +1 -0
  31. package/build/translations/ms.js +1 -0
  32. package/build/translations/nl.js +1 -0
  33. package/build/translations/no.js +1 -0
  34. package/build/translations/pl.js +1 -0
  35. package/build/translations/pt-br.js +1 -0
  36. package/build/translations/pt.js +1 -0
  37. package/build/translations/ro.js +1 -0
  38. package/build/translations/ru.js +1 -0
  39. package/build/translations/sk.js +1 -0
  40. package/build/translations/sq.js +1 -0
  41. package/build/translations/sr-latn.js +1 -0
  42. package/build/translations/sr.js +1 -0
  43. package/build/translations/sv.js +1 -0
  44. package/build/translations/th.js +1 -0
  45. package/build/translations/ti.js +1 -0
  46. package/build/translations/tk.js +1 -0
  47. package/build/translations/tr.js +1 -0
  48. package/build/translations/ug.js +1 -0
  49. package/build/translations/uk.js +1 -0
  50. package/build/translations/ur.js +1 -0
  51. package/build/translations/uz.js +1 -0
  52. package/build/translations/vi.js +1 -0
  53. package/build/translations/zh-cn.js +1 -0
  54. package/build/translations/zh.js +1 -0
  55. package/ckeditor5-metadata.json +78 -0
  56. package/dist/augmentation.d.ts +28 -0
  57. package/dist/index-content.css +4 -0
  58. package/dist/index-editor.css +92 -0
  59. package/dist/index.css +124 -0
  60. package/dist/index.css.map +1 -0
  61. package/dist/index.d.ts +20 -0
  62. package/dist/index.js +1844 -0
  63. package/dist/index.js.map +1 -0
  64. package/dist/specialcharacters.d.ts +110 -0
  65. package/dist/specialcharactersarrows.d.ts +38 -0
  66. package/dist/specialcharactersconfig.d.ts +55 -0
  67. package/dist/specialcharacterscurrency.d.ts +38 -0
  68. package/dist/specialcharactersessentials.d.ts +43 -0
  69. package/dist/specialcharacterslatin.d.ts +38 -0
  70. package/dist/specialcharactersmathematical.d.ts +38 -0
  71. package/dist/specialcharacterstext.d.ts +38 -0
  72. package/dist/translations/ar.d.ts +8 -0
  73. package/dist/translations/ar.js +5 -0
  74. package/dist/translations/ar.umd.js +11 -0
  75. package/dist/translations/az.d.ts +8 -0
  76. package/dist/translations/az.js +5 -0
  77. package/dist/translations/az.umd.js +11 -0
  78. package/dist/translations/bg.d.ts +8 -0
  79. package/dist/translations/bg.js +5 -0
  80. package/dist/translations/bg.umd.js +11 -0
  81. package/dist/translations/bn.d.ts +8 -0
  82. package/dist/translations/bn.js +5 -0
  83. package/dist/translations/bn.umd.js +11 -0
  84. package/dist/translations/ca.d.ts +8 -0
  85. package/dist/translations/ca.js +5 -0
  86. package/dist/translations/ca.umd.js +11 -0
  87. package/dist/translations/cs.d.ts +8 -0
  88. package/dist/translations/cs.js +5 -0
  89. package/dist/translations/cs.umd.js +11 -0
  90. package/dist/translations/da.d.ts +8 -0
  91. package/dist/translations/da.js +5 -0
  92. package/dist/translations/da.umd.js +11 -0
  93. package/dist/translations/de.d.ts +8 -0
  94. package/dist/translations/de.js +5 -0
  95. package/dist/translations/de.umd.js +11 -0
  96. package/dist/translations/el.d.ts +8 -0
  97. package/dist/translations/el.js +5 -0
  98. package/dist/translations/el.umd.js +11 -0
  99. package/dist/translations/en-au.d.ts +8 -0
  100. package/dist/translations/en-au.js +5 -0
  101. package/dist/translations/en-au.umd.js +11 -0
  102. package/dist/translations/en.d.ts +8 -0
  103. package/dist/translations/en.js +5 -0
  104. package/dist/translations/en.umd.js +11 -0
  105. package/dist/translations/es.d.ts +8 -0
  106. package/dist/translations/es.js +5 -0
  107. package/dist/translations/es.umd.js +11 -0
  108. package/dist/translations/et.d.ts +8 -0
  109. package/dist/translations/et.js +5 -0
  110. package/dist/translations/et.umd.js +11 -0
  111. package/dist/translations/fa.d.ts +8 -0
  112. package/dist/translations/fa.js +5 -0
  113. package/dist/translations/fa.umd.js +11 -0
  114. package/dist/translations/fi.d.ts +8 -0
  115. package/dist/translations/fi.js +5 -0
  116. package/dist/translations/fi.umd.js +11 -0
  117. package/dist/translations/fr.d.ts +8 -0
  118. package/dist/translations/fr.js +5 -0
  119. package/dist/translations/fr.umd.js +11 -0
  120. package/dist/translations/gl.d.ts +8 -0
  121. package/dist/translations/gl.js +5 -0
  122. package/dist/translations/gl.umd.js +11 -0
  123. package/dist/translations/he.d.ts +8 -0
  124. package/dist/translations/he.js +5 -0
  125. package/dist/translations/he.umd.js +11 -0
  126. package/dist/translations/hi.d.ts +8 -0
  127. package/dist/translations/hi.js +5 -0
  128. package/dist/translations/hi.umd.js +11 -0
  129. package/dist/translations/hr.d.ts +8 -0
  130. package/dist/translations/hr.js +5 -0
  131. package/dist/translations/hr.umd.js +11 -0
  132. package/dist/translations/hu.d.ts +8 -0
  133. package/dist/translations/hu.js +5 -0
  134. package/dist/translations/hu.umd.js +11 -0
  135. package/dist/translations/id.d.ts +8 -0
  136. package/dist/translations/id.js +5 -0
  137. package/dist/translations/id.umd.js +11 -0
  138. package/dist/translations/it.d.ts +8 -0
  139. package/dist/translations/it.js +5 -0
  140. package/dist/translations/it.umd.js +11 -0
  141. package/dist/translations/ja.d.ts +8 -0
  142. package/dist/translations/ja.js +5 -0
  143. package/dist/translations/ja.umd.js +11 -0
  144. package/dist/translations/ko.d.ts +8 -0
  145. package/dist/translations/ko.js +5 -0
  146. package/dist/translations/ko.umd.js +11 -0
  147. package/dist/translations/lt.d.ts +8 -0
  148. package/dist/translations/lt.js +5 -0
  149. package/dist/translations/lt.umd.js +11 -0
  150. package/dist/translations/lv.d.ts +8 -0
  151. package/dist/translations/lv.js +5 -0
  152. package/dist/translations/lv.umd.js +11 -0
  153. package/dist/translations/ms.d.ts +8 -0
  154. package/dist/translations/ms.js +5 -0
  155. package/dist/translations/ms.umd.js +11 -0
  156. package/dist/translations/nl.d.ts +8 -0
  157. package/dist/translations/nl.js +5 -0
  158. package/dist/translations/nl.umd.js +11 -0
  159. package/dist/translations/no.d.ts +8 -0
  160. package/dist/translations/no.js +5 -0
  161. package/dist/translations/no.umd.js +11 -0
  162. package/dist/translations/pl.d.ts +8 -0
  163. package/dist/translations/pl.js +5 -0
  164. package/dist/translations/pl.umd.js +11 -0
  165. package/dist/translations/pt-br.d.ts +8 -0
  166. package/dist/translations/pt-br.js +5 -0
  167. package/dist/translations/pt-br.umd.js +11 -0
  168. package/dist/translations/pt.d.ts +8 -0
  169. package/dist/translations/pt.js +5 -0
  170. package/dist/translations/pt.umd.js +11 -0
  171. package/dist/translations/ro.d.ts +8 -0
  172. package/dist/translations/ro.js +5 -0
  173. package/dist/translations/ro.umd.js +11 -0
  174. package/dist/translations/ru.d.ts +8 -0
  175. package/dist/translations/ru.js +5 -0
  176. package/dist/translations/ru.umd.js +11 -0
  177. package/dist/translations/sk.d.ts +8 -0
  178. package/dist/translations/sk.js +5 -0
  179. package/dist/translations/sk.umd.js +11 -0
  180. package/dist/translations/sq.d.ts +8 -0
  181. package/dist/translations/sq.js +5 -0
  182. package/dist/translations/sq.umd.js +11 -0
  183. package/dist/translations/sr-latn.d.ts +8 -0
  184. package/dist/translations/sr-latn.js +5 -0
  185. package/dist/translations/sr-latn.umd.js +11 -0
  186. package/dist/translations/sr.d.ts +8 -0
  187. package/dist/translations/sr.js +5 -0
  188. package/dist/translations/sr.umd.js +11 -0
  189. package/dist/translations/sv.d.ts +8 -0
  190. package/dist/translations/sv.js +5 -0
  191. package/dist/translations/sv.umd.js +11 -0
  192. package/dist/translations/th.d.ts +8 -0
  193. package/dist/translations/th.js +5 -0
  194. package/dist/translations/th.umd.js +11 -0
  195. package/dist/translations/ti.d.ts +8 -0
  196. package/dist/translations/ti.js +5 -0
  197. package/dist/translations/ti.umd.js +11 -0
  198. package/dist/translations/tk.d.ts +8 -0
  199. package/dist/translations/tk.js +5 -0
  200. package/dist/translations/tk.umd.js +11 -0
  201. package/dist/translations/tr.d.ts +8 -0
  202. package/dist/translations/tr.js +5 -0
  203. package/dist/translations/tr.umd.js +11 -0
  204. package/dist/translations/ug.d.ts +8 -0
  205. package/dist/translations/ug.js +5 -0
  206. package/dist/translations/ug.umd.js +11 -0
  207. package/dist/translations/uk.d.ts +8 -0
  208. package/dist/translations/uk.js +5 -0
  209. package/dist/translations/uk.umd.js +11 -0
  210. package/dist/translations/ur.d.ts +8 -0
  211. package/dist/translations/ur.js +5 -0
  212. package/dist/translations/ur.umd.js +11 -0
  213. package/dist/translations/uz.d.ts +8 -0
  214. package/dist/translations/uz.js +5 -0
  215. package/dist/translations/uz.umd.js +11 -0
  216. package/dist/translations/vi.d.ts +8 -0
  217. package/dist/translations/vi.js +5 -0
  218. package/dist/translations/vi.umd.js +11 -0
  219. package/dist/translations/zh-cn.d.ts +8 -0
  220. package/dist/translations/zh-cn.js +5 -0
  221. package/dist/translations/zh-cn.umd.js +11 -0
  222. package/dist/translations/zh.d.ts +8 -0
  223. package/dist/translations/zh.js +5 -0
  224. package/dist/translations/zh.umd.js +11 -0
  225. package/dist/ui/charactergridview.d.ts +98 -0
  226. package/dist/ui/characterinfoview.d.ts +39 -0
  227. package/dist/ui/specialcharacterscategoriesview.d.ts +45 -0
  228. package/dist/ui/specialcharactersview.d.ts +69 -0
  229. package/lang/contexts.json +267 -0
  230. package/lang/translations/ar.po +1080 -0
  231. package/lang/translations/az.po +1078 -0
  232. package/lang/translations/bg.po +1082 -0
  233. package/lang/translations/bn.po +1078 -0
  234. package/lang/translations/ca.po +1078 -0
  235. package/lang/translations/cs.po +1078 -0
  236. package/lang/translations/da.po +1078 -0
  237. package/lang/translations/de.po +1078 -0
  238. package/lang/translations/el.po +1078 -0
  239. package/lang/translations/en-au.po +1078 -0
  240. package/lang/translations/en.po +1078 -0
  241. package/lang/translations/es.po +1078 -0
  242. package/lang/translations/et.po +1078 -0
  243. package/lang/translations/fa.po +1078 -0
  244. package/lang/translations/fi.po +1078 -0
  245. package/lang/translations/fr.po +1078 -0
  246. package/lang/translations/gl.po +1078 -0
  247. package/lang/translations/he.po +1078 -0
  248. package/lang/translations/hi.po +1078 -0
  249. package/lang/translations/hr.po +1078 -0
  250. package/lang/translations/hu.po +1078 -0
  251. package/lang/translations/id.po +1078 -0
  252. package/lang/translations/it.po +1078 -0
  253. package/lang/translations/ja.po +1078 -0
  254. package/lang/translations/ko.po +1078 -0
  255. package/lang/translations/lt.po +1078 -0
  256. package/lang/translations/lv.po +1078 -0
  257. package/lang/translations/ms.po +1078 -0
  258. package/lang/translations/nl.po +1080 -0
  259. package/lang/translations/no.po +1080 -0
  260. package/lang/translations/pl.po +1078 -0
  261. package/lang/translations/pt-br.po +1078 -0
  262. package/lang/translations/pt.po +1078 -0
  263. package/lang/translations/ro.po +1078 -0
  264. package/lang/translations/ru.po +1078 -0
  265. package/lang/translations/sk.po +1078 -0
  266. package/lang/translations/sq.po +1078 -0
  267. package/lang/translations/sr-latn.po +1078 -0
  268. package/lang/translations/sr.po +1078 -0
  269. package/lang/translations/sv.po +1078 -0
  270. package/lang/translations/th.po +1078 -0
  271. package/lang/translations/ti.po +1078 -0
  272. package/lang/translations/tk.po +1078 -0
  273. package/lang/translations/tr.po +1078 -0
  274. package/lang/translations/ug.po +1078 -0
  275. package/lang/translations/uk.po +1078 -0
  276. package/lang/translations/ur.po +1078 -0
  277. package/lang/translations/uz.po +1078 -0
  278. package/lang/translations/vi.po +1078 -0
  279. package/lang/translations/zh-cn.po +1078 -0
  280. package/lang/translations/zh.po +1078 -0
  281. package/package.json +42 -0
  282. package/src/augmentation.d.ts +24 -0
  283. package/src/augmentation.js +5 -0
  284. package/src/index.d.ts +16 -0
  285. package/src/index.js +15 -0
  286. package/src/specialcharacters.d.ts +106 -0
  287. package/src/specialcharacters.js +235 -0
  288. package/src/specialcharactersarrows.d.ts +34 -0
  289. package/src/specialcharactersarrows.js +66 -0
  290. package/src/specialcharactersconfig.d.ts +51 -0
  291. package/src/specialcharactersconfig.js +5 -0
  292. package/src/specialcharacterscurrency.d.ts +34 -0
  293. package/src/specialcharacterscurrency.js +80 -0
  294. package/src/specialcharactersessentials.d.ts +39 -0
  295. package/src/specialcharactersessentials.js +51 -0
  296. package/src/specialcharacterslatin.d.ts +34 -0
  297. package/src/specialcharacterslatin.js +172 -0
  298. package/src/specialcharactersmathematical.d.ts +34 -0
  299. package/src/specialcharactersmathematical.js +88 -0
  300. package/src/specialcharacterstext.d.ts +34 -0
  301. package/src/specialcharacterstext.js +71 -0
  302. package/src/ui/charactergridview.d.ts +94 -0
  303. package/src/ui/charactergridview.js +129 -0
  304. package/src/ui/characterinfoview.d.ts +35 -0
  305. package/src/ui/characterinfoview.js +71 -0
  306. package/src/ui/specialcharacterscategoriesview.d.ts +41 -0
  307. package/src/ui/specialcharacterscategoriesview.js +94 -0
  308. package/src/ui/specialcharactersview.d.ts +65 -0
  309. package/src/ui/specialcharactersview.js +78 -0
  310. package/theme/charactergrid.css +12 -0
  311. package/theme/characterinfo.css +9 -0
  312. package/theme/icons/specialcharacters.svg +1 -0
  313. package/theme/specialcharacters.css +91 -0
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/charactergridview
7
+ */
8
+ import { View, ButtonView, type ViewCollection } from 'ckeditor5/src/ui.js';
9
+ import { KeystrokeHandler, FocusTracker, type Locale } from 'ckeditor5/src/utils.js';
10
+ import '../../theme/charactergrid.css';
11
+ /**
12
+ * A grid of character tiles. It allows browsing special characters and selecting the character to
13
+ * be inserted into the content.
14
+ */
15
+ export default class CharacterGridView extends View<HTMLDivElement> {
16
+ /**
17
+ * A collection of the child tile views. Each tile represents a particular character.
18
+ */
19
+ readonly tiles: ViewCollection<ButtonView>;
20
+ /**
21
+ * Tracks information about the DOM focus in the grid.
22
+ */
23
+ readonly focusTracker: FocusTracker;
24
+ /**
25
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
26
+ */
27
+ readonly keystrokes: KeystrokeHandler;
28
+ /**
29
+ * Creates an instance of a character grid containing tiles representing special characters.
30
+ *
31
+ * @param locale The localization services instance.
32
+ */
33
+ constructor(locale: Locale);
34
+ /**
35
+ * Creates a new tile for the grid.
36
+ *
37
+ * @param character A human-readable character displayed as the label (e.g. "ε").
38
+ * @param name The name of the character (e.g. "greek small letter epsilon").
39
+ */
40
+ createTile(character: string, name: string): ButtonView;
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ render(): void;
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ destroy(): void;
49
+ /**
50
+ * Focuses the first focusable in {@link ~CharacterGridView#tiles}.
51
+ */
52
+ focus(): void;
53
+ }
54
+ /**
55
+ * Fired when any of {@link ~CharacterGridView#tiles grid tiles} is clicked.
56
+ *
57
+ * @eventName ~CharacterGridView#execute
58
+ * @param data Additional information about the event.
59
+ */
60
+ export type CharacterGridViewExecuteEvent = {
61
+ name: 'execute';
62
+ args: [data: CharacterGridViewEventData];
63
+ };
64
+ /**
65
+ * Fired when a mouse or another pointing device caused the cursor to move onto any {@link ~CharacterGridView#tiles grid tile}
66
+ * (similar to the native `mouseover` DOM event).
67
+ *
68
+ * @eventName ~CharacterGridView#tileHover
69
+ * @param data Additional information about the event.
70
+ */
71
+ export type CharacterGridViewTileHoverEvent = {
72
+ name: 'tileHover';
73
+ args: [data: CharacterGridViewEventData];
74
+ };
75
+ /**
76
+ * Fired when {@link ~CharacterGridView#tiles grid tile} is focused (e.g. by navigating with arrow keys).
77
+ *
78
+ * @eventName ~CharacterGridView#tileFocus
79
+ * @param data Additional information about the event.
80
+ */
81
+ export type CharacterGridViewTileFocusEvent = {
82
+ name: 'tileFocus';
83
+ args: [data: CharacterGridViewEventData];
84
+ };
85
+ export interface CharacterGridViewEventData {
86
+ /**
87
+ * The name of the tile that caused the event (e.g. "greek small letter epsilon").
88
+ */
89
+ name: string;
90
+ /**
91
+ * A human-readable character displayed as the label (e.g. "ε").
92
+ */
93
+ character: string;
94
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/charactergridview
7
+ */
8
+ import { View, ButtonView, addKeyboardHandlingForGrid } from 'ckeditor5/src/ui.js';
9
+ import { KeystrokeHandler, FocusTracker, global } from 'ckeditor5/src/utils.js';
10
+ import '../../theme/charactergrid.css';
11
+ /**
12
+ * A grid of character tiles. It allows browsing special characters and selecting the character to
13
+ * be inserted into the content.
14
+ */
15
+ export default class CharacterGridView extends View {
16
+ /**
17
+ * Creates an instance of a character grid containing tiles representing special characters.
18
+ *
19
+ * @param locale The localization services instance.
20
+ */
21
+ constructor(locale) {
22
+ super(locale);
23
+ this.tiles = this.createCollection();
24
+ this.setTemplate({
25
+ tag: 'div',
26
+ children: [
27
+ {
28
+ tag: 'div',
29
+ attributes: {
30
+ class: [
31
+ 'ck',
32
+ 'ck-character-grid__tiles'
33
+ ]
34
+ },
35
+ children: this.tiles
36
+ }
37
+ ],
38
+ attributes: {
39
+ class: [
40
+ 'ck',
41
+ 'ck-character-grid'
42
+ ]
43
+ }
44
+ });
45
+ this.focusTracker = new FocusTracker();
46
+ this.keystrokes = new KeystrokeHandler();
47
+ addKeyboardHandlingForGrid({
48
+ keystrokeHandler: this.keystrokes,
49
+ focusTracker: this.focusTracker,
50
+ gridItems: this.tiles,
51
+ numberOfColumns: () => global.window
52
+ .getComputedStyle(this.element.firstChild) // Responsive .ck-character-grid__tiles
53
+ .getPropertyValue('grid-template-columns')
54
+ .split(' ')
55
+ .length,
56
+ uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
57
+ });
58
+ }
59
+ /**
60
+ * Creates a new tile for the grid.
61
+ *
62
+ * @param character A human-readable character displayed as the label (e.g. "ε").
63
+ * @param name The name of the character (e.g. "greek small letter epsilon").
64
+ */
65
+ createTile(character, name) {
66
+ const tile = new ButtonView(this.locale);
67
+ tile.set({
68
+ label: character,
69
+ withText: true,
70
+ class: 'ck-character-grid__tile'
71
+ });
72
+ // Labels are vital for the users to understand what character they're looking at.
73
+ // For now we're using native title attribute for that, see #5817.
74
+ tile.extendTemplate({
75
+ attributes: {
76
+ title: name
77
+ },
78
+ on: {
79
+ mouseover: tile.bindTemplate.to('mouseover'),
80
+ focus: tile.bindTemplate.to('focus')
81
+ }
82
+ });
83
+ tile.on('mouseover', () => {
84
+ this.fire('tileHover', { name, character });
85
+ });
86
+ tile.on('focus', () => {
87
+ this.fire('tileFocus', { name, character });
88
+ });
89
+ tile.on('execute', () => {
90
+ this.fire('execute', { name, character });
91
+ });
92
+ return tile;
93
+ }
94
+ /**
95
+ * @inheritDoc
96
+ */
97
+ render() {
98
+ super.render();
99
+ for (const item of this.tiles) {
100
+ this.focusTracker.add(item.element);
101
+ }
102
+ this.tiles.on('change', (eventInfo, { added, removed }) => {
103
+ if (added.length > 0) {
104
+ for (const item of added) {
105
+ this.focusTracker.add(item.element);
106
+ }
107
+ }
108
+ if (removed.length > 0) {
109
+ for (const item of removed) {
110
+ this.focusTracker.remove(item.element);
111
+ }
112
+ }
113
+ });
114
+ this.keystrokes.listenTo(this.element);
115
+ }
116
+ /**
117
+ * @inheritDoc
118
+ */
119
+ destroy() {
120
+ super.destroy();
121
+ this.keystrokes.destroy();
122
+ }
123
+ /**
124
+ * Focuses the first focusable in {@link ~CharacterGridView#tiles}.
125
+ */
126
+ focus() {
127
+ this.tiles.first.focus();
128
+ }
129
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/characterinfoview
7
+ */
8
+ import type { Locale } from 'ckeditor5/src/utils.js';
9
+ import { View } from 'ckeditor5/src/ui.js';
10
+ import '../../theme/characterinfo.css';
11
+ /**
12
+ * The view displaying detailed information about a special character glyph, e.g. upon
13
+ * hovering it with a mouse.
14
+ */
15
+ export default class CharacterInfoView extends View<HTMLDivElement> {
16
+ /**
17
+ * The character whose information is displayed by the view. For instance, "∑" or "¿".
18
+ *
19
+ * @observable
20
+ */
21
+ character: string | null;
22
+ /**
23
+ * The name of the {@link #character}. For instance, "N-ary summation" or "Inverted question mark".
24
+ *
25
+ * @observable
26
+ */
27
+ name: string | null;
28
+ /**
29
+ * The "Unicode string" of the {@link #character}. For instance "U+0061".
30
+ *
31
+ * @observable
32
+ */
33
+ readonly code: string;
34
+ constructor(locale: Locale);
35
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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
+ import { View } from 'ckeditor5/src/ui.js';
6
+ import '../../theme/characterinfo.css';
7
+ /**
8
+ * The view displaying detailed information about a special character glyph, e.g. upon
9
+ * hovering it with a mouse.
10
+ */
11
+ export default class CharacterInfoView extends View {
12
+ constructor(locale) {
13
+ super(locale);
14
+ const bind = this.bindTemplate;
15
+ this.set('character', null);
16
+ this.set('name', null);
17
+ this.bind('code').to(this, 'character', characterToUnicodeString);
18
+ this.setTemplate({
19
+ tag: 'div',
20
+ children: [
21
+ {
22
+ tag: 'span',
23
+ attributes: {
24
+ class: [
25
+ 'ck-character-info__name'
26
+ ]
27
+ },
28
+ children: [
29
+ {
30
+ // Note: ZWSP to prevent vertical collapsing.
31
+ text: bind.to('name', name => name ? name : '\u200B')
32
+ }
33
+ ]
34
+ },
35
+ {
36
+ tag: 'span',
37
+ attributes: {
38
+ class: [
39
+ 'ck-character-info__code'
40
+ ]
41
+ },
42
+ children: [
43
+ {
44
+ text: bind.to('code')
45
+ }
46
+ ]
47
+ }
48
+ ],
49
+ attributes: {
50
+ class: [
51
+ 'ck',
52
+ 'ck-character-info'
53
+ ]
54
+ }
55
+ });
56
+ }
57
+ }
58
+ /**
59
+ * Converts a character into a "Unicode string", for instance:
60
+ *
61
+ * "$" -> "U+0024"
62
+ *
63
+ * Returns an empty string when the character is `null`.
64
+ */
65
+ function characterToUnicodeString(character) {
66
+ if (character === null) {
67
+ return '';
68
+ }
69
+ const hexCode = character.codePointAt(0).toString(16);
70
+ return 'U+' + ('0000' + hexCode).slice(-4);
71
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/specialcharacterscategoriesview
7
+ */
8
+ import { type Locale } from 'ckeditor5/src/utils.js';
9
+ import { View } from 'ckeditor5/src/ui.js';
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
+ */
14
+ export default class SpecialCharactersCategoriesView extends View {
15
+ /**
16
+ * Currently selected special characters group's name.
17
+ */
18
+ currentGroupName: string;
19
+ private _groupNames;
20
+ private _dropdownView;
21
+ /**
22
+ * Creates an instance of the {@link module:special-characters/ui/specialcharacterscategoriesview~SpecialCharactersCategoriesView}
23
+ * class.
24
+ *
25
+ * @param locale The localization services instance.
26
+ * @param groupNames The names of the character groups.
27
+ */
28
+ constructor(locale: Locale, groupNames: Map<string, string>);
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ render(): void;
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ focus(): void;
37
+ /**
38
+ * Creates dropdown item list, sets up bindings and fills properties.
39
+ */
40
+ private _setupDropdown;
41
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/specialcharacterscategoriesview
7
+ */
8
+ import { Collection } from 'ckeditor5/src/utils.js';
9
+ import { addListToDropdown, createLabeledDropdown, LabeledFieldView, View, ViewModel } from 'ckeditor5/src/ui.js';
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
+ */
14
+ export default class SpecialCharactersCategoriesView extends View {
15
+ /**
16
+ * Creates an instance of the {@link module:special-characters/ui/specialcharacterscategoriesview~SpecialCharactersCategoriesView}
17
+ * class.
18
+ *
19
+ * @param locale The localization services instance.
20
+ * @param groupNames The names of the character groups.
21
+ */
22
+ constructor(locale, groupNames) {
23
+ super(locale);
24
+ this.set('currentGroupName', Array.from(groupNames.entries())[0][0]);
25
+ this._groupNames = groupNames;
26
+ this._dropdownView = new LabeledFieldView(locale, createLabeledDropdown);
27
+ this.setTemplate({
28
+ tag: 'div',
29
+ attributes: {
30
+ class: ['ck', 'ck-character-categories']
31
+ },
32
+ children: [
33
+ this._dropdownView
34
+ ]
35
+ });
36
+ }
37
+ /**
38
+ * @inheritDoc
39
+ */
40
+ render() {
41
+ super.render();
42
+ this._setupDropdown();
43
+ }
44
+ /**
45
+ * @inheritDoc
46
+ */
47
+ focus() {
48
+ this._dropdownView.focus();
49
+ }
50
+ /**
51
+ * Creates dropdown item list, sets up bindings and fills properties.
52
+ */
53
+ _setupDropdown() {
54
+ const items = new Collection();
55
+ for (const [name, label] of this._groupNames) {
56
+ const item = {
57
+ type: 'button',
58
+ model: new ViewModel({
59
+ name,
60
+ label,
61
+ role: 'menuitemradio',
62
+ withText: true
63
+ })
64
+ };
65
+ item.model.bind('isOn').to(this, 'currentGroupName', value => {
66
+ return value === name;
67
+ });
68
+ items.add(item);
69
+ }
70
+ const t = this.locale.t;
71
+ const accessibleLabel = t('Category');
72
+ this._dropdownView.set({
73
+ label: accessibleLabel,
74
+ isEmpty: false
75
+ });
76
+ this._dropdownView.fieldView.panelPosition = this.locale.uiLanguageDirection === 'rtl' ? 'se' : 'sw';
77
+ this._dropdownView.fieldView.buttonView.set({
78
+ withText: true,
79
+ tooltip: accessibleLabel,
80
+ ariaLabel: accessibleLabel,
81
+ ariaLabelledBy: undefined,
82
+ isOn: false
83
+ });
84
+ this._dropdownView.fieldView.buttonView.bind('label')
85
+ .to(this, 'currentGroupName', value => this._groupNames.get(value));
86
+ this._dropdownView.fieldView.on('execute', ({ source }) => {
87
+ this.currentGroupName = source.name;
88
+ });
89
+ addListToDropdown(this._dropdownView.fieldView, items, {
90
+ ariaLabel: accessibleLabel,
91
+ role: 'menu'
92
+ });
93
+ }
94
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/specialcharactersview
7
+ */
8
+ import { View, FocusCycler, type ViewCollection, type FocusableView } from 'ckeditor5/src/ui.js';
9
+ import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
10
+ import type CharacterGridView from './charactergridview.js';
11
+ import type CharacterInfoView from './characterinfoview.js';
12
+ import type SpecialCharactersCategoriesView from './specialcharacterscategoriesview.js';
13
+ /**
14
+ * A view that glues pieces of the special characters dropdown panel together:
15
+ *
16
+ * * the navigation view (allows selecting the category),
17
+ * * the grid view (displays characters as a grid),
18
+ * * and the info view (displays detailed info about a specific character).
19
+ */
20
+ export default class SpecialCharactersView extends View<HTMLDivElement> {
21
+ /**
22
+ * A collection of the focusable children of the view.
23
+ */
24
+ readonly items: ViewCollection<FocusableView>;
25
+ /**
26
+ * Tracks information about the DOM focus in the view.
27
+ */
28
+ readonly focusTracker: FocusTracker;
29
+ /**
30
+ * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
31
+ */
32
+ readonly keystrokes: KeystrokeHandler;
33
+ /**
34
+ * Helps cycling over focusable {@link #items} in the view.
35
+ */
36
+ protected readonly _focusCycler: FocusCycler;
37
+ /**
38
+ * An instance of the `SpecialCharactersCategoriesView`.
39
+ */
40
+ categoriesView: SpecialCharactersCategoriesView;
41
+ /**
42
+ * An instance of the `CharacterGridView`.
43
+ */
44
+ gridView: CharacterGridView;
45
+ /**
46
+ * An instance of the `CharacterInfoView`.
47
+ */
48
+ infoView: CharacterInfoView;
49
+ /**
50
+ * Creates an instance of the `SpecialCharactersView`.
51
+ */
52
+ constructor(locale: Locale, categoriesView: SpecialCharactersCategoriesView, gridView: CharacterGridView, infoView: CharacterInfoView);
53
+ /**
54
+ * @inheritDoc
55
+ */
56
+ render(): void;
57
+ /**
58
+ * @inheritDoc
59
+ */
60
+ destroy(): void;
61
+ /**
62
+ * Focuses the first focusable in {@link #items}.
63
+ */
64
+ focus(): void;
65
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2024, 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/ui/specialcharactersview
7
+ */
8
+ import { View, FocusCycler } from 'ckeditor5/src/ui.js';
9
+ import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
+ /**
11
+ * A view that glues pieces of the special characters dropdown panel together:
12
+ *
13
+ * * the navigation view (allows selecting the category),
14
+ * * the grid view (displays characters as a grid),
15
+ * * and the info view (displays detailed info about a specific character).
16
+ */
17
+ export default class SpecialCharactersView extends View {
18
+ /**
19
+ * Creates an instance of the `SpecialCharactersView`.
20
+ */
21
+ constructor(locale, categoriesView, gridView, infoView) {
22
+ super(locale);
23
+ this.categoriesView = categoriesView;
24
+ this.gridView = gridView;
25
+ this.infoView = infoView;
26
+ this.items = this.createCollection();
27
+ this.focusTracker = new FocusTracker();
28
+ this.keystrokes = new KeystrokeHandler();
29
+ this._focusCycler = new FocusCycler({
30
+ focusables: this.items,
31
+ focusTracker: this.focusTracker,
32
+ keystrokeHandler: this.keystrokes,
33
+ actions: {
34
+ focusPrevious: 'shift + tab',
35
+ focusNext: 'tab'
36
+ }
37
+ });
38
+ this.setTemplate({
39
+ tag: 'div',
40
+ children: [
41
+ this.categoriesView,
42
+ this.gridView,
43
+ this.infoView
44
+ ],
45
+ attributes: {
46
+ // Avoid focus loss when the user clicks the area of the grid that is not a button.
47
+ // https://github.com/ckeditor/ckeditor5/pull/12319#issuecomment-1231779819
48
+ tabindex: '-1'
49
+ }
50
+ });
51
+ this.items.add(this.categoriesView);
52
+ this.items.add(this.gridView);
53
+ }
54
+ /**
55
+ * @inheritDoc
56
+ */
57
+ render() {
58
+ super.render();
59
+ this.focusTracker.add(this.categoriesView.element);
60
+ this.focusTracker.add(this.gridView.element);
61
+ // Start listening for the keystrokes coming from #element.
62
+ this.keystrokes.listenTo(this.element);
63
+ }
64
+ /**
65
+ * @inheritDoc
66
+ */
67
+ destroy() {
68
+ super.destroy();
69
+ this.focusTracker.destroy();
70
+ this.keystrokes.destroy();
71
+ }
72
+ /**
73
+ * Focuses the first focusable in {@link #items}.
74
+ */
75
+ focus() {
76
+ this._focusCycler.focusFirst();
77
+ }
78
+ }
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) 2003-2024, 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
+ .ck.ck-character-grid {
7
+ max-width: 100%;
8
+
9
+ & .ck-character-grid__tiles {
10
+ display: grid;
11
+ }
12
+ }
@@ -0,0 +1,9 @@
1
+ /*
2
+ * Copyright (c) 2003-2024, 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
+ .ck.ck-character-info {
7
+ display: flex;
8
+ justify-content: space-between;
9
+ }
@@ -0,0 +1 @@
1
+ <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>