@ckeditor/ckeditor5-table 0.0.0-nightly-20251218.0 → 0.0.0-nightly-next-20251218.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 (112) hide show
  1. package/build/table.js +2 -2
  2. package/build/translations/af.js +1 -1
  3. package/build/translations/ar.js +1 -1
  4. package/build/translations/ast.js +1 -1
  5. package/build/translations/az.js +1 -1
  6. package/build/translations/be.js +1 -1
  7. package/build/translations/bg.js +1 -1
  8. package/build/translations/bn.js +1 -1
  9. package/build/translations/bs.js +1 -1
  10. package/build/translations/ca.js +1 -1
  11. package/build/translations/cs.js +1 -1
  12. package/build/translations/da.js +1 -1
  13. package/build/translations/de-ch.js +1 -1
  14. package/build/translations/de.js +1 -1
  15. package/build/translations/el.js +1 -1
  16. package/build/translations/en-au.js +1 -1
  17. package/build/translations/en-gb.js +1 -1
  18. package/build/translations/eo.js +1 -1
  19. package/build/translations/es-co.js +1 -1
  20. package/build/translations/es.js +1 -1
  21. package/build/translations/et.js +1 -1
  22. package/build/translations/eu.js +1 -1
  23. package/build/translations/fa.js +1 -1
  24. package/build/translations/fi.js +1 -1
  25. package/build/translations/fr.js +1 -1
  26. package/build/translations/gl.js +1 -1
  27. package/build/translations/gu.js +1 -1
  28. package/build/translations/he.js +1 -1
  29. package/build/translations/hi.js +1 -1
  30. package/build/translations/hr.js +1 -1
  31. package/build/translations/hu.js +1 -1
  32. package/build/translations/hy.js +1 -1
  33. package/build/translations/id.js +1 -1
  34. package/build/translations/it.js +1 -1
  35. package/build/translations/ja.js +1 -1
  36. package/build/translations/jv.js +1 -1
  37. package/build/translations/kk.js +1 -1
  38. package/build/translations/km.js +1 -1
  39. package/build/translations/kn.js +1 -1
  40. package/build/translations/ko.js +1 -1
  41. package/build/translations/ku.js +1 -1
  42. package/build/translations/lt.js +1 -1
  43. package/build/translations/lv.js +1 -1
  44. package/build/translations/ms.js +1 -1
  45. package/build/translations/nb.js +1 -1
  46. package/build/translations/ne.js +1 -1
  47. package/build/translations/nl.js +1 -1
  48. package/build/translations/no.js +1 -1
  49. package/build/translations/oc.js +1 -1
  50. package/build/translations/pl.js +1 -1
  51. package/build/translations/pt-br.js +1 -1
  52. package/build/translations/pt.js +1 -1
  53. package/build/translations/ro.js +1 -1
  54. package/build/translations/ru.js +1 -1
  55. package/build/translations/si.js +1 -1
  56. package/build/translations/sk.js +1 -1
  57. package/build/translations/sl.js +1 -1
  58. package/build/translations/sq.js +1 -1
  59. package/build/translations/sr-latn.js +1 -1
  60. package/build/translations/sr.js +1 -1
  61. package/build/translations/sv.js +1 -1
  62. package/build/translations/th.js +1 -1
  63. package/build/translations/ti.js +1 -1
  64. package/build/translations/tk.js +1 -1
  65. package/build/translations/tr.js +1 -1
  66. package/build/translations/tt.js +1 -1
  67. package/build/translations/ug.js +1 -1
  68. package/build/translations/uk.js +1 -1
  69. package/build/translations/ur.js +1 -1
  70. package/build/translations/uz.js +1 -1
  71. package/build/translations/vi.js +1 -1
  72. package/build/translations/zh-cn.js +1 -1
  73. package/build/translations/zh.js +1 -1
  74. package/ckeditor5-metadata.json +11 -2
  75. package/dist/index-content.css +30 -30
  76. package/dist/index-editor.css +104 -170
  77. package/dist/index.css +147 -237
  78. package/dist/index.css.map +1 -1
  79. package/dist/index.js +303 -2395
  80. package/dist/index.js.map +1 -1
  81. package/lang/contexts.json +0 -4
  82. package/package.json +9 -9
  83. package/src/augmentation.d.ts +0 -15
  84. package/src/converters/downcast.js +3 -12
  85. package/src/index.d.ts +0 -4
  86. package/src/index.js +0 -5
  87. package/src/tablecellproperties/tablecellpropertiesediting.js +2 -4
  88. package/src/tablecellproperties/tablecellpropertiesui.js +30 -10
  89. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +35 -0
  90. package/src/tablecellproperties/ui/tablecellpropertiesview.js +137 -23
  91. package/src/tableconfig.d.ts +4 -4
  92. package/src/tableproperties/tablepropertiesediting.js +14 -147
  93. package/src/tableproperties/ui/tablepropertiesview.d.ts +8 -0
  94. package/src/tableproperties/ui/tablepropertiesview.js +59 -37
  95. package/src/utils/common.js +2 -3
  96. package/theme/formrow.css +2 -0
  97. package/theme/tableform.css +1 -5
  98. package/theme/tableproperties.css +60 -0
  99. package/src/tablecellproperties/tablecellpropertiesuiexperimental.d.ts +0 -128
  100. package/src/tablecellproperties/tablecellpropertiesuiexperimental.js +0 -408
  101. package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.d.ts +0 -266
  102. package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.js +0 -744
  103. package/src/tableproperties/tablepropertiesuiexperimental.d.ts +0 -136
  104. package/src/tableproperties/tablepropertiesuiexperimental.js +0 -375
  105. package/src/tableproperties/ui/tablepropertiesviewexperimental.d.ts +0 -216
  106. package/src/tableproperties/ui/tablepropertiesviewexperimental.js +0 -544
  107. package/src/utils/ui/table-propertiesexperimental.d.ts +0 -215
  108. package/src/utils/ui/table-propertiesexperimental.js +0 -391
  109. package/theme/formrow-experimental.css +0 -15
  110. package/theme/tablecellproperties-experimental.css +0 -4
  111. package/theme/tableform-experimental.css +0 -61
  112. package/theme/tableproperties-experimental.css +0 -78
