qms-angular 1.1.70 → 1.1.72

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 (154) hide show
  1. package/bundles/qms-angular.umd.js +66 -164
  2. package/bundles/qms-angular.umd.js.map +1 -1
  3. package/esm2015/lib/model/en.js +13 -2
  4. package/esm2015/lib/model/no.js +12 -1
  5. package/esm2015/lib/model/sv.js +12 -1
  6. package/esm2015/lib/qms-ckeditor-components/common/functions/common.function.js +2 -1
  7. package/esm2015/lib/qms-ckeditor-components/common/functions/resource.function.js +17 -6
  8. package/esm2015/lib/qms-ckeditor-components/qms-ckeditor.component.js +9 -2
  9. package/fesm2015/qms-angular.js +59 -7
  10. package/fesm2015/qms-angular.js.map +1 -1
  11. package/lib/model/en.d.ts +11 -0
  12. package/lib/model/no.d.ts +11 -0
  13. package/lib/model/sv.d.ts +11 -0
  14. package/lib/qms-ckeditor-components/common/functions/resource.function.d.ts +15 -4
  15. package/package.json +1 -1
  16. package/qms-angular.metadata.json +1 -1
  17. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js +1 -1
  18. package/src/assets/qms-ckeditor-plugin/build/ckeditor.js.map +1 -1
  19. package/src/assets/qms-ckeditor-plugin/build/translations/af.js +1 -0
  20. package/src/assets/qms-ckeditor-plugin/build/translations/ar.js +1 -0
  21. package/src/assets/qms-ckeditor-plugin/build/translations/ast.js +1 -0
  22. package/src/assets/qms-ckeditor-plugin/build/translations/az.js +1 -0
  23. package/src/assets/qms-ckeditor-plugin/build/translations/bg.js +1 -0
  24. package/src/assets/qms-ckeditor-plugin/build/translations/ca.js +1 -0
  25. package/src/assets/qms-ckeditor-plugin/build/translations/cs.js +1 -0
  26. package/src/assets/qms-ckeditor-plugin/build/translations/da.js +1 -0
  27. package/src/assets/qms-ckeditor-plugin/build/translations/de-ch.js +1 -0
  28. package/src/assets/qms-ckeditor-plugin/build/translations/de.js +1 -0
  29. package/src/assets/qms-ckeditor-plugin/build/translations/el.js +1 -0
  30. package/src/assets/qms-ckeditor-plugin/build/translations/en-au.js +1 -0
  31. package/src/assets/qms-ckeditor-plugin/build/translations/en-gb.js +1 -0
  32. package/src/assets/qms-ckeditor-plugin/build/translations/eo.js +1 -0
  33. package/src/assets/qms-ckeditor-plugin/build/translations/es.js +1 -0
  34. package/src/assets/qms-ckeditor-plugin/build/translations/et.js +1 -0
  35. package/src/assets/qms-ckeditor-plugin/build/translations/eu.js +1 -0
  36. package/src/assets/qms-ckeditor-plugin/build/translations/fa.js +1 -0
  37. package/src/assets/qms-ckeditor-plugin/build/translations/fi.js +1 -0
  38. package/src/assets/qms-ckeditor-plugin/build/translations/fr.js +1 -0
  39. package/src/assets/qms-ckeditor-plugin/build/translations/gl.js +1 -0
  40. package/src/assets/qms-ckeditor-plugin/build/translations/gu.js +1 -0
  41. package/src/assets/qms-ckeditor-plugin/build/translations/he.js +1 -0
  42. package/src/assets/qms-ckeditor-plugin/build/translations/hi.js +1 -0
  43. package/src/assets/qms-ckeditor-plugin/build/translations/hr.js +1 -0
  44. package/src/assets/qms-ckeditor-plugin/build/translations/hu.js +1 -0
  45. package/src/assets/qms-ckeditor-plugin/build/translations/id.js +1 -0
  46. package/src/assets/qms-ckeditor-plugin/build/translations/it.js +1 -0
  47. package/src/assets/qms-ckeditor-plugin/build/translations/ja.js +1 -0
  48. package/src/assets/qms-ckeditor-plugin/build/translations/kk.js +1 -0
  49. package/src/assets/qms-ckeditor-plugin/build/translations/km.js +1 -0
  50. package/src/assets/qms-ckeditor-plugin/build/translations/kn.js +1 -0
  51. package/src/assets/qms-ckeditor-plugin/build/translations/ko.js +1 -0
  52. package/src/assets/qms-ckeditor-plugin/build/translations/ku.js +1 -0
  53. package/src/assets/qms-ckeditor-plugin/build/translations/lt.js +1 -0
  54. package/src/assets/qms-ckeditor-plugin/build/translations/lv.js +1 -0
  55. package/src/assets/qms-ckeditor-plugin/build/translations/ms.js +1 -0
  56. package/src/assets/qms-ckeditor-plugin/build/translations/nb.js +1 -0
  57. package/src/assets/qms-ckeditor-plugin/build/translations/ne.js +1 -0
  58. package/src/assets/qms-ckeditor-plugin/build/translations/nl.js +1 -0
  59. package/src/assets/qms-ckeditor-plugin/build/translations/no.js +1 -0
  60. package/src/assets/qms-ckeditor-plugin/build/translations/oc.js +1 -0
  61. package/src/assets/qms-ckeditor-plugin/build/translations/pl.js +1 -0
  62. package/src/assets/qms-ckeditor-plugin/build/translations/pt-br.js +1 -0
  63. package/src/assets/qms-ckeditor-plugin/build/translations/pt.js +1 -0
  64. package/src/assets/qms-ckeditor-plugin/build/translations/ro.js +1 -0
  65. package/src/assets/qms-ckeditor-plugin/build/translations/ru.js +1 -0
  66. package/src/assets/qms-ckeditor-plugin/build/translations/si.js +1 -0
  67. package/src/assets/qms-ckeditor-plugin/build/translations/sk.js +1 -0
  68. package/src/assets/qms-ckeditor-plugin/build/translations/sl.js +1 -0
  69. package/src/assets/qms-ckeditor-plugin/build/translations/sq.js +1 -0
  70. package/src/assets/qms-ckeditor-plugin/build/translations/sr-latn.js +1 -0
  71. package/src/assets/qms-ckeditor-plugin/build/translations/sr.js +1 -0
  72. package/src/assets/qms-ckeditor-plugin/build/translations/sv.js +1 -0
  73. package/src/assets/qms-ckeditor-plugin/build/translations/th.js +1 -0
  74. package/src/assets/qms-ckeditor-plugin/build/translations/tk.js +1 -0
  75. package/src/assets/qms-ckeditor-plugin/build/translations/tr.js +1 -0
  76. package/src/assets/qms-ckeditor-plugin/build/translations/tt.js +1 -0
  77. package/src/assets/qms-ckeditor-plugin/build/translations/ug.js +1 -0
  78. package/src/assets/qms-ckeditor-plugin/build/translations/uk.js +1 -0
  79. package/src/assets/qms-ckeditor-plugin/build/translations/vi.js +1 -0
  80. package/src/assets/qms-ckeditor-plugin/build/translations/zh-cn.js +1 -0
  81. package/src/assets/qms-ckeditor-plugin/build/translations/zh.js +1 -0
  82. package/src/assets/qms-ckeditor-plugin/package-lock.json +5717 -8776
  83. package/src/assets/qms-ckeditor-plugin/src/ckeditor.js +259 -152
  84. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/index.js +62 -16
  85. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacters.js +255 -254
  86. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersarrows.js +154 -60
  87. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbasiclatin.js +137 -0
  88. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersblockelements.js +74 -0
  89. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbopomofo.js +90 -0
  90. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersboxdrawing.js +170 -0
  91. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersbraillepatterns.js +298 -0
  92. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscjkradicalssupplement.js +170 -0
  93. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscjksymbolsandpunctuation.js +106 -0
  94. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscombiningdiacriticalmarks.js +139 -0
  95. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscombiningdiacriticalmarksforsymbols.js +90 -0
  96. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscontrolpictures.js +106 -0
  97. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscurrencysymbols.js +90 -0
  98. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscyrillic.js +298 -0
  99. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterscyrillicsupplementary.js +90 -0
  100. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersdingbats.js +234 -0
  101. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersenclosedalphanumerics.js +202 -0
  102. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgeneralpunctuation.js +160 -0
  103. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgeometricshapes.js +138 -0
  104. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgreekandcoptic.js +186 -0
  105. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersgreekextended.js +154 -0
  106. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactershiragana.js +138 -0
  107. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersideographicdescriptioncharacters.js +58 -0
  108. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersipaextensions.js +174 -0
  109. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterskangxiradicals.js +266 -0
  110. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterskatakana.js +138 -0
  111. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatin1supplement.js +144 -0
  112. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendeda.js +179 -0
  113. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendedadditional.js +327 -0
  114. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterslatinextendedb.js +340 -0
  115. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersletterlikesymbols.js +122 -0
  116. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmathematicaloperatorssymbol.js +300 -0
  117. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmestbrukte.js +99 -0
  118. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneousmathematicalsymbolsa.js +90 -0
  119. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneousmathematicalsymbolsb.js +170 -0
  120. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoussymbols.js +297 -0
  121. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoussymbolsandarrows.js +298 -0
  122. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersmiscellaneoustechnical.js +298 -0
  123. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersnumberforms.js +106 -0
  124. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersopticalcharacterrecognition.js +74 -0
  125. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersphoneticextensions.js +179 -0
  126. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersspacingmodifierletters.js +139 -0
  127. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharactersspecials.js +46 -0
  128. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssuperscriptsandsubscripts.js +92 -0
  129. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalarrowsa.js +58 -0
  130. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalarrowsb.js +170 -0
  131. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/src/specialcharacterssupplementalmathematicaloperators.js +298 -0
  132. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/charactergrid.css +14 -12
  133. package/src/assets/qms-ckeditor-plugin/src/plugins/ckeditor5-special-characters/theme/specialcharacters.css +15 -10
  134. package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/clipboardPlugin.js +161 -0
  135. package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/qms-clipboardcommand-paste.js +20 -0
  136. package/src/assets/qms-ckeditor-plugin/src/plugins/clipboard/qms-clipboardcommand.js +21 -0
  137. package/src/assets/qms-ckeditor-plugin/src/plugins/showBlocks/showBlocksPlugin.js +131 -0
  138. package/src/assets/qms-ckeditor-plugin/src/plugins/showBlocks/showBlockscommand.js +13 -0
  139. package/src/assets/qms-ckeditor-plugin/src/plugins/softHyphen/softHyphenPlugin.js +91 -0
  140. package/src/assets/qms-ckeditor-plugin/src/plugins/softHyphen/softHyphencommand.js +13 -0
  141. package/src/assets/qms-ckeditor-plugin/src/plugins/table/verticalAlign/verticalAlignPlugin.js +102 -0
  142. package/src/assets/qms-ckeditor-plugin/src/plugins/table/verticalAlign/verticalAligncommand.js +13 -0
  143. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentscommand.js +87 -87
  144. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsediting.js +59 -59
  145. package/src/assets/qms-ckeditor-plugin/src/plugins/tableofcontents/tableofcontentsui.js +34 -34
  146. package/src/assets/qms-ckeditor-plugin/src/themes/icons/copy.svg +1 -0
  147. package/src/assets/qms-ckeditor-plugin/src/themes/icons/cut.svg +1 -0
  148. package/src/assets/qms-ckeditor-plugin/src/themes/icons/paste.svg +1 -0
  149. package/src/assets/qms-ckeditor-plugin/src/themes/icons/pasteText.svg +3 -0
  150. package/src/assets/qms-ckeditor-plugin/src/themes/icons/pasteWord.svg +3 -0
  151. package/src/assets/qms-ckeditor-plugin/src/themes/icons/show-blocks.svg +24 -0
  152. package/src/assets/qms-ckeditor-plugin/src/themes/icons/soft-hyphen.svg +1 -0
  153. package/src/assets/qms-ckeditor-plugin/src/themes/icons/table-excel.svg +1 -44
  154. package/src/lib/qms-ckeditor-components/qms-ckeditor.component.scss +50 -4
