@ckeditor/ckeditor5-table 45.2.1 → 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
@@ -6,16 +6,16 @@
6
6
  * @module table/tableproperties/tablepropertiesediting
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import { addBackgroundRules, addBorderRules } from 'ckeditor5/src/engine.js';
10
- import TableEditing from '../tableediting.js';
9
+ import { addBackgroundStylesRules, addBorderStylesRules } from 'ckeditor5/src/engine.js';
10
+ import { TableEditing } from '../tableediting.js';
11
11
  import { downcastAttributeToStyle, downcastTableAttribute, getDefaultValueAdjusted, upcastBorderStyles, upcastStyleToAttribute } from '../converters/tableproperties.js';
12
- import TableBackgroundColorCommand from './commands/tablebackgroundcolorcommand.js';
13
- import TableBorderColorCommand from './commands/tablebordercolorcommand.js';
14
- import TableBorderStyleCommand from './commands/tableborderstylecommand.js';
15
- import TableBorderWidthCommand from './commands/tableborderwidthcommand.js';
16
- import TableWidthCommand from './commands/tablewidthcommand.js';
17
- import TableHeightCommand from './commands/tableheightcommand.js';
18
- import TableAlignmentCommand from './commands/tablealignmentcommand.js';
12
+ import { TableBackgroundColorCommand } from './commands/tablebackgroundcolorcommand.js';
13
+ import { TableBorderColorCommand } from './commands/tablebordercolorcommand.js';
14
+ import { TableBorderStyleCommand } from './commands/tableborderstylecommand.js';
15
+ import { TableBorderWidthCommand } from './commands/tableborderwidthcommand.js';
16
+ import { TableWidthCommand } from './commands/tablewidthcommand.js';
17
+ import { TableHeightCommand } from './commands/tableheightcommand.js';
18
+ import { TableAlignmentCommand } from './commands/tablealignmentcommand.js';
19
19
  import { getNormalizedDefaultTableProperties } from '../utils/table-properties.js';
20
20
  const ALIGN_VALUES_REG_EXP = /^(left|center|right)$/;
21
21
  const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
@@ -36,7 +36,7 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
36
36
  * - horizontal alignment: `'tableAlignment'`
37
37
  * - width & height: `'tableWidth'` & `'tableHeight'`
38
38
  */