@@ -36,7 +36,6 @@
36
36
  "Dimensions": "The label describing a group of form fields that allows setting dimensions of a table or a table cell.",
37
37
  "Table cell text alignment": "The label for the group of toolbars that allows configuring the text alignment in a table cell.",
38
38
  "Table Alignment": "The label for the toolbar that allows configuring the alignment of a table.",
39
- "Alignment": "The label for the toolbar that allows configuring the alignment of a table.",
40
39
  "Horizontal text alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the horizontal text alignment in a table cell.",
41
40
  "Vertical text alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the vertical text alignment in a table cell.",
42
41
  "Table alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the alignment of a table.",
@@ -61,9 +60,6 @@
61
60
  "Align table to the right with text wrapping": "The label used by assistive technologies describing a button that aligns the table to the right as an inline element, allowing text to wrap around it.",
62
61
  "Align table to the left with no text wrapping": "The label used by assistive technologies describing a button that aligns the table to the left as a block element with no text wrapping.",
63
62
  "Align table to the right with no text wrapping": "The label used by assistive technologies describing a button that aligns the table to the right as a block element with no text wrapping.",
64
- "Align table to the left": "The label used by assistive technologies describing a button that aligns the table to the left.",
65
- "Center table": "The label used by assistive technologies describing a button that centers the table.",
66
- "Align table to the right": "The label used by assistive technologies describing a button that aligns the table to the right.",
67
63
  "The color is invalid. Try \"#FF0000\" or \"rgb(255,0,0)\" or \"red\".": "The localized error string that can be displayed next to color (background, border) fields that have an invalid value",
68
64
  "The value is invalid. Try \"10px\" or \"2em\" or simply \"2\".": "The localized error string that can be displayed next to length (padding, border width) fields that have an invalid value.",
69
65
  "Enter table caption": "The placeholder text for the table caption displayed when the caption is empty.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-table",
3
- "version": "0.0.0-nightly-20251218.0",
3
+ "version": "0.0.0-nightly-next-20251218.0",
4
4
  "description": "Table feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,14 +13,14 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "ckeditor5": "0.0.0-nightly-20251218.0",
