@ckeditor/ckeditor5-table 45.2.1-alpha.9 → 46.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 (179) hide show
  1. package/build/table.js +1 -1
  2. package/dist/index-content.css +6 -5
  3. package/dist/index-editor.css +46 -46
  4. package/dist/index.css +63 -62
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.js +305 -49
  7. package/dist/index.js.map +1 -1
  8. package/package.json +10 -10
  9. package/src/commands/insertcolumncommand.d.ts +1 -1
  10. package/src/commands/insertcolumncommand.js +1 -1
  11. package/src/commands/insertrowcommand.d.ts +1 -1
  12. package/src/commands/insertrowcommand.js +1 -1
  13. package/src/commands/inserttablecommand.d.ts +1 -1
  14. package/src/commands/inserttablecommand.js +1 -1
  15. package/src/commands/inserttablelayoutcommand.d.ts +1 -1
  16. package/src/commands/inserttablelayoutcommand.js +1 -1
  17. package/src/commands/mergecellcommand.d.ts +3 -3
  18. package/src/commands/mergecellcommand.js +2 -2
  19. package/src/commands/mergecellscommand.d.ts +1 -1
  20. package/src/commands/mergecellscommand.js +2 -2
  21. package/src/commands/removecolumncommand.d.ts +1 -1
  22. package/src/commands/removecolumncommand.js +2 -2
  23. package/src/commands/removerowcommand.d.ts +1 -1
  24. package/src/commands/removerowcommand.js +1 -1
  25. package/src/commands/selectcolumncommand.d.ts +1 -1
  26. package/src/commands/selectcolumncommand.js +2 -2
  27. package/src/commands/selectrowcommand.d.ts +1 -1
  28. package/src/commands/selectrowcommand.js +1 -1
  29. package/src/commands/setheadercolumncommand.d.ts +2 -2
  30. package/src/commands/setheadercolumncommand.js +1 -1
  31. package/src/commands/setheaderrowcommand.d.ts +2 -2
  32. package/src/commands/setheaderrowcommand.js +1 -1
  33. package/src/commands/splitcellcommand.d.ts +1 -1
  34. package/src/commands/splitcellcommand.js +1 -1
  35. package/src/converters/downcast.d.ts +21 -9
  36. package/src/converters/downcast.js +11 -3
  37. package/src/converters/table-caption-post-fixer.d.ts +3 -1
  38. package/src/converters/table-caption-post-fixer.js +3 -1
  39. package/src/converters/table-cell-paragraph-post-fixer.d.ts +3 -1
  40. package/src/converters/table-cell-paragraph-post-fixer.js +3 -1
  41. package/src/converters/table-cell-refresh-handler.d.ts +3 -1
  42. package/src/converters/table-cell-refresh-handler.js +3 -1
  43. package/src/converters/table-headings-refresh-handler.d.ts +3 -1
  44. package/src/converters/table-headings-refresh-handler.js +4 -2
  45. package/src/converters/table-layout-post-fixer.d.ts +3 -1
  46. package/src/converters/table-layout-post-fixer.js +4 -2
  47. package/src/converters/tableproperties.d.ts +17 -1
  48. package/src/converters/tableproperties.js +49 -2
  49. package/src/converters/upcasttable.d.ts +6 -1
  50. package/src/converters/upcasttable.js +6 -1
  51. package/src/index.d.ts +89 -56
  52. package/src/index.js +84 -24
  53. package/src/plaintableoutput.d.ts +2 -2
  54. package/src/plaintableoutput.js +2 -2
  55. package/src/table.d.ts +7 -7
  56. package/src/table.js +7 -7
  57. package/src/tablecaption/tablecaptionediting.d.ts +6 -6
  58. package/src/tablecaption/tablecaptionediting.js +8 -8
  59. package/src/tablecaption/tablecaptionui.d.ts +1 -1
  60. package/src/tablecaption/tablecaptionui.js +1 -1
  61. package/src/tablecaption/toggletablecaptioncommand.d.ts +1 -1
  62. package/src/tablecaption/toggletablecaptioncommand.js +1 -1
  63. package/src/tablecaption/utils.d.ts +8 -4
  64. package/src/tablecaption/utils.js +4 -0
  65. package/src/tablecaption.d.ts +3 -3
  66. package/src/tablecaption.js +3 -3
  67. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +2 -2
  68. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +2 -2
  69. package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +4 -4
  70. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +2 -2
  71. package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +4 -4
  72. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +2 -2
  73. package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +4 -4
  74. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +2 -2
  75. package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +2 -2
  76. package/src/tablecellproperties/commands/tablecellheightcommand.js +2 -2
  77. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +2 -2
  78. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +2 -2
  79. package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +4 -4
  80. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +2 -2
  81. package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +3 -3
  82. package/src/tablecellproperties/commands/tablecellpropertycommand.js +1 -1
  83. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +2 -2
  84. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +2 -2
  85. package/src/tablecellproperties/tablecellpropertiesediting.d.ts +3 -3
  86. package/src/tablecellproperties/tablecellpropertiesediting.js +44 -19
  87. package/src/tablecellproperties/tablecellpropertiesui.d.ts +2 -2
  88. package/src/tablecellproperties/tablecellpropertiesui.js +2 -2
  89. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +2 -2
  90. package/src/tablecellproperties/ui/tablecellpropertiesview.js +1 -1
  91. package/src/tablecellproperties.d.ts +3 -3
  92. package/src/tablecellproperties.js +3 -3
  93. package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +2 -2
  94. package/src/tablecellwidth/commands/tablecellwidthcommand.js +2 -2
  95. package/src/tablecellwidth/tablecellwidthediting.d.ts +2 -2
  96. package/src/tablecellwidth/tablecellwidthediting.js +5 -3
  97. package/src/tableclipboard.d.ts +6 -6
  98. package/src/tableclipboard.js +4 -4
  99. package/src/tablecolumnresize/constants.d.ts +9 -0
  100. package/src/tablecolumnresize/constants.js +9 -0
  101. package/src/tablecolumnresize/converters.d.ts +11 -1
  102. package/src/tablecolumnresize/converters.js +16 -0
  103. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +7 -7
  104. package/src/tablecolumnresize/tablecolumnresizeediting.js +13 -11
  105. package/src/tablecolumnresize/tablewidthscommand.d.ts +3 -3
  106. package/src/tablecolumnresize/tablewidthscommand.js +1 -1
  107. package/src/tablecolumnresize/utils.d.ts +23 -11
  108. package/src/tablecolumnresize/utils.js +14 -2
  109. package/src/tablecolumnresize.d.ts +3 -3
  110. package/src/tablecolumnresize.js +3 -3
  111. package/src/tableconfig.d.ts +3 -1
  112. package/src/tableediting.d.ts +7 -7
  113. package/src/tableediting.js +19 -19
  114. package/src/tablekeyboard.d.ts +8 -8
  115. package/src/tablekeyboard.js +7 -7
  116. package/src/tablelayout/commands/tabletypecommand.d.ts +1 -1
  117. package/src/tablelayout/commands/tabletypecommand.js +1 -1
  118. package/src/tablelayout/tablelayoutediting.d.ts +2 -2
  119. package/src/tablelayout/tablelayoutediting.js +4 -4
  120. package/src/tablelayout/tablelayoutui.d.ts +1 -1
  121. package/src/tablelayout/tablelayoutui.js +4 -4
  122. package/src/tablelayout.d.ts +5 -5
  123. package/src/tablelayout.js +5 -5
  124. package/src/tablemouse/mouseeventsobserver.d.ts +13 -11
  125. package/src/tablemouse/mouseeventsobserver.js +4 -2
  126. package/src/tablemouse.d.ts +3 -3
  127. package/src/tablemouse.js +4 -4
  128. package/src/tableproperties/commands/tablealignmentcommand.d.ts +2 -2
  129. package/src/tableproperties/commands/tablealignmentcommand.js +2 -2
  130. package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +2 -2
  131. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +2 -2
  132. package/src/tableproperties/commands/tablebordercolorcommand.d.ts +4 -4
  133. package/src/tableproperties/commands/tablebordercolorcommand.js +2 -2
  134. package/src/tableproperties/commands/tableborderstylecommand.d.ts +4 -4
  135. package/src/tableproperties/commands/tableborderstylecommand.js +2 -2
  136. package/src/tableproperties/commands/tableborderwidthcommand.d.ts +4 -4
  137. package/src/tableproperties/commands/tableborderwidthcommand.js +2 -2
  138. package/src/tableproperties/commands/tableheightcommand.d.ts +2 -2
  139. package/src/tableproperties/commands/tableheightcommand.js +2 -2
  140. package/src/tableproperties/commands/tablepropertycommand.d.ts +4 -4
  141. package/src/tableproperties/commands/tablepropertycommand.js +1 -1
  142. package/src/tableproperties/commands/tablewidthcommand.d.ts +2 -2
  143. package/src/tableproperties/commands/tablewidthcommand.js +2 -2
  144. package/src/tableproperties/tablepropertiesediting.d.ts +2 -2
  145. package/src/tableproperties/tablepropertiesediting.js +49 -21
  146. package/src/tableproperties/tablepropertiesui.d.ts +2 -2
  147. package/src/tableproperties/tablepropertiesui.js +2 -2
  148. package/src/tableproperties/ui/tablepropertiesview.d.ts +2 -2
  149. package/src/tableproperties/ui/tablepropertiesview.js +1 -1
  150. package/src/tableproperties.d.ts +3 -3
  151. package/src/tableproperties.js +3 -3
  152. package/src/tableselection.d.ts +9 -9
  153. package/src/tableselection.js +4 -4
  154. package/src/tabletoolbar.d.ts +1 -1
  155. package/src/tabletoolbar.js +1 -1
  156. package/src/tableui.d.ts +1 -1
  157. package/src/tableui.js +4 -4
  158. package/src/tableutils.d.ts +25 -26
  159. package/src/tableutils.js +4 -4
  160. package/src/tablewalker.d.ts +8 -8
  161. package/src/tablewalker.js +2 -2
  162. package/src/ui/colorinputview.d.ts +6 -1
  163. package/src/ui/colorinputview.js +1 -1
  164. package/src/ui/inserttableview.d.ts +3 -1
  165. package/src/ui/inserttableview.js +3 -1
  166. package/src/utils/common.d.ts +16 -7
  167. package/src/utils/common.js +9 -1
  168. package/src/utils/structure.d.ts +24 -14
  169. package/src/utils/structure.js +11 -1
  170. package/src/utils/table-properties.d.ts +15 -2
  171. package/src/utils/table-properties.js +6 -0
  172. package/src/utils/ui/contextualballoon.d.ts +4 -3
  173. package/src/utils/ui/contextualballoon.js +1 -0
  174. package/src/utils/ui/table-properties.d.ts +20 -7
  175. package/src/utils/ui/table-properties.js +24 -11
  176. package/src/utils/ui/widget.d.ts +6 -0
  177. package/src/utils/ui/widget.js +6 -0
  178. package/theme/tablecaption.css +9 -8
  179. package/theme/tablecolumnresize.css +2 -2