39
- export default class TablePropertiesEditing extends Plugin {
39
+ export class TablePropertiesEditing extends Plugin {
40
40
  /**
41
41
  * @inheritDoc
42
42
  */
@@ -66,7 +66,7 @@ export default class TablePropertiesEditing extends Plugin {
66
66
  const defaultTableProperties = getNormalizedDefaultTableProperties(editor.config.get('table.tableProperties.defaultProperties'), {
67
67
  includeAlignmentProperty: true
68
68
  });
69
- editor.data.addStyleProcessorRules(addBorderRules);
69
+ editor.data.addStyleProcessorRules(addBorderStylesRules);
70
70
  enableBorderProperties(schema, conversion, {
71
71
  color: defaultTableProperties.borderColor,
72
72
  style: defaultTableProperties.borderStyle,
@@ -80,19 +80,25 @@ export default class TablePropertiesEditing extends Plugin {
80
80
  enableTableToFigureProperty(schema, conversion, {
81
81
  modelAttribute: 'tableWidth',
82
82
  styleName: 'width',
83
+ attributeName: 'width',
84
+ attributeType: 'length',
83
85
  defaultValue: defaultTableProperties.width
84
86
  });
85
87
  editor.commands.add('tableWidth', new TableWidthCommand(editor, defaultTableProperties.width));
86
88
  enableTableToFigureProperty(schema, conversion, {
87
89
  modelAttribute: 'tableHeight',
88
90
  styleName: 'height',
91
+ attributeName: 'height',
92
+ attributeType: 'length',
89
93
  defaultValue: defaultTableProperties.height
90
94
  });
91
95
  editor.commands.add('tableHeight', new TableHeightCommand(editor, defaultTableProperties.height));
92
- editor.data.addStyleProcessorRules(addBackgroundRules);
96
+ editor.data.addStyleProcessorRules(addBackgroundStylesRules);
93
97
  enableProperty(schema, conversion, {
94
98
  modelAttribute: 'tableBackgroundColor',
95
99
  styleName: 'background-color',
100
+ attributeName: 'bgcolor',
101
+ attributeType: 'color',
96
102
  defaultValue: defaultTableProperties.backgroundColor
97
103
  });
98
104
  editor.commands.add('tableBackgroundColor', new TableBackgroundColorCommand(editor, defaultTableProperties.backgroundColor));
@@ -115,6 +121,9 @@ function enableBorderProperties(schema, conversion, defaultBorder) {
115
121
  schema.extend('table', {
116
122
  allowAttributes: Object.values(modelAttributes)
117
123
  });
124
+ for (const modelAttribute of Object.values(modelAttributes)) {
125
+ schema.setAttributeProperties(modelAttribute, { isFormatting: true });
126
+ }
118
127
  upcastBorderStyles(conversion, 'table', modelAttributes, defaultBorder);
119
128
  downcastTableAttribute(conversion, { modelAttribute: modelAttributes.color, styleName: 'border-color' });
120
129
  downcastTableAttribute(conversion, { modelAttribute: modelAttributes.style, styleName: 'border-style' });
@@ -129,6 +138,7 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
129
138
  schema.extend('table', {
130
139
  allowAttributes: ['tableAlignment']
131
140
  });
141
+ schema.setAttributeProperties('tableAlignment', { isFormatting: true });
132
142
  conversion.for('downcast')
133
143
  .attributeToAttribute({
134
144
  model: {
@@ -177,13 +187,21 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
177
187
  model: {
178
188
  key: 'tableAlignment',
179
189
  value: (viewElement, conversionApi, data) => {
190
+ // Ignore other figure elements.
191
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
192
+ return;
193
+ }
180
194
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
181
195
  let align = viewElement.getStyle('float');
182
196
  // CSS: `float:none` => Model: `alignment:center`.
183
197
  if (align === 'none') {
184
198
  align = 'center';
185
199
  }
186
- return align === localDefaultValue ? null : align;
200
+ if (align !== localDefaultValue) {
201
+ return align;
202
+ }
203
+ // Consume the style even if not applied to the element so it won't be processed by other converters.
204
+ conversionApi.consumable.consume(viewElement, { styles: 'float' });
187
205
  }
188
206
  }
189
207
  })
@@ -199,26 +217,38 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
199
217
  model: {
200
218
  key: 'tableAlignment',
201
219
  value: (viewElement, conversionApi, data) => {
220
+ // Ignore other figure elements.
221
+ if (viewElement.name == 'figure' && !viewElement.hasClass('table')) {
222
+ return;
223
+ }
202
224
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
203
225
  const align = 'center';
204
- return align === localDefaultValue ? null : align;
226
+ if (align !== localDefaultValue) {
227
+ return align;
228
+ }
229
+ // Consume the styles even if not applied to the element so it won't be processed by other converters.
230
+ conversionApi.consumable.consume(viewElement, { styles: ['margin-left', 'margin-right'] });
205
231
  }
206
232
  }
207
233
  })
208
234
  // Support for the `align` attribute as the backward compatibility while pasting from other sources.
209
235
  .attributeToAttribute({
210
236
  view: {
237
+ name: 'table',
211
238
  attributes: {
212
239
  align: ALIGN_VALUES_REG_EXP
213
240
  }
214
241
  },
215
242
  model: {
216
- name: 'table',
217
243
  key: 'tableAlignment',
218
244
  value: (viewElement, conversionApi, data) => {
219
245
  const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
220
246
  const align = viewElement.getAttribute('align');
221
- return align === localDefaultValue ? null : align;
247
+ if (align !== localDefaultValue) {
248
+ return align;
249
+ }
250
+ // Consume the attribute even if not applied to the element so it won't be processed by other converters.
251
+ conversionApi.consumable.consume(viewElement, { attributes: 'align' });
222
252
  }
223
253
  }
224
254
  });
@@ -233,6 +263,7 @@ function enableProperty(schema, conversion, options) {
233
263
  schema.extend('table', {
234
264
  allowAttributes: [modelAttribute]
235
265
  });
266
+ schema.setAttributeProperties(modelAttribute, { isFormatting: true });
236
267
  upcastStyleToAttribute(conversion, { viewElement: 'table', ...options });
237
268
  downcastTableAttribute(conversion, options);
238
269
  }
@@ -244,10 +275,7 @@ function enableTableToFigureProperty(schema, conversion, options) {
244
275
  schema.extend('table', {
245
276
  allowAttributes: [modelAttribute]
246
277
  });
247
- upcastStyleToAttribute(conversion, {
248
- viewElement: /^(table|figure)$/,
249
- shouldUpcast: (element) => !(element.name == 'table' && element.parent.name == 'figure'),
250
- ...options
251
- });
278
+ schema.setAttributeProperties(modelAttribute, { isFormatting: true });
279
+ upcastStyleToAttribute(conversion, { viewElement: /^(table|figure)$/, ...options });
252
280
  downcastAttributeToStyle(conversion, { modelElement: 'table', ...options });
253
281
  }
@@ -7,14 +7,14 @@
7
7
  */
8
8
  import { Plugin, type Editor } from 'ckeditor5/src/core.js';
9
9
  import { ButtonView, ContextualBalloon } from 'ckeditor5/src/ui.js';
10
- import TablePropertiesView from './ui/tablepropertiesview.js';
10
+ import { TablePropertiesView } from './ui/tablepropertiesview.js';
11
11
  /**
12
12
  * The table properties UI plugin. It introduces the `'tableProperties'` button
13
13
  * that opens a form allowing to specify visual styling of an entire table.
14
14
  *
15
15
  * It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
16
16
  */
17
- export default class TablePropertiesUI extends Plugin {
17
+ export declare class TablePropertiesUI extends Plugin {
18
18
  /**
19
19
  * The default table properties.
20
20
  */
@@ -9,7 +9,7 @@ import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { IconTableProperties } from 'ckeditor5/src/icons.js';
10
10
  import { ButtonView, ContextualBalloon, clickOutsideHandler, getLocalizedColorOptions, normalizeColorOptions } from 'ckeditor5/src/ui.js';
11
11
  import { debounce } from 'es-toolkit/compat';
12
- import TablePropertiesView from './ui/tablepropertiesview.js';
12
+ import { TablePropertiesView } from './ui/tablepropertiesview.js';
13
13
  import { colorFieldValidator, getLocalizedColorErrorText, getLocalizedLengthErrorText, lengthFieldValidator, lineWidthFieldValidator, defaultColors } from '../utils/ui/table-properties.js';
14
14
  import { getSelectionAffectedTableWidget } from '../utils/ui/widget.js';
15
15
  import { getBalloonTablePositionData, repositionContextualBalloon } from '../utils/ui/contextualballoon.js';
@@ -31,7 +31,7 @@ const propertyToCommandMap = {
31
31
  *
32
32
  * It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
33
33
  */
34
- export default class TablePropertiesUI extends Plugin {
34
+ export class TablePropertiesUI extends Plugin {
35
35
  /**
36
36
  * The default table properties.
37
37
  */
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { ButtonView, FocusCycler, LabeledFieldView, ToolbarView, View, ViewCollection, type DropdownView, type InputTextView, type NormalizedColorOption, type ColorPickerConfig, type FocusableView } from 'ckeditor5/src/ui.js';
9
9
  import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
10
- import type ColorInputView from '../../ui/colorinputview.js';
10
+ import { type ColorInputView } from '../../ui/colorinputview.js';
11
11
  import type { TablePropertiesOptions } from '../../tableconfig.js';
12
12
  import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
13
13
  import '../../../theme/formrow.css';
@@ -40,7 +40,7 @@ export interface TablePropertiesViewOptions {
40
40
  * The class representing a table properties form, allowing users to customize
41
41
  * certain style aspects of a table, for instance, border, background color, alignment, etc..
42
42
  */
43
- export default class TablePropertiesView extends View {
43
+ export declare class TablePropertiesView extends View {
44
44
  /**
45
45
  * The value of the border style.
46
46
  *
@@ -18,7 +18,7 @@ import '../../../theme/tableproperties.css';
18
18
  * The class representing a table properties form, allowing users to customize
19
19
  * certain style aspects of a table, for instance, border, background color, alignment, etc..
20
20
  */
21
- export default class TablePropertiesView extends View {
21
+ export class TablePropertiesView extends View {
22
22
  /**
23
23
  * Options passed to the view. See {@link #constructor} to learn more.
24
24
  */
@@ -6,8 +6,8 @@
6
6
  * @module table/tableproperties
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import TablePropertiesEditing from './tableproperties/tablepropertiesediting.js';
10
- import TablePropertiesUI from './tableproperties/tablepropertiesui.js';
9
+ import { TablePropertiesEditing } from './tableproperties/tablepropertiesediting.js';
10
+ import { TablePropertiesUI } from './tableproperties/tablepropertiesui.js';
11
11
  /**
12
12
  * The table properties feature. Enables support for setting properties of tables (size, border, background, etc.).
13
13
  *
@@ -18,7 +18,7 @@ import TablePropertiesUI from './tableproperties/tablepropertiesui.js';
18
18
  * {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing table properties editing feature} and
19
19
  * the {@link module:table/tableproperties/tablepropertiesui~TablePropertiesUI table properties UI feature}.
20
20
  */
21
- export default class TableProperties extends Plugin {
21
+ export declare class TableProperties extends Plugin {
22
22
  /**
23
23
  * @inheritDoc
24
24
  */
@@ -6,8 +6,8 @@
6
6
  * @module table/tableproperties
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import TablePropertiesEditing from './tableproperties/tablepropertiesediting.js';
10
- import TablePropertiesUI from './tableproperties/tablepropertiesui.js';
9
+ import { TablePropertiesEditing } from './tableproperties/tablepropertiesediting.js';
10
+ import { TablePropertiesUI } from './tableproperties/tablepropertiesui.js';
11
11
  /**
12
12
  * The table properties feature. Enables support for setting properties of tables (size, border, background, etc.).
13
13
  *
@@ -18,7 +18,7 @@ import TablePropertiesUI from './tableproperties/tablepropertiesui.js';
18
18
  * {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing table properties editing feature} and
19
19
  * the {@link module:table/tableproperties/tablepropertiesui~TablePropertiesUI table properties UI feature}.
20
20
  */
21
- export default class TableProperties extends Plugin {
21
+ export class TableProperties extends Plugin {
22
22
  /**
23
23
  * @inheritDoc
24
24
  */
@@ -6,14 +6,14 @@
6
6
  * @module table/tableselection
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
- import type { Element, DocumentFragment } from 'ckeditor5/src/engine.js';
10
- import TableUtils from './tableutils.js';
9
+ import type { ModelElement, ModelDocumentFragment } from 'ckeditor5/src/engine.js';
10
+ import { TableUtils } from './tableutils.js';
11
11
  import '../theme/tableselection.css';
12
12
  /**
13
13
  * This plugin enables the advanced table cells, rows and columns selection.
14
14
  * It is loaded automatically by the {@link module:table/table~Table} plugin.
15
15
  */
16
- export default class TableSelection extends Plugin {
16
+ export declare class TableSelection extends Plugin {
17
17
  /**
18
18
  * @inheritDoc
19
19
  */
@@ -33,11 +33,11 @@ export default class TableSelection extends Plugin {
33
33
  /**
34
34
  * Returns the currently selected table cells or `null` if it is not a table cells selection.
35
35
  */
36
- getSelectedTableCells(): Array<Element> | null;
36
+ getSelectedTableCells(): Array<ModelElement> | null;
37
37
  /**
38
38
  * Returns the selected table fragment as a document fragment.
39
39
  */
40
- getSelectionAsFragment(): DocumentFragment | null;
40
+ getSelectionAsFragment(): ModelDocumentFragment | null;
41
41
  /**
42
42
  * Sets the model selection based on given anchor and target cells (can be the same cell).
43
43
  * Takes care of setting the backward flag.
@@ -51,15 +51,15 @@ export default class TableSelection extends Plugin {
51
51
  * tableSelection.setCellSelection( firstCell, lastCell );
52
52
  * ```
53
53
  */
54
- setCellSelection(anchorCell: Element, targetCell: Element): void;
54
+ setCellSelection(anchorCell: ModelElement, targetCell: ModelElement): void;
55
55
  /**
56
56
  * Returns the focus cell from the current selection.
57
57
  */
58
- getFocusCell(): Element | null;
58
+ getFocusCell(): ModelElement | null;
59
59
  /**
60
60
  * Returns the anchor cell from the current selection.
61
61
  */
62
- getAnchorCell(): Element | null;
62
+ getAnchorCell(): ModelElement | null;
63
63
  /**
64
64
  * Defines a selection converter which marks the selected cells with a specific class.
65
65
  *
@@ -91,7 +91,7 @@ export default class TableSelection extends Plugin {
91
91
  * yes, it's a hack).
92
92
  *
93
93
  * When multiple cells are selected in the model and the user starts to type, the
94
- * {@link module:engine/view/document~Document#event:insertText} event carries information provided by the
94
+ * {@link module:engine/view/document~ViewDocument#event:insertText} event carries information provided by the
95
95
  * beforeinput DOM event, that in turn only knows about this collapsed DOM selection in the last cell.
96
96
  *
97
97
  * As a result, the selected cells have no chance to be cleaned up. To fix this, this listener intercepts
@@ -7,15 +7,15 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { first } from 'ckeditor5/src/utils.js';
10
- import TableWalker from './tablewalker.js';
11
- import TableUtils from './tableutils.js';
10
+ import { TableWalker } from './tablewalker.js';
11
+ import { TableUtils } from './tableutils.js';
12
12
  import { cropTableToDimensions, adjustLastRowIndex, adjustLastColumnIndex } from './utils/structure.js';
13
13
  import '../theme/tableselection.css';
14
14
  /**
15
15
  * This plugin enables the advanced table cells, rows and columns selection.
16
16
  * It is loaded automatically by the {@link module:table/table~Table} plugin.
17
17
  */
18
- export default class TableSelection extends Plugin {
18
+ export class TableSelection extends Plugin {
19
19
  /**
20
20
  * @inheritDoc
21
21
  */
@@ -242,7 +242,7 @@ export default class TableSelection extends Plugin {
242
242
  * yes, it's a hack).
243
243
  *
244
244
  * When multiple cells are selected in the model and the user starts to type, the
245
- * {@link module:engine/view/document~Document#event:insertText} event carries information provided by the
245
+ * {@link module:engine/view/document~ViewDocument#event:insertText} event carries information provided by the
246
246
  * beforeinput DOM event, that in turn only knows about this collapsed DOM selection in the last cell.
247
247
  *
248
248
  * As a result, the selected cells have no chance to be cleaned up. To fix this, this listener intercepts
@@ -16,7 +16,7 @@ import { WidgetToolbarRepository } from 'ckeditor5/src/widget.js';
16
16
  * Table content toolbar shows up when the selection is inside the content of a table. It creates its component based on the
17
17
  * {@link module:table/tableconfig~TableConfig#contentToolbar `table.contentToolbar` configuration option}.
18
18
  */
19
- export default class TableToolbar extends Plugin {
19
+ export declare class TableToolbar extends Plugin {
20
20
  /**
21
21
  * @inheritDoc
22
22
  */
@@ -17,7 +17,7 @@ import { getSelectedTableWidget, getTableWidgetAncestor } from './utils/ui/widge
17
17
  * Table content toolbar shows up when the selection is inside the content of a table. It creates its component based on the
18
18
  * {@link module:table/tableconfig~TableConfig#contentToolbar `table.contentToolbar` configuration option}.
19
19
  */
20
- export default class TableToolbar extends Plugin {
20
+ export class TableToolbar extends Plugin {
21
21
  /**
22
22
  * @inheritDoc
23
23
  */
package/src/tableui.d.ts CHANGED
@@ -17,7 +17,7 @@ import { Plugin } from 'ckeditor5/src/core.js';
17
17
  *
18
18
  * The `'tableColumn'`, `'tableRow'` and `'mergeTableCells'` dropdowns work best with {@link module:table/tabletoolbar~TableToolbar}.
19
19
  */
20
- export default class TableUI extends Plugin {
20
+ export declare class TableUI extends Plugin {
21
21
  /**
22
22
  * @inheritDoc
23
23
  */
package/src/tableui.js CHANGED
@@ -7,9 +7,9 @@
7
7
  */
8
8
  import { Plugin } from 'ckeditor5/src/core.js';
9
9
  import { IconTable, IconTableColumn, IconTableRow, IconTableMergeCell } from 'ckeditor5/src/icons.js';
10
- import { addListToDropdown, createDropdown, ViewModel, SplitButtonView, SwitchButtonView, MenuBarMenuView } from 'ckeditor5/src/ui.js';
10
+ import { addListToDropdown, createDropdown, UIModel, SplitButtonView, SwitchButtonView, MenuBarMenuView } from 'ckeditor5/src/ui.js';
11
11
  import { Collection } from 'ckeditor5/src/utils.js';
12
- import InsertTableView from './ui/inserttableview.js';
12
+ import { InsertTableView } from './ui/inserttableview.js';
13
13
  /**
14
14
  * The table UI plugin. It introduces:
15
15
  *
@@ -21,7 +21,7 @@ import InsertTableView from './ui/inserttableview.js';
21
21
  *
22
22
  * The `'tableColumn'`, `'tableRow'` and `'mergeTableCells'` dropdowns work best with {@link module:table/tabletoolbar~TableToolbar}.
23
23
  */
24
- export default class TableUI extends Plugin {
24
+ export class TableUI extends Plugin {
25
25
  /**
26
26
  * @inheritDoc
27
27
  */
@@ -318,7 +318,7 @@ export default class TableUI extends Plugin {
318
318
  */
319
319
  function addListOption(option, editor, commands, itemDefinitions) {
320
320
  if (option.type === 'button' || option.type === 'switchbutton') {
321
- const model = option.model = new ViewModel(option.model);
321
+ const model = option.model = new UIModel(option.model);
322
322
  const { commandName, bindIsOn } = option.model;
323
323
  const command = editor.commands.get(commandName);
324
324
  commands.push(command);
@@ -3,16 +3,16 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
5
  import { Plugin } from 'ckeditor5/src/core.js';
6
- import type { DocumentSelection, Element, Range, Selection, Writer } from 'ckeditor5/src/engine.js';
7
- import TableWalker, { type TableWalkerOptions } from './tablewalker.js';
8
- type IndexesObject = {
6
+ import type { ModelDocumentSelection, ModelElement, ModelRange, ModelSelection, ModelWriter } from 'ckeditor5/src/engine.js';
7
+ import { TableWalker, type TableWalkerOptions } from './tablewalker.js';
8
+ export type TableIndexesObject = {
9
9
  first: number;
10
10
  last: number;
11
11
  };
12
12
  /**
13
13
  * The table utilities plugin.
14
14
  */
15
- export default class TableUtils extends Plugin {
15
+ export declare class TableUtils extends Plugin {
16
16
  /**
17
17
  * @inheritDoc
18
18
  */
@@ -53,7 +53,7 @@ export default class TableUtils extends Plugin {
53
53
  *
54
54
  * @returns Returns a `{row, column}` object.
55
55
  */
56
- getCellLocation(tableCell: Element): {
56
+ getCellLocation(tableCell: ModelElement): {
57
57
  row: number;
58
58
  column: number;
59
59
  };
@@ -78,12 +78,12 @@ export default class TableUtils extends Plugin {
78
78
  * @param options.headingColumns The number of heading columns. Default value is 0.
79
79
  * @returns The created table element.
80
80
  */
81
- createTable(writer: Writer, options: {
81
+ createTable(writer: ModelWriter, options: {
82
82
  rows?: number;
83
83
  columns?: number;
84
84
  headingRows?: number;
85
85
  headingColumns?: number;
86
- }): Element;
86
+ }): ModelElement;
87
87
  /**
88
88
  * Inserts rows into a table.
89
89
  *
@@ -112,7 +112,7 @@ export default class TableUtils extends Plugin {
112
112
  * @param options.copyStructureFromAbove The flag for copying row structure. Note that
113
113
  * the row structure will not be copied if this option is not provided.
114
114
  */
115
- insertRows(table: Element, options?: {
115
+ insertRows(table: ModelElement, options?: {
116
116
  at?: number;
117
117
  rows?: number;
118
118
  copyStructureFromAbove?: boolean;
@@ -144,7 +144,7 @@ export default class TableUtils extends Plugin {
144
144
  * @param options.at The column index at which the columns will be inserted. Default value is 0.
145
145
  * @param options.columns The number of columns to insert. Default value is 1.
146
146
  */
147
- insertColumns(table: Element, options?: {
147
+ insertColumns(table: ModelElement, options?: {
148
148
  at?: number;
149
149
  columns?: number;
150
150
  }): void;
@@ -176,7 +176,7 @@ export default class TableUtils extends Plugin {
176
176
  * @param options.at The row index at which the removing rows will start.
177
177
  * @param options.rows The number of rows to remove. Default value is 1.
178
178
  */
179
- removeRows(table: Element, options: {
179
+ removeRows(table: ModelElement, options: {
180
180
  at: number;
181
181
  rows?: number;
182
182
  }): void;
@@ -209,7 +209,7 @@ export default class TableUtils extends Plugin {
209
209
  * @param options.at The row index at which the removing columns will start.
210
210
  * @param options.columns The number of columns to remove.
211
211
  */
212
- removeColumns(table: Element, options: {
212
+ removeColumns(table: ModelElement, options: {
213
213
  at: number;
214
214
  columns?: number;
215
215
  }): void;
@@ -254,7 +254,7 @@ export default class TableUtils extends Plugin {
254
254
  * | b | c | d |
255
255
  * +---+---+---+
256
256
  */
257
- splitCellVertically(tableCell: Element, numberOfCells?: number): void;
257
+ splitCellVertically(tableCell: ModelElement, numberOfCells?: number): void;
258
258
  /**
259
259
  * Divides a table cell horizontally into several ones.
260
260
  *
@@ -308,7 +308,7 @@ export default class TableUtils extends Plugin {
308
308
  * | | h | i |
309
309
  * +---+---+---+
310
310
  */
311
- splitCellHorizontally(tableCell: Element, numberOfCells?: number): void;
311
+ splitCellHorizontally(tableCell: ModelElement, numberOfCells?: number): void;
312
312
  /**
313
313
  * Returns the number of columns for a given table.
314
314
  *
@@ -318,7 +318,7 @@ export default class TableUtils extends Plugin {
318
318
  *
319
319
  * @param table The table to analyze.
320
320
  */
321
- getColumns(table: Element): number;
321
+ getColumns(table: ModelElement): number;
322
322
  /**
323
323
  * Returns the number of rows for a given table. Any other element present in the table model is omitted.
324
324
  *
@@ -328,7 +328,7 @@ export default class TableUtils extends Plugin {
328
328
  *
329
329
  * @param table The table to analyze.
330
330
  */
331
- getRows(table: Element): number;
331
+ getRows(table: ModelElement): number;
332
332
  /**
333
333
  * Creates an instance of the table walker.
334
334
  *
@@ -341,7 +341,7 @@ export default class TableUtils extends Plugin {
341
341
  * @param table A table over which the walker iterates.
342
342
  * @param options An object with configuration.
343
343
  */
344
- createTableWalker(table: Element, options?: TableWalkerOptions): TableWalker;
344
+ createTableWalker(table: ModelElement, options?: TableWalkerOptions): TableWalker;
345
345
  /**
346
346
  * Returns all model table cells that are fully selected (from the outside)
347
347
  * within the provided model selection's ranges.
@@ -349,24 +349,24 @@ export default class TableUtils extends Plugin {
349
349
  * To obtain the cells selected from the inside, use
350
350
  * {@link #getTableCellsContainingSelection}.
351
351
  */
352
- getSelectedTableCells(selection: Selection | DocumentSelection): Array<Element>;
352
+ getSelectedTableCells(selection: ModelSelection | ModelDocumentSelection): Array<ModelElement>;
353
353
  /**
354
354
  * Returns all model table cells that the provided model selection's ranges
355
- * {@link module:engine/model/range~Range#start} inside.
355
+ * {@link module:engine/model/range~ModelRange#start} inside.
356
356
  *
357
357
  * To obtain the cells selected from the outside, use
358
358
  * {@link #getSelectedTableCells}.
359
359
  */
360
- getTableCellsContainingSelection(selection: Selection | DocumentSelection): Array<Element>;
360
+ getTableCellsContainingSelection(selection: ModelSelection | ModelDocumentSelection): Array<ModelElement>;
361
361
  /**
362
362
  * Returns all model table cells that are either completely selected
363
363
  * by selection ranges or host selection range
364
- * {@link module:engine/model/range~Range#start start positions} inside them.
364
+ * {@link module:engine/model/range~ModelRange#start start positions} inside them.
365
365
  *
366
366
  * Combines {@link #getTableCellsContainingSelection} and
367
367
  * {@link #getSelectedTableCells}.
368
368
  */
369
- getSelectionAffectedTableCells(selection: Selection | DocumentSelection): Array<Element>;
369
+ getSelectionAffectedTableCells(selection: ModelSelection | ModelDocumentSelection): Array<ModelElement>;
370
370
  /**
371
371
  * Returns an object with the `first` and `last` row index contained in the given `tableCells`.
372
372
  *
@@ -380,7 +380,7 @@ export default class TableUtils extends Plugin {
380
380
  *
381
381
  * @returns Returns an object with the `first` and `last` table row indexes.
382
382
  */
383
- getRowIndexes(tableCells: Array<Element>): IndexesObject;
383
+ getRowIndexes(tableCells: Array<ModelElement>): TableIndexesObject;
384
384
  /**
385
385
  * Returns an object with the `first` and `last` column index contained in the given `tableCells`.
386
386
  *
@@ -394,7 +394,7 @@ export default class TableUtils extends Plugin {
394
394
  *
395
395
  * @returns Returns an object with the `first` and `last` table column indexes.
396
396
  */
397
- getColumnIndexes(tableCells: Array<Element>): IndexesObject;
397
+ getColumnIndexes(tableCells: Array<ModelElement>): TableIndexesObject;
398
398
  /**
399
399
  * Checks if the selection contains cells that do not exceed rectangular selection.
400
400
  *
@@ -418,11 +418,11 @@ export default class TableUtils extends Plugin {
418
418
  * - a, c (the unselected cell "b" creates a gap)
419
419
  * - f, g, h (cell "d" spans over a cell from the row of "f" cell - thus creates a gap)
420
420
  */
421
- isSelectionRectangular(selectedTableCells: Array<Element>): boolean;
421
+ isSelectionRectangular(selectedTableCells: Array<ModelElement>): boolean;
422
422
  /**
423
423
  * Returns array of sorted ranges.
424
424
  */
425
- sortRanges(ranges: Iterable<Range>): Array<Range>;
425
+ sortRanges(ranges: Iterable<ModelRange>): Array<ModelRange>;
426
426
  /**
427
427
  * Helper method to get an object with `first` and `last` indexes from an unsorted array of indexes.
428
428
  */
@@ -449,4 +449,3 @@ export default class TableUtils extends Plugin {
449
449
  */
450
450
  private _areIndexesInSameSection;
451
451
  }
452
- export {};
package/src/tableutils.js CHANGED
@@ -7,14 +7,14 @@
7
7
  */
8
8
  import { CKEditorError } from 'ckeditor5/src/utils.js';
9
9
  import { Plugin } from 'ckeditor5/src/core.js';
10
- import TableWalker from './tablewalker.js';
10
+ import { TableWalker } from './tablewalker.js';
11
11
  import { createEmptyTableCell, updateNumericAttribute } from './utils/common.js';
12
12
  import { removeEmptyColumns, removeEmptyRows } from './utils/structure.js';
13
13
  import { getTableColumnElements } from './tablecolumnresize/utils.js';
14
14
  /**
15
15
  * The table utilities plugin.
16
16
  */
17
- export default class TableUtils extends Plugin {
17
+ export class TableUtils extends Plugin {
18
18
  /**
19
19
  * @inheritDoc
20
20
  */
@@ -730,7 +730,7 @@ export default class TableUtils extends Plugin {
730
730
  }
731
731
  /**
732
732
  * Returns all model table cells that the provided model selection's ranges
733
- * {@link module:engine/model/range~Range#start} inside.
733
+ * {@link module:engine/model/range~ModelRange#start} inside.
734
734
  *
735
735
  * To obtain the cells selected from the outside, use
736
736
  * {@link #getSelectedTableCells}.
@@ -748,7 +748,7 @@ export default class TableUtils extends Plugin {
748
748
  /**
749
749
  * Returns all model table cells that are either completely selected
750
750
  * by selection ranges or host selection range
751
- * {@link module:engine/model/range~Range#start start positions} inside them.
751
+ * {@link module:engine/model/range~ModelRange#start start positions} inside them.
752
752
  *
753
753
  * Combines {@link #getTableCellsContainingSelection} and
754
754
  * {@link #getSelectedTableCells}.