17
- "@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-20251218.0",
18
- "@ckeditor/ckeditor5-core": "0.0.0-nightly-20251218.0",
19
- "@ckeditor/ckeditor5-engine": "0.0.0-nightly-20251218.0",
20
- "@ckeditor/ckeditor5-icons": "0.0.0-nightly-20251218.0",
21
- "@ckeditor/ckeditor5-ui": "0.0.0-nightly-20251218.0",
22
- "@ckeditor/ckeditor5-utils": "0.0.0-nightly-20251218.0",
23
- "@ckeditor/ckeditor5-widget": "0.0.0-nightly-20251218.0",
16
+ "ckeditor5": "0.0.0-nightly-next-20251218.0",
17
+ "@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-next-20251218.0",
18
+ "@ckeditor/ckeditor5-core": "0.0.0-nightly-next-20251218.0",
19
+ "@ckeditor/ckeditor5-engine": "0.0.0-nightly-next-20251218.0",
20
+ "@ckeditor/ckeditor5-icons": "0.0.0-nightly-next-20251218.0",
21
+ "@ckeditor/ckeditor5-ui": "0.0.0-nightly-next-20251218.0",
22
+ "@ckeditor/ckeditor5-utils": "0.0.0-nightly-next-20251218.0",
23
+ "@ckeditor/ckeditor5-widget": "0.0.0-nightly-next-20251218.0",
24
24
  "es-toolkit": "1.39.5"
25
25
  },
26
26
  "author": "CKSource (http://cksource.com/)",
@@ -15,21 +15,6 @@ declare module '@ckeditor/ckeditor5-engine' {
15
15
  * This will be enabled by default in the future CKEditor 5 releases.
16
16
  */
17
17
  upcastTableBorderZeroAttributes?: boolean;
18
- /**
19
- * When enabled, the the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing table properties feature}
20
- * will support extended alignment options for tables, i.e. `blockLeft` and `blockRight`, using CSS `margin` property.
21
- *
22
- * This will be enabled by default in the future CKEditor 5 releases.
23
- */
24
- useExtendedTableBlockAlignment?: boolean;
25
- /**
26
- * When enabled, the
27
- * {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing table cell properties feature}
28
- * will introduce a special selector for table cell types (i.e. header and data cells) in the cell properties dropdown.
29
- *
30
- * This will be enabled by default in the future CKEditor 5 releases.
31
- */
32
- tableCellTypeSupport?: boolean;
33
18
  }
34
19
  }
