@ckeditor/ckeditor5-table 45.0.0-alpha.0 → 45.0.0-alpha.10

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 (182) hide show
  1. package/build/table.js +1 -1
  2. package/build/translations/ar.js +1 -1
  3. package/build/translations/bg.js +1 -1
  4. package/build/translations/bn.js +1 -1
  5. package/build/translations/ca.js +1 -1
  6. package/build/translations/cs.js +1 -1
  7. package/build/translations/da.js +1 -1
  8. package/build/translations/de.js +1 -1
  9. package/build/translations/el.js +1 -1
  10. package/build/translations/es.js +1 -1
  11. package/build/translations/et.js +1 -1
  12. package/build/translations/fi.js +1 -1
  13. package/build/translations/fr.js +1 -1
  14. package/build/translations/he.js +1 -1
  15. package/build/translations/hi.js +1 -1
  16. package/build/translations/hu.js +1 -1
  17. package/build/translations/id.js +1 -1
  18. package/build/translations/it.js +1 -1
  19. package/build/translations/ja.js +1 -1
  20. package/build/translations/ko.js +1 -1
  21. package/build/translations/lt.js +1 -1
  22. package/build/translations/lv.js +1 -1
  23. package/build/translations/ms.js +1 -1
  24. package/build/translations/nl.js +1 -1
  25. package/build/translations/no.js +1 -1
  26. package/build/translations/pl.js +1 -1
  27. package/build/translations/pt-br.js +1 -1
  28. package/build/translations/pt.js +1 -1
  29. package/build/translations/ro.js +1 -1
  30. package/build/translations/ru.js +1 -1
  31. package/build/translations/sk.js +1 -1
  32. package/build/translations/sr.js +1 -1
  33. package/build/translations/sv.js +1 -1
  34. package/build/translations/th.js +1 -1
  35. package/build/translations/tr.js +1 -1
  36. package/build/translations/uk.js +1 -1
  37. package/build/translations/vi.js +1 -1
  38. package/build/translations/zh-cn.js +1 -1
  39. package/build/translations/zh.js +1 -1
  40. package/ckeditor5-metadata.json +2 -2
  41. package/dist/index-content.css +0 -4
  42. package/dist/index-editor.css +9 -3
  43. package/dist/index.css +13 -11
  44. package/dist/index.css.map +1 -1
  45. package/dist/index.js +278 -50
  46. package/dist/index.js.map +1 -1
  47. package/dist/translations/ar.js +1 -1
  48. package/dist/translations/ar.umd.js +1 -1
  49. package/dist/translations/bg.js +1 -1
  50. package/dist/translations/bg.umd.js +1 -1
  51. package/dist/translations/bn.js +1 -1
  52. package/dist/translations/bn.umd.js +1 -1
  53. package/dist/translations/ca.js +1 -1
  54. package/dist/translations/ca.umd.js +1 -1
  55. package/dist/translations/cs.js +1 -1
  56. package/dist/translations/cs.umd.js +1 -1
  57. package/dist/translations/da.js +1 -1
  58. package/dist/translations/da.umd.js +1 -1
  59. package/dist/translations/de.js +1 -1
  60. package/dist/translations/de.umd.js +1 -1
  61. package/dist/translations/el.js +1 -1
  62. package/dist/translations/el.umd.js +1 -1
  63. package/dist/translations/es.js +1 -1
  64. package/dist/translations/es.umd.js +1 -1
  65. package/dist/translations/et.js +1 -1
  66. package/dist/translations/et.umd.js +1 -1
  67. package/dist/translations/fi.js +1 -1
  68. package/dist/translations/fi.umd.js +1 -1
  69. package/dist/translations/fr.js +1 -1
  70. package/dist/translations/fr.umd.js +1 -1
  71. package/dist/translations/he.js +1 -1
  72. package/dist/translations/he.umd.js +1 -1
  73. package/dist/translations/hi.js +1 -1
  74. package/dist/translations/hi.umd.js +1 -1
  75. package/dist/translations/hu.js +1 -1
  76. package/dist/translations/hu.umd.js +1 -1
  77. package/dist/translations/id.js +1 -1
  78. package/dist/translations/id.umd.js +1 -1
  79. package/dist/translations/it.js +1 -1
  80. package/dist/translations/it.umd.js +1 -1
  81. package/dist/translations/ja.js +1 -1
  82. package/dist/translations/ja.umd.js +1 -1
  83. package/dist/translations/ko.js +1 -1
  84. package/dist/translations/ko.umd.js +1 -1
  85. package/dist/translations/lt.js +1 -1
  86. package/dist/translations/lt.umd.js +1 -1
  87. package/dist/translations/lv.js +1 -1
  88. package/dist/translations/lv.umd.js +1 -1
  89. package/dist/translations/ms.js +1 -1
  90. package/dist/translations/ms.umd.js +1 -1
  91. package/dist/translations/nl.js +1 -1
  92. package/dist/translations/nl.umd.js +1 -1
  93. package/dist/translations/no.js +1 -1
  94. package/dist/translations/no.umd.js +1 -1
  95. package/dist/translations/pl.js +1 -1
  96. package/dist/translations/pl.umd.js +1 -1
  97. package/dist/translations/pt-br.js +1 -1
  98. package/dist/translations/pt-br.umd.js +1 -1
  99. package/dist/translations/pt.js +1 -1
  100. package/dist/translations/pt.umd.js +1 -1
  101. package/dist/translations/ro.js +1 -1
  102. package/dist/translations/ro.umd.js +1 -1
  103. package/dist/translations/ru.js +1 -1
  104. package/dist/translations/ru.umd.js +1 -1
  105. package/dist/translations/sk.js +1 -1
  106. package/dist/translations/sk.umd.js +1 -1
  107. package/dist/translations/sr.js +1 -1
  108. package/dist/translations/sr.umd.js +1 -1
  109. package/dist/translations/sv.js +1 -1
  110. package/dist/translations/sv.umd.js +1 -1
  111. package/dist/translations/th.js +1 -1
  112. package/dist/translations/th.umd.js +1 -1
  113. package/dist/translations/tr.js +1 -1
  114. package/dist/translations/tr.umd.js +1 -1
  115. package/dist/translations/uk.js +1 -1
  116. package/dist/translations/uk.umd.js +1 -1
  117. package/dist/translations/vi.js +1 -1
  118. package/dist/translations/vi.umd.js +1 -1
  119. package/dist/translations/zh-cn.js +1 -1
  120. package/dist/translations/zh-cn.umd.js +1 -1
  121. package/dist/translations/zh.js +1 -1
  122. package/dist/translations/zh.umd.js +1 -1
  123. package/lang/translations/ar.po +7 -7
  124. package/lang/translations/bg.po +7 -7
  125. package/lang/translations/bn.po +7 -7
  126. package/lang/translations/ca.po +7 -7
  127. package/lang/translations/cs.po +7 -7
  128. package/lang/translations/da.po +7 -7
  129. package/lang/translations/de.po +7 -7
  130. package/lang/translations/el.po +7 -7
  131. package/lang/translations/es.po +7 -7
  132. package/lang/translations/et.po +7 -7
  133. package/lang/translations/fi.po +7 -7
  134. package/lang/translations/fr.po +7 -7
  135. package/lang/translations/he.po +7 -7
  136. package/lang/translations/hi.po +7 -7
  137. package/lang/translations/hu.po +7 -7
  138. package/lang/translations/id.po +7 -7
  139. package/lang/translations/it.po +7 -7
  140. package/lang/translations/ja.po +7 -7
  141. package/lang/translations/ko.po +7 -7
  142. package/lang/translations/lt.po +7 -7
  143. package/lang/translations/lv.po +7 -7
  144. package/lang/translations/ms.po +7 -7
  145. package/lang/translations/nl.po +7 -7
  146. package/lang/translations/no.po +7 -7
  147. package/lang/translations/pl.po +7 -7
  148. package/lang/translations/pt-br.po +7 -7
  149. package/lang/translations/pt.po +7 -7
  150. package/lang/translations/ro.po +7 -7
  151. package/lang/translations/ru.po +7 -7
  152. package/lang/translations/sk.po +7 -7
  153. package/lang/translations/sr.po +7 -7
  154. package/lang/translations/sv.po +7 -7
  155. package/lang/translations/th.po +7 -7
  156. package/lang/translations/tr.po +7 -7
  157. package/lang/translations/uk.po +7 -7
  158. package/lang/translations/vi.po +7 -7
  159. package/lang/translations/zh-cn.po +7 -7
  160. package/lang/translations/zh.po +7 -7
  161. package/package.json +9 -9
  162. package/src/converters/tableproperties.d.ts +5 -1
  163. package/src/converters/tableproperties.js +27 -5
  164. package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +11 -1
  165. package/src/tablecellproperties/commands/tablecellpropertycommand.js +32 -2
  166. package/src/tablecellproperties/tablecellpropertiesediting.js +13 -9
  167. package/src/tablecellproperties/tablecellpropertiesui.d.ts +13 -1
  168. package/src/tablecellproperties/tablecellpropertiesui.js +36 -9
  169. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +28 -0
  170. package/src/tablecolumnresize/tablecolumnresizeediting.js +81 -2
  171. package/src/tablelayout.d.ts +1 -1
  172. package/src/tablelayout.js +1 -1
  173. package/src/tableproperties/commands/tablepropertycommand.d.ts +11 -1
  174. package/src/tableproperties/commands/tablepropertycommand.js +15 -1
  175. package/src/tableproperties/tablepropertiesediting.js +53 -12
  176. package/src/tableproperties/tablepropertiesui.d.ts +13 -1
  177. package/src/tableproperties/tablepropertiesui.js +30 -8
  178. package/src/tableproperties/ui/tablepropertiesview.d.ts +2 -2
  179. package/src/utils/table-properties.d.ts +3 -3
  180. package/src/utils/ui/table-properties.js +7 -1
  181. package/theme/tablecolumnresize.css +0 -10
  182. package/theme/tablelayout.css +13 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  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
