@ckeditor/ckeditor5-style 47.6.1-alpha.1 → 48.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +1 -1
  3. package/dist/index-editor.css +117 -15
  4. package/dist/index.css +116 -19
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.js +14 -8
  7. package/dist/index.js.map +1 -1
  8. package/{src → dist}/integrations/link.d.ts +3 -2
  9. package/{src → dist}/integrations/list.d.ts +3 -2
  10. package/{src → dist}/integrations/table.d.ts +1 -1
  11. package/{src → dist}/style.d.ts +1 -1
  12. package/{src → dist}/stylecommand.d.ts +1 -1
  13. package/{src → dist}/styleediting.d.ts +3 -2
  14. package/{src → dist}/styleui.d.ts +1 -1
  15. package/{src → dist}/styleutils.d.ts +4 -4
  16. package/{src → dist}/ui/stylegridbuttonview.d.ts +2 -2
  17. package/{src → dist}/ui/stylegridview.d.ts +2 -2
  18. package/{src → dist}/ui/stylegroupview.d.ts +2 -2
  19. package/{src → dist}/ui/stylepanelview.d.ts +2 -2
  20. package/package.json +27 -50
  21. package/build/style.js +0 -5
  22. package/build/translations/af.js +0 -1
  23. package/build/translations/ar.js +0 -1
  24. package/build/translations/ast.js +0 -1
  25. package/build/translations/az.js +0 -1
  26. package/build/translations/be.js +0 -1
  27. package/build/translations/bg.js +0 -1
  28. package/build/translations/bn.js +0 -1
  29. package/build/translations/bs.js +0 -1
  30. package/build/translations/ca.js +0 -1
  31. package/build/translations/cs.js +0 -1
  32. package/build/translations/da.js +0 -1
  33. package/build/translations/de-ch.js +0 -1
  34. package/build/translations/de.js +0 -1
  35. package/build/translations/el.js +0 -1
  36. package/build/translations/en-au.js +0 -1
  37. package/build/translations/en-gb.js +0 -1
  38. package/build/translations/eo.js +0 -1
  39. package/build/translations/es-co.js +0 -1
  40. package/build/translations/es.js +0 -1
  41. package/build/translations/et.js +0 -1
  42. package/build/translations/eu.js +0 -1
  43. package/build/translations/fa.js +0 -1
  44. package/build/translations/fi.js +0 -1
  45. package/build/translations/fr.js +0 -1
  46. package/build/translations/gl.js +0 -1
  47. package/build/translations/gu.js +0 -1
  48. package/build/translations/he.js +0 -1
  49. package/build/translations/hi.js +0 -1
  50. package/build/translations/hr.js +0 -1
  51. package/build/translations/hu.js +0 -1
  52. package/build/translations/hy.js +0 -1
  53. package/build/translations/id.js +0 -1
  54. package/build/translations/it.js +0 -1
  55. package/build/translations/ja.js +0 -1
  56. package/build/translations/jv.js +0 -1
  57. package/build/translations/kk.js +0 -1
  58. package/build/translations/km.js +0 -1
  59. package/build/translations/kn.js +0 -1
  60. package/build/translations/ko.js +0 -1
  61. package/build/translations/ku.js +0 -1
  62. package/build/translations/lt.js +0 -1
  63. package/build/translations/lv.js +0 -1
  64. package/build/translations/ms.js +0 -1
  65. package/build/translations/nb.js +0 -1
  66. package/build/translations/ne.js +0 -1
  67. package/build/translations/nl.js +0 -1
  68. package/build/translations/no.js +0 -1
  69. package/build/translations/oc.js +0 -1
  70. package/build/translations/pl.js +0 -1
  71. package/build/translations/pt-br.js +0 -1
  72. package/build/translations/pt.js +0 -1
  73. package/build/translations/ro.js +0 -1
  74. package/build/translations/ru.js +0 -1
  75. package/build/translations/si.js +0 -1
  76. package/build/translations/sk.js +0 -1
  77. package/build/translations/sl.js +0 -1
  78. package/build/translations/sq.js +0 -1
  79. package/build/translations/sr-latn.js +0 -1
  80. package/build/translations/sr.js +0 -1
  81. package/build/translations/sv.js +0 -1
  82. package/build/translations/th.js +0 -1
  83. package/build/translations/ti.js +0 -1
  84. package/build/translations/tk.js +0 -1
  85. package/build/translations/tr.js +0 -1
  86. package/build/translations/tt.js +0 -1
  87. package/build/translations/ug.js +0 -1
  88. package/build/translations/uk.js +0 -1
  89. package/build/translations/ur.js +0 -1
  90. package/build/translations/uz.js +0 -1
  91. package/build/translations/vi.js +0 -1
  92. package/build/translations/zh-cn.js +0 -1
  93. package/build/translations/zh.js +0 -1
  94. package/lang/contexts.json +0 -6
  95. package/lang/translations/af.po +0 -28
  96. package/lang/translations/ar.po +0 -28
  97. package/lang/translations/ast.po +0 -28
  98. package/lang/translations/az.po +0 -28
  99. package/lang/translations/be.po +0 -28
  100. package/lang/translations/bg.po +0 -28
  101. package/lang/translations/bn.po +0 -28
  102. package/lang/translations/bs.po +0 -28
  103. package/lang/translations/ca.po +0 -28
  104. package/lang/translations/cs.po +0 -28
  105. package/lang/translations/da.po +0 -28
  106. package/lang/translations/de-ch.po +0 -28
  107. package/lang/translations/de.po +0 -28
  108. package/lang/translations/el.po +0 -28
  109. package/lang/translations/en-au.po +0 -28
  110. package/lang/translations/en-gb.po +0 -28
  111. package/lang/translations/en.po +0 -28
  112. package/lang/translations/eo.po +0 -28
  113. package/lang/translations/es-co.po +0 -28
  114. package/lang/translations/es.po +0 -28
  115. package/lang/translations/et.po +0 -28
  116. package/lang/translations/eu.po +0 -28
  117. package/lang/translations/fa.po +0 -28
  118. package/lang/translations/fi.po +0 -28
  119. package/lang/translations/fr.po +0 -28
  120. package/lang/translations/gl.po +0 -28
  121. package/lang/translations/gu.po +0 -28
  122. package/lang/translations/he.po +0 -28
  123. package/lang/translations/hi.po +0 -28
  124. package/lang/translations/hr.po +0 -28
  125. package/lang/translations/hu.po +0 -28
  126. package/lang/translations/hy.po +0 -28
  127. package/lang/translations/id.po +0 -28
  128. package/lang/translations/it.po +0 -28
  129. package/lang/translations/ja.po +0 -28
  130. package/lang/translations/jv.po +0 -28
  131. package/lang/translations/kk.po +0 -28
  132. package/lang/translations/km.po +0 -28
  133. package/lang/translations/kn.po +0 -28
  134. package/lang/translations/ko.po +0 -28
  135. package/lang/translations/ku.po +0 -28
  136. package/lang/translations/lt.po +0 -28
  137. package/lang/translations/lv.po +0 -28
  138. package/lang/translations/ms.po +0 -28
  139. package/lang/translations/nb.po +0 -28
  140. package/lang/translations/ne.po +0 -28
  141. package/lang/translations/nl.po +0 -28
  142. package/lang/translations/no.po +0 -28
  143. package/lang/translations/oc.po +0 -28
  144. package/lang/translations/pl.po +0 -28
  145. package/lang/translations/pt-br.po +0 -28
  146. package/lang/translations/pt.po +0 -28
  147. package/lang/translations/ro.po +0 -28
  148. package/lang/translations/ru.po +0 -28
  149. package/lang/translations/si.po +0 -28
  150. package/lang/translations/sk.po +0 -28
  151. package/lang/translations/sl.po +0 -28
  152. package/lang/translations/sq.po +0 -28
  153. package/lang/translations/sr-latn.po +0 -28
  154. package/lang/translations/sr.po +0 -28
  155. package/lang/translations/sv.po +0 -28
  156. package/lang/translations/th.po +0 -28
  157. package/lang/translations/ti.po +0 -28
  158. package/lang/translations/tk.po +0 -28
  159. package/lang/translations/tr.po +0 -28
  160. package/lang/translations/tt.po +0 -28
  161. package/lang/translations/ug.po +0 -28
  162. package/lang/translations/uk.po +0 -28
  163. package/lang/translations/ur.po +0 -28
  164. package/lang/translations/uz.po +0 -28
  165. package/lang/translations/vi.po +0 -28
  166. package/lang/translations/zh-cn.po +0 -28
  167. package/lang/translations/zh.po +0 -28
  168. package/src/augmentation.js +0 -5
  169. package/src/index.js +0 -20
  170. package/src/integrations/link.js +0 -164
  171. package/src/integrations/list.js +0 -151
  172. package/src/integrations/table.js +0 -123
  173. package/src/style.js +0 -36
  174. package/src/stylecommand.js +0 -208
  175. package/src/styleconfig.js +0 -5
  176. package/src/styleediting.js +0 -52
  177. package/src/styleui.js +0 -100
  178. package/src/styleutils.js +0 -275
  179. package/src/ui/stylegridbuttonview.js +0 -65
  180. package/src/ui/stylegridview.js +0 -103
  181. package/src/ui/stylegroupview.js +0 -55
  182. package/src/ui/stylepanelview.js +0 -125
  183. package/theme/style.css +0 -4
  184. package/theme/stylegrid.css +0 -29
  185. package/theme/stylegroup.css +0 -4
  186. package/theme/stylepanel.css +0 -5
  187. /package/{src → dist}/augmentation.d.ts +0 -0
  188. /package/{src → dist}/index.d.ts +0 -0
  189. /package/{src → dist}/styleconfig.d.ts +0 -0