@@ -1,254 +1,255 @@
1
- /**
2
- * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
-
6
- /**
7
- * @module special-characters/specialcharacters
8
- */
9
-
10
- import { Plugin } from '@ckeditor/ckeditor5-core';
11
- import { Typing } from '@ckeditor/ckeditor5-typing';
12
- import { createDropdown } from '@ckeditor/ckeditor5-ui';
13
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
14
- import SpecialCharactersNavigationView from './ui/specialcharactersnavigationview';
15
- import CharacterGridView from './ui/charactergridview';
16
- import CharacterInfoView from './ui/characterinfoview';
17
-
18
- import specialCharactersIcon from '../theme/icons/specialcharacters.svg';
19
- import '../theme/specialcharacters.css';
20
-
21
- const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
22
-
23
- /**
24
- * The special characters feature.
25
- *
26
- * Introduces the `'specialCharacters'` dropdown.
27
- *
28
- * @extends module:core/plugin~Plugin
29
- */
30
- export default class SpecialCharacters extends Plugin {
31
- /**
32
- * @inheritDoc
33
- */
34
- static get requires() {
35
- return [ Typing ];
36
- }
37
-
38
- /**
39
- * @inheritDoc
40
- */
41
- static get pluginName() {
42
- return 'SpecialCharacters';
43
- }
44
-
45
- /**
46
- * @inheritDoc
47
- */
48
- constructor( editor ) {
49
- super( editor );
50
-
51
- /**
52
- * Registered characters. A pair of a character name and its symbol.
53
- *
54
- * @private
55
- * @member {Map.<String, String>} #_characters
56
- */
57
- this._characters = new Map();
58
-
59
- /**
60
- * Registered groups. Each group contains a collection with symbol names.
61
- *
62
- * @private
63
- * @member {Map.<String, Set.<String>>} #_groups
64
- */
65
- this._groups = new Map();
66
- }
67
-
68
- /**
69
- * @inheritDoc
70
- */
71
- init() {
72
- const editor = this.editor;
73
- const t = editor.t;
74
-
75
- const inputCommand = editor.commands.get( 'input' );
76
-
77
- // Add the `specialCharacters` dropdown button to feature components.
78
- editor.ui.componentFactory.add( 'specialCharacters', locale => {
79
- const dropdownView = createDropdown( locale );
80
- let dropdownPanelContent;
81
-
82
- dropdownView.buttonView.set( {
83
- label: t( 'Special characters' ),
84
- icon: specialCharactersIcon,
85
- tooltip: true
86
- } );
87
-
88
- dropdownView.bind( 'isEnabled' ).to( inputCommand );
89
-
90
- // Insert a special character when a tile was clicked.
91
- dropdownView.on( 'execute', ( evt, data ) => {
92
- editor.execute( 'input', { text: data.character } );
93
- editor.editing.view.focus();
94
- } );
95
-
96
- dropdownView.on( 'change:isOpen', () => {
97
- if ( !dropdownPanelContent ) {
98
- dropdownPanelContent = this._createDropdownPanelContent( locale, dropdownView );
99
-
100
- dropdownView.panelView.children.add( dropdownPanelContent.navigationView );
101
- dropdownView.panelView.children.add( dropdownPanelContent.gridView );
102
- dropdownView.panelView.children.add( dropdownPanelContent.infoView );
103
- }
104
-
105
- dropdownPanelContent.infoView.set( {
106
- character: null,
107
- name: null
108
- } );
109
- } );
110
-
111
- return dropdownView;
112
- } );
113
- }
114
-
115
- /**
116
- * Adds a collection of special characters to the specified group. The title of a special character must be unique.
117
- *
118
- * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
119
- * characters category.
120
- *
121
- * @param {String} groupName
122
- * @param {Array.<module:special-characters/specialcharacters~SpecialCharacterDefinition>} items
123
- */
124
- addItems( groupName, items ) {
125
- if ( groupName === ALL_SPECIAL_CHARACTERS_GROUP ) {
126
- /**
127
- * The name "All" for a special category group cannot be used because it is a special category that displays all
128
- * available special characters.
129
- *
130
- * @error special-character-invalid-group-name
131
- */
132
- throw new CKEditorError(
133
- `special-character-invalid-group-name: The name "${ ALL_SPECIAL_CHARACTERS_GROUP }" is reserved and cannot be used.`
134
- );
135
- }
136
-
137
- const group = this._getGroup( groupName );
138
-
139
- for ( const item of items ) {
140
- group.add( item.title );
141
- this._characters.set( item.title, item.character );
142
- }
143
- }
144
-
145
- /**
146
- * Returns an iterator of special characters groups.
147
- *
148
- * @returns {Iterable.<String>}
149
- */
150
- getGroups() {
151
- return this._groups.keys();
152
- }
153
-
154
- /**
155
- * Returns a collection of special characters symbol names (titles).
156
- *
157
- * @param {String} groupName
158
- * @returns {Set.<String>|undefined}
159
- */
160
- getCharactersForGroup( groupName ) {
161
- if ( groupName === ALL_SPECIAL_CHARACTERS_GROUP ) {
162
- return new Set( this._characters.keys() );
163
- }
164
-
165
- return this._groups.get( groupName );
166
- }
167
-
168
- /**
169
- * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
170
- * is returned.
171
- *
172
- * @param {String} title The title of a special character.
173
- * @returns {String|undefined}
174
- */
175
- getCharacter( title ) {
176
- return this._characters.get( title );
177
- }
178
-
179
- /**
180
- * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
181
- *
182
- * @private
183
- * @param {String} groupName The name of the group to create.
184
- */
185
- _getGroup( groupName ) {
186
- if ( !this._groups.has( groupName ) ) {
187
- this._groups.set( groupName, new Set() );
188
- }
189
-
190
- return this._groups.get( groupName );
191
- }
192
-
193
- /**
194
- * Updates the symbol grid depending on the currently selected character group.
195
- *
196
- * @private
197
- * @param {String} currentGroupName
198
- * @param {module:special-characters/ui/charactergridview~CharacterGridView} gridView
199
- */
200
- _updateGrid( currentGroupName, gridView ) {
201
- // Updating the grid starts with removing all tiles belonging to the old group.
202
- gridView.tiles.clear();
203
-
204
- const characterTitles = this.getCharactersForGroup( currentGroupName );
205
-
206
- for ( const title of characterTitles ) {
207
- const character = this.getCharacter( title );
208
-
209
- gridView.tiles.add( gridView.createTile( character, title ) );
210
- }
211
- }
212
-
213
- /**
214
- * Initializes the dropdown, used for lazy loading.
215
- *
216
- * @private
217
- * @param {module:utils/locale~Locale} locale
218
- * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
219
- * @returns {Object} Returns an object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
220
- */
221
- _createDropdownPanelContent( locale, dropdownView ) {
222
- const specialCharsGroups = [ ...this.getGroups() ];
223
-
224
- // Add a special group that shows all available special characters.
225
- specialCharsGroups.unshift( ALL_SPECIAL_CHARACTERS_GROUP );
226
-
227
- const navigationView = new SpecialCharactersNavigationView( locale, specialCharsGroups );
228
- const gridView = new CharacterGridView( locale );
229
- const infoView = new CharacterInfoView( locale );
230
-
231
- gridView.delegate( 'execute' ).to( dropdownView );
232
-
233
- gridView.on( 'tileHover', ( evt, data ) => {
234
- infoView.set( data );
235
- } );
236
-
237
- // Update the grid of special characters when a user changed the character group.
238
- navigationView.on( 'execute', () => {
239
- this._updateGrid( navigationView.currentGroupName, gridView );
240
- } );
241
-
242
- // Set the initial content of the special characters grid.
243
- this._updateGrid( navigationView.currentGroupName, gridView );
244
-
245
- return { navigationView, gridView, infoView };
246
- }
247
- }
248
-
249
- /**
250
- * @typedef {Object} module:special-characters/specialcharacters~SpecialCharacterDefinition
251
- *
252
- * @property {String} title A unique name of the character (e.g. "greek small letter epsilon").
253
- * @property {String} character A human-readable character displayed as the label (e.g. "ε").
254
- */
1
+ /**
2
+ * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ /**
7
+ * @module special-characters/specialcharacters
8
+ */
9
+
10
+ import { Plugin } from '@ckeditor/ckeditor5-core';
11
+ import { Typing } from '@ckeditor/ckeditor5-typing';
12
+ import { createDropdown } from '@ckeditor/ckeditor5-ui';
13
+ import { CKEditorError } from '@ckeditor/ckeditor5-utils';
14
+ import SpecialCharactersNavigationView from './ui/specialcharactersnavigationview';
15
+ import CharacterGridView from './ui/charactergridview';
16
+ import CharacterInfoView from './ui/characterinfoview';
17
+
18
+ import specialCharactersIcon from '../theme/icons/specialcharacters.svg';
19
+ import '../theme/specialcharacters.css';
20
+
21
+ const ALL_SPECIAL_CHARACTERS_GROUP = 'All';
22
+
23
+ /**
24
+ * The special characters feature.
25
+ *
26
+ * Introduces the `'specialCharacters'` dropdown.
27
+ *
28
+ * @extends module:core/plugin~Plugin
29
+ */
30
+ export default class SpecialCharacters extends Plugin {
31
+ /**
32
+ * @inheritDoc
33
+ */
34
+ static get requires() {
35
+ return [ Typing ];
36
+ }
37
+
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ static get pluginName() {
42
+ return 'SpecialCharacters';
43
+ }
44
+
45
+ /**
46
+ * @inheritDoc
47
+ */
48
+ constructor( editor ) {
49
+ super( editor );
50
+
51
+ /**
52
+ * Registered characters. A pair of a character name and its symbol.
53
+ *
54
+ * @private
55
+ * @member {Map.<String, String>} #_characters
56
+ */
57
+ this._characters = new Map();
58
+
59
+ /**
60
+ * Registered groups. Each group contains a collection with symbol names.
61
+ *
62
+ * @private
63
+ * @member {Map.<String, Set.<String>>} #_groups
64
+ */
65
+ this._groups = new Map();
66
+ }
67
+
68
+ /**
69
+ * @inheritDoc
70
+ */
71
+ init() {
72
+ const editor = this.editor;
73
+ const t = editor.t;
74
+
75
+ const inputCommand = editor.commands.get( 'input' );
76
+
77
+ // Add the `specialCharacters` dropdown button to feature components.
78
+ editor.ui.componentFactory.add( 'specialCharacters', locale => {
79
+ const dropdownView = createDropdown( locale );
80
+ let dropdownPanelContent;
81
+
82
+ dropdownView.buttonView.set( {
83
+ label: t( 'Special characters' ),
84
+ icon: specialCharactersIcon,
85
+ tooltip: true
86
+ } );
87
+
88
+ dropdownView.bind( 'isEnabled' ).to( inputCommand );
89
+
90
+ // Insert a special character when a tile was clicked.
91
+ dropdownView.on( 'execute', ( evt, data ) => {
92
+ editor.execute( 'input', { text: data.character } );
93
+ editor.editing.view.focus();
94
+ } );
95
+
96
+ dropdownView.on( 'change:isOpen', () => {
97
+ if ( !dropdownPanelContent ) {
98
+ dropdownPanelContent = this._createDropdownPanelContent( locale, dropdownView );
99
+
100
+ dropdownView.panelView.children.add( dropdownPanelContent.navigationView );
101
+ dropdownView.panelView.children.add( dropdownPanelContent.gridView );
102
+ dropdownView.panelView.children.add( dropdownPanelContent.infoView );
103
+ }
104
+
105
+ dropdownPanelContent.infoView.set( {
106
+ character: null,
107
+ name: null
108
+ } );
109
+ } );
110
+
111
+ return dropdownView;
112
+ } );
113
+ }
114
+
115
+ /**
116
+ * Adds a collection of special characters to the specified group. The title of a special character must be unique.
117
+ *
118
+ * **Note:** The "All" category name is reserved by the plugin and cannot be used as a new name for a special
119
+ * characters category.
120
+ *
121
+ * @param {String} groupName
122
+ * @param {Array.<module:special-characters/specialcharacters~SpecialCharacterDefinition>} items
123
+ */
124
+ addItems( groupName, items ) {
125
+ if ( groupName === ALL_SPECIAL_CHARACTERS_GROUP ) {
126
+ /**
127
+ * The name "All" for a special category group cannot be used because it is a special category that displays all
128
+ * available special characters.
129
+ *
130
+ * @error special-character-invalid-group-name
131
+ */
132
+ throw new CKEditorError(
133
+ `special-character-invalid-group-name: The name "${ ALL_SPECIAL_CHARACTERS_GROUP }" is reserved and cannot be used.`
134
+ );
135
+ }
136
+
137
+ const group = this._getGroup( groupName );
138
+
139
+ for ( const item of items ) {
140
+ group.add( item.title );
141
+ this._characters.set( item.title, item.character );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Returns an iterator of special characters groups.
147
+ *
148
+ * @returns {Iterable.<String>}
149
+ */
150
+ getGroups() {
151
+ return this._groups.keys();
152
+ }
153
+
154
+ /**
155
+ * Returns a collection of special characters symbol names (titles).
156
+ *
157
+ * @param {String} groupName
158
+ * @returns {Set.<String>|undefined}
159
+ */
160
+ getCharactersForGroup( groupName ) {
161
+ if ( groupName === ALL_SPECIAL_CHARACTERS_GROUP ) {
162
+ return new Set( this._characters.keys() );
163
+ }
164
+
165
+ return this._groups.get( groupName );
166
+ }
167
+
168
+ /**
169
+ * Returns the symbol of a special character for the specified name. If the special character could not be found, `undefined`
170
+ * is returned.
171
+ *
172
+ * @param {String} title The title of a special character.
173
+ * @returns {String|undefined}
174
+ */
175
+ getCharacter( title ) {
176
+ return this._characters.get( title );
177
+ }
178
+
179
+ /**
180
+ * Returns a group of special characters. If the group with the specified name does not exist, it will be created.
181
+ *
182
+ * @private
183
+ * @param {String} groupName The name of the group to create.
184
+ */
185
+ _getGroup( groupName ) {
186
+ if ( !this._groups.has( groupName ) ) {
187
+ this._groups.set( groupName, new Set() );
188
+ }
189
+
190
+ return this._groups.get( groupName );
191
+ }
192
+
193
+ /**
194
+ * Updates the symbol grid depending on the currently selected character group.
195
+ *
196
+ * @private
197
+ * @param {String} currentGroupName
198
+ * @param {module:special-characters/ui/charactergridview~CharacterGridView} gridView
199
+ */
200
+ _updateGrid( currentGroupName, gridView ) {
201
+ // Updating the grid starts with removing all tiles belonging to the old group.
202
+ gridView.tiles.clear();
203
+
204
+ const characterTitles = this.getCharactersForGroup( currentGroupName );
205
+
206
+ for ( const title of characterTitles ) {
207
+ const character = this.getCharacter( title );
208
+
209
+ gridView.tiles.add( gridView.createTile( character, title ) );
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Initializes the dropdown, used for lazy loading.
215
+ *
216
+ * @private
217
+ * @param {module:utils/locale~Locale} locale
218
+ * @param {module:ui/dropdown/dropdownview~DropdownView} dropdownView
219
+ * @returns {Object} Returns an object with `navigationView`, `gridView` and `infoView` properties, containing UI parts.
220
+ */
221
+ _createDropdownPanelContent( locale, dropdownView ) {
222
+ const specialCharsGroups = [ ...this.getGroups() ];
223
+
224
+ // Add a special group that shows all available special characters.
225
+ // Commented, not use 'All' group
226
+ // specialCharsGroups.unshift( ALL_SPECIAL_CHARACTERS_GROUP );
227
+
228
+ const navigationView = new SpecialCharactersNavigationView( locale, specialCharsGroups );
229
+ const gridView = new CharacterGridView( locale );
230
+ const infoView = new CharacterInfoView( locale );
231
+
232
+ gridView.delegate( 'execute' ).to( dropdownView );
233
+
234
+ gridView.on( 'tileHover', ( evt, data ) => {
235
+ infoView.set( data );
236
+ } );
237
+
238
+ // Update the grid of special characters when a user changed the character group.
239
+ navigationView.on( 'execute', () => {
240
+ this._updateGrid( navigationView.currentGroupName, gridView );
241
+ } );
242
+
243
+ // Set the initial content of the special characters grid.
244
+ this._updateGrid( navigationView.currentGroupName, gridView );
245
+
246
+ return { navigationView, gridView, infoView };
247
+ }
248
+ }
249
+
250
+ /**
251
+ * @typedef {Object} module:special-characters/specialcharacters~SpecialCharacterDefinition
252
+ *
253
+ * @property {String} title A unique name of the character (e.g. "greek small letter epsilon").
254
+ * @property {String} character A human-readable character displayed as the label (e.g. "ε").
255
+ */