@ckeditor/ckeditor5-style 47.6.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
@@ -1,123 +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/integrations/table
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { StyleUtils } from '../styleutils.js';
10
- export class TableStyleSupport extends Plugin {
11
- _tableUtils;
12
- _styleUtils;
13
- /**
14
- * @inheritDoc
15
- */
16
- static get pluginName() {
17
- return 'TableStyleSupport';
18
- }
19
- /**
20
- * @inheritDoc
21
- */
22
- static get isOfficialPlugin() {
23
- return true;
24
- }
25
- /**
26
- * @inheritDoc
27
- */
28
- static get requires() {
29
- return [StyleUtils];
30
- }
31
- /**
32
- * @inheritDoc
33
- */
34
- init() {
35
- const editor = this.editor;
36
- if (!editor.plugins.has('TableEditing')) {
37
- return;
38
- }
39
- this._styleUtils = editor.plugins.get(StyleUtils);
40
- this._tableUtils = this.editor.plugins.get('TableUtils');
41
- this.listenTo(this._styleUtils, 'isStyleEnabledForBlock', (evt, [definition, block]) => {
42
- if (this._isApplicable(definition, block)) {
43
- evt.return = this._isStyleEnabledForBlock(definition, block);
44
- evt.stop();
45
- }
46
- }, { priority: 'high' });
47
- this.listenTo(this._styleUtils, 'getAffectedBlocks', (evt, [definition, block]) => {
48
- if (this._isApplicable(definition, block)) {
49
- evt.return = this._getAffectedBlocks(definition, block);
50
- evt.stop();
51
- }
52
- }, { priority: 'high' });
53
- this.listenTo(this._styleUtils, 'configureGHSDataFilter', (evt, [{ block }]) => {
54
- const ghsDataFilter = this.editor.plugins.get('DataFilter');
55
- ghsDataFilter.loadAllowedConfig(block
56
- .filter(definition => definition.element == 'figcaption')
57
- .map(definition => ({ name: 'caption', classes: definition.classes })));
58
- });
59
- }
60
- /**
61
- * Checks if this plugin's custom logic should be applied for defintion-block pair.
62
- *
63
- * @param definition Style definition that is being considered.
64
- * @param block Block element to check if should be styled.
65
- * @returns True if the defintion-block pair meet the plugin criteria, false otherwise.
66
- */
67
- _isApplicable(definition, block) {
68
- if (['td', 'th'].includes(definition.element)) {
69
- return block.name == 'tableCell';
70
- }
71
- if (['thead', 'tbody'].includes(definition.element)) {
72
- return block.name == 'table';
73
- }
74
- return false;
75
- }
76
- /**
77
- * Checks if the style definition should be applied to selected block.
78
- *
79
- * @param definition Style definition that is being considered.
80
- * @param block Block element to check if should be styled.
81
- * @returns True if the block should be style with the style description, false otherwise.
82
- */
83
- _isStyleEnabledForBlock(definition, block) {
84
- if (['td', 'th'].includes(definition.element)) {
85
- const location = this._tableUtils.getCellLocation(block);
86
- const tableRow = block.parent;
87
- const table = tableRow.parent;
88
- const headingRows = table.getAttribute('headingRows') || 0;
89
- const headingColumns = table.getAttribute('headingColumns') || 0;
90
- const isHeadingCell = location.row < headingRows || location.column < headingColumns;
91
- if (definition.element == 'th') {
92
- return isHeadingCell;
93
- }
94
- else {
95
- return !isHeadingCell;
96
- }
97
- }
98
- if (['thead', 'tbody'].includes(definition.element)) {
99
- const headingRows = block.getAttribute('headingRows') || 0;
100
- if (definition.element == 'thead') {
101
- return headingRows > 0;
102
- }
103
- else {
104
- return headingRows < this._tableUtils.getRows(block);
105
- }
106
- }
107
- /* istanbul ignore next -- @preserve */
108
- return false;
109
- }
110
- /**
111
- * Gets all blocks that the style should be applied to.
112
- *
113
- * @param definition Style definition that is being considered.
114
- * @param block A block element from selection.
115
- * @returns An array with the block that was passed as an argument if meets the criteria, null otherwise.
116
- */
117
- _getAffectedBlocks(definition, block) {
118
- if (!this._isStyleEnabledForBlock(definition, block)) {
119
- return null;
120
- }
121
- return [block];
122
- }
123
- }
package/src/style.js DELETED
@@ -1,36 +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/style
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { StyleUI } from './styleui.js';
10
- import { StyleEditing } from './styleediting.js';
11
- /**
12
- * The style plugin.
13
- *
14
- * This is a "glue" plugin that loads the {@link module:style/styleediting~StyleEditing style editing feature}
15
- * and {@link module:style/styleui~StyleUI style UI feature}.
16
- */
17
- export class Style extends Plugin {
18
- /**
19
- * @inheritDoc
20
- */
21
- static get pluginName() {
22
- return 'Style';
23
- }
24
- /**
25
- * @inheritDoc
26
- */
27
- static get isOfficialPlugin() {
28
- return true;
29
- }
30
- /**
31
- * @inheritDoc
32
- */
33
- static get requires() {
34
- return [StyleEditing, StyleUI];
35
- }
36
- }
@@ -1,208 +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 { Command } from 'ckeditor5/src/core.js';
6
- import { logWarning, first } from 'ckeditor5/src/utils.js';
7
- import { StyleUtils } from './styleutils.js';
8
- /**
9
- * Style command.
10
- *
11
- * Applies and removes styles from selection and elements.
12
- */
13
- export class StyleCommand extends Command {
14
- /**
15
- * Normalized definitions of the styles.
16
- */
17
- _styleDefinitions;
18
- /**
19
- * The StyleUtils plugin.
20
- */
21
- _styleUtils;
22
- /**
23
- * Creates an instance of the command.
24
- *
25
- * @param editor Editor on which this command will be used.
26
- * @param styleDefinitions Normalized definitions of the styles.
27
- */
28
- constructor(editor, styleDefinitions) {
29
- super(editor);
30
- this.set('value', []);
31
- this.set('enabledStyles', []);
32
- this._styleDefinitions = styleDefinitions;
33
- this._styleUtils = this.editor.plugins.get(StyleUtils);
34
- }
35
- /**
36
- * @inheritDoc
37
- */
38
- refresh() {
39
- const model = this.editor.model;
40
- const selection = model.document.selection;
41
- const value = new Set();
42
- const enabledStyles = new Set();
43
- // Inline styles.
44
- for (const definition of this._styleDefinitions.inline) {
45
- // Check if this inline style is enabled.
46
- if (this._styleUtils.isStyleEnabledForInlineSelection(definition, selection)) {
47
- enabledStyles.add(definition.name);
48
- }
49
- // Check if this inline style is active.
50
- if (this._styleUtils.isStyleActiveForInlineSelection(definition, selection)) {
51
- value.add(definition.name);
52
- }
53
- }
54
- // Block styles.
55
- const firstBlock = first(selection.getSelectedBlocks()) || selection.getFirstPosition().parent;
56
- if (firstBlock) {
57
- const ancestorBlocks = firstBlock.getAncestors({ includeSelf: true, parentFirst: true });
58
- for (const block of ancestorBlocks) {
59
- if (block.is('rootElement')) {
60
- break;
61
- }
62
- for (const definition of this._styleDefinitions.block) {
63
- // Check if this block style is enabled.
64
- if (!this._styleUtils.isStyleEnabledForBlock(definition, block)) {
65
- continue;
66
- }
67
- enabledStyles.add(definition.name);
68
- // Check if this block style is active.
69
- if (this._styleUtils.isStyleActiveForBlock(definition, block)) {
70
- value.add(definition.name);
71
- }
72
- }
73
- // E.g. reached a model table when the selection is in a cell. The command should not modify
74
- // ancestors of a table.
75
- if (model.schema.isObject(block)) {
76
- break;
77
- }
78
- }
79
- }
80
- this.enabledStyles = Array.from(enabledStyles).sort();
81
- this.isEnabled = this.enabledStyles.length > 0;
82
- this.value = this.isEnabled ? Array.from(value).sort() : [];
83
- }
84
- /**
85
- * Executes the command &ndash; applies the style classes to the selection or removes it from the selection.
86
- *
87
- * If the command value already contains the requested style, it will remove the style classes. Otherwise, it will set it.
88
- *
89
- * The execution result differs, depending on the {@link module:engine/model/document~ModelDocument#selection} and the
90
- * style type (inline or block):
91
- *
92
- * * When applying inline styles:
93
- * * If the selection is on a range, the command applies the style classes to all nodes in that range.
94
- * * If the selection is collapsed in a non-empty node, the command applies the style classes to the
95
- * {@link module:engine/model/document~ModelDocument#selection}.
96
- *
97
- * * When applying block styles:
98
- * * If the selection is on a range, the command applies the style classes to the nearest block parent element.
99
- *
100
- * @fires execute
101
- * @param options Command options.
102
- * @param options.styleName Style name matching the one defined in the
103
- * {@link module:style/styleconfig~StyleConfig#definitions configuration}.
104
- * @param options.forceValue Whether the command should add given style (`true`) or remove it (`false`) from the selection.
105
- * If not set (default), the command will toggle the style basing on the first selected node. Note, that this will not force
106
- * setting a style on an element that cannot receive given style.
107
- */
108
- execute({ styleName, forceValue }) {
109
- if (!this.enabledStyles.includes(styleName)) {
110
- /**
111
- * Style command can be executed only with a correct style name.
112
- *
113
- * This warning may be caused by:
114
- *
115
- * * passing a name that is not specified in the {@link module:style/styleconfig~StyleConfig#definitions configuration}
116
- * (e.g. a CSS class name),
117
- * * when trying to apply a style that is not allowed on a given element.
118
- *
119
- * @error style-command-executed-with-incorrect-style-name
120
- */
121
- logWarning('style-command-executed-with-incorrect-style-name');
122
- return;
123
- }
124
- const model = this.editor.model;
125
- const selection = model.document.selection;
126
- const htmlSupport = this.editor.plugins.get('GeneralHtmlSupport');
127
- const allDefinitions = [
128
- ...this._styleDefinitions.inline,
129
- ...this._styleDefinitions.block
130
- ];
131
- const activeDefinitions = allDefinitions.filter(({ name }) => this.value.includes(name));
132
- const definition = allDefinitions.find(({ name }) => name == styleName);
133
- const shouldAddStyle = forceValue === undefined ? !this.value.includes(definition.name) : forceValue;
134
- model.change(() => {
135
- let selectables;
136
- if (isBlockStyleDefinition(definition)) {
137
- selectables = this._findAffectedBlocks(getBlocksFromSelection(selection), definition);
138
- }
139
- else {
140
- selectables = [this._styleUtils.getAffectedInlineSelectable(definition, selection)];
141
- }
142
- for (const selectable of selectables) {
143
- if (shouldAddStyle) {
144
- htmlSupport.addModelHtmlClass(definition.element, definition.classes, selectable);
145
- }
146
- else {
147
- htmlSupport.removeModelHtmlClass(definition.element, getDefinitionExclusiveClasses(activeDefinitions, definition), selectable);
148
- }
149
- }
150
- });
151
- }
152
- /**
153
- * Returns a set of elements that should be affected by the block-style change.
154
- */
155
- _findAffectedBlocks(selectedBlocks, definition) {
156
- const blocks = new Set();
157
- for (const selectedBlock of selectedBlocks) {
158
- const ancestorBlocks = selectedBlock.getAncestors({ includeSelf: true, parentFirst: true });
159
- for (const block of ancestorBlocks) {
160
- if (block.is('rootElement')) {
161
- break;
162
- }
163
- const affectedBlocks = this._styleUtils.getAffectedBlocks(definition, block);
164
- if (affectedBlocks) {
165
- for (const affectedBlock of affectedBlocks) {
166
- blocks.add(affectedBlock);
167
- }
168
- break;
169
- }
170
- }
171
- }
172
- return blocks;
173
- }
174
- }
175
- /**
176
- * Returns classes that are defined only in the supplied definition and not in any other active definition. It's used
177
- * to ensure that classes used by other definitions are preserved when a style is removed. See #11748.
178
- *
179
- * @param activeDefinitions All currently active definitions affecting selected element(s).
180
- * @param definition Definition whose classes will be compared with all other active definition classes.
181
- * @returns Array of classes exclusive to the supplied definition.
182
- */
183
- function getDefinitionExclusiveClasses(activeDefinitions, definition) {
184
- return activeDefinitions.reduce((classes, currentDefinition) => {
185
- if (currentDefinition.name === definition.name) {
186
- return classes;
187
- }
188
- return classes.filter(className => !currentDefinition.classes.includes(className));
189
- }, definition.classes);
190
- }
191
- /**
192
- * Checks if provided style definition is of type block.
193
- */
194
- function isBlockStyleDefinition(definition) {
195
- return 'isBlock' in definition;
196
- }
197
- /**
198
- * Gets block elements from selection. If there are none, returns first selected element.
199
- * @param selection Current document's selection.
200
- * @returns Selected blocks if there are any, first selected element otherwise.
201
- */
202
- function getBlocksFromSelection(selection) {
203
- const blocks = Array.from(selection.getSelectedBlocks());
204
- if (blocks.length) {
205
- return blocks;
206
- }
207
- return [selection.getFirstPosition().parent];
208
- }
@@ -1,5 +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
- export {};
@@ -1,52 +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/styleediting
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { StyleCommand } from './stylecommand.js';
10
- import { StyleUtils } from './styleutils.js';
11
- import { ListStyleSupport } from './integrations/list.js';
12
- import { TableStyleSupport } from './integrations/table.js';
13
- import { LinkStyleSupport } from './integrations/link.js';
14
- /**
15
- * The style engine feature.
16
- *
17
- * It configures the {@glink features/html/general-html-support General HTML Support feature} based on
18
- * {@link module:style/styleconfig~StyleConfig#definitions configured style definitions} and introduces the
19
- * {@link module:style/stylecommand~StyleCommand style command} that applies styles to the content of the document.
20
- */
21
- export class StyleEditing extends Plugin {
22
- /**
23
- * @inheritDoc
24
- */
25
- static get pluginName() {
26
- return 'StyleEditing';
27
- }
28
- /**
29
- * @inheritDoc
30
- */
31
- static get isOfficialPlugin() {
32
- return true;
33
- }
34
- /**
35
- * @inheritDoc
36
- */
37
- static get requires() {
38
- return ['GeneralHtmlSupport', StyleUtils, ListStyleSupport, TableStyleSupport, LinkStyleSupport];
39
- }
40
- /**
41
- * @inheritDoc
42
- */
43
- init() {
44
- const editor = this.editor;
45
- const dataSchema = editor.plugins.get('DataSchema');
46
- const styleUtils = editor.plugins.get('StyleUtils');
47
- const styleDefinitions = editor.config.get('style.definitions');
48
- const normalizedStyleDefinitions = styleUtils.normalizeConfig(dataSchema, styleDefinitions);
49
- editor.commands.add('style', new StyleCommand(editor, normalizedStyleDefinitions));
50
- styleUtils.configureGHSDataFilter(normalizedStyleDefinitions);
51
- }
52
- }
package/src/styleui.js DELETED
@@ -1,100 +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/styleui
7
- */
8
- import { Plugin } from 'ckeditor5/src/core.js';
9
- import { createDropdown } from 'ckeditor5/src/ui.js';
10
- import { StylePanelView } from './ui/stylepanelview.js';
11
- import { StyleUtils } from './styleutils.js';
12
- import '../theme/style.css';
13
- /**
14
- * The UI plugin of the style feature .
15
- *
16
- * It registers the `'style'` UI dropdown in the editor's {@link module:ui/componentfactory~ComponentFactory component factory}
17
- * that displays a grid of styles and allows changing styles of the content.
18
- */
19
- export class StyleUI extends Plugin {
20
- /**
21
- * @inheritDoc
22
- */
23
- static get pluginName() {
24
- return 'StyleUI';
25
- }
26
- /**
27
- * @inheritDoc
28
- */
29
- static get isOfficialPlugin() {
30
- return true;
31
- }
32
- /**
33
- * @inheritDoc
34
- */
35
- static get requires() {
36
- return [StyleUtils];
37
- }
38
- /**
39
- * @inheritDoc
40
- */
41
- init() {
42
- const editor = this.editor;
43
- const dataSchema = editor.plugins.get('DataSchema');
44
- const styleUtils = editor.plugins.get('StyleUtils');
45
- const styleDefinitions = editor.config.get('style.definitions');
46
- const normalizedStyleDefinitions = styleUtils.normalizeConfig(dataSchema, styleDefinitions);
47
- // Add the dropdown to the component factory.
48
- editor.ui.componentFactory.add('style', locale => {
49
- const t = locale.t;
50
- const dropdown = createDropdown(locale);
51
- const styleCommand = editor.commands.get('style');
52
- dropdown.once('change:isOpen', () => {
53
- const panelView = new StylePanelView(locale, normalizedStyleDefinitions);
54
- // Put the styles panel is the dropdown.
55
- dropdown.panelView.children.add(panelView);
56
- // Close the dropdown when a style is selected in the styles panel.
57
- panelView.delegate('execute').to(dropdown);
58
- // Bind the state of the styles panel to the command.
59
- panelView.bind('activeStyles').to(styleCommand, 'value');
60
- panelView.bind('enabledStyles').to(styleCommand, 'enabledStyles');
61
- });
62
- // The entire dropdown will be disabled together with the command (e.g. when the editor goes read-only).
63
- dropdown.bind('isEnabled').to(styleCommand);
64
- // This dropdown has no icon. It displays text label depending on the selection.
65
- dropdown.buttonView.withText = true;
66
- // The label of the dropdown is dynamic and depends on how many styles are active at a time.
67
- dropdown.buttonView.bind('label').to(styleCommand, 'value', value => {
68
- if (value.length > 1) {
69
- return t('Multiple styles');
70
- }
71
- else if (value.length === 1) {
72
- return value[0];
73
- }
74
- else {
75
- return t('Styles');
76
- }
77
- });
78
- // The dropdown has a static CSS class for easy customization. There's another CSS class
79
- // that gets displayed when multiple styles are active at a time allowing visual customization of
80
- // the label.
81
- dropdown.bind('class').to(styleCommand, 'value', value => {
82
- const classes = [
83
- 'ck-style-dropdown'
84
- ];
85
- if (value.length > 1) {
86
- classes.push('ck-style-dropdown_multiple-active');
87
- }
88
- return classes.join(' ');
89
- });
90
- // Execute the command when a style is selected in the styles panel.
91
- // Also focus the editable after executing the command.
92
- // It overrides a default behaviour where the focus is moved to the dropdown button (#12125).
93
- dropdown.on('execute', evt => {
94
- editor.execute('style', { styleName: evt.source.styleDefinition.name });
95
- editor.editing.view.focus();
96
- });
97
- return dropdown;
98
- });
99
- }
100
- }