package/dist/index.js CHANGED
@@ -6,9 +6,9 @@ import { Command, Plugin } from '@ckeditor/ckeditor5-core/dist/index.js';
6
6
  import { toWidgetEditable, toWidget, Widget, isWidget, WidgetToolbarRepository } from '@ckeditor/ckeditor5-widget/dist/index.js';
7
7
  import { first, global, CKEditorError, KeystrokeHandler, FocusTracker, Collection, getLocalizedArrowKeyCodeDirection, Rect, DomEmitterMixin, toUnit } from '@ckeditor/ckeditor5-utils/dist/index.js';
8
8
  import { IconTable, IconTableColumn, IconTableRow, IconTableMergeCell, IconCheck, IconCancel, IconAlignBottom, IconAlignMiddle, IconAlignTop, IconAlignJustify, IconAlignRight, IconAlignCenter, IconAlignLeft, IconTableCellProperties, IconTableLayout, IconTableProperties, IconObjectInlineRight, IconObjectCenter, IconObjectInlineLeft, IconCaption } from '@ckeditor/ckeditor5-icons/dist/index.js';
9
- import { View, addKeyboardHandlingForGrid, ButtonView, createDropdown, MenuBarMenuView, SwitchButtonView, SplitButtonView, addListToDropdown, ViewModel, ViewCollection, FocusCycler, InputTextView, ColorSelectorView, FormHeaderView, FormRowView, submitHandler, LabelView, LabeledFieldView, createLabeledDropdown, createLabeledInputText, ToolbarView, BalloonPanelView, ContextualBalloon, normalizeColorOptions, getLocalizedColorOptions, clickOutsideHandler, DropdownButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
9
+ import { View, addKeyboardHandlingForGrid, ButtonView, createDropdown, MenuBarMenuView, SwitchButtonView, SplitButtonView, addListToDropdown, UIModel, ViewCollection, FocusCycler, InputTextView, ColorSelectorView, FormHeaderView, FormRowView, submitHandler, LabelView, LabeledFieldView, createLabeledDropdown, createLabeledInputText, ToolbarView, BalloonPanelView, ContextualBalloon, normalizeColorOptions, getLocalizedColorOptions, clickOutsideHandler, DropdownButtonView } from '@ckeditor/ckeditor5-ui/dist/index.js';
10
10
  import { ClipboardMarkersUtils, ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
11
- import { DomEventObserver, isColor, isLength, isPercentage, addBorderRules, addPaddingRules, addBackgroundRules, enablePlaceholder, Element } from '@ckeditor/ckeditor5-engine/dist/index.js';
11
+ import { DomEventObserver, isColorStyleValue, isLengthStyleValue, isPercentageStyleValue, addBorderStylesRules, addPaddingStylesRules, addBackgroundStylesRules, enableViewPlaceholder, ModelElement } from '@ckeditor/ckeditor5-engine/dist/index.js';
12
12
  import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
13
13
 
14
14
  /**
@@ -16,11 +16,14 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
16
16
  *
17
17
  * @param options.modelAttribute The attribute to set.
18
18
  * @param options.styleName The style name to convert.
19
+ * @param options.attributeName The HTML attribute name to convert.
20
+ * @param options.attributeType The HTML attribute type for value normalization.
19
21
  * @param options.viewElement The view element name that should be converted.
20
22
  * @param options.defaultValue The default value for the specified `modelAttribute`.
21
23
  * @param options.shouldUpcast The function which returns `true` if style should be upcasted from this element.
24
+ * @internal
22
25
  */ function upcastStyleToAttribute(conversion, options) {
23
- const { modelAttribute, styleName, viewElement, defaultValue, reduceBoxSides = false, shouldUpcast = ()=>true } = options;
26
+ const { modelAttribute, styleName, attributeName, attributeType, viewElement, defaultValue, reduceBoxSides = false } = options;
24
27
  conversion.for('upcast').attributeToAttribute({
25
28
  view: {
26
29
  name: viewElement,
@@ -31,7 +34,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
31
34
  model: {
32
35
  key: modelAttribute,
33
36
  value: (viewElement, conversionApi, data)=>{
34
- if (!shouldUpcast(viewElement)) {
37
+ // Ignore table elements inside figures and figures without the table class.
38
+ if (viewElement.name == 'table' && viewElement.parent.name == 'figure' || viewElement.name == 'figure' && !viewElement.hasClass('table')) {
35
39
  return;
36
40
  }
37
41
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
@@ -40,9 +44,46 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
40
44
  if (localDefaultValue !== value) {
41
45
  return value;
42
46
  }
47
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
48
+ conversionApi.consumable.consume(viewElement, {
49
+ styles: styleName
50
+ });
43
51
  }
44
52
  }
45
53
  });
54
+ if (attributeName) {
55
+ conversion.for('upcast').attributeToAttribute({
56
+ view: {
57
+ name: viewElement,
58
+ attributes: {
59
+ [attributeName]: /.+/
60
+ }
61
+ },
62
+ model: {
63
+ key: modelAttribute,
64
+ value: (viewElement, conversionApi, data)=>{
65
+ // Convert attributes of table and table cell elements, ignore figure.
66
+ // Do not convert attribute if related style is set as it has a higher priority.
67
+ // Do not convert attribute if the element is a table inside a figure with the related style set.
68
+ if (viewElement.name == 'figure' || viewElement.hasStyle(styleName) || viewElement.name == 'table' && viewElement.parent.name == 'figure' && viewElement.parent.hasStyle(styleName)) {
69
+ return;
70
+ }
71
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
72
+ let value = viewElement.getAttribute(attributeName);
73
+ if (value && attributeType == 'length' && !value.endsWith('px')) {
74
+ value += 'px';
75
+ }
76
+ if (localDefaultValue !== value) {
77
+ return value;
78
+ }
79
+ // Consume the attribute even if not applied to the element so it won't be processed by other converters.
80
+ conversionApi.consumable.consume(viewElement, {
81
+ attributes: attributeName
82
+ });
83
+ }
84
+ }
85
+ });
86
+ }
46
87
  }
47
88
  /**
48
89
  * Conversion helper for upcasting border styles for view elements.
@@ -51,6 +92,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
51
92
  * @param defaultBorder.color The default `borderColor` value.
52
93
  * @param defaultBorder.style The default `borderStyle` value.
53
94
  * @param defaultBorder.width The default `borderWidth` value.
95
+ * @internal
54
96
  */ function upcastBorderStyles(conversion, viewElementName, modelAttributes, defaultBorder) {
55
97
  conversion.for('upcast').add((dispatcher)=>dispatcher.on('element:' + viewElementName, (evt, data, conversionApi)=>{
56
98
  // If the element was not converted by element-to-element converter,
@@ -124,6 +166,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
124
166
  }
125
167
  /**
126
168
  * Conversion helper for downcasting an attribute to a style.
169
+ *
170
+ * @internal
127
171
  */ function downcastAttributeToStyle(conversion, options) {
128
172
  const { modelElement, modelAttribute, styleName } = options;
129
173
  conversion.for('downcast').attributeToAttribute({
@@ -141,6 +185,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
141
185
  }
142
186
  /**
143
187
  * Conversion helper for downcasting attributes from the model table to a view table (not to `<figure>`).
188
+ *
189
+ * @internal
144
190
  */ function downcastTableAttribute(conversion, options) {
145
191
  const { modelAttribute, styleName } = options;
146
192
  conversion.for('downcast').add((dispatcher)=>dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi)=>{
@@ -161,6 +207,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
161
207
  }
162
208
  /**
163
209
  * Returns the default value for table or table cell property adjusted for layout tables.
210
+ *
211
+ * @internal
164
212
  */ function getDefaultValueAdjusted(defaultValue, layoutTableDefault, data) {
165
213
  const modelElement = data.modelRange && first(data.modelRange.getItems({
166
214
  shallow: true
@@ -201,6 +249,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
201
249
  /**
202
250
  * A common method to update the numeric value. If a value is the default one, it will be unset.
203
251
  *
252
+ * @internal
204
253
  * @param key An attribute key.
205
254
  * @param value The new attribute value.
206
255
  * @param item A model item on which the attribute will be set.
@@ -215,6 +264,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
215
264
  /**
216
265
  * A common method to create an empty table cell. It creates a proper model structure as a table cell must have at least one block inside.
217
266
  *
267
+ * @internal
218
268
  * @param writer The model writer.
219
269
  * @param insertPosition The position at which the table cell should be inserted.
220
270
  * @param attributes The element attributes.
@@ -227,6 +277,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
227
277
  }
228
278
  /**
229
279
  * Checks if a table cell belongs to the heading column section.
280
+ *
281
+ * @internal
230
282
  */ function isHeadingColumnCell(tableUtils, tableCell) {
231
283
  const table = tableCell.parent.parent;
232
284
  const headingColumns = parseInt(table.getAttribute('headingColumns') || '0');
@@ -236,6 +288,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
236
288
  /**
237
289
  * Enables conversion for an attribute for simple view-model mappings.
238
290
  *
291
+ * @internal
239
292
  * @param options.defaultValue The default value for the specified `modelAttribute`.
240
293
  */ function enableProperty$1(schema, conversion, options) {
241
294
  const { modelAttribute } = options;
@@ -244,6 +297,9 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
244
297
  modelAttribute
245
298
  ]
246
299
  });
300
+ schema.setAttributeProperties(modelAttribute, {
301
+ isFormatting: true
302
+ });
247
303
  upcastStyleToAttribute(conversion, {
248
304
  viewElement: /^(td|th)$/,
249
305
  ...options
@@ -255,6 +311,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
255
311
  }
256
312
  /**
257
313
  * Depending on the position of the selection we either return the table under cursor or look for the table higher in the hierarchy.
314
+ *
315
+ * @internal
258
316
  */ function getSelectionAffectedTable(selection) {
259
317
  const selectedElement = selection.getSelectedElement();
260
318
  // Is the command triggered from the `tableToolbar`?
@@ -276,6 +334,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
276
334
  * ```xml
277
335
  * <table></table>
278
336
  * ```
337
+ *
338
+ * @internal
279
339
  */ function upcastTableFigure() {
280
340
  return (dispatcher)=>{
281
341
  dispatcher.on('element:figure', (evt, data, conversionApi)=>{
@@ -323,6 +383,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
323
383
  * This conversion helper converts the table element as well as table rows.
324
384
  *
325
385
  * @returns Conversion helper.
386
+ * @internal
326
387
  */ function upcastTable() {
327
388
  return (dispatcher)=>{
328
389
  dispatcher.on('element:table', (evt, data, conversionApi)=>{
@@ -373,6 +434,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
373
434
  * *Note:* Only the first empty rows are removed because they have no meaning and it solves the issue
374
435
  * of an improper table with all empty rows.
375
436
  *
437
+ * @internal
376
438
  * @returns Conversion helper.
377
439
  */ function skipEmptyTableRow() {
378
440
  return (dispatcher)=>{
@@ -388,6 +450,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
388
450
  /**
389
451
  * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.
390
452
  *
453
+ * @internal
391
454
  * @returns Conversion helper.
392
455
  */ function ensureParagraphInTableCell(elementName) {
393
456
  return (dispatcher)=>{
@@ -950,7 +1013,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
950
1013
  return this._rowIndex;
951
1014
  }
952
1015
  /**
953
- * Returns the {@link module:engine/model/position~Position} before the table slot.
1016
+ * Returns the {@link module:engine/model/position~ModelPosition} before the table slot.
954
1017
  */ getPositionBefore() {
955
1018
  const model = this._table.root.document.model;
956
1019
  return model.createPositionAt(this._table.getChild(this.row), this._cellIndex);
@@ -971,6 +1034,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
971
1034
 
972
1035
  /**
973
1036
  * Model table element to view table element conversion helper.
1037
+ *
1038
+ * @internal
974
1039
  */ function downcastTable(tableUtils, options) {
975
1040
  return (table, { writer })=>{
976
1041
  const headingRows = table.getAttribute('headingRows') || 0;
@@ -1003,6 +1068,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1003
1068
  /**
1004
1069
  * Model table row element to view `<tr>` element conversion helper.
1005
1070
  *
1071
+ * @internal
1006
1072
  * @returns Element creator.
1007
1073
  */ function downcastRow() {
1008
1074
  return (tableRow, { writer })=>{
@@ -1015,6 +1081,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1015
1081
  * This conversion helper will create proper `<th>` elements for table cells that are in the heading section (heading row or column)
1016
1082
  * and `<td>` otherwise.
1017
1083
  *
1084
+ * @internal
1018
1085
  * @param options.asWidget If set to `true`, the downcast conversion will produce a widget.
1019
1086
  * @returns Element creator.
1020
1087
  */ function downcastCell(options = {}) {
@@ -1051,6 +1118,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1051
1118
  * * For a single paragraph without attributes it returns `<span>` to simulate data table.
1052
1119
  * * For all other cases it returns `<p>` element.
1053
1120
  *
1121
+ * @internal
1054
1122
  * @param options.asWidget If set to `true`, the downcast conversion will produce a widget.
1055
1123
  * @returns Element creator.
1056
1124
  */ function convertParagraphInTableCell(options = {}) {
@@ -1080,14 +1148,17 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1080
1148
  *
1081
1149
  * * If returned `true` - to a `<span class="ck-table-bogus-paragraph">`
1082
1150
  * * If returned `false` - to a `<p>`
1151
+ *
1152
+ * @internal
1083
1153
  */ function isSingleParagraphWithoutAttributes(modelElement) {
1084
1154
  const tableCell = modelElement.parent;
1085
1155
  const isSingleParagraph = tableCell.childCount == 1;
1086
1156
  return isSingleParagraph && !hasAnyAttribute(modelElement);
1087
1157
  }
1088
1158
  /**
1089
- * Converts a given {@link module:engine/view/element~Element} to a table widget:
1090
- * * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the table widget element.
1159
+ * Converts a given {@link module:engine/view/element~ViewElement} to a table widget:
1160
+ * * Adds a {@link module:engine/view/element~ViewElement#_setCustomProperty custom property}
1161
+ * allowing to recognize the table widget element.
1091
1162
  * * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
1092
1163
  *
1093
1164
  * @param writer An instance of the view writer.
@@ -1371,6 +1442,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1371
1442
  * ├───┼───┬───┤ ├───┤ └───────┴───┘
1372
1443
  * 4 │ n │ o │ p │ │ q │
1373
1444
  * └───┴───┴───┴───┴───┘
1445
+ *
1446
+ * @internal
1374
1447
  */ function cropTableToDimensions(sourceTable, cropDimensions, writer) {
1375
1448
  const { startRow, startColumn, endRow, endColumn } = cropDimensions;
1376
1449
  // Initialize the cropped table element.
@@ -1437,6 +1510,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1437
1510
  *
1438
1511
  * will return slot info for cells: "j", "f", "k".
1439
1512
  *
1513
+ * @internal
1440
1514
  * @param table The table to check.
1441
1515
  * @param overlapRow The index of the row to check.
1442
1516
  * @param startRow row to start analysis. Use it when it is known that the cells above that row will not overlap. Default value is 0.
@@ -1458,6 +1532,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1458
1532
  /**
1459
1533
  * Splits the table cell horizontally.
1460
1534
  *
1535
+ * @internal
1461
1536
  * @returns Created table cell, if any were created.
1462
1537
  */ function splitHorizontally(tableCell, splitRow, writer) {
1463
1538
  const tableRow = tableCell.parent;
@@ -1520,6 +1595,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1520
1595
  *
1521
1596
  * will return slot info for cells: "b", "e", "i".
1522
1597
  *
1598
+ * @internal
1523
1599
  * @param table The table to check.
1524
1600
  * @param overlapColumn The index of the column to check.
1525
1601
  */ function getHorizontallyOverlappingCells(table, overlapColumn) {
@@ -1537,6 +1613,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1537
1613
  /**
1538
1614
  * Splits the table cell vertically.
1539
1615
  *
1616
+ * @internal
1540
1617
  * @param columnIndex The table cell column index.
1541
1618
  * @param splitColumn The index of column to split cell on.
1542
1619
  * @returns Created table cell.
@@ -1562,6 +1639,8 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1562
1639
  *
1563
1640
  * If table cell width (or height) covers a column (or row) that is after a limit column (or row)
1564
1641
  * this method will trim "colspan" (or "rowspan") attribute so the table cell will fit in a defined limits.
1642
+ *
1643
+ * @internal
1565
1644
  */ function trimTableCellIfNeeded(tableCell, cellRow, cellColumn, limitRow, limitColumn, writer) {
1566
1645
  const colspan = parseInt(tableCell.getAttribute('colspan') || '1');
1567
1646
  const rowspan = parseInt(tableCell.getAttribute('rowspan') || '1');
@@ -1728,6 +1807,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1728
1807
  * 3 | | | | |
1729
1808
  * +---+---+---+---+
1730
1809
  *
1810
+ * @internal
1731
1811
  * @returns Adjusted last row index.
1732
1812
  */ function adjustLastRowIndex(table, dimensions) {
1733
1813
  const lastRowMap = Array.from(new TableWalker(table, {
@@ -1763,6 +1843,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
1763
1843
  * ^
1764
1844
  * last column, each cell has colspan = 2, so we need to return 3, not 2
1765
1845
  *
1846
+ * @internal
1766
1847
  * @returns Adjusted last column index.
1767
1848
  */ function adjustLastColumnIndex(table, dimensions) {
1768
1849
  const lastColumnMap = Array.from(new TableWalker(table, {
@@ -2271,15 +2352,24 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2271
2352
  */ /**
2272
2353
  * The minimum column width given as a percentage value. Used in situations when the table is not yet rendered, so it is impossible to
2273
2354
  * calculate how many percentage of the table width would be {@link ~COLUMN_MIN_WIDTH_IN_PIXELS minimum column width in pixels}.
2355
+ *
2356
+ * @internal
2274
2357
  */ const COLUMN_MIN_WIDTH_AS_PERCENTAGE = 5;
2275
2358
  /**
2276
2359
  * The minimum column width in pixels when the maximum table width is known.
2360
+ * This value is an equivalent of `10%` of the default editor width (600px).
2361
+ *
2362
+ * @internal
2277
2363
  */ const COLUMN_MIN_WIDTH_IN_PIXELS = 40;
2278
2364
  /**
2279
2365
  * Determines how many digits after the decimal point are used to store the column width as a percentage value.
2366
+ *
2367
+ * @internal
2280
2368
  */ const COLUMN_WIDTH_PRECISION = 2;
2281
2369
  /**
2282
2370
  * The distance in pixels that the mouse has to move to start resizing the column.
2371
+ *
2372
+ * @internal
2283
2373
  */ const COLUMN_RESIZE_DISTANCE_THRESHOLD = 3;
2284
2374
 
2285
2375
  /**
@@ -2288,6 +2378,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2288
2378
  *
2289
2379
  * Most notably if an entire table is removed it will not be included in returned set.
2290
2380
  *
2381
+ * @internal
2291
2382
  * @param model The model to collect the affected elements from.
2292
2383
  * @returns A set of table model elements.
2293
2384
  */ function getChangedResizedTables(model) {
@@ -2342,6 +2433,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2342
2433
  /**
2343
2434
  * Calculates the percentage of the minimum column width given in pixels for a given table.
2344
2435
  *
2436
+ * @internal
2345
2437
  * @param modelTable A table model element.
2346
2438
  * @param editor The editor instance.
2347
2439
  * @returns The minimal column width in percentage.
@@ -2351,6 +2443,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2351
2443
  /**
2352
2444
  * Calculates the table width in pixels.
2353
2445
  *
2446
+ * @internal
2354
2447
  * @param modelTable A table model element.
2355
2448
  * @param editor The editor instance.
2356
2449
  * @returns The width of the table in pixels.
@@ -2378,6 +2471,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2378
2471
  /**
2379
2472
  * Returns the computed width (in pixels) of the DOM element without padding and borders.
2380
2473
  *
2474
+ * @internal
2381
2475
  * @param domElement A DOM element.
2382
2476
  * @returns The width of the DOM element in pixels.
2383
2477
  */ function getElementWidthInPixels(domElement) {
@@ -2394,6 +2488,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2394
2488
  * Returns the column indexes on the left and right edges of a cell. They differ if the cell spans
2395
2489
  * across multiple columns.
2396
2490
  *
2491
+ * @internal
2397
2492
  * @param cell A table cell model element.
2398
2493
  * @param tableUtils The Table Utils plugin instance.
2399
2494
  * @returns An object containing the indexes of the left and right edges of the cell.
@@ -2408,6 +2503,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2408
2503
  /**
2409
2504
  * Rounds the provided value to a fixed-point number with defined number of digits after the decimal point.
2410
2505
  *
2506
+ * @internal
2411
2507
  * @param value A number to be rounded.
2412
2508
  * @returns The rounded number.
2413
2509
  */ function toPrecision(value) {
@@ -2419,6 +2515,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2419
2515
  * Clamps the number within the inclusive lower (min) and upper (max) bounds. Returned number is rounded using the
2420
2516
  * {@link ~toPrecision `toPrecision()`} function.
2421
2517
  *
2518
+ * @internal
2422
2519
  * @param number A number to be clamped.
2423
2520
  * @param min A lower bound.
2424
2521
  * @param max An upper bound.
@@ -2435,6 +2532,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2435
2532
  /**
2436
2533
  * Creates an array with defined length and fills all elements with defined value.
2437
2534
  *
2535
+ * @internal
2438
2536
  * @param length The length of the array.
2439
2537
  * @param value The value to fill the array with.
2440
2538
  * @returns An array with defined length and filled with defined value.
@@ -2444,6 +2542,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2444
2542
  /**
2445
2543
  * Sums all array values that can be parsed to a float.
2446
2544
  *
2545
+ * @internal
2447
2546
  * @param array An array of numbers.
2448
2547
  * @returns The sum of all array values.
2449
2548
  */ function sumArray(array) {
@@ -2454,12 +2553,13 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2454
2553
  * changed proportionally so that they all sum back to 100%. If there are columns without specified width, the amount remaining
2455
2554
  * after assigning the known widths will be distributed equally between them.
2456
2555
  *
2556
+ * @internal
2457
2557
  * @param columnWidths An array of column widths.
2458
2558
  * @returns An array of column widths guaranteed to sum up to 100%.
2459
2559
  */ function normalizeColumnWidths(columnWidths) {
2460
2560
  const widths = columnWidths.map((width)=>{
2461
- if (width === 'auto') {
2462
- return width;
2561
+ if (width === 'auto' || width === undefined) {
2562
+ return 'auto';
2463
2563
  }
2464
2564
  return parseFloat(width.replace('%', ''));
2465
2565
  });
@@ -2506,6 +2606,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2506
2606
  * * left and red padding,
2507
2607
  * * border width.
2508
2608
  *
2609
+ * @internal
2509
2610
  * @param domCell A DOM cell element.
2510
2611
  * @returns Width in pixels without `px` at the end.
2511
2612
  */ function getDomCellOuterWidth(domCell) {
@@ -2521,6 +2622,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
2521
2622
  /**
2522
2623
  * Updates column elements to match columns widths.
2523
2624
  *
2625
+ * @internal
2524
2626
  * @param columns
2525
2627
  * @param tableColumnGroup
2526
2628
  * @param normalizedWidths
@@ -3334,7 +3436,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
3334
3436
  }
3335
3437
  /**
3336
3438
  * Returns all model table cells that the provided model selection's ranges
3337
- * {@link module:engine/model/range~Range#start} inside.
3439
+ * {@link module:engine/model/range~ModelRange#start} inside.
3338
3440
  *
3339
3441
  * To obtain the cells selected from the outside, use
3340
3442
  * {@link #getSelectedTableCells}.
@@ -3351,7 +3453,7 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
3351
3453
  /**
3352
3454
  * Returns all model table cells that are either completely selected
3353
3455
  * by selection ranges or host selection range
3354
- * {@link module:engine/model/range~Range#start start positions} inside them.
3456
+ * {@link module:engine/model/range~ModelRange#start start positions} inside them.
3355
3457
  *
3356
3458
  * Combines {@link #getTableCellsContainingSelection} and
3357
3459
  * {@link #getSelectedTableCells}.
@@ -4070,6 +4172,8 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
4070
4172
  * </tbody>
4071
4173
  * </table>
4072
4174
  * ```
4175
+ *
4176
+ * @internal
4073
4177
  */ function injectTableLayoutPostFixer(model) {
4074
4178
  model.document.registerPostFixer((writer)=>tableLayoutPostFixer(writer, model));
4075
4179
  }
@@ -4240,6 +4344,8 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
4240
4344
  * </tableRow>
4241
4345
  * </table>
4242
4346
  * ```
4347
+ *
4348
+ * @internal
4243
4349
  */ function injectTableCellParagraphPostFixer(model) {
4244
4350
  model.document.registerPostFixer((writer)=>tableCellContentsPostFixer(writer, model));
4245
4351
  }
@@ -4323,6 +4429,8 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
4323
4429
  * Table heading rows and heading columns are represented in the model by a `headingRows` and `headingColumns` attributes.
4324
4430
  *
4325
4431
  * When table headings attribute changes, all the cells/rows are marked to re-render to change between `<td>` and `<th>`.
4432
+ *
4433
+ * @internal
4326
4434
  */ function tableHeadingsRefreshHandler(model, editing) {
4327
4435
  const differ = model.document.differ;
4328
4436
  for (const change of differ.getChanges()){
@@ -4367,6 +4475,8 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
4367
4475
  *
4368
4476
  * When table cell content changes, for example a second `paragraph` element is added, we need to ensure that the first `paragraph` is
4369
4477
  * re-rendered so it changes from `<span>` to `<p>`. The easiest way to do it is to re-render the entire table cell.
4478
+ *
4479
+ * @internal
4370
4480
  */ function tableCellRefreshHandler(model, editing) {
4371
4481
  const differ = model.document.differ;
4372
4482
  // Stores cells to be refreshed, so the table cell will be refreshed once for multiple changes.
@@ -4623,6 +4733,8 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
4623
4733
  * The table size view.
4624
4734
  *
4625
4735
  * It renders a 10x10 grid to choose the inserted table size.
4736
+ *
4737
+ * @internal
4626
4738
  */ class InsertTableView extends View {
4627
4739
  /**
4628
4740
  * A collection of table size box items.
@@ -5108,7 +5220,7 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
5108
5220
  * @param itemDefinitions A collection of dropdown items to update with the given option.
5109
5221
  */ function addListOption(option, editor, commands, itemDefinitions) {
5110
5222
  if (option.type === 'button' || option.type === 'switchbutton') {
5111
- const model = option.model = new ViewModel(option.model);
5223
+ const model = option.model = new UIModel(option.model);
5112
5224
  const { commandName, bindIsOn } = option.model;
5113
5225
  const command = editor.commands.get(commandName);
5114
5226
  commands.push(command);
@@ -5356,7 +5468,7 @@ function getMaxOffset(tableCell, start, currentMaxOffset, which) {
5356
5468
  * yes, it's a hack).
5357
5469
  *
5358
5470
  * When multiple cells are selected in the model and the user starts to type, the
5359
- * {@link module:engine/view/document~Document#event:insertText} event carries information provided by the
5471
+ * {@link module:engine/view/document~ViewDocument#event:insertText} event carries information provided by the
5360
5472
  * beforeinput DOM event, that in turn only knows about this collapsed DOM selection in the last cell.
5361
5473
  *
5362
5474
  * As a result, the selected cells have no chance to be cleaned up. To fix this, this listener intercepts
@@ -5998,7 +6110,7 @@ function doVerticalSplit(table, splitColumn, limitRows, writer) {
5998
6110
  });
5999
6111
  }
6000
6112
  /**
6001
- * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
6113
+ * Handles {@link module:engine/view/document~ViewDocument#event:tab tab} events for the <kbd>Tab</kbd> key executed
6002
6114
  * when the table widget is selected.
6003
6115
  */ _handleTabOnSelectedTable(bubblingEventInfo, domEventData) {
6004
6116
  const editor = this.editor;
@@ -6015,7 +6127,7 @@ function doVerticalSplit(table, splitColumn, limitRows, writer) {
6015
6127
  });
6016
6128
  }
6017
6129
  /**
6018
- * Handles {@link module:engine/view/document~Document#event:tab tab} events for the <kbd>Tab</kbd> key executed
6130
+ * Handles {@link module:engine/view/document~ViewDocument#event:tab tab} events for the <kbd>Tab</kbd> key executed
6019
6131
  * inside table cells.
6020
6132
  */ _handleTab(bubblingEventInfo, domEventData) {
6021
6133
  const editor = this.editor;
@@ -6074,7 +6186,7 @@ function doVerticalSplit(table, splitColumn, limitRows, writer) {
6074
6186
  });
6075
6187
  }
6076
6188
  /**
6077
- * Handles {@link module:engine/view/document~Document#event:keydown keydown} events.
6189
+ * Handles {@link module:engine/view/document~ViewDocument#event:keydown keydown} events.
6078
6190
  */ _onArrowKey(eventInfo, domEventData) {
6079
6191
  const editor = this.editor;
6080
6192
  const keyCode = domEventData.keyCode;
@@ -6244,9 +6356,11 @@ function doVerticalSplit(table, splitColumn, limitRows, writer) {
6244
6356
  * - `'mouseleave'`
6245
6357
  *
6246
6358
  * Note that this observer is disabled by default. To enable this observer, it needs to be added to
6247
- * {@link module:engine/view/view~View} using the {@link module:engine/view/view~View#addObserver} method.
6359
+ * {@link module:engine/view/view~EditingView} using the {@link module:engine/view/view~EditingView#addObserver} method.
6248
6360
  *
6249
6361
  * The observer is registered by the {@link module:table/tableselection~TableSelection} plugin.
6362
+ *
6363
+ * @internal
6250
6364
  */ class MouseEventsObserver extends DomEventObserver {
6251
6365
  domEventType = [
6252
6366
  'mousemove',
@@ -6604,6 +6718,8 @@ function haveSameTableParent(cellA, cellB) {
6604
6718
 
6605
6719
  /**
6606
6720
  * Depending on the position of the selection either return the selected table or the table higher in the hierarchy.
6721
+ *
6722
+ * @internal
6607
6723
  */ function getSelectionAffectedTableWidget(selection) {
6608
6724
  const selectedTable = getSelectedTableWidget(selection);
6609
6725
  if (selectedTable) {
@@ -6613,6 +6729,8 @@ function haveSameTableParent(cellA, cellB) {
6613
6729
  }
6614
6730
  /**
6615
6731
  * Returns a table widget editing view element if one is selected.
6732
+ *
6733
+ * @internal
6616
6734
  */ function getSelectedTableWidget(selection) {
6617
6735
  const viewElement = selection.getSelectedElement();
6618
6736
  if (viewElement && isTableWidget(viewElement)) {
@@ -6622,6 +6740,8 @@ function haveSameTableParent(cellA, cellB) {
6622
6740
  }
6623
6741
  /**
6624
6742
  * Returns a table widget editing view element if one is among the selection's ancestors.
6743
+ *
6744
+ * @internal
6625
6745
  */ function getTableWidgetAncestor(selection) {
6626
6746
  const selectionPosition = selection.getFirstPosition();
6627
6747
  if (!selectionPosition) {
@@ -6974,6 +7094,7 @@ const isEmpty = (val)=>val === '';
6974
7094
  * labels. Used by {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView}
6975
7095
  * and {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView}.
6976
7096
  *
7097
+ * @internal
6977
7098
  * @param t The "t" function provided by the editor that is used to localize strings.
6978
7099
  */ function getBorderStyleLabels(t) {
6979
7100
  return {
@@ -6992,6 +7113,7 @@ const isEmpty = (val)=>val === '';
6992
7113
  * Returns a localized error string that can be displayed next to color (background, border)
6993
7114
  * fields that have an invalid value.
6994
7115
  *
7116
+ * @internal
6995
7117
  * @param t The "t" function provided by the editor that is used to localize strings.
6996
7118
  */ function getLocalizedColorErrorText(t) {
6997
7119
  return t('The color is invalid. Try "#FF0000" or "rgb(255,0,0)" or "red".');
@@ -7000,6 +7122,7 @@ const isEmpty = (val)=>val === '';
7000
7122
  * Returns a localized error string that can be displayed next to length (padding, border width)
7001
7123
  * fields that have an invalid value.
7002
7124
  *
7125
+ * @internal
7003
7126
  * @param t The "t" function provided by the editor that is used to localize strings.
7004
7127
  */ function getLocalizedLengthErrorText(t) {
7005
7128
  return t('The value is invalid. Try "10px" or "2em" or simply "2".');
@@ -7008,33 +7131,40 @@ const isEmpty = (val)=>val === '';
7008
7131
  * Returns `true` when the passed value is an empty string or a valid CSS color expression.
7009
7132
  * Otherwise, `false` is returned.
7010
7133
  *
7011
- * See {@link module:engine/view/styles/utils~isColor}.
7134
+ * See {@link module:engine/view/styles/utils~isColorStyleValue}.
7135
+ *
7136
+ * @internal
7012
7137
  */ function colorFieldValidator(value) {
7013
7138
  value = value.trim().toLowerCase();
7014
- return isEmpty(value) || isColor(value);
7139
+ return isEmpty(value) || isColorStyleValue(value);
7015
7140
  }
7016
7141
  /**
7017
7142
  * Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.
7018
7143
  * Otherwise, `false` is returned.
7019
7144
  *
7020
- * See {@link module:engine/view/styles/utils~isLength}.
7021
- * See {@link module:engine/view/styles/utils~isPercentage}.
7145
+ * See {@link module:engine/view/styles/utils~isLengthStyleValue}.
7146
+ * See {@link module:engine/view/styles/utils~isPercentageStyleValue}.
7147
+ *
7148
+ * @internal
7022
7149
  */ function lengthFieldValidator(value) {
7023
7150
  value = value.trim();
7024
- return isEmpty(value) || isNumberString(value) || isLength(value) || isPercentage(value);
7151
+ return isEmpty(value) || isNumberString(value) || isLengthStyleValue(value) || isPercentageStyleValue(value);
7025
7152
  }
7026
7153
  /**
7027
7154
  * Returns `true` when the passed value is an empty string, a number without a unit or a valid CSS length expression.
7028
7155
  * Otherwise, `false` is returned.
7029
7156
  *
7030
- * See {@link module:engine/view/styles/utils~isLength}.
7157
+ * See {@link module:engine/view/styles/utils~isLengthStyleValue}.
7158
+ *
7159
+ * @internal
7031
7160
  */ function lineWidthFieldValidator(value) {
7032
7161
  value = value.trim();
7033
- return isEmpty(value) || isNumberString(value) || isLength(value);
7162
+ return isEmpty(value) || isNumberString(value) || isLengthStyleValue(value);
7034
7163
  }
7035
7164
  /**
7036
7165
  * Generates item definitions for a UI dropdown that allows changing the border style of a table or a table cell.
7037
7166
  *
7167
+ * @internal
7038
7168
  * @param defaultStyle The default border.
7039
7169
  */ function getBorderStyleDefinitions(view, defaultStyle) {
7040
7170
  const itemDefinitions = new Collection();
@@ -7042,7 +7172,7 @@ const isEmpty = (val)=>val === '';
7042
7172
  for(const style in styleLabels){
7043
7173
  const definition = {
7044
7174
  type: 'button',
7045
- model: new ViewModel({
7175
+ model: new UIModel({
7046
7176
  _borderStyleValue: style,
7047
7177
  label: styleLabels[style],
7048
7178
  role: 'menuitemradio',
@@ -7072,6 +7202,7 @@ const isEmpty = (val)=>val === '';
7072
7202
  * * have some icons,
7073
7203
  * * set a certain UI view property value upon execution.
7074
7204
  *
7205
+ * @internal
7075
7206
  * @param options Configuration options
7076
7207
  * @param options.view The view that has the observable property.
7077
7208
  * @param options.icons Object with button icons.
@@ -7186,6 +7317,8 @@ const isEmpty = (val)=>val === '';
7186
7317
  * }
7187
7318
  * ];
7188
7319
  * ```
7320
+ *
7321
+ * @internal
7189
7322
  */ const defaultColors = [
7190
7323
  {
7191
7324
  color: 'hsl(0, 0%, 0%)',
@@ -7917,6 +8050,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
7917
8050
  * {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon} instance
7918
8051
  * with respect to the table in the editor content, if one is selected.
7919
8052
  *
8053
+ * @internal
7920
8054
  * @param editor The editor instance.
7921
8055
  * @param target Either "cell" or "table". Determines the target the balloon will be attached to.
7922
8056
  */ function repositionContextualBalloon(editor, target) {
@@ -8010,6 +8144,8 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
8010
8144
  * getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );
8011
8145
  * getSingleValue( { top: 'foo', right: 'foo' } );
8012
8146
  * ```
8147
+ *
8148
+ * @internal
8013
8149
  */ function getSingleValue(objectOrString) {
8014
8150
  if (!objectOrString || !isObject(objectOrString)) {
8015
8151
  return objectOrString;
@@ -8031,6 +8167,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
8031
8167
  * getSingleValue( 'foo', 'px' ); // 'foo'
8032
8168
  * ```
8033
8169
  *
8170
+ * @internal
8034
8171
  * @param defaultUnit A default unit added to a numeric value.
8035
8172
  */ function addDefaultUnitToNumericValue(value, defaultUnit) {
8036
8173
  const numericValue = parseFloat(value);
@@ -8045,6 +8182,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
8045
8182
  /**
8046
8183
  * Returns the normalized configuration.
8047
8184
  *
8185
+ * @internal
8048
8186
  * @param config The configuration to normalize.
8049
8187
  * @param options Options used to determine which properties should be added.
8050
8188
  */ function getNormalizedDefaultProperties(config, options = {}) {
@@ -8074,6 +8212,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
8074
8212
  /**
8075
8213
  * Returns the normalized default table properties.
8076
8214
  *
8215
+ * @internal
8077
8216
  * @param config The configuration to normalize.
8078
8217
  * @param options Options used to determine which properties should be added.
8079
8218
  */ function getNormalizedDefaultTableProperties(config, options) {
@@ -8089,6 +8228,7 @@ const BALLOON_POSITIONS = /* #__PURE__ */ (()=>[
8089
8228
  /**
8090
8229
  * Returns the normalized default cell properties.
8091
8230
  *
8231
+ * @internal
8092
8232
  * @param config The configuration to normalize.
8093
8233
  * @param options Options used to determine which properties should be added.
8094
8234
  */ function getNormalizedDefaultCellProperties(config, options) {
@@ -8626,6 +8766,8 @@ const propertyToCommandMap$1 = {
8626
8766
  enableProperty$1(editor.model.schema, editor.conversion, {
8627
8767
  modelAttribute: 'tableCellWidth',
8628
8768
  styleName: 'width',
8769
+ attributeName: 'width',
8770
+ attributeType: 'length',
8629
8771
  defaultValue: defaultTableCellProperties.width
8630
8772
  });
8631
8773
  editor.commands.add('tableCellWidth', new TableCellWidthCommand(editor, defaultTableCellProperties.width));
@@ -8989,7 +9131,7 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
8989
9131
  includePaddingProperty: true,
8990
9132
  isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
8991
9133
  });
8992
- editor.data.addStyleProcessorRules(addBorderRules);
9134
+ editor.data.addStyleProcessorRules(addBorderStylesRules);
8993
9135
  enableBorderProperties$1(schema, conversion, {
8994
9136
  color: defaultTableCellProperties.borderColor,
8995
9137
  style: defaultTableCellProperties.borderStyle,
@@ -9001,10 +9143,12 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9001
9143
  enableProperty$1(schema, conversion, {
9002
9144
  modelAttribute: 'tableCellHeight',
9003
9145
  styleName: 'height',
9146
+ attributeName: 'height',
9147
+ attributeType: 'length',
9004
9148
  defaultValue: defaultTableCellProperties.height
9005
9149
  });
9006
9150
  editor.commands.add('tableCellHeight', new TableCellHeightCommand(editor, defaultTableCellProperties.height));
9007
- editor.data.addStyleProcessorRules(addPaddingRules);
9151
+ editor.data.addStyleProcessorRules(addPaddingStylesRules);
9008
9152
  enableProperty$1(schema, conversion, {
9009
9153
  modelAttribute: 'tableCellPadding',
9010
9154
  styleName: 'padding',
@@ -9012,10 +9156,12 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9012
9156
  defaultValue: defaultTableCellProperties.padding
9013
9157
  });
9014
9158
  editor.commands.add('tableCellPadding', new TableCellPaddingCommand(editor, defaultTableCellProperties.padding));
9015
- editor.data.addStyleProcessorRules(addBackgroundRules);
9159
+ editor.data.addStyleProcessorRules(addBackgroundStylesRules);
9016
9160
  enableProperty$1(schema, conversion, {
9017
9161
  modelAttribute: 'tableCellBackgroundColor',
9018
9162
  styleName: 'background-color',
9163
+ attributeName: 'bgcolor',
9164
+ attributeType: 'color',
9019
9165
  defaultValue: defaultTableCellProperties.backgroundColor
9020
9166
  });
9021
9167
  editor.commands.add('tableCellBackgroundColor', new TableCellBackgroundColorCommand(editor, defaultTableCellProperties.backgroundColor));
@@ -9041,6 +9187,11 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9041
9187
  schema.extend('tableCell', {
9042
9188
  allowAttributes: Object.values(modelAttributes)
9043
9189
  });
9190
+ for (const modelAttribute of Object.values(modelAttributes)){
9191
+ schema.setAttributeProperties(modelAttribute, {
9192
+ isFormatting: true
9193
+ });
9194
+ }
9044
9195
  upcastBorderStyles(conversion, 'td', modelAttributes, defaultBorder);
9045
9196
  upcastBorderStyles(conversion, 'th', modelAttributes, defaultBorder);
9046
9197
  downcastAttributeToStyle(conversion, {
@@ -9069,6 +9220,9 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9069
9220
  'tableCellHorizontalAlignment'
9070
9221
  ]
9071
9222
  });
9223
+ schema.setAttributeProperties('tableCellHorizontalAlignment', {
9224
+ isFormatting: true
9225
+ });
9072
9226
  conversion.for('downcast').attributeToAttribute({
9073
9227
  model: {
9074
9228
  name: 'tableCell',
@@ -9094,7 +9248,13 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9094
9248
  value: (viewElement, conversionApi, data)=>{
9095
9249
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
9096
9250
  const align = viewElement.getStyle('text-align');
9097
- return align === localDefaultValue ? null : align;
9251
+ if (align !== localDefaultValue) {
9252
+ return align;
9253
+ }
9254
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
9255
+ conversionApi.consumable.consume(viewElement, {
9256
+ styles: 'text-align'
9257
+ });
9098
9258
  }
9099
9259
  }
9100
9260
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
@@ -9110,7 +9270,13 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9110
9270
  value: (viewElement, conversionApi, data)=>{
9111
9271
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
9112
9272
  const align = viewElement.getAttribute('align');
9113
- return align === localDefaultValue ? null : align;
9273
+ if (align !== localDefaultValue) {
9274
+ return align;
9275
+ }
9276
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
9277
+ conversionApi.consumable.consume(viewElement, {
9278
+ attributes: 'align'
9279
+ });
9114
9280
  }
9115
9281
  }
9116
9282
  });
@@ -9125,6 +9291,9 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9125
9291
  'tableCellVerticalAlignment'
9126
9292
  ]
9127
9293
  });
9294
+ schema.setAttributeProperties('tableCellVerticalAlignment', {
9295
+ isFormatting: true
9296
+ });
9128
9297
  conversion.for('downcast').attributeToAttribute({
9129
9298
  model: {
9130
9299
  name: 'tableCell',
@@ -9150,7 +9319,13 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9150
9319
  value: (viewElement, conversionApi, data)=>{
9151
9320
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
9152
9321
  const align = viewElement.getStyle('vertical-align');
9153
- return align === localDefaultValue ? null : align;
9322
+ if (align !== localDefaultValue) {
9323
+ return align;
9324
+ }
9325
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
9326
+ conversionApi.consumable.consume(viewElement, {
9327
+ styles: 'vertical-align'
9328
+ });
9154
9329
  }
9155
9330
  }
9156
9331
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
@@ -9166,7 +9341,13 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9166
9341
  value: (viewElement, conversionApi, data)=>{
9167
9342
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
9168
9343
  const valign = viewElement.getAttribute('valign');
9169
- return valign === localDefaultValue ? null : valign;
9344
+ if (valign !== localDefaultValue) {
9345
+ return valign;
9346
+ }
9347
+ // Consume the attribute even if not applied to the element so it won't be processed by other converters.
9348
+ conversionApi.consumable.consume(viewElement, {
9349
+ attributes: 'valign'
9350
+ });
9170
9351
  }
9171
9352
  }
9172
9353
  });
@@ -9358,7 +9539,7 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9358
9539
  * @param label The localized label for the dropdown item.
9359
9540
  * @returns The dropdown item definition.
9360
9541
  */ function createTableTypeDropdownItem(tableTypeCommand, type, label) {
9361
- const model = new ViewModel({
9542
+ const model = new UIModel({
9362
9543
  label,
9363
9544
  role: 'menuitemradio',
9364
9545
  withText: true,
@@ -9489,6 +9670,8 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9489
9670
  /**
9490
9671
  * Returns a upcast helper that ensures the number of `<tableColumn>` elements corresponds to the actual number of columns in the table,
9491
9672
  * because the input data might have too few or too many <col> elements.
9673
+ *
9674
+ * @internal
9492
9675
  */ function upcastColgroupElement(tableUtilsPlugin) {
9493
9676
  return (dispatcher)=>dispatcher.on('element:colgroup', (evt, data, conversionApi)=>{
9494
9677
  const modelTable = data.modelCursor.findAncestor('table');
@@ -9512,6 +9695,8 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9512
9695
  }
9513
9696
  /**
9514
9697
  * Returns downcast helper for adding `ck-table-resized` class if there is a `<tableColumnGroup>` element inside the table.
9698
+ *
9699
+ * @internal
9515
9700
  */ function downcastTableResizedClass() {
9516
9701
  return (dispatcher)=>dispatcher.on('insert:table', (evt, data, conversionApi)=>{
9517
9702
  const viewWriter = conversionApi.writer;
@@ -9528,6 +9713,19 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9528
9713
  priority: 'low'
9529
9714
  });
9530
9715
  }
9716
+ /**
9717
+ * Returns a upcast helper that removes the `ck-table-resized` class from the table element.
9718
+ *
9719
+ * @internal
9720
+ */ function upcastTableResizedClass() {
9721
+ return (dispatcher)=>{
9722
+ dispatcher.on('element:table', (evt, data, conversionApi)=>{
9723
+ conversionApi.consumable.consume(data.viewItem, {
9724
+ classes: 'ck-table-resized'
9725
+ });
9726
+ });
9727
+ };
9728
+ }
9531
9729
 
9532
9730
  const toPx = /* #__PURE__ */ toUnit('px');
9533
9731
  /**
@@ -9644,16 +9842,17 @@ const toPx = /* #__PURE__ */ toUnit('px');
9644
9842
  /**
9645
9843
  * Registers new attributes for a table model element.
9646
9844
  */ _extendSchema() {
9647
- this.editor.model.schema.extend('table', {
9845
+ const schema = this.editor.model.schema;
9846
+ schema.extend('table', {
9648
9847
  allowAttributes: [
9649
9848
  'tableWidth'
9650
9849
  ]
9651
9850
  });
9652
- this.editor.model.schema.register('tableColumnGroup', {
9851
+ schema.register('tableColumnGroup', {
9653
9852
  allowIn: 'table',
9654
9853
  isLimit: true
9655
9854
  });
9656
- this.editor.model.schema.register('tableColumn', {
9855
+ schema.register('tableColumn', {
9657
9856
  allowIn: 'tableColumnGroup',
9658
9857
  allowAttributes: [
9659
9858
  'columnWidth',
@@ -9661,6 +9860,9 @@ const toPx = /* #__PURE__ */ toUnit('px');
9661
9860
  ],
9662
9861
  isLimit: true
9663
9862
  });
9863
+ schema.setAttributeProperties('columnWidth', {
9864
+ isFormatting: true
9865
+ });
9664
9866
  }
9665
9867
  /**
9666
9868
  * Registers table column resize post-fixer.
@@ -9757,7 +9959,6 @@ const toPx = /* #__PURE__ */ toUnit('px');
9757
9959
  }
9758
9960
  },
9759
9961
  model: {
9760
- name: 'table',
9761
9962
  key: 'tableWidth',
9762
9963
  value: (viewElement)=>{
9763
9964
  const parent = viewElement.parent;
@@ -9790,6 +9991,7 @@ const toPx = /* #__PURE__ */ toUnit('px');
9790
9991
  view: 'col'
9791
9992
  });
9792
9993
  conversion.for('downcast').add(downcastTableResizedClass());
9994
+ conversion.for('upcast').add(upcastTableResizedClass());
9793
9995
  conversion.for('upcast').add(upcastColgroupElement(this._tableUtilsPlugin));
9794
9996
  conversion.for('upcast').attributeToAttribute({
9795
9997
  view: {
@@ -11002,7 +11204,7 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11002
11204
  const defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {
11003
11205
  includeAlignmentProperty: true
11004
11206
  });
11005
- editor.data.addStyleProcessorRules(addBorderRules);
11207
+ editor.data.addStyleProcessorRules(addBorderStylesRules);
11006
11208
  enableBorderProperties(schema, conversion, {
11007
11209
  color: defaultTableProperties.borderColor,
11008
11210
  style: defaultTableProperties.borderStyle,
@@ -11016,19 +11218,25 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11016
11218
  enableTableToFigureProperty(schema, conversion, {
11017
11219
  modelAttribute: 'tableWidth',
11018
11220
  styleName: 'width',
11221
+ attributeName: 'width',
11222
+ attributeType: 'length',
11019
11223
  defaultValue: defaultTableProperties.width
11020
11224
  });
11021
11225
  editor.commands.add('tableWidth', new TableWidthCommand(editor, defaultTableProperties.width));
11022
11226
  enableTableToFigureProperty(schema, conversion, {
11023
11227
  modelAttribute: 'tableHeight',
11024
11228
  styleName: 'height',
11229
+ attributeName: 'height',
11230
+ attributeType: 'length',
11025
11231
  defaultValue: defaultTableProperties.height
11026
11232
  });
11027
11233
  editor.commands.add('tableHeight', new TableHeightCommand(editor, defaultTableProperties.height));
11028
- editor.data.addStyleProcessorRules(addBackgroundRules);
11234
+ editor.data.addStyleProcessorRules(addBackgroundStylesRules);
11029
11235
  enableProperty(schema, conversion, {
11030
11236
  modelAttribute: 'tableBackgroundColor',
11031
11237
  styleName: 'background-color',
11238
+ attributeName: 'bgcolor',
11239
+ attributeType: 'color',
11032
11240
  defaultValue: defaultTableProperties.backgroundColor
11033
11241
  });
11034
11242
  editor.commands.add('tableBackgroundColor', new TableBackgroundColorCommand(editor, defaultTableProperties.backgroundColor));
@@ -11050,6 +11258,11 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11050
11258
  schema.extend('table', {
11051
11259
  allowAttributes: Object.values(modelAttributes)
11052
11260
  });
11261
+ for (const modelAttribute of Object.values(modelAttributes)){
11262
+ schema.setAttributeProperties(modelAttribute, {
11263
+ isFormatting: true
11264
+ });
11265
+ }
11053
11266
  upcastBorderStyles(conversion, 'table', modelAttributes, defaultBorder);
11054
11267
  downcastTableAttribute(conversion, {
11055
11268
  modelAttribute: modelAttributes.color,
@@ -11074,6 +11287,9 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11074
11287
  'tableAlignment'
11075
11288
  ]
11076
11289
  });
11290
+ schema.setAttributeProperties('tableAlignment', {
11291
+ isFormatting: true
11292
+ });
11077
11293
  conversion.for('downcast').attributeToAttribute({
11078
11294
  model: {
11079
11295
  name: 'table',
@@ -11124,13 +11340,23 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11124
11340
  model: {
11125
11341
  key: 'tableAlignment',
11126
11342
  value: (viewElement, conversionApi, data)=>{
11343
+ // Ignore other figure elements.
11344
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
11345
+ return;
11346
+ }
11127
11347
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
11128
11348
  let align = viewElement.getStyle('float');
11129
11349
  // CSS: `float:none` => Model: `alignment:center`.
11130
11350
  if (align === 'none') {
11131
11351
  align = 'center';
11132
11352
  }
11133
- return align === localDefaultValue ? null : align;
11353
+ if (align !== localDefaultValue) {
11354
+ return align;
11355
+ }
11356
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
11357
+ conversionApi.consumable.consume(viewElement, {
11358
+ styles: 'float'
11359
+ });
11134
11360
  }
11135
11361
  }
11136
11362
  })// Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.
@@ -11145,25 +11371,44 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11145
11371
  model: {
11146
11372
  key: 'tableAlignment',
11147
11373
  value: (viewElement, conversionApi, data)=>{
11374
+ // Ignore other figure elements.
11375
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
11376
+ return;
11377
+ }
11148
11378
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
11149
11379
  const align = 'center';
11150
- return align === localDefaultValue ? null : align;
11380
+ if (align !== localDefaultValue) {
11381
+ return align;
11382
+ }
11383
+ // Consume the styles even if not applied to the element so it won't be processed by other converters.
11384
+ conversionApi.consumable.consume(viewElement, {
11385
+ styles: [
11386
+ 'margin-left',
11387
+ 'margin-right'
11388
+ ]
11389
+ });
11151
11390
  }
11152
11391
  }
11153
11392
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
11154
11393
  .attributeToAttribute({
11155
11394
  view: {
11395
+ name: 'table',
11156
11396
  attributes: {
11157
11397
  align: ALIGN_VALUES_REG_EXP
11158
11398
  }
11159
11399
  },
11160
11400
  model: {
11161
- name: 'table',
11162
11401
  key: 'tableAlignment',
11163
11402
  value: (viewElement, conversionApi, data)=>{
11164
11403
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
11165
11404
  const align = viewElement.getAttribute('align');
11166
- return align === localDefaultValue ? null : align;
11405
+ if (align !== localDefaultValue) {
11406
+ return align;
11407
+ }
11408
+ // Consume the attribute even if not applied to the element so it won't be processed by other converters.
11409
+ conversionApi.consumable.consume(viewElement, {
11410
+ attributes: 'align'
11411
+ });
11167
11412
  }
11168
11413
  }
11169
11414
  });
@@ -11179,6 +11424,9 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11179
11424
  modelAttribute
11180
11425
  ]
11181
11426
  });
11427
+ schema.setAttributeProperties(modelAttribute, {
11428
+ isFormatting: true
11429
+ });
11182
11430
  upcastStyleToAttribute(conversion, {
11183
11431
  viewElement: 'table',
11184
11432
  ...options
@@ -11194,9 +11442,11 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
11194
11442
  modelAttribute
11195
11443
  ]
11196
11444
  });
11445
+ schema.setAttributeProperties(modelAttribute, {
11446
+ isFormatting: true
11447
+ });
11197
11448
  upcastStyleToAttribute(conversion, {
11198
11449
  viewElement: /^(table|figure)$/,
11199
- shouldUpcast: (element)=>!(element.name == 'table' && element.parent.name == 'figure'),
11200
11450
  ...options
11201
11451
  });
11202
11452
  downcastAttributeToStyle(conversion, {
@@ -12075,6 +12325,8 @@ const propertyToCommandMap = {
12075
12325
  *
12076
12326
  * * If there are many caption model element, they are merged into one model.
12077
12327
  * * A final, merged caption model is placed at the end of the table.
12328
+ *
12329
+ * @internal
12078
12330
  */ function injectTableCaptionPostFixer(model) {
12079
12331
  model.document.registerPostFixer((writer)=>tableCaptionPostFixer(writer, model));
12080
12332
  }
@@ -12116,6 +12368,7 @@ const propertyToCommandMap = {
12116
12368
  * Checks if the provided model element is a `table`.
12117
12369
  *
12118
12370
  * @param modelElement Element to check if it is a table.
12371
+ * @internal
12119
12372
  */ function isTable(modelElement) {
12120
12373
  return !!modelElement && modelElement.is('element', 'table');
12121
12374
  }
@@ -12123,6 +12376,7 @@ const propertyToCommandMap = {
12123
12376
  * Returns the caption model element from a given table element. Returns `null` if no caption is found.
12124
12377
  *
12125
12378
  * @param tableModelElement Table element in which we will try to find a caption element.
12379
+ * @internal
12126
12380
  */ function getCaptionFromTableModelElement(tableModelElement) {
12127
12381
  for (const node of tableModelElement.getChildren()){
12128
12382
  if (node.is('element', 'caption')) {
@@ -12135,6 +12389,7 @@ const propertyToCommandMap = {
12135
12389
  * Returns the caption model element for a model selection. Returns `null` if the selection has no caption element ancestor.
12136
12390
  *
12137
12391
  * @param selection The selection checked for caption presence.
12392
+ * @internal
12138
12393
  */ function getCaptionFromModelSelection(selection) {
12139
12394
  const tableElement = getSelectionAffectedTable(selection);
12140
12395
  if (!tableElement) {
@@ -12150,6 +12405,7 @@ const propertyToCommandMap = {
12150
12405
  * - A `<caption>` inside a <table>.
12151
12406
  *
12152
12407
  * @returns Returns the object accepted by {@link module:engine/view/matcher~Matcher} or `null` if the element cannot be matched.
12408
+ * @internal
12153
12409
  */ function matchTableCaptionViewElement(element) {
12154
12410
  const parent = element.parent;
12155
12411
  if (element.name == 'figcaption' && parent && parent.is('element', 'figure') && parent.hasClass('table')) {
@@ -12323,7 +12579,7 @@ const propertyToCommandMap = {
12323
12579
  const figcaptionElement = writer.createEditableElement('figcaption');
12324
12580
  writer.setCustomProperty('tableCaption', true, figcaptionElement);
12325
12581
  figcaptionElement.placeholder = t('Enter table caption');
12326
- enablePlaceholder({
12582
+ enableViewPlaceholder({
12327
12583
  view,
12328
12584
  element: figcaptionElement,
12329
12585
  keepOnFocus: true
@@ -12334,7 +12590,7 @@ const propertyToCommandMap = {
12334
12590
  injectTableCaptionPostFixer(editor.model);
12335
12591
  }
12336
12592
  /**
12337
- * Returns the saved {@link module:engine/model/element~Element#toJSON JSONified} caption
12593
+ * Returns the saved {@link module:engine/model/element~ModelElement#toJSON JSONified} caption
12338
12594
  * of a table model element.
12339
12595
  *
12340
12596
  * See {@link #_saveCaption}.
@@ -12344,10 +12600,10 @@ const propertyToCommandMap = {
12344
12600
  * @returns The model caption element or `null` if there is none.
12345
12601
  */ _getSavedCaption(tableModelElement) {
12346
12602
  const jsonObject = this._savedCaptionsMap.get(tableModelElement);
12347
- return jsonObject ? Element.fromJSON(jsonObject) : null;
12603
+ return jsonObject ? ModelElement.fromJSON(jsonObject) : null;
12348
12604
  }
12349
12605
  /**
12350
- * Saves a {@link module:engine/model/element~Element#toJSON JSONified} caption for
12606
+ * Saves a {@link module:engine/model/element~ModelElement#toJSON JSONified} caption for
12351
12607
  * a table element to allow restoring it in the future.
12352
12608
  *
12353
12609
  * A caption is saved every time it gets hidden. The
@@ -12443,5 +12699,5 @@ const propertyToCommandMap = {
12443
12699
  }
12444
12700
  }
12445
12701
 
12446
- export { PlainTableOutput, Table, TableCaption, TableCaptionEditing, TableCaptionUI, TableCellProperties, TableCellPropertiesEditing, TableCellPropertiesUI, TableCellWidthEditing, TableClipboard, TableColumnResize, TableColumnResizeEditing, TableEditing, TableKeyboard, TableLayout, TableLayoutEditing, TableMouse, TableProperties, TablePropertiesEditing, TablePropertiesUI, TableSelection, TableToolbar, TableUI, TableUtils };
12702
+ export { InsertColumnCommand, InsertRowCommand, InsertTableCommand, InsertTableLayoutCommand, MergeCellCommand, MergeCellsCommand, PlainTableOutput, RemoveColumnCommand, RemoveRowCommand, SelectColumnCommand, SelectRowCommand, SetHeaderColumnCommand, SetHeaderRowCommand, SplitCellCommand, Table, TableAlignmentCommand, TableBackgroundColorCommand, TableBorderColorCommand, TableBorderStyleCommand, TableBorderWidthCommand, TableCaption, TableCaptionEditing, TableCaptionUI, TableCellBackgroundColorCommand, TableCellBorderColorCommand, TableCellBorderStyleCommand, TableCellBorderWidthCommand, TableCellHeightCommand, TableCellHorizontalAlignmentCommand, TableCellPaddingCommand, TableCellProperties, TableCellPropertiesEditing, TableCellPropertiesUI, TableCellPropertiesView, TableCellPropertyCommand, TableCellVerticalAlignmentCommand, TableCellWidthCommand, TableCellWidthEditing, TableClipboard, TableColumnResize, TableColumnResizeEditing, TableEditing, TableHeightCommand, TableKeyboard, TableLayout, TableLayoutEditing, TableLayoutUI, TableMouse, TableProperties, TablePropertiesEditing, TablePropertiesUI, TablePropertiesView, TablePropertyCommand, TableSelection, TableToolbar, TableTypeCommand, TableUI, TableUtils, TableWalker, TableWidthCommand, TableWidthsCommand, ToggleTableCaptionCommand, InsertTableView as _InsertTableView, COLUMN_MIN_WIDTH_AS_PERCENTAGE as _TABLE_COLUMN_MIN_WIDTH_AS_PERCENTAGE, COLUMN_MIN_WIDTH_IN_PIXELS as _TABLE_COLUMN_MIN_WIDTH_IN_PIXELS, COLUMN_RESIZE_DISTANCE_THRESHOLD as _TABLE_COLUMN_RESIZE_DISTANCE_THRESHOLD, COLUMN_WIDTH_PRECISION as _TABLE_COLUMN_WIDTH_PRECISION, defaultColors as _TABLE_DEFAULT_COLORS, ColorInputView as _TableColorInputView, MouseEventsObserver as _TableMouseEventsObserver, addDefaultUnitToNumericValue as _addDefaultUnitToNumericValue, adjustLastColumnIndex as _adjustLastTableColumnIndex, adjustLastRowIndex as _adjustLastTableRowIndex, clamp as _clamp, colorFieldValidator as _colorTableFieldValidator, convertParagraphInTableCell as _convertParagraphInTableCell, createEmptyTableCell as _createEmptyTableCell, createFilledArray as _createFilledArray, cropTableToDimensions as _cropTableToDimensions, downcastTable as _downcastTable, downcastTableAttribute as _downcastTableAttribute, downcastAttributeToStyle as _downcastTableAttributeToStyle, downcastCell as _downcastTableCell, downcastTableResizedClass as _downcastTableResizedClass, downcastRow as _downcastTableRow, enableProperty$1 as _enableTableCellProperty, ensureParagraphInTableCell as _ensureParagraphInTableCell, fillToolbar as _fillTableOrCellToolbar, getBalloonCellPositionData as _getBalloonTableCellPositionData, getBalloonTablePositionData as _getBalloonTablePositionData, getBorderStyleLabels as _getBorderTableStyleLabels, getChangedResizedTables as _getChangedResizedTables, getDefaultValueAdjusted as _getDefaultTableValueAdjusted, getDomCellOuterWidth as _getDomTableCellOuterWidth, getElementWidthInPixels as _getElementWidthInPixels, getHorizontallyOverlappingCells as _getHorizontallyOverlappingTableCells, getLabeledColorInputCreator as _getLabeledTableColorInputCreator, getLocalizedColorErrorText as _getLocalizedTableColorErrorText, getLocalizedLengthErrorText as _getLocalizedTableLengthErrorText, getNormalizedDefaultProperties as _getNormalizedDefaultTableBaseProperties, getNormalizedDefaultCellProperties as _getNormalizedDefaultTableCellProperties, getNormalizedDefaultTableProperties as _getNormalizedDefaultTableProperties, getSelectedTableWidget as _getSelectedTableWidget, getSelectionAffectedTable as _getSelectionAffectedTable, getSelectionAffectedTableWidget as _getSelectionAffectedTableWidget, getSingleValue as _getTableBorderBoxSingleValue, getCaptionFromTableModelElement as _getTableCaptionFromModelElement, getCaptionFromModelSelection as _getTableCaptionFromModelSelection, getColumnEdgesIndexes as _getTableColumnEdgesIndexes, getTableColumnElements as _getTableColumnElements, getColumnGroupElement as _getTableColumnGroupElement, getColumnMinWidthAsPercentage as _getTableColumnMinWidthAsPercentage, getTableColumnsWidths as _getTableColumnsWidths, getBorderStyleDefinitions as _getTableOrCellBorderStyleDefinitions, getTableWidgetAncestor as _getTableWidgetAncestor, getTableWidthInPixels as _getTableWidthInPixels, getVerticallyOverlappingCells as _getVerticallyOverlappingTableCells, injectTableCaptionPostFixer as _injectTableCaptionPostFixer, injectTableCellParagraphPostFixer as _injectTableCellParagraphPostFixer, injectTableLayoutPostFixer as _injectTableLayoutPostFixer, isSingleParagraphWithoutAttributes as _isSingleTableParagraphWithoutAttributes, isHeadingColumnCell as _isTableHeadingColumnCell, isTable as _isTableModelElement, lengthFieldValidator as _lengthTableFieldValidator, lineWidthFieldValidator as _lineWidthTableFieldValidator, matchTableCaptionViewElement as _matchTableCaptionViewElement, normalizeColumnWidths as _normalizeTableColumnWidths, removeEmptyColumns as _removeEmptyTableColumns, removeEmptyRows as _removeEmptyTableRows, removeEmptyRowsColumns as _removeEmptyTableRowsColumns, repositionContextualBalloon as _repositionTableContextualBalloon, skipEmptyTableRow as _skipEmptyTableRow, splitHorizontally as _splitTableCellHorizontally, splitVertically as _splitTableCellVertically, sumArray as _sumArray, tableCellRefreshHandler as _tableCellRefreshHandler, tableHeadingsRefreshHandler as _tableHeadingsRefreshHandler, toPrecision as _toPrecision, translateColSpanAttribute as _translateTableColspanAttribute, trimTableCellIfNeeded as _trimTableCellIfNeeded, upcastStyleToAttribute as _upcastNormalizedTableStyleToAttribute, upcastTable as _upcastTable, upcastBorderStyles as _upcastTableBorderStyles, upcastColgroupElement as _upcastTableColgroupElement, upcastTableFigure as _upcastTableFigure, updateColumnElements as _updateTableColumnElements, updateNumericAttribute as _updateTableNumericAttribute };
12447
12703
  //# sourceMappingURL=index.js.map