35
20
  declare module '@ckeditor/ckeditor5-core' {
@@ -174,10 +174,7 @@ function hasAnyAttribute(element) {
174
174
  */
175
175
  export function convertPlainTable(editor) {
176
176
  return (table, conversionApi) => {
177
- const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
178
- const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
179
- const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
180
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
177
+ if (!conversionApi.options.isClipboardPipeline && !editor.plugins.has('PlainTableOutput')) {
181
178
  return null;
182
179
  }
183
180
  return downcastPlainTable(table, conversionApi, editor);
@@ -188,10 +185,7 @@ export function convertPlainTable(editor) {
188
185
  */
189
186
  export function convertPlainTableCaption(editor) {
190
187
  return (modelElement, { writer, options }) => {
191
- const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
192
- const isClipboardPipeline = options.isClipboardPipeline;
193
- const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
194
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
188
+ if (!options.isClipboardPipeline && !editor.plugins.has('PlainTableOutput')) {
195
189
  return null;
196
190
  }
197
191
  if (modelElement.parent.name === 'table') {
@@ -276,10 +270,7 @@ export function downcastTableBorderAndBackgroundAttributes(editor) {
276
270
  return dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi) => {
277
271
  const { item, attributeNewValue } = data;
278
272
  const { mapper, writer } = conversionApi;
279
- const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
280
- const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
281
- const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
282
- if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
273
+ if (!conversionApi.options.isClipboardPipeline && !editor.plugins.has('PlainTableOutput')) {
283
274
  return;
284
275
  }
285
276
  if (!conversionApi.consumable.consume(item, evt.name)) {
package/src/index.d.ts CHANGED
@@ -34,10 +34,6 @@ export { TableUtils, type TableIndexesObject } from './tableutils.js';
34
34
  export { TableColumnResize } from './tablecolumnresize.js';
35
35
  export { TableColumnResizeEditing } from './tablecolumnresize/tablecolumnresizeediting.js';
36
36
  export { TableWidthsCommand, type TableWidthsCommandOptions } from './tablecolumnresize/tablewidthscommand.js';
37
- export { TablePropertiesUIExperimental } from './tableproperties/tablepropertiesuiexperimental.js';
38
- export { TablePropertiesViewExperimental, type TablePropertiesViewOptionsExperimental } from './tableproperties/ui/tablepropertiesviewexperimental.js';
39
- export { TableCellPropertiesUIExperimental } from './tablecellproperties/tablecellpropertiesuiexperimental.js';
40
- export { TableCellPropertiesViewExperimental, type TableCellPropertiesViewOptionsExperimental } from './tablecellproperties/ui/tablecellpropertiesviewexperimental.js';
41
37
  export { InsertColumnCommand } from './commands/insertcolumncommand.js';
42
38
  export { InsertRowCommand } from './commands/insertrowcommand.js';
43
39
  export { InsertTableCommand } from './commands/inserttablecommand.js';
package/src/index.js CHANGED
@@ -34,11 +34,6 @@ export { TableUtils } from './tableutils.js';
34
34
  export { TableColumnResize } from './tablecolumnresize.js';
35
35
  export { TableColumnResizeEditing } from './tablecolumnresize/tablecolumnresizeediting.js';
36
36
  export { TableWidthsCommand } from './tablecolumnresize/tablewidthscommand.js';
37
- // [experimental] Remove in the v48.
38
- export { TablePropertiesUIExperimental } from './tableproperties/tablepropertiesuiexperimental.js';
39
- export { TablePropertiesViewExperimental } from './tableproperties/ui/tablepropertiesviewexperimental.js';
40
- export { TableCellPropertiesUIExperimental } from './tablecellproperties/tablecellpropertiesuiexperimental.js';
41
- export { TableCellPropertiesViewExperimental } from './tablecellproperties/ui/tablecellpropertiesviewexperimental.js';
42
37
  export { InsertColumnCommand } from './commands/insertcolumncommand.js';
43
38
  export { InsertRowCommand } from './commands/insertrowcommand.js';
44
39
  export { InsertTableCommand } from './commands/inserttablecommand.js';
@@ -129,10 +129,8 @@ export class TableCellPropertiesEditing extends Plugin {
129
129
  editor.commands.add('tableCellHorizontalAlignment', new TableCellHorizontalAlignmentCommand(editor, defaultTableCellProperties.horizontalAlignment));
130
130
  enableVerticalAlignmentProperty(schema, conversion, defaultTableCellProperties.verticalAlignment);
131
131
  editor.commands.add('tableCellVerticalAlignment', new TableCellVerticalAlignmentCommand(editor, defaultTableCellProperties.verticalAlignment));
132
- if (editor.config.get('experimentalFlags.tableCellTypeSupport')) {
133
- enableCellTypeProperty(editor);
134
- editor.commands.add('tableCellType', new TableCellTypeCommand(editor));
135
- }
132
+ enableCellTypeProperty(editor);
133
+ editor.commands.add('tableCellType', new TableCellTypeCommand(editor));
136
134
  }
137
135
  }
138
136
  /**
@@ -25,7 +25,8 @@ const propertyToCommandMap = {
25
25
  padding: 'tableCellPadding',
26
26
  backgroundColor: 'tableCellBackgroundColor',
27
27
  horizontalAlignment: 'tableCellHorizontalAlignment',
28
- verticalAlignment: 'tableCellVerticalAlignment'
28
+ verticalAlignment: 'tableCellVerticalAlignment',
29
+ cellType: 'tableCellType'
29
30
  };
30
31
  /**
31
32
  * The table cell properties UI plugin. It introduces the `'tableCellProperties'` button
@@ -124,8 +125,10 @@ export class TableCellPropertiesUI extends Plugin {
124
125
  tooltip: true
125
126
  });
126
127
  this.listenTo(view, 'execute', () => this._showView());
127
- const commands = Object.values(propertyToCommandMap)
128
- .map(commandName => editor.commands.get(commandName));
128
+ const commands = (Object
129
+ .values(propertyToCommandMap)
130
+ .map(commandName => editor.commands.get(commandName))
131
+ .filter(val => !!val));
129
132
  view.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => (areEnabled.some(isCommandEnabled => isCommandEnabled)));
130
133
  return view;
131
134
  });
@@ -231,6 +234,11 @@ export class TableCellPropertiesUI extends Plugin {
231
234
  }));
232
235
  view.on('change:horizontalAlignment', this._getPropertyChangeCallback('tableCellHorizontalAlignment'));
233
236
  view.on('change:verticalAlignment', this._getPropertyChangeCallback('tableCellVerticalAlignment'));
237
+ const cellTypeCommand = editor.commands.get('tableCellType');
238
+ if (cellTypeCommand) {
239
+ view.cellTypeDropdown.bind('isEnabled').to(cellTypeCommand, 'isEnabled');
240
+ view.on('change:cellType', this._getPropertyChangeCallback('tableCellType'));
241
+ }
234
242
  return view;
235
243
  }
236
244
  /**
@@ -244,16 +252,28 @@ export class TableCellPropertiesUI extends Plugin {
244
252
  _fillViewFormFromCommandValues() {
245
253
  const commands = this.editor.commands;
246
254
  const borderStyleCommand = commands.get('tableCellBorderStyle');
247
- Object.entries(propertyToCommandMap)
248
- .map(([property, commandName]) => {
255
+ Object
256
+ .entries(propertyToCommandMap)
257
+ .flatMap(([property, commandName]) => {
258
+ const command = commands.get(commandName);
259
+ if (!command) {
260
+ return [];
261
+ }
249
262
  const propertyKey = property;
250
- const defaultValue = this.view === this._viewWithContentTableDefaults ?
251
- this._defaultContentTableCellProperties[propertyKey] || '' :
252
- this._defaultLayoutTableCellProperties[propertyKey] || '';
253
- return [
263
+ let defaultValue;
264
+ if (propertyKey === 'cellType') {
265
+ defaultValue = '';
266
+ }
267
+ else {
268
+ defaultValue = this.view === this._viewWithContentTableDefaults ?
269
+ this._defaultContentTableCellProperties[propertyKey] || '' :
270
+ this._defaultLayoutTableCellProperties[propertyKey] || '';
271
+ }
272
+ const entry = [
254
273
  property,
255
- commands.get(commandName).value || defaultValue
274
+ command.value || defaultValue
256
275
  ];
276
+ return [entry];
257
277
  })
258
278
  .forEach(([property, value]) => {
259
279
  // Do not set the `border-color` and `border-width` fields if `border-style:none`.
@@ -87,6 +87,13 @@ export declare class TableCellPropertiesView extends View {
87
87
  * @default ''
88
88
  */
89
89
  verticalAlignment: string;
90
+ /**
91
+ * The type of the table cell ('data' or 'header').
92
+ *
93
+ * @observable
94
+ * @default ''
95
+ */
96
+ cellType: string;
90
97
  /**
91
98
  * Options passed to the view. See {@link #constructor} to learn more.
92
99
  */
@@ -119,6 +126,10 @@ export declare class TableCellPropertiesView extends View {
119
126
  * An input that allows specifying the table cell background color.
120
127
  */
121
128
  readonly backgroundInput: LabeledFieldView<ColorInputView>;
129
+ /**
130
+ * A dropdown that allows selecting the type of the table cell (data or header).
131
+ */
132
+ readonly cellTypeDropdown: LabeledFieldView<FocusableView>;
122
133
  /**
123
134
  * An input that allows specifying the table cell padding.
124
135
  */
@@ -147,6 +158,10 @@ export declare class TableCellPropertiesView extends View {
147
158
  * The "Cancel" button view.
148
159
  */
149
160
  cancelButtonView: ButtonView;
161
+ /**
162
+ * The "Back" button view.
163
+ */
164
+ backButtonView: ButtonView;
150
165
  /**
151
166
  * A collection of views that can be focused in the form.
152
167
  */
@@ -191,6 +206,14 @@ export declare class TableCellPropertiesView extends View {
191
206
  * * {@link #backgroundInput}.
192
207
  */
193
208
  private _createBackgroundFields;
209
+ /**
210
+ * Create cell type field.
211
+ *
212
+ * * {@link #cellTypeDropdown}.
213
+ *
214
+ * @internal
215
+ */
216
+ private _createCellTypeField;
194
217
  /**
195
218
  * Creates the following form fields:
196
219
  *
@@ -218,6 +241,14 @@ export declare class TableCellPropertiesView extends View {
218
241
  * * {@link #cancelButtonView}.
219
242
  */
220
243
  private _createActionButtons;
244
+ /**
245
+ * Creates a back button view that cancels the form.
246
+ */
247
+ private _createBackButton;
248
+ /**
249
+ * Creates the cell type dropdown definitions.
250
+ */
251
+ private _getCellTypeDefinitions;
221
252
  /**
222
253
  * Provides localized labels for {@link #horizontalAlignmentToolbar} buttons.
223
254
  */
@@ -226,4 +257,8 @@ export declare class TableCellPropertiesView extends View {
226
257
  * Provides localized labels for {@link #verticalAlignmentToolbar} buttons.
227
258
  */
228
259
  private get _verticalAlignmentLabels();
260
+ /**
261
+ * Provides localized labels for {@link #cellTypeDropdown}.
262
+ */
263
+ private get _cellTypeLabels();
229
264
  }
@@ -5,9 +5,9 @@
5
5
  /**
6
6
  * @module table/tablecellproperties/ui/tablecellpropertiesview
7
7
  */
8
- import { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui.js';
9
- import { KeystrokeHandler, FocusTracker } from 'ckeditor5/src/utils.js';
10
- import { IconAlignBottom, IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignMiddle, IconAlignRight, IconAlignTop, IconCancel, IconCheck } from 'ckeditor5/src/icons.js';
8
+ import { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, UIModel, View, ViewCollection } from 'ckeditor5/src/ui.js';
9
+ import { Collection, KeystrokeHandler, FocusTracker } from 'ckeditor5/src/utils.js';
10
+ import { IconAlignBottom, IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignMiddle, IconAlignRight, IconAlignTop, IconPreviousArrow } from 'ckeditor5/src/icons.js';
11
11
  import { fillToolbar, getBorderStyleDefinitions, getBorderStyleLabels, getLabeledColorInputCreator } from '../../utils/ui/table-properties.js';
12
12
  // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
13
13
  import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
@@ -51,6 +51,10 @@ export class TableCellPropertiesView extends View {
51
51
  * An input that allows specifying the table cell background color.
52
52
  */
53
53
  backgroundInput;
54
+ /**
55
+ * A dropdown that allows selecting the type of the table cell (data or header).
56
+ */
57
+ cellTypeDropdown;
54
58
  /**
55
59
  * An input that allows specifying the table cell padding.
56
60
  */
@@ -79,6 +83,10 @@ export class TableCellPropertiesView extends View {
79
83
  * The "Cancel" button view.
80
84
  */
81
85
  cancelButtonView;
86
+ /**
87
+ * The "Back" button view.
88
+ */
89
+ backButtonView;
82
90
  /**
83
91
  * A collection of views that can be focused in the form.
84
92
  */
@@ -107,11 +115,13 @@ export class TableCellPropertiesView extends View {
107
115
  width: '',
108
116
  height: '',
109
117
  horizontalAlignment: '',
110
- verticalAlignment: ''
118
+ verticalAlignment: '',
119
+ cellType: ''
111
120
  });
112
121
  this.options = options;
113
122
  const { borderStyleDropdown, borderWidthInput, borderColorInput, borderRowLabel } = this._createBorderFields();
114
123
  const { backgroundRowLabel, backgroundInput } = this._createBackgroundFields();
124
+ const { cellTypeRowLabel, cellTypeDropdown } = this._createCellTypeField();
115
125
  const { widthInput, operatorLabel, heightInput, dimensionsLabel } = this._createDimensionFields();
116
126
  const { horizontalAlignmentToolbar, verticalAlignmentToolbar, alignmentLabel } = this._createAlignmentFields();
117
127
  this.focusTracker = new FocusTracker();
@@ -121,6 +131,7 @@ export class TableCellPropertiesView extends View {
121
131
  this.borderWidthInput = borderWidthInput;
122
132
  this.borderColorInput = borderColorInput;
123
133
  this.backgroundInput = backgroundInput;
134
+ this.cellTypeDropdown = cellTypeDropdown;
124
135
  this.paddingInput = this._createPaddingField();
125
136
  this.widthInput = widthInput;
126
137
  this.heightInput = heightInput;
@@ -132,6 +143,7 @@ export class TableCellPropertiesView extends View {
132
143
  const { saveButtonView, cancelButtonView } = this._createActionButtons();
133
144
  this.saveButtonView = saveButtonView;
134
145
  this.cancelButtonView = cancelButtonView;
146
+ this.backButtonView = this._createBackButton();
135
147
  this._focusables = new ViewCollection();
136
148
  this._focusCycler = new FocusCycler({
137
149
  focusables: this._focusables,
@@ -145,28 +157,42 @@ export class TableCellPropertiesView extends View {
145
157
  }
146
158
  });
147
159
  // Form header.
148
- this.children.add(new FormHeaderView(locale, {
160
+ const header = new FormHeaderView(locale, {
149
161
  label: this.t('Cell properties')
150
- }));
162
+ });
163
+ header.children.add(this.backButtonView, 0);
164
+ this.children.add(header);
151
165
  // Border row.
152
166
  this.children.add(new FormRowView(locale, {
153
167
  labelView: borderRowLabel,
154
168
  children: [
155
169
  borderRowLabel,
156
170
  borderStyleDropdown,
157
- borderColorInput,
158
- borderWidthInput
171
+ borderWidthInput,
172
+ borderColorInput
159
173
  ],
160
174
  class: 'ck-table-form__border-row'
161
175
  }));
162
- // Background.
176
+ // Background and cell type.
163
177
  this.children.add(new FormRowView(locale, {
164
- labelView: backgroundRowLabel,
165
178
  children: [
166
- backgroundRowLabel,
167
- backgroundInput
168
- ],
169
- class: 'ck-table-form__background-row'
179
+ new FormRowView(locale, {
180
+ labelView: cellTypeRowLabel,
181
+ children: [
182
+ cellTypeRowLabel,
183
+ cellTypeDropdown
184
+ ],
185
+ class: 'ck-table-form__cell-type-row'
186
+ }),
187
+ new FormRowView(locale, {
188
+ labelView: backgroundRowLabel,
189
+ children: [
190
+ backgroundRowLabel,
191
+ backgroundInput
192
+ ],
193
+ class: 'ck-table-form__background-row'
194
+ })
195
+ ]
170
196
  }));
171
197
  // Dimensions row and padding.
172
198
  this.children.add(new FormRowView(locale, {
@@ -204,8 +230,8 @@ export class TableCellPropertiesView extends View {
204
230
  // Action row.
205
231
  this.children.add(new FormRowView(locale, {
206
232
  children: [
207
- this.saveButtonView,
208
- this.cancelButtonView
233
+ this.cancelButtonView,
234
+ this.saveButtonView
209
235
  ],
210
236
  class: 'ck-table-form__action-row'
211
237
  }));
@@ -242,14 +268,16 @@ export class TableCellPropertiesView extends View {
242
268
  this.borderStyleDropdown,
243
269
  this.borderColorInput,
244
270
  this.borderWidthInput,
271
+ this.cellTypeDropdown,
245
272
  this.backgroundInput,
246
273
  this.widthInput,
247
274
  this.heightInput,
248
275
  this.paddingInput,
249
276
  this.horizontalAlignmentToolbar,
250
277
  this.verticalAlignmentToolbar,
278
+ this.cancelButtonView,
251
279
  this.saveButtonView,
252
- this.cancelButtonView
280
+ this.backButtonView
253
281
  ].forEach(view => {
254
282
  // Register the view as focusable.
255
283
  this._focusables.add(view);
@@ -399,6 +427,47 @@ export class TableCellPropertiesView extends View {
399
427
  backgroundInput
400
428
  };
401
429
  }
430
+ /**
431
+ * Create cell type field.
432
+ *
433
+ * * {@link #cellTypeDropdown}.
434
+ *
435
+ * @internal
436
+ */
437
+ _createCellTypeField() {
438
+ const locale = this.locale;
439
+ const t = this.t;
440
+ const cellTypeRowLabel = new LabelView(locale);
441
+ cellTypeRowLabel.text = t('Cell type');
442
+ const cellTypeLabels = this._cellTypeLabels;
443
+ const cellTypeDropdown = new LabeledFieldView(locale, createLabeledDropdown);
444
+ cellTypeDropdown.set({
445
+ label: t('Cell type'),
446
+ class: 'ck-table-cell-properties-form__cell-type'
447
+ });
448
+ cellTypeDropdown.fieldView.buttonView.set({
449
+ ariaLabel: t('Cell type'),
450
+ ariaLabelledBy: undefined,
451
+ isOn: false,
452
+ withText: true,
453
+ tooltip: t('Cell type')
454
+ });
455
+ cellTypeDropdown.fieldView.buttonView.bind('label').to(this, 'cellType', value => {
456
+ return cellTypeLabels[value || 'data'];
457
+ });
458
+ cellTypeDropdown.fieldView.on('execute', evt => {
459
+ this.cellType = evt.source._cellTypeValue;
460
+ });
461
+ cellTypeDropdown.bind('isEmpty').to(this, 'cellType', value => !value);
462
+ addListToDropdown(cellTypeDropdown.fieldView, this._getCellTypeDefinitions(), {
463
+ role: 'menu',
464
+ ariaLabel: t('Cell type')
465
+ });
466
+ return {
467
+ cellTypeRowLabel,
468
+ cellTypeDropdown
469
+ };
470
+ }
402
471
  /**
403
472
  * Creates the following form fields:
404
473
  *
@@ -496,7 +565,8 @@ export class TableCellPropertiesView extends View {
496
565
  horizontalAlignmentToolbar.set({
497
566
  isCompact: true,
498
567
  role: 'radiogroup',
499
- ariaLabel: t('Horizontal text alignment toolbar')
568
+ ariaLabel: t('Horizontal text alignment toolbar'),
569
+ class: 'ck-table-cell-properties-form__horizontal-alignment-toolbar'
500
570
  });
501
571
  fillToolbar({
502
572
  view: this,
@@ -523,7 +593,8 @@ export class TableCellPropertiesView extends View {
523
593
  verticalAlignmentToolbar.set({
524
594
  isCompact: true,
525
595
  role: 'radiogroup',
526
- ariaLabel: t('Vertical text alignment toolbar')
596
+ ariaLabel: t('Vertical text alignment toolbar'),
597
+ class: 'ck-table-cell-properties-form__vertical-alignment-toolbar'
527
598
  });
528
599
  fillToolbar({
529
600
  view: this,
@@ -558,8 +629,7 @@ export class TableCellPropertiesView extends View {
558
629
  ];
559
630
  saveButtonView.set({
560
631
  label: t('Save'),
561
- icon: IconCheck,
562
- class: 'ck-button-save',
632
+ class: 'ck-button-action',
563
633
  type: 'submit',
564
634
  withText: true
565
635
  });
@@ -568,8 +638,6 @@ export class TableCellPropertiesView extends View {
568
638
  });
569
639
  cancelButtonView.set({
570
640
  label: t('Cancel'),
571
- icon: IconCancel,
572
- class: 'ck-button-cancel',
573
641
  withText: true
574
642
  });
575
643
  cancelButtonView.delegate('execute').to(this, 'cancel');
@@ -577,6 +645,42 @@ export class TableCellPropertiesView extends View {
577
645
  saveButtonView, cancelButtonView
578
646
  };
579
647
  }
648
+ /**
649
+ * Creates a back button view that cancels the form.
650
+ */
651
+ _createBackButton() {
652
+ const t = this.locale.t;
653
+ const backButton = new ButtonView(this.locale);
654
+ backButton.set({
655
+ class: 'ck-button-back',
656
+ label: t('Back'),
657
+ icon: IconPreviousArrow,
658
+ tooltip: true
659
+ });
660
+ backButton.delegate('execute').to(this, 'cancel');
661
+ return backButton;
662
+ }
663
+ /**
664
+ * Creates the cell type dropdown definitions.
665
+ */
666
+ _getCellTypeDefinitions() {
667
+ const itemDefinitions = new Collection();
668
+ const cellTypeLabels = this._cellTypeLabels;
669
+ for (const type of ['data', 'header']) {
670
+ const definition = {
671
+ type: 'button',
672
+ model: new UIModel({
673
+ _cellTypeValue: type,
674
+ label: cellTypeLabels[type],
675
+ role: 'menuitemradio',
676
+ withText: true
677
+ })
678
+ };
679
+ definition.model.bind('isOn').to(this, 'cellType', value => value === type);
680
+ itemDefinitions.add(definition);
681
+ }
682
+ return itemDefinitions;
683
+ }
580
684
  /**
581
685
  * Provides localized labels for {@link #horizontalAlignmentToolbar} buttons.
582
686
  */
@@ -606,6 +710,16 @@ export class TableCellPropertiesView extends View {
606
710
  bottom: t('Align cell text to the bottom')
607
711
  };
608
712
  }
713
+ /**
714
+ * Provides localized labels for {@link #cellTypeDropdown}.
715
+ */
716
+ get _cellTypeLabels() {
717
+ const t = this.t;
718
+ return {
719
+ data: t('Data cell'),
720
+ header: t('Header cell')
721
+ };
722
+ }
609
723
  }
610
724
  function isBorderStyleSet(value) {
611
725
  return value !== 'none';
@@ -311,7 +311,7 @@ export interface TablePropertiesConfig {
311
311
  * const tableConfig = {
312
312
  * tableProperties: {
313
313
  * alignment: {
314
- * useInlineStyles: false // Use CSS classes instead of inline styles
314
+ * useInlineStyles: true // Use inline styles instead of CSS classes
315
315
  * }
316
316
  * }
317
317
  * };
@@ -603,10 +603,10 @@ export interface TableAlignmentConfig {
603
603
  /**
604
604
  * Whether to use inline styles for table alignment in the editor output.
605
605
  *
606
- * * When `true` (default), the alignment is rendered as inline styles.
607
- * * When `false`, the alignment is rendered as CSS classes.
606
+ * * When `true`, the alignment is rendered as inline styles.
607
+ * * When `false` (default), the alignment is rendered as CSS classes.
608
608
  *
609
- * @default true
609
+ * @default false
610
610
  */
611
611
  useInlineStyles?: boolean;
612
612
  }