@ckeditor/ckeditor5-table 0.0.0-nightly-next-20251222.0 → 0.0.0-nightly-20251223.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 +2 -11
  75. package/dist/index-content.css +30 -30
  76. package/dist/index-editor.css +170 -104
  77. package/dist/index.css +237 -147
  78. package/dist/index.css.map +1 -1
  79. package/dist/index.js +2399 -307
  80. package/dist/index.js.map +1 -1
  81. package/lang/contexts.json +4 -0
  82. package/package.json +9 -9
  83. package/src/augmentation.d.ts +15 -0
  84. package/src/converters/downcast.js +12 -3
  85. package/src/index.d.ts +4 -0
  86. package/src/index.js +5 -0
  87. package/src/tablecellproperties/tablecellpropertiesediting.js +4 -2
  88. package/src/tablecellproperties/tablecellpropertiesui.js +10 -30
  89. package/src/tablecellproperties/tablecellpropertiesuiexperimental.d.ts +128 -0
  90. package/src/tablecellproperties/tablecellpropertiesuiexperimental.js +408 -0
  91. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +0 -35
  92. package/src/tablecellproperties/ui/tablecellpropertiesview.js +23 -137
  93. package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.d.ts +266 -0
  94. package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.js +744 -0
  95. package/src/tableconfig.d.ts +4 -4
  96. package/src/tableproperties/tablepropertiesediting.js +147 -14
  97. package/src/tableproperties/tablepropertiesuiexperimental.d.ts +136 -0
  98. package/src/tableproperties/tablepropertiesuiexperimental.js +375 -0
  99. package/src/tableproperties/ui/tablepropertiesview.d.ts +0 -8
  100. package/src/tableproperties/ui/tablepropertiesview.js +37 -59
  101. package/src/tableproperties/ui/tablepropertiesviewexperimental.d.ts +216 -0
  102. package/src/tableproperties/ui/tablepropertiesviewexperimental.js +544 -0
  103. package/src/utils/common.js +3 -2
  104. package/src/utils/ui/table-propertiesexperimental.d.ts +215 -0
  105. package/src/utils/ui/table-propertiesexperimental.js +391 -0
  106. package/theme/formrow-experimental.css +15 -0
  107. package/theme/formrow.css +0 -2
  108. package/theme/tablecellproperties-experimental.css +4 -0
  109. package/theme/tableform-experimental.css +61 -0
  110. package/theme/tableform.css +5 -1
  111. package/theme/tableproperties-experimental.css +78 -0
  112. package/theme/tableproperties.css +0 -60