package/src/styleutils.js DELETED
@@ -1,275 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module style/styleutils
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { isObject } from 'es-toolkit/compat';
10
- // These are intermediate element names that can't be rendered as style preview because they don't make sense standalone.
11
- const NON_PREVIEWABLE_ELEMENT_NAMES = [
12
- 'caption', 'colgroup', 'dd', 'dt', 'figcaption', 'legend', 'li', 'optgroup', 'option', 'rp',
13
- 'rt', 'summary', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr'
14
- ];
15
- export class StyleUtils extends Plugin {
16
- _htmlSupport;
17
- /**
18
- * @inheritDoc
19
- */
20
- static get pluginName() {
21
- return 'StyleUtils';
22
- }
23
- /**
24
- * @inheritDoc
25
- */
26
- static get isOfficialPlugin() {
27
- return true;
28
- }
29
- /**
30
- * @inheritDoc
31
- */
32
- constructor(editor) {
33
- super(editor);
34
- this.decorate('isStyleEnabledForBlock');
35
- this.decorate('isStyleActiveForBlock');
36
- this.decorate('getAffectedBlocks');
37
- this.decorate('isStyleEnabledForInlineSelection');
38
- this.decorate('isStyleActiveForInlineSelection');
39
- this.decorate('getAffectedInlineSelectable');
40
- this.decorate('getStylePreview');
41
- this.decorate('configureGHSDataFilter');
42
- }
43
- /**
44
- * @inheritDoc
45
- */
46
- init() {
47
- this._htmlSupport = this.editor.plugins.get('GeneralHtmlSupport');
48
- }
49
- /**
50
- * Normalizes {@link module:style/styleconfig~StyleConfig#definitions} in the configuration of the styles feature.
51
- * The structure of normalized styles looks as follows:
52
- *
53
- * ```ts
54
- * {
55
- * block: [
56
- * <module:style/style~StyleDefinition>,
57
- * <module:style/style~StyleDefinition>,
58
- * ...
59
- * ],
60
- * inline: [
61
- * <module:style/style~StyleDefinition>,
62
- * <module:style/style~StyleDefinition>,
63
- * ...
64
- * ]
65
- * }
66
- * ```
67
- *
68
- * @returns An object with normalized style definitions grouped into `block` and `inline` categories (arrays).
69
- */
70
- normalizeConfig(dataSchema, styleDefinitions = []) {
71
- const normalizedDefinitions = {
72
- block: [],
73
- inline: []
74
- };
75
- for (const definition of styleDefinitions) {
76
- const modelElements = [];
77
- const ghsAttributes = [];
78
- for (const ghsDefinition of dataSchema.getDefinitionsForView(definition.element)) {
79
- const appliesToBlock = 'appliesToBlock' in ghsDefinition ? ghsDefinition.appliesToBlock : false;
80
- if (ghsDefinition.isBlock || appliesToBlock) {
81
- if (typeof appliesToBlock == 'string') {
82
- modelElements.push(appliesToBlock);
83
- }
84
- else if (ghsDefinition.isBlock) {
85
- const ghsBlockDefinition = ghsDefinition;
86
- modelElements.push(ghsDefinition.model);
87
- if (ghsBlockDefinition.paragraphLikeModel) {
88
- modelElements.push(ghsBlockDefinition.paragraphLikeModel);
89
- }
90
- }
91
- }
92
- else {
93
- ghsAttributes.push(ghsDefinition.model);
94
- }
95
- }
96
- const previewTemplate = this.getStylePreview(definition, [
97
- { text: 'AaBbCcDdEeFfGgHhIiJj' }
98
- ]);
99
- if (modelElements.length) {
100
- normalizedDefinitions.block.push({
101
- ...definition,
102
- previewTemplate,
103
- modelElements,
104
- isBlock: true
105
- });
106
- }
107
- else {
108
- normalizedDefinitions.inline.push({
109
- ...definition,
110
- previewTemplate,
111
- ghsAttributes
112
- });
113
- }
114
- }
115
- return normalizedDefinitions;
116
- }
117
- /**
118
- * Verifies if the given style is applicable to the provided block element.
119
- *
120
- * @internal
121
- */
122
- isStyleEnabledForBlock(definition, block) {
123
- const model = this.editor.model;
124
- const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
125
- if (!model.schema.checkAttribute(block, attributeName)) {
126
- return false;
127
- }
128
- return definition.modelElements.includes(block.name);
129
- }
130
- /**
131
- * Returns true if the given style is applied to the specified block element.
132
- *
133
- * @internal
134
- */
135
- isStyleActiveForBlock(definition, block) {
136
- const attributeName = this._htmlSupport.getGhsAttributeNameForElement(definition.element);
137
- const ghsAttributeValue = block.getAttribute(attributeName);
138
- return this.hasAllClasses(ghsAttributeValue, definition.classes);
139
- }
140
- /**
141
- * Returns an array of block elements that style should be applied to.
142
- *
143
- * @internal
144
- */
145
- getAffectedBlocks(definition, block) {
146
- if (definition.modelElements.includes(block.name)) {
147
- return [block];
148
- }
149
- return null;
150
- }
151
- /**
152
- * Verifies if the given style is applicable to the provided document selection.
153
- *
154
- * @internal
155
- */
156
- isStyleEnabledForInlineSelection(definition, selection) {
157
- const model = this.editor.model;
158
- for (const ghsAttributeName of definition.ghsAttributes) {
159
- if (model.schema.checkAttributeInSelection(selection, ghsAttributeName)) {
160
- return true;
161
- }
162
- }
163
- return false;
164
- }
165
- /**
166
- * Returns true if the given style is applied to the specified document selection.
167
- *
168
- * @internal
169
- */
170
- isStyleActiveForInlineSelection(definition, selection) {
171
- for (const ghsAttributeName of definition.ghsAttributes) {
172
- const ghsAttributeValue = this._getValueFromFirstAllowedNode(selection, ghsAttributeName);
173
- if (this.hasAllClasses(ghsAttributeValue, definition.classes)) {
174
- return true;
175
- }
176
- }
177
- return false;
178
- }
179
- /**
180
- * Returns a selectable that given style should be applied to.
181
- *
182
- * @internal
183
- */
184
- getAffectedInlineSelectable(definition, selection) {
185
- return selection;
186
- }
187
- /**
188
- * Returns the `TemplateDefinition` used by styles dropdown to render style preview.
189
- *
190
- * @internal
191
- */
192
- getStylePreview(definition, children) {
193
- const { element, classes } = definition;
194
- return {
195
- tag: isPreviewable(element) ? element : 'div',
196
- attributes: {
197
- class: classes
198
- },
199
- children
200
- };
201
- }
202
- /**
203
- * Verifies if all classes are present in the given GHS attribute.
204
- *
205
- * @internal
206
- */
207
- hasAllClasses(ghsAttributeValue, classes) {
208
- return isObject(ghsAttributeValue) &&
209
- hasClassesProperty(ghsAttributeValue) &&
210
- classes.every(className => ghsAttributeValue.classes.includes(className));
211
- }
212
- /**
213
- * This is where the styles feature configures the GHS feature. This method translates normalized
214
- * {@link module:style/styleconfig~StyleDefinition style definitions} to
215
- * {@link module:engine/view/matcher~MatcherObjectPattern matcher patterns} and feeds them to the GHS
216
- * {@link module:html-support/datafilter~DataFilter} plugin.
217
- *
218
- * @internal
219
- */
220
- configureGHSDataFilter({ block, inline }) {
221
- const ghsDataFilter = this.editor.plugins.get('DataFilter');
222
- ghsDataFilter.loadAllowedConfig(block.map(normalizedStyleDefinitionToMatcherPattern));
223
- ghsDataFilter.loadAllowedConfig(inline.map(normalizedStyleDefinitionToMatcherPattern));
224
- }
225
- /**
226
- * Checks the attribute value of the first node in the selection that allows the attribute.
227
- * For the collapsed selection, returns the selection attribute.
228
- *
229
- * @param selection The document selection.
230
- * @param attributeName Name of the GHS attribute.
231
- * @returns The attribute value.
232
- */
233
- _getValueFromFirstAllowedNode(selection, attributeName) {
234
- const model = this.editor.model;
235
- const schema = model.schema;
236
- if (selection.isCollapsed) {
237
- return selection.getAttribute(attributeName);
238
- }
239
- for (const range of selection.getRanges()) {
240
- for (const item of range.getItems()) {
241
- if (schema.checkAttribute(item, attributeName)) {
242
- return item.getAttribute(attributeName);
243
- }
244
- }
245
- }
246
- return null;
247
- }
248
- }
249
- /**
250
- * Checks if given object has `classes` property which is an array.
251
- *
252
- * @param obj Object to check.
253
- */
254
- function hasClassesProperty(obj) {
255
- return Boolean(obj.classes) && Array.isArray(obj.classes);
256
- }
257
- /**
258
- * Decides whether an element should be created in the preview or a substitute `<div>` should
259
- * be used instead. This avoids previewing a standalone `<td>`, `<li>`, etc. without a parent.
260
- *
261
- * @param elementName Name of the element
262
- * @returns Boolean indicating whether the element can be rendered.
263
- */
264
- function isPreviewable(elementName) {
265
- return !NON_PREVIEWABLE_ELEMENT_NAMES.includes(elementName);
266
- }
267
- /**
268
- * Translates a normalized style definition to a view matcher pattern.
269
- */
270
- function normalizedStyleDefinitionToMatcherPattern({ element, classes }) {
271
- return {
272
- name: element,
273
- classes
274
- };
275
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- import { ButtonView, View } from 'ckeditor5/src/ui.js';
6
- /**
7
- * A class representing an individual button (style) in the grid. Renders a rich preview of the style.
8
- *
9
- * @internal
10
- */
11
- export class StyleGridButtonView extends ButtonView {
12
- /**
13
- * Definition of the style the button will apply when executed.
14
- */
15
- styleDefinition;
16
- /**
17
- * The view rendering the preview of the style.
18
- */
19
- previewView;
20
- /**
21
- * Creates an instance of the {@link module:style/ui/stylegridbuttonview~StyleGridButtonView} class.
22
- *
23
- * @param locale The localization services instance.
24
- * @param styleDefinition Definition of the style.
25
- */
26
- constructor(locale, styleDefinition) {
27
- super(locale);
28
- this.styleDefinition = styleDefinition;
29
- this.previewView = this._createPreview();
30
- this.set({
31
- label: styleDefinition.name,
32
- class: 'ck-style-grid__button',
33
- withText: true
34
- });
35
- this.extendTemplate({
36
- attributes: {
37
- role: 'option'
38
- }
39
- });
40
- this.children.add(this.previewView, 0);
41
- }
42
- /**
43
- * Creates the view representing the preview of the style.
44
- */
45
- _createPreview() {
46
- const previewView = new View(this.locale);
47
- previewView.setTemplate({
48
- tag: 'div',
49
- attributes: {
50
- class: [
51
- 'ck',
52
- 'ck-reset_all-excluded',
53
- 'ck-style-grid__button__preview',
54
- 'ck-content'
55
- ],
56
- // The preview "AaBbCcDdEeFfGgHhIiJj" should not be read by screen readers because it is purely presentational.
57
- 'aria-hidden': 'true'
58
- },
59
- children: [
60
- this.styleDefinition.previewTemplate
61
- ]
62
- });
63
- return previewView;
64
- }
65
- }
@@ -1,103 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module style/ui/stylegridview
7
- */
8
- import { View, addKeyboardHandlingForGrid } from 'ckeditor5/src/ui.js';
9
- import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { StyleGridButtonView } from './stylegridbuttonview.js';
11
- import '../../theme/stylegrid.css';
12
- /**
13
- * A class representing a grid of styles ({@link module:style/ui/stylegridbuttonview~StyleGridButtonView buttons}).
14
- * Allows users to select a style.
15
- *
16
- * @internal
17
- */
18
- export class StyleGridView extends View {
19
- /**
20
- * Tracks information about the DOM focus in the view.
21
- */
22
- focusTracker;
23
- /**
24
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
25
- */
26
- keystrokes;
27
- /**
28
- * A collection of style {@link module:style/ui/stylegridbuttonview~StyleGridButtonView buttons}.
29
- */
30
- children;
31
- /**
32
- * Creates an instance of the {@link module:style/ui/stylegridview~StyleGridView} class.
33
- *
34
- * @param locale The localization services instance.
35
- * @param styleDefinitions Definitions of the styles.
36
- */
37
- constructor(locale, styleDefinitions) {
38
- super(locale);
39
- this.focusTracker = new FocusTracker();
40
- this.keystrokes = new KeystrokeHandler();
41
- this.set('activeStyles', []);
42
- this.set('enabledStyles', []);
43
- this.children = this.createCollection();
44
- this.children.delegate('execute').to(this);
45
- for (const definition of styleDefinitions) {
46
- const gridTileView = new StyleGridButtonView(locale, definition);
47
- this.children.add(gridTileView);
48
- }
49
- this.on('change:activeStyles', () => {
50
- for (const child of this.children) {
51
- child.isOn = this.activeStyles.includes(child.styleDefinition.name);
52
- }
53
- });
54
- this.on('change:enabledStyles', () => {
55
- for (const child of this.children) {
56
- child.isEnabled = this.enabledStyles.includes(child.styleDefinition.name);
57
- }
58
- });
59
- this.setTemplate({
60
- tag: 'div',
61
- attributes: {
62
- class: [
63
- 'ck',
64
- 'ck-style-grid'
65
- ],
66
- role: 'listbox'
67
- },
68
- children: this.children
69
- });
70
- }
71
- /**
72
- * @inheritDoc
73
- */
74
- render() {
75
- super.render();
76
- for (const child of this.children) {
77
- this.focusTracker.add(child.element);
78
- }
79
- addKeyboardHandlingForGrid({
80
- keystrokeHandler: this.keystrokes,
81
- focusTracker: this.focusTracker,
82
- gridItems: this.children,
83
- numberOfColumns: 3,
84
- uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
85
- });
86
- // Start listening for the keystrokes coming from the grid view.
87
- this.keystrokes.listenTo(this.element);
88
- }
89
- /**
90
- * Focuses the first style button in the grid.
91
- */
92
- focus() {
93
- this.children.first.focus();
94
- }
95
- /**
96
- * @inheritDoc
97
- */
98
- destroy() {
99
- super.destroy();
100
- this.focusTracker.destroy();
101
- this.keystrokes.destroy();
102
- }
103
- }
@@ -1,55 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module style/ui/stylegroupview
7
- */
8
- import { LabelView, View } from 'ckeditor5/src/ui.js';
9
- import { StyleGridView } from './stylegridview.js';
10
- import '../../theme/stylegroup.css';
11
- /**
12
- * A class representing a group of styles (e.g. "block" or "inline").
13
- *
14
- * Renders a {@link module:style/ui/stylegridview~StyleGridView style grid} and a label.
15
- *
16
- * @internal
17
- */
18
- export class StyleGroupView extends View {
19
- /**
20
- * The styles grid of the group.
21
- */
22
- gridView;
23
- /**
24
- * The label of the group.
25
- */
26
- labelView;
27
- /**
28
- * Creates an instance of the {@link module:style/ui/stylegroupview~StyleGroupView} class.
29
- *
30
- * @param locale The localization services instance.
31
- * @param label The localized label of the group.
32
- * @param styleDefinitions Definitions of the styles in the group.
33
- */
34
- constructor(locale, label, styleDefinitions) {
35
- super(locale);
36
- this.labelView = new LabelView(locale);
37
- this.labelView.text = label;
38
- this.gridView = new StyleGridView(locale, styleDefinitions);
39
- this.setTemplate({
40
- tag: 'div',
41
- attributes: {
42
- class: [
43
- 'ck',
44
- 'ck-style-panel__style-group'
45
- ],
46
- role: 'group',
47
- 'aria-labelledby': this.labelView.id
48
- },
49
- children: [
50
- this.labelView,
51
- this.gridView
52
- ]
53
- });
54
- }
55
- }
@@ -1,125 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
- /**
6
- * @module style/ui/stylepanelview
7
- */
8
- import { FocusCycler, View, ViewCollection } from 'ckeditor5/src/ui.js';
9
- import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { StyleGroupView } from './stylegroupview.js';
11
- import '../../theme/stylepanel.css';
12
- /**
13
- * A class representing a panel with available content styles. It renders styles in button grids, grouped
14
- * in categories.
15
- *
16
- * @internal
17
- */
18
- export class StylePanelView extends View {
19
- /**
20
- * Tracks information about DOM focus in the panel.
21
- */
22
- focusTracker;
23
- /**
24
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
25
- */
26
- keystrokes;
27
- /**
28
- * A collection of panel children.
29
- */
30
- children;
31
- /**
32
- * A view representing block styles group.
33
- */
34
- blockStylesGroupView;
35
- /**
36
- * A view representing inline styles group
37
- */
38
- inlineStylesGroupView;
39
- /**
40
- * A collection of views that can be focused in the panel.
41
- */
42
- _focusables;
43
- /**
44
- * Helps cycling over {@link #_focusables} in the panel.
45
- */
46
- _focusCycler;
47
- /**
48
- * Creates an instance of the {@link module:style/ui/stylegroupview~StyleGroupView} class.
49
- *
50
- * @param locale The localization services instance.
51
- * @param styleDefinitions Normalized definitions of the styles.
52
- */
53
- constructor(locale, styleDefinitions) {
54
- super(locale);
55
- const t = locale.t;
56
- this.focusTracker = new FocusTracker();
57
- this.keystrokes = new KeystrokeHandler();
58
- this.children = this.createCollection();
59
- this.blockStylesGroupView = new StyleGroupView(locale, t('Block styles'), styleDefinitions.block);
60
- this.inlineStylesGroupView = new StyleGroupView(locale, t('Text styles'), styleDefinitions.inline);
61
- this.set('activeStyles', []);
62
- this.set('enabledStyles', []);
63
- this._focusables = new ViewCollection();
64
- this._focusCycler = new FocusCycler({
65
- focusables: this._focusables,
66
- focusTracker: this.focusTracker,
67
- keystrokeHandler: this.keystrokes,
68
- actions: {
69
- // Navigate style groups backwards using the <kbd>Shift</kbd> + <kbd>Tab</kbd> keystroke.
70
- focusPrevious: ['shift + tab'],
71
- // Navigate style groups forward using the <kbd>Tab</kbd> key.
72
- focusNext: ['tab']
73
- }
74
- });
75
- if (styleDefinitions.block.length) {
76
- this.children.add(this.blockStylesGroupView);
77
- }
78
- if (styleDefinitions.inline.length) {
79
- this.children.add(this.inlineStylesGroupView);
80
- }
81
- this.blockStylesGroupView.gridView.delegate('execute').to(this);
82
- this.inlineStylesGroupView.gridView.delegate('execute').to(this);
83
- this.blockStylesGroupView.gridView
84
- .bind('activeStyles', 'enabledStyles')
85
- .to(this, 'activeStyles', 'enabledStyles');
86
- this.inlineStylesGroupView.gridView
87
- .bind('activeStyles', 'enabledStyles')
88
- .to(this, 'activeStyles', 'enabledStyles');
89
- this.setTemplate({
90
- tag: 'div',
91
- attributes: {
92
- class: [
93
- 'ck',
94
- 'ck-style-panel'
95
- ]
96
- },
97
- children: this.children
98
- });
99
- }
100
- /**
101
- * @inheritDoc
102
- */
103
- render() {
104
- super.render();
105
- // Register the views as focusable.
106
- this._focusables.add(this.blockStylesGroupView.gridView);
107
- this._focusables.add(this.inlineStylesGroupView.gridView);
108
- // Register the views in the focus tracker.
109
- this.focusTracker.add(this.blockStylesGroupView.gridView.element);
110
- this.focusTracker.add(this.inlineStylesGroupView.gridView.element);
111
- this.keystrokes.listenTo(this.element);
112
- }
113
- /**
114
- * Focuses the first focusable element in the panel.
115
- */
116
- focus() {
117
- this._focusCycler.focusFirst();
118
- }
119
- /**
120
- * Focuses the last focusable element in the panel.
121
- */
122
- focusLast() {
123
- this._focusCycler.focusLast();
124
- }
125
- }
package/theme/style.css DELETED
@@ -1,4 +0,0 @@
1
- /*
2
- * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
@@ -1,29 +0,0 @@
1
- /*
2
- * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
-
6
- :root {
7
- --ck-style-panel-columns: 3;
8
- }
9
-
10
- .ck.ck-style-panel .ck-style-grid {
11
- display: grid;
12
- grid-template-columns: repeat(var(--ck-style-panel-columns),auto);
13
- justify-content: start;
14
-
15
- & .ck-style-grid__button {
16
- display: flex;
17
- justify-content: space-between;
18
- flex-direction: column;
19
-
20
- & .ck-style-grid__button__preview {
21
- display: flex;
22
- align-content: center;
23
- justify-content: flex-start;
24
- align-items: center;
25
- flex-grow: 1;
26
- flex-basis: 100%;
27
- }
28
- }
29
- }
@@ -1,4 +0,0 @@
1
- /*
2
- * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
@@ -1,5 +0,0 @@
1
- /*
2
- * Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */
5
-
File without changes
File without changes
File without changes