- import { first, global, CKEditorError, KeystrokeHandler, FocusTracker, Collection, getLocalizedArrowKeyCodeDirection, Rect, DomEmitterMixin } from '@ckeditor/ckeditor5-utils/dist/index.js';
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
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';
10
10
  import { ClipboardMarkersUtils, ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
@@ -12,11 +12,6 @@ import { DomEventObserver, isColor, isLength, isPercentage, addBorderRules, addP
12
12
  import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
13
13
 
14
14
  /**
15
- * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
16
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
17
- */ /**
18
- * @module table/converters/tableproperties
19
- */ /**
20
15
  * Conversion helper for upcasting attributes using normalized styles.
21
16
  *
22
17
  * @param options.modelAttribute The attribute to set.
@@ -35,13 +30,14 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
35
30
  },
36
31
  model: {
37
32
  key: modelAttribute,
38
- value: (viewElement)=>{
33
+ value: (viewElement, conversionApi, data)=>{
39
34
  if (!shouldUpcast(viewElement)) {
40
35
  return;
41
36
  }
37
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
42
38
  const normalized = viewElement.getNormalizedStyle(styleName);
43
39
  const value = reduceBoxSides ? reduceBoxSidesValue(normalized) : normalized;
44
- if (defaultValue !== value) {
40
+ if (localDefaultValue !== value) {
45
41
  return value;
46
42
  }
47
43
  }
@@ -93,6 +89,17 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
93
89
  shallow: true
94
90
  })
95
91
  ].pop();
92
+ const tableElement = modelElement.findAncestor('table', {
93
+ includeSelf: true
94
+ });
95
+ let localDefaultBorder = defaultBorder;
96
+ if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
97
+ localDefaultBorder = {
98
+ style: 'none',
99
+ color: '',
100
+ width: ''
101
+ };
102
+ }
96
103
  conversionApi.consumable.consume(data.viewItem, matcherPattern);
97
104
  const normalizedBorder = {
98
105
  style: data.viewItem.getNormalizedStyle('border-style'),
@@ -104,13 +111,13 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
104
111
  color: reduceBoxSidesValue(normalizedBorder.color),
105
112
  width: reduceBoxSidesValue(normalizedBorder.width)
106
113
  };
107
- if (reducedBorder.style !== defaultBorder.style) {
114
+ if (reducedBorder.style !== localDefaultBorder.style) {
108
115
  conversionApi.writer.setAttribute(modelAttributes.style, reducedBorder.style, modelElement);
109
116
  }
110
- if (reducedBorder.color !== defaultBorder.color) {
117
+ if (reducedBorder.color !== localDefaultBorder.color) {
111
118
  conversionApi.writer.setAttribute(modelAttributes.color, reducedBorder.color, modelElement);
112
119
  }
113
- if (reducedBorder.width !== defaultBorder.width) {
120
+ if (reducedBorder.width !== localDefaultBorder.width) {
114
121
  conversionApi.writer.setAttribute(modelAttributes.width, reducedBorder.width, modelElement);
115
122
  }
116
123
  }));
@@ -152,6 +159,20 @@ import { isObject, debounce, isEqual, throttle } from 'es-toolkit/compat';
152
159
  }
153
160
  }));
154
161
  }
162
+ /**
163
+ * Returns the default value for table or table cell property adjusted for layout tables.
164
+ */ function getDefaultValueAdjusted(defaultValue, layoutTableDefault, data) {
165
+ const modelElement = data.modelRange && first(data.modelRange.getItems({
166
+ shallow: true
167
+ }));
168
+ const tableElement = modelElement && modelElement.is('element') && modelElement.findAncestor('table', {
169
+ includeSelf: true
170
+ });
171
+ if (tableElement && tableElement.getAttribute('tableType') === 'layout') {
172
+ return layoutTableDefault;
173
+ }
174
+ return defaultValue;
175
+ }
155
176
  /**
156
177
  * Reduces the full top, right, bottom, left object to a single string if all sides are equal.
157
178
  * Returns original style otherwise.
@@ -7073,7 +7094,12 @@ const isEmpty = (val)=>val === '';
7073
7094
  return buttonValue === valueToCompare;
7074
7095
  });
7075
7096
  button.on('execute', ()=>{
7076
- view[propertyName] = buttonValue;
7097
+ // Allow toggling alignment if there is no default value specified (especially for layout tables).
7098
+ if (!defaultValue && buttonValue && view[propertyName] === buttonValue) {
7099
+ view[propertyName] = undefined;
7100
+ } else {
7101
+ view[propertyName] = buttonValue;
7102
+ }
7077
7103
  });
7078
7104
  toolbar.items.add(button);
7079
7105
  }
@@ -8088,13 +8114,22 @@ const propertyToCommandMap$1 = {
8088
8114
  */ class TableCellPropertiesUI extends Plugin {
8089
8115
  /**
8090
8116
  * The default table cell properties.
8091
- */ _defaultTableCellProperties;
8117
+ */ _defaultContentTableCellProperties;
8118
+ /**
8119
+ * The default layout table cell properties.
8120
+ */ _defaultLayoutTableCellProperties;
8092
8121
  /**
8093
8122
  * The contextual balloon plugin instance.
8094
8123
  */ _balloon;
8095
8124
  /**
8096
8125
  * The cell properties form view displayed inside the balloon.
8097
8126
  */ view;
8127
+ /**
8128
+ * The cell properties form view displayed inside the balloon (content table).
8129
+ */ _viewWithContentTableDefaults;
8130
+ /**
8131
+ * The cell properties form view displayed inside the balloon (layout table).
8132
+ */ _viewWithLayoutTableDefaults;
8098
8133
  /**
8099
8134
  * The batch used to undo all changes made by the form (which are live, as the user types)
8100
8135
  * when "Cancel" was pressed. Each time the view is shown, a new batch is created.
@@ -8134,12 +8169,17 @@ const propertyToCommandMap$1 = {
8134
8169
  */ init() {
8135
8170
  const editor = this.editor;
8136
8171
  const t = editor.t;
8137
- this._defaultTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'), {
8172
+ this._defaultContentTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'), {
8138
8173
  includeVerticalAlignmentProperty: true,
8139
8174
  includeHorizontalAlignmentProperty: true,
8140
8175
  includePaddingProperty: true,
8141
8176
  isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
8142
8177
  });
8178
+ this._defaultLayoutTableCellProperties = getNormalizedDefaultProperties(undefined, {
8179
+ includeVerticalAlignmentProperty: true,
8180
+ includeHorizontalAlignmentProperty: true,
8181
+ isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
8182
+ });
8143
8183
  this._balloon = editor.plugins.get(ContextualBalloon);
8144
8184
  this.view = null;
8145
8185
  this._isReady = false;
@@ -8170,7 +8210,7 @@ const propertyToCommandMap$1 = {
8170
8210
  * Creates the {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView} instance.
8171
8211
  *
8172
8212
  * @returns The cell properties form view instance.
8173
- */ _createPropertiesView() {
8213
+ */ _createPropertiesView(defaultTableCellProperties) {
8174
8214
  const editor = this.editor;
8175
8215
  const config = editor.config.get('table.tableCellProperties');
8176
8216
  const borderColorsConfig = normalizeColorOptions(config.borderColors);
@@ -8181,7 +8221,7 @@ const propertyToCommandMap$1 = {
8181
8221
  const view = new TableCellPropertiesView(editor.locale, {
8182
8222
  borderColors: localizedBorderColors,
8183
8223
  backgroundColors: localizedBackgroundColors,
8184
- defaultTableCellProperties: this._defaultTableCellProperties,
8224
+ defaultTableCellProperties,
8185
8225
  colorPickerConfig: hasColorPicker ? config.colorPicker || {} : false
8186
8226
  });
8187
8227
  const t = editor.t;
@@ -8270,7 +8310,8 @@ const propertyToCommandMap$1 = {
8270
8310
  const commands = this.editor.commands;
8271
8311
  const borderStyleCommand = commands.get('tableCellBorderStyle');
8272
8312
  Object.entries(propertyToCommandMap$1).map(([property, commandName])=>{
8273
- const defaultValue = this._defaultTableCellProperties[property] || '';
8313
+ const propertyKey = property;
8314
+ const defaultValue = this.view === this._viewWithContentTableDefaults ? this._defaultContentTableCellProperties[propertyKey] || '' : this._defaultLayoutTableCellProperties[propertyKey] || '';
8274
8315
  return [
8275
8316
  property,
8276
8317
  commands.get(commandName).value || defaultValue
@@ -8292,9 +8333,15 @@ const propertyToCommandMap$1 = {
8292
8333
  * for all of them.
8293
8334
  */ _showView() {
8294
8335
  const editor = this.editor;
8295
- if (!this.view) {
8296
- this.view = this._createPropertiesView();
8297
- }
8336
+ const viewTable = getSelectionAffectedTableWidget(editor.editing.view.document.selection);
8337
+ const modelTable = viewTable && editor.editing.mapper.toModelElement(viewTable);
8338
+ const useDefaults = !modelTable || modelTable.getAttribute('tableType') !== 'layout';
8339
+ if (useDefaults && !this._viewWithContentTableDefaults) {
8340
+ this._viewWithContentTableDefaults = this._createPropertiesView(this._defaultContentTableCellProperties);
8341
+ } else if (!useDefaults && !this._viewWithLayoutTableDefaults) {
8342
+ this._viewWithLayoutTableDefaults = this._createPropertiesView(this._defaultLayoutTableCellProperties);
8343
+ }
8344
+ this.view = useDefaults ? this._viewWithContentTableDefaults : this._viewWithLayoutTableDefaults;
8298
8345
  this.listenTo(editor.ui, 'update', ()=>{
8299
8346
  this._updateView();
8300
8347
  });
@@ -8398,7 +8445,15 @@ const propertyToCommandMap$1 = {
8398
8445
  */ attributeName;
8399
8446
  /**
8400
8447
  * The default value for the attribute.
8448
+ *
8449
+ * @readonly
8401
8450
  */ _defaultValue;
8451
+ /**
8452
+ * The default value for the attribute for the content table.
8453
+ */ _defaultContentTableValue;
8454
+ /**
8455
+ * The default value for the attribute for the layout table.
8456
+ */ _defaultLayoutTableValue;
8402
8457
  /**
8403
8458
  * Creates a new `TableCellPropertyCommand` instance.
8404
8459
  *
@@ -8408,14 +8463,31 @@ const propertyToCommandMap$1 = {
8408
8463
  */ constructor(editor, attributeName, defaultValue){
8409
8464
  super(editor);
8410
8465
  this.attributeName = attributeName;
8411
- this._defaultValue = defaultValue;
8466
+ this._defaultContentTableValue = defaultValue;
8467
+ // Hardcoded defaults for layout table.
8468
+ switch(attributeName){
8469
+ case 'tableCellBorderStyle':
8470
+ this._defaultLayoutTableValue = 'none';
8471
+ break;
8472
+ case 'tableCellHorizontalAlignment':
8473
+ this._defaultLayoutTableValue = 'left';
8474
+ break;
8475
+ case 'tableCellVerticalAlignment':
8476
+ this._defaultLayoutTableValue = 'middle';
8477
+ break;
8478
+ default:
8479
+ this._defaultLayoutTableValue = undefined;
8480
+ }
8412
8481
  }
8413
8482
  /**
8414
8483
  * @inheritDoc
8415
8484
  */ refresh() {
8416
8485
  const editor = this.editor;
8486
+ const selection = editor.model.document.selection;
8417
8487
  const tableUtils = this.editor.plugins.get('TableUtils');
8418
- const selectedTableCells = tableUtils.getSelectionAffectedTableCells(editor.model.document.selection);
8488
+ const selectedTableCells = tableUtils.getSelectionAffectedTableCells(selection);
8489
+ const table = getSelectionAffectedTable(selection);
8490
+ this._defaultValue = !table || table.getAttribute('tableType') !== 'layout' ? this._defaultContentTableValue : this._defaultLayoutTableValue;
8419
8491
  this.isEnabled = !!selectedTableCells.length;
8420
8492
  this.value = this._getSingleValue(selectedTableCells);
8421
8493
  }
@@ -9010,9 +9082,10 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9010
9082
  },
9011
9083
  model: {
9012
9084
  key: 'tableCellHorizontalAlignment',
9013
- value: (viewElement)=>{
9085
+ value: (viewElement, conversionApi, data)=>{
9086
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
9014
9087
  const align = viewElement.getStyle('text-align');
9015
- return align === defaultValue ? null : align;
9088
+ return align === localDefaultValue ? null : align;
9016
9089
  }
9017
9090
  }
9018
9091
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
@@ -9025,9 +9098,10 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9025
9098
  },
9026
9099
  model: {
9027
9100
  key: 'tableCellHorizontalAlignment',
9028
- value: (viewElement)=>{
9101
+ value: (viewElement, conversionApi, data)=>{
9102
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
9029
9103
  const align = viewElement.getAttribute('align');
9030
- return align === defaultValue ? null : align;
9104
+ return align === localDefaultValue ? null : align;
9031
9105
  }
9032
9106
  }
9033
9107
  });
@@ -9064,9 +9138,10 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9064
9138
  },
9065
9139
  model: {
9066
9140
  key: 'tableCellVerticalAlignment',
9067
- value: (viewElement)=>{
9141
+ value: (viewElement, conversionApi, data)=>{
9142
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
9068
9143
  const align = viewElement.getStyle('vertical-align');
9069
- return align === defaultValue ? null : align;
9144
+ return align === localDefaultValue ? null : align;
9070
9145
  }
9071
9146
  }
9072
9147
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
@@ -9079,9 +9154,10 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9079
9154
  },
9080
9155
  model: {
9081
9156
  key: 'tableCellVerticalAlignment',
9082
- value: (viewElement)=>{
9157
+ value: (viewElement, conversionApi, data)=>{
9158
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
9083
9159
  const valign = viewElement.getAttribute('valign');
9084
- return valign === defaultValue ? null : valign;
9160
+ return valign === localDefaultValue ? null : valign;
9085
9161
  }
9086
9162
  }
9087
9163
  });
@@ -9444,6 +9520,7 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9444
9520
  });
9445
9521
  }
9446
9522
 
9523
+ const toPx = /* #__PURE__ */ toUnit('px');
9447
9524
  /**
9448
9525
  * The table column resize editing plugin.
9449
9526
  */ class TableColumnResizeEditing extends Plugin {
@@ -9747,12 +9824,88 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9747
9824
  */ _registerResizingListeners() {
9748
9825
  const editingView = this.editor.editing.view;
9749
9826
  editingView.addObserver(MouseEventsObserver);
9827
+ editingView.document.on('mouseover', this._onMouseOverHandler.bind(this), {
9828
+ priority: 'high'
9829
+ });
9750
9830
  editingView.document.on('mousedown', this._onMouseDownHandler.bind(this), {
9751
9831
  priority: 'high'
9752
9832
  });
9833
+ editingView.document.on('mouseout', this._onMouseOutHandler.bind(this), {
9834
+ priority: 'high'
9835
+ });
9753
9836
  this._domEmitter.listenTo(global.window.document, 'mousemove', throttle(this._onMouseMoveHandler.bind(this), 50));
9754
9837
  this._domEmitter.listenTo(global.window.document, 'mouseup', this._onMouseUpHandler.bind(this));
9755
9838
  }
9839
+ /**
9840
+ * Calculate and set `top` and `bottom` styles to the column resizer element to fit the height of the table.
9841
+ *
9842
+ * @param viewResizer The column resizer element.
9843
+ */ _recalculateResizerElement(viewResizer) {
9844
+ const editor = this.editor;
9845
+ const domConverter = editor.editing.view.domConverter;
9846
+ // Get DOM target figure ancestor element.
9847
+ const domTable = domConverter.mapViewToDom(viewResizer.findAncestor('table'));
9848
+ // Get DOM table cell element.
9849
+ const domCell = domConverter.mapViewToDom(viewResizer.findAncestor((item)=>[
9850
+ 'td',
9851
+ 'th'
9852
+ ].includes(item.name)));
9853
+ const rectTable = new Rect(domTable);
9854
+ const rectCell = new Rect(domCell);
9855
+ // Calculate the top, and bottom positions of the column resizer element.
9856
+ const targetTopPosition = toPx(Number((rectTable.top - rectCell.top).toFixed(4)));
9857
+ const targetBottomPosition = toPx(Number((rectCell.bottom - rectTable.bottom).toFixed(4)));
9858
+ // Set `top` and `bottom` styles to the column resizer element.
9859
+ editor.editing.view.change((viewWriter)=>{
9860
+ viewWriter.setStyle('top', targetTopPosition, viewResizer);
9861
+ viewWriter.setStyle('bottom', targetBottomPosition, viewResizer);
9862
+ });
9863
+ }
9864
+ /**
9865
+ * Remove `top` and `bottom` styles of the column resizer element.
9866
+ *
9867
+ * @param viewResizer The column resizer element.
9868
+ */ _resetResizerStyles(viewResizer) {
9869
+ this.editor.editing.view.change((viewWriter)=>{
9870
+ viewWriter.removeStyle('top', viewResizer);
9871
+ viewWriter.removeStyle('bottom', viewResizer);
9872
+ });
9873
+ }
9874
+ /**
9875
+ * Handles the `mouseover` event on column resizer element.
9876
+ * Recalculates the `top` and `bottom` styles of the column resizer element to fit the height of the table.
9877
+ *
9878
+ * @param eventInfo An object containing information about the fired event.
9879
+ * @param domEventData The data related to the DOM event.
9880
+ */ _onMouseOverHandler(eventInfo, domEventData) {
9881
+ const target = domEventData.target;
9882
+ if (!target.hasClass('ck-table-column-resizer')) {
9883
+ return;
9884
+ }
9885
+ if (!this._isResizingAllowed) {
9886
+ return;
9887
+ }
9888
+ this._recalculateResizerElement(target);
9889
+ }
9890
+ /**
9891
+ * Handles the `mouseout` event on column resizer element.
9892
+ * When resizing is not active, it resets the `top` and `bottom` styles of the column resizer element.
9893
+ *
9894
+ * @param eventInfo An object containing information about the fired event.
9895
+ * @param domEventData The data related to the DOM event.
9896
+ */ _onMouseOutHandler(eventInfo, domEventData) {
9897
+ const target = domEventData.target;
9898
+ if (!target.hasClass('ck-table-column-resizer')) {
9899
+ return;
9900
+ }
9901
+ if (!this._isResizingAllowed) {
9902
+ return;
9903
+ }
9904
+ if (this._isResizingActive) {
9905
+ return;
9906
+ }
9907
+ this._resetResizerStyles(target);
9908
+ }
9756
9909
  /**
9757
9910
  * Handles the `mousedown` event on column resizer element:
9758
9911
  * * calculates the initial column pixel widths,
@@ -9877,7 +10030,7 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9877
10030
  this._onMouseUpHandler();
9878
10031
  return;
9879
10032
  }
9880
- const { columnPosition, flags: { isRightEdge, isTableCentered, isLtrContent }, elements: { viewFigure, viewLeftColumn, viewRightColumn }, widths: { viewFigureParentWidth, tableWidth, leftColumnWidth, rightColumnWidth } } = this._resizingData;
10033
+ const { columnPosition, flags: { isRightEdge, isTableCentered, isLtrContent }, elements: { viewFigure, viewLeftColumn, viewRightColumn, viewResizer }, widths: { viewFigureParentWidth, tableWidth, leftColumnWidth, rightColumnWidth } } = this._resizingData;
9881
10034
  const dxLowerBound = -leftColumnWidth + COLUMN_MIN_WIDTH_IN_PIXELS;
9882
10035
  const dxUpperBound = isRightEdge ? viewFigureParentWidth - tableWidth : rightColumnWidth - COLUMN_MIN_WIDTH_IN_PIXELS;
9883
10036
  // The multiplier is needed for calculating the proper movement offset:
@@ -9899,6 +10052,7 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9899
10052
  writer.setStyle('width', `${rightColumnWidthAsPercentage}%`, viewRightColumn);
9900
10053
  }
9901
10054
  });
10055
+ this._recalculateResizerElement(viewResizer);
9902
10056
  }
9903
10057
  /**
9904
10058
  * Handles the `mouseup` event.
@@ -9963,6 +10117,10 @@ const ALIGN_VALUES_REG_EXP$1 = /^(left|center|right|justify)$/;
9963
10117
  editingView.change((writer)=>{
9964
10118
  writer.removeClass('ck-table-column-resizer__active', viewResizer);
9965
10119
  });
10120
+ const element = editingView.domConverter.mapViewToDom(viewResizer);
10121
+ if (!element.matches(':hover')) {
10122
+ this._resetResizerStyles(viewResizer);
10123
+ }
9966
10124
  this._isResizingActive = false;
9967
10125
  this._resizingData = null;
9968
10126
  }
@@ -10413,7 +10571,7 @@ const TABLE_TYPES = [
10413
10571
  /**
10414
10572
  * The table plugin.
10415
10573
  *
10416
- * For a detailed overview, check the {@glink features/tables/tables-layout Layout table feature documentation}.
10574
+ * For a detailed overview, check the {@glink features/tables/layout-tables Layout table feature documentation}.
10417
10575
  */ class TableLayout extends Plugin {
10418
10576
  /**
10419
10577
  * @inheritDoc
@@ -10447,7 +10605,15 @@ const TABLE_TYPES = [
10447
10605
  */ attributeName;
10448
10606
  /**
10449
10607
  * The default value for the attribute.
10608
+ *
10609
+ * @readonly
10450
10610
  */ _defaultValue;
10611
+ /**
10612
+ * The default value for the attribute for the content table.
10613
+ */ _defaultContentTableValue;
10614
+ /**
10615
+ * The default value for the attribute for the layout table.
10616
+ */ _defaultLayoutTableValue;
10451
10617
  /**
10452
10618
  * Creates a new `TablePropertyCommand` instance.
10453
10619
  *
@@ -10457,7 +10623,8 @@ const TABLE_TYPES = [
10457
10623
  */ constructor(editor, attributeName, defaultValue){
10458
10624
  super(editor);
10459
10625
  this.attributeName = attributeName;
10460
- this._defaultValue = defaultValue;
10626
+ this._defaultContentTableValue = defaultValue;
10627
+ this._defaultLayoutTableValue = attributeName === 'tableBorderStyle' ? 'none' : undefined;
10461
10628
  }
10462
10629
  /**
10463
10630
  * @inheritDoc
@@ -10465,6 +10632,7 @@ const TABLE_TYPES = [
10465
10632
  const editor = this.editor;
10466
10633
  const selection = editor.model.document.selection;
10467
10634
  const table = getSelectionAffectedTable(selection);
10635
+ this._defaultValue = !table || table.getAttribute('tableType') !== 'layout' ? this._defaultContentTableValue : this._defaultLayoutTableValue;
10468
10636
  this.isEnabled = !!table;
10469
10637
  this.value = this._getValue(table);
10470
10638
  }
@@ -10894,15 +11062,40 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
10894
11062
  conversion.for('downcast').attributeToAttribute({
10895
11063
  model: {
10896
11064
  name: 'table',
10897
- key: 'tableAlignment'
11065
+ key: 'tableAlignment',
11066
+ values: [
11067
+ 'left',
11068
+ 'center',
11069
+ 'right'
11070
+ ]
10898
11071
  },
10899
- view: (alignment)=>({
11072
+ view: {
11073
+ left: {
10900
11074
  key: 'style',
10901
11075
  value: {
10902
- // Model: `alignment:center` => CSS: `float:none`.
10903
- float: alignment === 'center' ? 'none' : alignment
11076
+ float: 'left'
10904
11077
  }
10905
- }),
11078
+ },
11079
+ right: {
11080
+ key: 'style',
11081
+ value: {
11082
+ float: 'right'
11083
+ }
11084
+ },
11085
+ center: (alignment, conversionApi, data)=>{
11086
+ const value = data.item.getAttribute('tableType') !== 'layout' ? {
11087
+ // Model: `alignment:center` => CSS: `float:none`.
11088
+ float: 'none'
11089
+ } : {
11090
+ 'margin-left': 'auto',
11091
+ 'margin-right': 'auto'
11092
+ };
11093
+ return {
11094
+ key: 'style',
11095
+ value
11096
+ };
11097
+ }
11098
+ },
10906
11099
  converterPriority: 'high'
10907
11100
  });
10908
11101
  conversion.for('upcast')// Support for the `float:*;` CSS definition for the table alignment.
@@ -10915,13 +11108,31 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
10915
11108
  },
10916
11109
  model: {
10917
11110
  key: 'tableAlignment',
10918
- value: (viewElement)=>{
11111
+ value: (viewElement, conversionApi, data)=>{
11112
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
10919
11113
  let align = viewElement.getStyle('float');
10920
11114
  // CSS: `float:none` => Model: `alignment:center`.
10921
11115
  if (align === 'none') {
10922
11116
  align = 'center';
10923
11117
  }
10924
- return align === defaultValue ? null : align;
11118
+ return align === localDefaultValue ? null : align;
11119
+ }
11120
+ }
11121
+ })// Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.
11122
+ .attributeToAttribute({
11123
+ view: {
11124
+ name: /^(table|figure)$/,
11125
+ styles: {
11126
+ 'margin-left': 'auto',
11127
+ 'margin-right': 'auto'
11128
+ }
11129
+ },
11130
+ model: {
11131
+ key: 'tableAlignment',
11132
+ value: (viewElement, conversionApi, data)=>{
11133
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
11134
+ const align = 'center';
11135
+ return align === localDefaultValue ? null : align;
10925
11136
  }
10926
11137
  }
10927
11138
  })// Support for the `align` attribute as the backward compatibility while pasting from other sources.
@@ -10934,9 +11145,10 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
10934
11145
  model: {
10935
11146
  name: 'table',
10936
11147
  key: 'tableAlignment',
10937
- value: (viewElement)=>{
11148
+ value: (viewElement, conversionApi, data)=>{
11149
+ const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
10938
11150
  const align = viewElement.getAttribute('align');
10939
- return align === defaultValue ? null : align;
11151
+ return align === localDefaultValue ? null : align;
10940
11152
  }
10941
11153
  }
10942
11154
  });
@@ -11489,13 +11701,22 @@ const propertyToCommandMap = {
11489
11701
  */ class TablePropertiesUI extends Plugin {
11490
11702
  /**
11491
11703
  * The default table properties.
11492
- */ _defaultTableProperties;
11704
+ */ _defaultContentTableProperties;
11705
+ /**
11706
+ * The default layout table properties.
11707
+ */ _defaultLayoutTableProperties;
11493
11708
  /**
11494
11709
  * The contextual balloon plugin instance.
11495
11710
  */ _balloon;
11496
11711
  /**
11497
11712
  * The properties form view displayed inside the balloon.
11498
11713
  */ view = null;
11714
+ /**
11715
+ * The properties form view displayed inside the balloon (content table).
11716
+ */ _viewWithContentTableDefaults = null;
11717
+ /**
11718
+ * The properties form view displayed inside the balloon (layout table).
11719
+ */ _viewWithLayoutTableDefaults = null;
11499
11720
  /**
11500
11721
  * The batch used to undo all changes made by the form (which are live, as the user types)
11501
11722
  * when "Cancel" was pressed. Each time the view is shown, a new batch is created.
@@ -11534,9 +11755,10 @@ const propertyToCommandMap = {
11534
11755
  * @inheritDoc
11535
11756
  */ init() {
11536
11757
  const editor = this.editor;
11537
- this._defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {
11758
+ this._defaultContentTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {
11538
11759
  includeAlignmentProperty: true
11539
11760
  });
11761
+ this._defaultLayoutTableProperties = getNormalizedDefaultProperties();
11540
11762
  this._balloon = editor.plugins.get(ContextualBalloon);
11541
11763
  editor.ui.componentFactory.add('tableProperties', ()=>this._createTablePropertiesButton());
11542
11764
  }
@@ -11572,7 +11794,7 @@ const propertyToCommandMap = {
11572
11794
  * Creates the {@link module:table/tableproperties/ui/tablepropertiesview~TablePropertiesView} instance.
11573
11795
  *
11574
11796
  * @returns The table properties form view instance.
11575
- */ _createPropertiesView() {
11797
+ */ _createPropertiesView(defaultTableProperties) {
11576
11798
  const editor = this.editor;
11577
11799
  const config = editor.config.get('table.tableProperties');
11578
11800
  const borderColorsConfig = normalizeColorOptions(config.borderColors);
@@ -11583,7 +11805,7 @@ const propertyToCommandMap = {
11583
11805
  const view = new TablePropertiesView(editor.locale, {
11584
11806
  borderColors: localizedBorderColors,
11585
11807
  backgroundColors: localizedBackgroundColors,
11586
- defaultTableProperties: this._defaultTableProperties,
11808
+ defaultTableProperties,
11587
11809
  colorPickerConfig: hasColorPicker ? config.colorPicker || {} : false
11588
11810
  });
11589
11811
  const t = editor.t;
@@ -11666,7 +11888,7 @@ const propertyToCommandMap = {
11666
11888
  const borderStyleCommand = commands.get('tableBorderStyle');
11667
11889
  Object.entries(propertyToCommandMap).map(([property, commandName])=>{
11668
11890
  const propertyKey = property;
11669
- const defaultValue = this._defaultTableProperties[propertyKey] || '';
11891
+ const defaultValue = this.view === this._viewWithContentTableDefaults ? this._defaultContentTableProperties[propertyKey] || '' : this._defaultLayoutTableProperties[propertyKey] || '';
11670
11892
  return [
11671
11893
  propertyKey,
11672
11894
  commands.get(commandName).value || defaultValue
@@ -11688,9 +11910,15 @@ const propertyToCommandMap = {
11688
11910
  * for all of them.
11689
11911
  */ _showView() {
11690
11912
  const editor = this.editor;
11691
- if (!this.view) {
11692
- this.view = this._createPropertiesView();
11693
- }
11913
+ const viewTable = getSelectionAffectedTableWidget(editor.editing.view.document.selection);
11914
+ const modelTable = viewTable && editor.editing.mapper.toModelElement(viewTable);
11915
+ const useDefaults = !modelTable || modelTable.getAttribute('tableType') !== 'layout';
11916
+ if (useDefaults && !this._viewWithContentTableDefaults) {
11917
+ this._viewWithContentTableDefaults = this._createPropertiesView(this._defaultContentTableProperties);
11918
+ } else if (!useDefaults && !this._viewWithLayoutTableDefaults) {
11919
+ this._viewWithLayoutTableDefaults = this._createPropertiesView(this._defaultLayoutTableProperties);
11920
+ }
11921
+ this.view = useDefaults ? this._viewWithContentTableDefaults : this._viewWithLayoutTableDefaults;
11694
11922
  this.listenTo(editor.ui, 'update', ()=>{
11695
11923
  this._updateView();
11696
11924
  });