@@ -329,7 +329,7 @@ export interface TablePropertiesConfig {
329
329
  * const tableConfig = {
330
330
  * tableProperties: {
331
331
  * alignment: {
332
- * useInlineStyles: true // Use inline styles instead of CSS classes
332
+ * useInlineStyles: false // Use CSS classes instead of inline styles
333
333
  * }
334
334
  * }
335
335
  * };
@@ -621,10 +621,10 @@ export interface TableAlignmentConfig {
621
621
  /**
622
622
  * Whether to use inline styles for table alignment in the editor output.
623
623
  *
624
- * * When `true`, the alignment is rendered as inline styles.
625
- * * When `false` (default), the alignment is rendered as CSS classes.
624
+ * * When `true` (default), the alignment is rendered as inline styles.
625
+ * * When `false`, the alignment is rendered as CSS classes.
626
626
  *
627
- * @default false
627
+ * @default true
628
628
  */
629
629
  useInlineStyles?: boolean;
630
630
  }
@@ -79,7 +79,7 @@ export class TablePropertiesEditing extends Plugin {
79
79
  const defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {
80
80
  includeAlignmentProperty: true
81
81
  });
82
- const useInlineStyles = editor.config.get('table.tableProperties.alignment.useInlineStyles') === true;
82
+ const useInlineStyles = editor.config.get('table.tableProperties.alignment.useInlineStyles') !== false;
83
83
  editor.data.addStyleProcessorRules(addMarginStylesRules);
84
84
  editor.data.addStyleProcessorRules(addBorderStylesRules);
85
85
  enableBorderProperties(editor, {
@@ -90,7 +90,12 @@ export class TablePropertiesEditing extends Plugin {
90
90
  editor.commands.add('tableBorderColor', new TableBorderColorCommand(editor, defaultTableProperties.borderColor));
91
91
  editor.commands.add('tableBorderStyle', new TableBorderStyleCommand(editor, defaultTableProperties.borderStyle));
92
92
  editor.commands.add('tableBorderWidth', new TableBorderWidthCommand(editor, defaultTableProperties.borderWidth));
93
- enableAlignmentProperty(schema, conversion, defaultTableProperties.alignment, useInlineStyles);
93
+ if (editor.config.get('experimentalFlags.useExtendedTableBlockAlignment')) {
94
+ enableExtendedAlignmentProperty(schema, conversion, defaultTableProperties.alignment, useInlineStyles);
95
+ }
96
+ else {
97
+ enableAlignmentProperty(schema, conversion, defaultTableProperties.alignment);
98
+ }
94
99
  editor.commands.add('tableAlignment', new TableAlignmentCommand(editor, defaultTableProperties.alignment));
95
100
  enableTableToFigureProperty(schema, conversion, {
96
101
  modelAttribute: 'tableWidth',
@@ -117,16 +122,18 @@ export class TablePropertiesEditing extends Plugin {
117
122
  defaultValue: defaultTableProperties.backgroundColor
118
123
  });
119
124
  editor.commands.add('tableBackgroundColor', new TableBackgroundColorCommand(editor, defaultTableProperties.backgroundColor));
120
- const viewDoc = editor.editing.view.document;
121
- // Adjust clipboard output to wrap tables in divs if needed (for alignment).
122
- this.listenTo(viewDoc, 'clipboardOutput', (evt, data) => {
123
- editor.editing.view.change(writer => {
124
- for (const { item } of writer.createRangeIn(data.content)) {
125
- wrapInDivIfNeeded(item, writer);
126
- }
127
- data.dataTransfer.setData('text/html', this.editor.data.htmlProcessor.toData(data.content));
128
- });
129
- }, { priority: 'lowest' });
125
+ if (editor.config.get('experimentalFlags.useExtendedTableBlockAlignment')) {
126
+ const viewDoc = editor.editing.view.document;
127
+ // Adjust clipboard output to wrap tables in divs if needed (for alignment).
128
+ this.listenTo(viewDoc, 'clipboardOutput', (evt, data) => {
129
+ editor.editing.view.change(writer => {
130
+ for (const { item } of writer.createRangeIn(data.content)) {
131
+ wrapInDivIfNeeded(item, writer);
132
+ }
133
+ data.dataTransfer.setData('text/html', this.editor.data.htmlProcessor.toData(data.content));
134
+ });
135
+ }, { priority: 'lowest' });
136
+ }
130
137
  }
131
138
  }
132
139
  /**
@@ -187,11 +194,11 @@ function enableBorderProperties(editor, defaultBorder) {
187
194
  downcastTableAttribute(conversion, { modelAttribute: modelAttributes.width, styleName: 'border-width' });
188
195
  }
189
196
  /**
190
- * Enables the `'alignment'` attribute for table.
197
+ * Enables the extended block`'alignment'` attribute for table.
191
198
  *
192
199
  * @param defaultValue The default alignment value.
193
200
  */
194
- function enableAlignmentProperty(schema, conversion, defaultValue, useInlineStyles) {
201
+ function enableExtendedAlignmentProperty(schema, conversion, defaultValue, useInlineStyles) {
195
202
  schema.extend('table', {
196
203
  allowAttributes: ['tableAlignment']
197
204
  });
@@ -282,6 +289,132 @@ function enableAlignmentProperty(schema, conversion, defaultValue, useInlineStyl
282
289
  });
283
290
  conversion.for('upcast').add(upcastTableAlignedDiv(defaultValue));
284
291
  }
292
+ /**
293
+ * Enables the `'alignment'` attribute for table.
294
+ *
295
+ * @param defaultValue The default alignment value.
296
+ */
297
+ function enableAlignmentProperty(schema, conversion, defaultValue) {
298
+ const ALIGN_VALUES_REG_EXP = /^(left|center|right)$/;
299
+ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
300
+ schema.extend('table', {
301
+ allowAttributes: ['tableAlignment']
302
+ });
303
+ schema.setAttributeProperties('tableAlignment', { isFormatting: true });
304
+ conversion.for('downcast')
305
+ .attributeToAttribute({
306
+ model: {
307
+ name: 'table',
308
+ key: 'tableAlignment',
309
+ values: ['left', 'center', 'right']
310
+ },
311
+ view: {
312
+ left: {
313
+ key: 'style',
314
+ value: {
315
+ float: 'left'
316
+ }
317
+ },
318
+ right: {
319
+ key: 'style',
320
+ value: {
321
+ float: 'right'
322
+ }
323
+ },
324
+ center: (alignment, conversionApi, data) => {
325
+ const value = data.item.getAttribute('tableType') !== 'layout' ? {
326
+ // Model: `alignment:center` => CSS: `float:none`.
327
+ float: 'none'
328
+ } : {
329
+ 'margin-left': 'auto',
330
+ 'margin-right': 'auto'
331
+ };
332
+ return {
333
+ key: 'style',
334
+ value
335
+ };
336
+ }
337
+ },
338
+ converterPriority: 'high'
339
+ });
340
+ conversion.for('upcast')
341
+ // Support for the `float:*;` CSS definition for the table alignment.
342
+ .attributeToAttribute({
343
+ view: {
344
+ name: /^(table|figure)$/,
345
+ styles: {
346
+ float: FLOAT_VALUES_REG_EXP
347
+ }
348
+ },
349
+ model: {
350
+ key: 'tableAlignment',
351
+ value: (viewElement, conversionApi, data) => {
352
+ // Ignore other figure elements.
353
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
354
+ return;
355
+ }
356
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
357
+ let align = viewElement.getStyle('float');
358
+ // CSS: `float:none` => Model: `alignment:center`.
359
+ if (align === 'none') {
360
+ align = 'center';
361
+ }
362
+ if (align !== localDefaultValue) {
363
+ return align;
364
+ }
365
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
366
+ conversionApi.consumable.consume(viewElement, { styles: 'float' });
367
+ }
368
+ }
369
+ })
370
+ // Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.
371
+ .attributeToAttribute({
372
+ view: {
373
+ name: /^(table|figure)$/,
374
+ styles: {
375
+ 'margin-left': 'auto',
376
+ 'margin-right': 'auto'
377
+ }
378
+ },
379
+ model: {
380
+ key: 'tableAlignment',
381
+ value: (viewElement, conversionApi, data) => {
382
+ // Ignore other figure elements.
383
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
384
+ return;
385
+ }
386
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
387
+ const align = 'center';
388
+ if (align !== localDefaultValue) {
389
+ return align;
390
+ }
391
+ // Consume the styles even if not applied to the element so it won't be processed by other converters.
392
+ conversionApi.consumable.consume(viewElement, { styles: ['margin-left', 'margin-right'] });
393
+ }
394
+ }
395
+ })
396
+ // Support for the `align` attribute as the backward compatibility while pasting from other sources.
397
+ .attributeToAttribute({
398
+ view: {
399
+ name: 'table',
400
+ attributes: {
401
+ align: ALIGN_VALUES_REG_EXP
402
+ }
403
+ },
404
+ model: {
405
+ key: 'tableAlignment',
406
+ value: (viewElement, conversionApi, data) => {
407
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
408
+ const align = viewElement.getAttribute('align');
409
+ if (align !== localDefaultValue) {
410
+ return align;
411
+ }
412
+ // Consume the attribute even if not applied to the element so it won't be processed by other converters.
413
+ conversionApi.consumable.consume(viewElement, { attributes: 'align' });
414
+ }
415
+ }
416
+ });
417
+ }
285
418
  /**
286
419
  * Returns a function that converts the table view representation:
287
420
  *
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, 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 table/tableproperties/tablepropertiesuiexperimental
7
+ */
8
+ import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
+ import { ButtonView, ContextualBalloon } from 'ckeditor5/src/ui.js';
10
+ import { TablePropertiesViewExperimental } from './ui/tablepropertiesviewexperimental.js';
11
+ /**
12
+ * The table properties UI plugin. It introduces the `'tableProperties'` button
13
+ * that opens a form allowing to specify visual styling of an entire table.
14
+ *
15
+ * It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
16
+ */
17
+ export declare class TablePropertiesUIExperimental extends Plugin {
18
+ /**
19
+ * The default table properties.
20
+ */
21
+ private _defaultContentTableProperties;
22
+ /**
23
+ * The default layout table properties.
24
+ */
25
+ private _defaultLayoutTableProperties;
26
+ /**
27
+ * The contextual balloon plugin instance.
28
+ */
29
+ private _balloon;
30
+ /**
31
+ * The properties form view displayed inside the balloon.
32
+ */
33
+ view: TablePropertiesViewExperimental | null;
34
+ /**
35
+ * The properties form view displayed inside the balloon (content table).
36
+ */
37
+ private _viewWithContentTableDefaults;
38
+ /**
39
+ * The properties form view displayed inside the balloon (layout table).
40
+ */
41
+ private _viewWithLayoutTableDefaults;
42
+ /**
43
+ * The batch used to undo all changes made by the form (which are live, as the user types)
44
+ * when "Cancel" was pressed. Each time the view is shown, a new batch is created.
45
+ */
46
+ private _undoStepBatch?;
47
+ /**
48
+ * Flag used to indicate whether view is ready to execute update commands
49
+ * (it finished loading initial data).
50
+ */
51
+ private _isReady?;
52
+ /**
53
+ * @inheritDoc
54
+ */
55
+ static get requires(): readonly [typeof ContextualBalloon];
56
+ /**
57
+ * @inheritDoc
58
+ */
59
+ static get pluginName(): "TablePropertiesUIExperimental";
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ static get isOfficialPlugin(): true;
64
+ /**
65
+ * @inheritDoc
66
+ */
67
+ constructor(editor: Editor);
68
+ /**
69
+ * @inheritDoc
70
+ */
71
+ init(): void;
72
+ /**
73
+ * Creates the table properties button.
74
+ *
75
+ * @internal
76
+ */
77
+ _createTablePropertiesButton(): ButtonView;
78
+ /**
79
+ * @inheritDoc
80
+ */
81
+ destroy(): void;
82
+ /**
83
+ * Creates the {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView} instance.
84
+ *
85
+ * @returns The table properties form view instance.
86
+ */
87
+ private _createPropertiesView;
88
+ /**
89
+ * In this method the "editor data -> UI" binding is happening.
90
+ *
91
+ * When executed, this method obtains selected table property values from various table commands
92
+ * and passes them to the {@link #view}.
93
+ *
94
+ * This way, the UI stays up–to–date with the editor data.
95
+ */
96
+ private _fillViewFormFromCommandValues;
97
+ /**
98
+ * Shows the {@link #view} in the {@link #_balloon}.
99
+ *
100
+ * **Note**: Each time a view is shown, the new {@link #_undoStepBatch} is created that contains
101
+ * all changes made to the document when the view is visible, allowing a single undo step
102
+ * for all of them.
103
+ */
104
+ protected _showView(): void;
105
+ /**
106
+ * Removes the {@link #view} from the {@link #_balloon}.
107
+ */
108
+ protected _hideView(): void;
109
+ /**
110
+ * Repositions the {@link #_balloon} or hides the {@link #view} if a table is no longer selected.
111
+ */
112
+ protected _updateView(): void;
113
+ /**
114
+ * Returns `true` when the {@link #view} is the visible in the {@link #_balloon}.
115
+ */
116
+ private get _isViewVisible();
117
+ /**
118
+ * Returns `true` when the {@link #view} is in the {@link #_balloon}.
119
+ */
120
+ private get _isViewInBalloon();
121
+ /**
122
+ * Creates a callback that when executed upon {@link #view view's} property change
123
+ * executes a related editor command with the new property value.
124
+ *
125
+ * If new value will be set to the default value, the command will not be executed.
126
+ *
127
+ * @param commandName The command that will be executed.
128
+ */
129
+ private _getPropertyChangeCallback;
130
+ /**
131
+ * Creates a callback that when executed upon {@link #view view's} property change:
132
+ * * executes a related editor command with the new property value if the value is valid,
133
+ * * or sets the error text next to the invalid field, if the value did not pass the validation.
134
+ */
135
+ private _getValidatedPropertyChangeCallback;
136
+ }