@ckeditor/ckeditor5-table 36.0.0 → 37.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 (166) hide show
  1. package/build/table.js +1 -1
  2. package/package.json +34 -29
  3. package/src/commands/insertcolumncommand.d.ts +61 -0
  4. package/src/commands/insertcolumncommand.js +45 -60
  5. package/src/commands/insertrowcommand.d.ts +60 -0
  6. package/src/commands/insertrowcommand.js +44 -59
  7. package/src/commands/inserttablecommand.d.ts +50 -0
  8. package/src/commands/inserttablecommand.js +51 -68
  9. package/src/commands/mergecellcommand.d.ts +76 -0
  10. package/src/commands/mergecellcommand.js +169 -244
  11. package/src/commands/mergecellscommand.d.ts +33 -0
  12. package/src/commands/mergecellscommand.js +72 -101
  13. package/src/commands/removecolumncommand.d.ts +34 -0
  14. package/src/commands/removecolumncommand.js +88 -102
  15. package/src/commands/removerowcommand.d.ts +34 -0
  16. package/src/commands/removerowcommand.js +63 -80
  17. package/src/commands/selectcolumncommand.d.ts +38 -0
  18. package/src/commands/selectcolumncommand.js +41 -54
  19. package/src/commands/selectrowcommand.d.ts +38 -0
  20. package/src/commands/selectrowcommand.js +38 -48
  21. package/src/commands/setheadercolumncommand.d.ts +55 -0
  22. package/src/commands/setheadercolumncommand.js +48 -73
  23. package/src/commands/setheaderrowcommand.d.ts +58 -0
  24. package/src/commands/setheaderrowcommand.js +56 -85
  25. package/src/commands/splitcellcommand.d.ts +49 -0
  26. package/src/commands/splitcellcommand.js +35 -49
  27. package/src/converters/downcast.d.ts +63 -0
  28. package/src/converters/downcast.js +98 -130
  29. package/src/converters/table-caption-post-fixer.d.ts +20 -0
  30. package/src/converters/table-caption-post-fixer.js +36 -52
  31. package/src/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
  32. package/src/converters/table-cell-paragraph-post-fixer.js +88 -119
  33. package/src/converters/table-cell-refresh-handler.d.ts +18 -0
  34. package/src/converters/table-cell-refresh-handler.js +29 -48
  35. package/src/converters/table-headings-refresh-handler.d.ts +17 -0
  36. package/src/converters/table-headings-refresh-handler.js +35 -54
  37. package/src/converters/table-layout-post-fixer.d.ts +226 -0
  38. package/src/converters/table-layout-post-fixer.js +276 -313
  39. package/src/converters/tableproperties.d.ts +54 -0
  40. package/src/converters/tableproperties.js +136 -168
  41. package/src/converters/upcasttable.d.ts +49 -0
  42. package/src/converters/upcasttable.js +196 -251
  43. package/src/index.d.ts +29 -0
  44. package/src/index.js +0 -2
  45. package/src/plaintableoutput.d.ts +30 -0
  46. package/src/plaintableoutput.js +107 -135
  47. package/src/table.d.ts +38 -0
  48. package/src/table.js +12 -88
  49. package/src/tablecaption/tablecaptionediting.d.ts +68 -0
  50. package/src/tablecaption/tablecaptionediting.js +104 -135
  51. package/src/tablecaption/tablecaptionui.d.ts +26 -0
  52. package/src/tablecaption/tablecaptionui.js +42 -58
  53. package/src/tablecaption/toggletablecaptioncommand.d.ts +73 -0
  54. package/src/tablecaption/toggletablecaptioncommand.js +77 -92
  55. package/src/tablecaption/utils.d.ts +42 -0
  56. package/src/tablecaption/utils.js +35 -61
  57. package/src/tablecaption.d.ts +27 -0
  58. package/src/tablecaption.js +12 -19
  59. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +37 -0
  60. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +14 -20
  61. package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +42 -0
  62. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +27 -37
  63. package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +42 -0
  64. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +27 -37
  65. package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +56 -0
  66. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +42 -53
  67. package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +51 -0
  68. package/src/tablecellproperties/commands/tablecellheightcommand.js +29 -36
  69. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +37 -0
  70. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +14 -20
  71. package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +56 -0
  72. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +42 -53
  73. package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
  74. package/src/tablecellproperties/commands/tablecellpropertycommand.js +77 -122
  75. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +45 -0
  76. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +14 -20
  77. package/src/tablecellproperties/tablecellpropertiesediting.d.ts +47 -0
  78. package/src/tablecellproperties/tablecellpropertiesediting.js +194 -236
  79. package/src/tablecellproperties/tablecellpropertiesui.d.ts +117 -0
  80. package/src/tablecellproperties/tablecellpropertiesui.js +303 -456
  81. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +227 -0
  82. package/src/tablecellproperties/ui/tablecellpropertiesview.js +509 -844
  83. package/src/tablecellproperties.d.ts +33 -0
  84. package/src/tablecellproperties.js +12 -98
  85. package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +51 -0
  86. package/src/tablecellwidth/commands/tablecellwidthcommand.js +29 -35
  87. package/src/tablecellwidth/tablecellwidthediting.d.ts +34 -0
  88. package/src/tablecellwidth/tablecellwidthediting.js +26 -38
  89. package/src/tableclipboard.d.ts +68 -0
  90. package/src/tableclipboard.js +429 -568
  91. package/src/tablecolumnresize/constants.d.ts +20 -0
  92. package/src/tablecolumnresize/constants.js +0 -10
  93. package/src/tablecolumnresize/converters.d.ts +18 -0
  94. package/src/tablecolumnresize/converters.js +35 -119
  95. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +142 -0
  96. package/src/tablecolumnresize/tablecolumnresizeediting.js +545 -711
  97. package/src/tablecolumnresize/tablewidthscommand.d.ts +38 -0
  98. package/src/tablecolumnresize/tablewidthscommand.js +61 -0
  99. package/src/tablecolumnresize/utils.d.ts +141 -0
  100. package/src/tablecolumnresize/utils.js +256 -233
  101. package/src/tablecolumnresize.d.ts +29 -0
  102. package/src/tablecolumnresize.js +12 -19
  103. package/src/tableconfig.d.ts +341 -0
  104. package/src/tableconfig.js +5 -0
  105. package/src/tableediting.d.ts +102 -0
  106. package/src/tableediting.js +157 -176
  107. package/src/tablekeyboard.d.ts +68 -0
  108. package/src/tablekeyboard.js +261 -344
  109. package/src/tablemouse/mouseeventsobserver.d.ts +62 -0
  110. package/src/tablemouse/mouseeventsobserver.js +12 -49
  111. package/src/tablemouse.d.ts +51 -0
  112. package/src/tablemouse.js +154 -202
  113. package/src/tableproperties/commands/tablealignmentcommand.d.ts +37 -0
  114. package/src/tableproperties/commands/tablealignmentcommand.js +14 -20
  115. package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +37 -0
  116. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +14 -20
  117. package/src/tableproperties/commands/tablebordercolorcommand.d.ts +42 -0
  118. package/src/tableproperties/commands/tablebordercolorcommand.js +27 -37
  119. package/src/tableproperties/commands/tableborderstylecommand.d.ts +42 -0
  120. package/src/tableproperties/commands/tableborderstylecommand.js +27 -37
  121. package/src/tableproperties/commands/tableborderwidthcommand.d.ts +56 -0
  122. package/src/tableproperties/commands/tableborderwidthcommand.js +42 -53
  123. package/src/tableproperties/commands/tableheightcommand.d.ts +51 -0
  124. package/src/tableproperties/commands/tableheightcommand.js +29 -33
  125. package/src/tableproperties/commands/tablepropertycommand.d.ts +61 -0
  126. package/src/tableproperties/commands/tablepropertycommand.js +68 -112
  127. package/src/tableproperties/commands/tablewidthcommand.d.ts +51 -0
  128. package/src/tableproperties/commands/tablewidthcommand.js +29 -33
  129. package/src/tableproperties/tablepropertiesediting.d.ts +45 -0
  130. package/src/tableproperties/tablepropertiesediting.js +164 -210
  131. package/src/tableproperties/tablepropertiesui.d.ts +119 -0
  132. package/src/tableproperties/tablepropertiesui.js +294 -439
  133. package/src/tableproperties/ui/tablepropertiesview.d.ts +203 -0
  134. package/src/tableproperties/ui/tablepropertiesview.js +427 -718
  135. package/src/tableproperties.d.ts +33 -0
  136. package/src/tableproperties.js +12 -95
  137. package/src/tableselection.d.ts +111 -0
  138. package/src/tableselection.js +279 -376
  139. package/src/tabletoolbar.d.ts +37 -0
  140. package/src/tabletoolbar.js +39 -92
  141. package/src/tableui.d.ts +58 -0
  142. package/src/tableui.js +281 -338
  143. package/src/tableutils.d.ts +453 -0
  144. package/src/tableutils.js +1015 -1229
  145. package/src/tablewalker.d.ts +323 -0
  146. package/src/tablewalker.js +308 -548
  147. package/src/ui/colorinputview.d.ts +143 -0
  148. package/src/ui/colorinputview.js +229 -366
  149. package/src/ui/formrowview.d.ts +61 -0
  150. package/src/ui/formrowview.js +38 -84
  151. package/src/ui/inserttableview.d.ts +77 -0
  152. package/src/ui/inserttableview.js +152 -242
  153. package/src/utils/common.d.ts +42 -0
  154. package/src/utils/common.js +33 -57
  155. package/src/utils/structure.d.ts +245 -0
  156. package/src/utils/structure.js +261 -379
  157. package/src/utils/table-properties.d.ts +67 -0
  158. package/src/utils/table-properties.js +60 -81
  159. package/src/utils/ui/contextualballoon.d.ts +34 -0
  160. package/src/utils/ui/contextualballoon.js +70 -89
  161. package/src/utils/ui/table-properties.d.ts +193 -0
  162. package/src/utils/ui/table-properties.js +259 -319
  163. package/src/utils/ui/widget.d.ts +16 -0
  164. package/src/utils/ui/widget.js +24 -46
  165. package/src/tablecolumnresize/tablecolumnwidthscommand.js +0 -55
  166. package/src/tablecolumnresize/tablewidthresizecommand.js +0 -65
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module table/converters/tableproperites
7
+ */
8
+ import type { Conversion, ViewElement } from 'ckeditor5/src/engine';
9
+ /**
10
+ * Conversion helper for upcasting attributes using normalized styles.
11
+ *
12
+ * @param options.modelAttribute The attribute to set.
13
+ * @param options.styleName The style name to convert.
14
+ * @param options.viewElement The view element name that should be converted.
15
+ * @param options.defaultValue The default value for the specified `modelAttribute`.
16
+ * @param options.shouldUpcast The function which returns `true` if style should be upcasted from this element.
17
+ */
18
+ export declare function upcastStyleToAttribute(conversion: Conversion, options: {
19
+ modelAttribute: string;
20
+ styleName: string;
21
+ viewElement: string | RegExp;
22
+ defaultValue: string;
23
+ reduceBoxSides?: boolean;
24
+ shouldUpcast?: (viewElement: ViewElement) => boolean;
25
+ }): void;
26
+ export interface StyleValues {
27
+ color: string;
28
+ style: string;
29
+ width: string;
30
+ }
31
+ /**
32
+ * Conversion helper for upcasting border styles for view elements.
33
+ *
34
+ * @param defaultBorder The default border values.
35
+ * @param defaultBorder.color The default `borderColor` value.
36
+ * @param defaultBorder.style The default `borderStyle` value.
37
+ * @param defaultBorder.width The default `borderWidth` value.
38
+ */
39
+ export declare function upcastBorderStyles(conversion: Conversion, viewElementName: string, modelAttributes: StyleValues, defaultBorder: StyleValues): void;
40
+ /**
41
+ * Conversion helper for downcasting an attribute to a style.
42
+ */
43
+ export declare function downcastAttributeToStyle(conversion: Conversion, options: {
44
+ modelElement: string;
45
+ modelAttribute: string;
46
+ styleName: string;
47
+ }): void;
48
+ /**
49
+ * Conversion helper for downcasting attributes from the model table to a view table (not to `<figure>`).
50
+ */
51
+ export declare function downcastTableAttribute(conversion: Conversion, options: {
52
+ modelAttribute: string;
53
+ styleName: string;
54
+ }): void;
@@ -2,190 +2,158 @@
2
2
  * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
- /**
7
- * @module table/converters/tableproperites
8
- */
9
-
10
5
  /**
11
6
  * Conversion helper for upcasting attributes using normalized styles.
12
7
  *
13
- * @param {module:engine/conversion/conversion~Conversion} conversion
14
- * @param {Object} options
15
- * @param {String} options.modelAttribute The attribute to set.
16
- * @param {String} options.styleName The style name to convert.
17
- * @param {String} options.viewElement The view element name that should be converted.
18
- * @param {String} options.defaultValue The default value for the specified `modelAttribute`.
19
- * @param {Boolean} [options.reduceBoxSides=false]
20
- * @param {Function} [options.shouldUpcast] The function which returns `true` if style should be upcasted from this element.
8
+ * @param options.modelAttribute The attribute to set.
9
+ * @param options.styleName The style name to convert.
10
+ * @param options.viewElement The view element name that should be converted.
11
+ * @param options.defaultValue The default value for the specified `modelAttribute`.
12
+ * @param options.shouldUpcast The function which returns `true` if style should be upcasted from this element.
21
13
  */
22
- export function upcastStyleToAttribute( conversion, options ) {
23
- const { viewElement, defaultValue, modelAttribute, styleName, reduceBoxSides = false, shouldUpcast = () => true } = options;
24
-
25
- conversion.for( 'upcast' ).attributeToAttribute( {
26
- view: {
27
- name: viewElement,
28
- styles: {
29
- [ styleName ]: /[\s\S]+/
30
- }
31
- },
32
- model: {
33
- key: modelAttribute,
34
- value: viewElement => {
35
- if ( !shouldUpcast( viewElement ) ) {
36
- return;
37
- }
38
-
39
- const normalized = viewElement.getNormalizedStyle( styleName );
40
- const value = reduceBoxSides ? reduceBoxSidesValue( normalized ) : normalized;
41
-
42
- if ( defaultValue !== value ) {
43
- return value;
44
- }
45
- }
46
- }
47
- } );
14
+ export function upcastStyleToAttribute(conversion, options) {
15
+ const { modelAttribute, styleName, viewElement, defaultValue, reduceBoxSides = false, shouldUpcast = () => true } = options;
16
+ conversion.for('upcast').attributeToAttribute({
17
+ view: {
18
+ name: viewElement,
19
+ styles: {
20
+ [styleName]: /[\s\S]+/
21
+ }
22
+ },
23
+ model: {
24
+ key: modelAttribute,
25
+ value: (viewElement) => {
26
+ if (!shouldUpcast(viewElement)) {
27
+ return;
28
+ }
29
+ const normalized = viewElement.getNormalizedStyle(styleName);
30
+ const value = reduceBoxSides ? reduceBoxSidesValue(normalized) : normalized;
31
+ if (defaultValue !== value) {
32
+ return value;
33
+ }
34
+ }
35
+ }
36
+ });
48
37
  }
49
-
50
38
  /**
51
39
  * Conversion helper for upcasting border styles for view elements.
52
40
  *
53
- * @param {module:engine/conversion/conversion~Conversion} conversion
54
- * @param {String} viewElementName
55
- * @param {Object} modelAttributes
56
- * @param {Object} defaultBorder The default border values.
57
- * @param {String} defaultBorder.color The default `borderColor` value.
58
- * @param {String} defaultBorder.style The default `borderStyle` value.
59
- * @param {String} defaultBorder.width The default `borderWidth` value.
41
+ * @param defaultBorder The default border values.
42
+ * @param defaultBorder.color The default `borderColor` value.
43
+ * @param defaultBorder.style The default `borderStyle` value.
44
+ * @param defaultBorder.width The default `borderWidth` value.
60
45
  */
61
- export function upcastBorderStyles( conversion, viewElementName, modelAttributes, defaultBorder ) {
62
- conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element:' + viewElementName, ( evt, data, conversionApi ) => {
63
- // If the element was not converted by element-to-element converter,
64
- // we should not try to convert the style. See #8393.
65
- if ( !data.modelRange ) {
66
- return;
67
- }
68
-
69
- // Check the most detailed properties. These will be always set directly or
70
- // when using the "group" properties like: `border-(top|right|bottom|left)` or `border`.
71
- const stylesToConsume = [
72
- 'border-top-width',
73
- 'border-top-color',
74
- 'border-top-style',
75
- 'border-bottom-width',
76
- 'border-bottom-color',
77
- 'border-bottom-style',
78
- 'border-right-width',
79
- 'border-right-color',
80
- 'border-right-style',
81
- 'border-left-width',
82
- 'border-left-color',
83
- 'border-left-style'
84
- ].filter( styleName => data.viewItem.hasStyle( styleName ) );
85
-
86
- if ( !stylesToConsume.length ) {
87
- return;
88
- }
89
-
90
- const matcherPattern = {
91
- styles: stylesToConsume
92
- };
93
-
94
- // Try to consume appropriate values from consumable values list.
95
- if ( !conversionApi.consumable.test( data.viewItem, matcherPattern ) ) {
96
- return;
97
- }
98
-
99
- const modelElement = [ ...data.modelRange.getItems( { shallow: true } ) ].pop();
100
-
101
- conversionApi.consumable.consume( data.viewItem, matcherPattern );
102
-
103
- const normalizedBorder = {
104
- style: data.viewItem.getNormalizedStyle( 'border-style' ),
105
- color: data.viewItem.getNormalizedStyle( 'border-color' ),
106
- width: data.viewItem.getNormalizedStyle( 'border-width' )
107
- };
108
-
109
- const reducedBorder = {
110
- style: reduceBoxSidesValue( normalizedBorder.style ),
111
- color: reduceBoxSidesValue( normalizedBorder.color ),
112
- width: reduceBoxSidesValue( normalizedBorder.width )
113
- };
114
-
115
- if ( reducedBorder.style !== defaultBorder.style ) {
116
- conversionApi.writer.setAttribute( modelAttributes.style, reducedBorder.style, modelElement );
117
- }
118
-
119
- if ( reducedBorder.color !== defaultBorder.color ) {
120
- conversionApi.writer.setAttribute( modelAttributes.color, reducedBorder.color, modelElement );
121
- }
122
-
123
- if ( reducedBorder.width !== defaultBorder.width ) {
124
- conversionApi.writer.setAttribute( modelAttributes.width, reducedBorder.width, modelElement );
125
- }
126
- } ) );
46
+ export function upcastBorderStyles(conversion, viewElementName, modelAttributes, defaultBorder) {
47
+ conversion.for('upcast').add(dispatcher => dispatcher.on('element:' + viewElementName, (evt, data, conversionApi) => {
48
+ // If the element was not converted by element-to-element converter,
49
+ // we should not try to convert the style. See #8393.
50
+ if (!data.modelRange) {
51
+ return;
52
+ }
53
+ // Check the most detailed properties. These will be always set directly or
54
+ // when using the "group" properties like: `border-(top|right|bottom|left)` or `border`.
55
+ const stylesToConsume = [
56
+ 'border-top-width',
57
+ 'border-top-color',
58
+ 'border-top-style',
59
+ 'border-bottom-width',
60
+ 'border-bottom-color',
61
+ 'border-bottom-style',
62
+ 'border-right-width',
63
+ 'border-right-color',
64
+ 'border-right-style',
65
+ 'border-left-width',
66
+ 'border-left-color',
67
+ 'border-left-style'
68
+ ].filter(styleName => data.viewItem.hasStyle(styleName));
69
+ if (!stylesToConsume.length) {
70
+ return;
71
+ }
72
+ const matcherPattern = {
73
+ styles: stylesToConsume
74
+ };
75
+ // Try to consume appropriate values from consumable values list.
76
+ if (!conversionApi.consumable.test(data.viewItem, matcherPattern)) {
77
+ return;
78
+ }
79
+ const modelElement = [...data.modelRange.getItems({ shallow: true })].pop();
80
+ conversionApi.consumable.consume(data.viewItem, matcherPattern);
81
+ const normalizedBorder = {
82
+ style: data.viewItem.getNormalizedStyle('border-style'),
83
+ color: data.viewItem.getNormalizedStyle('border-color'),
84
+ width: data.viewItem.getNormalizedStyle('border-width')
85
+ };
86
+ const reducedBorder = {
87
+ style: reduceBoxSidesValue(normalizedBorder.style),
88
+ color: reduceBoxSidesValue(normalizedBorder.color),
89
+ width: reduceBoxSidesValue(normalizedBorder.width)
90
+ };
91
+ if (reducedBorder.style !== defaultBorder.style) {
92
+ conversionApi.writer.setAttribute(modelAttributes.style, reducedBorder.style, modelElement);
93
+ }
94
+ if (reducedBorder.color !== defaultBorder.color) {
95
+ conversionApi.writer.setAttribute(modelAttributes.color, reducedBorder.color, modelElement);
96
+ }
97
+ if (reducedBorder.width !== defaultBorder.width) {
98
+ conversionApi.writer.setAttribute(modelAttributes.width, reducedBorder.width, modelElement);
99
+ }
100
+ }));
127
101
  }
128
-
129
102
  /**
130
103
  * Conversion helper for downcasting an attribute to a style.
131
- *
132
- * @param {module:engine/conversion/conversion~Conversion} conversion
133
- * @param {Object} options
134
- * @param {String} options.modelElement
135
- * @param {String} options.modelAttribute
136
- * @param {String} options.styleName
137
104
  */
138
- export function downcastAttributeToStyle( conversion, { modelElement, modelAttribute, styleName } ) {
139
- conversion.for( 'downcast' ).attributeToAttribute( {
140
- model: {
141
- name: modelElement,
142
- key: modelAttribute
143
- },
144
- view: modelAttributeValue => ( {
145
- key: 'style',
146
- value: {
147
- [ styleName ]: modelAttributeValue
148
- }
149
- } )
150
- } );
105
+ export function downcastAttributeToStyle(conversion, options) {
106
+ const { modelElement, modelAttribute, styleName } = options;
107
+ conversion.for('downcast').attributeToAttribute({
108
+ model: {
109
+ name: modelElement,
110
+ key: modelAttribute
111
+ },
112
+ view: modelAttributeValue => ({
113
+ key: 'style',
114
+ value: {
115
+ [styleName]: modelAttributeValue
116
+ }
117
+ })
118
+ });
151
119
  }
152
-
153
120
  /**
154
121
  * Conversion helper for downcasting attributes from the model table to a view table (not to `<figure>`).
155
- *
156
- * @param {module:engine/conversion/conversion~Conversion} conversion
157
- * @param {Object} options
158
- * @param {String} options.modelAttribute
159
- * @param {String} options.styleName
160
122
  */
161
- export function downcastTableAttribute( conversion, { modelAttribute, styleName } ) {
162
- conversion.for( 'downcast' ).add( dispatcher => dispatcher.on( `attribute:${ modelAttribute }:table`, ( evt, data, conversionApi ) => {
163
- const { item, attributeNewValue } = data;
164
- const { mapper, writer } = conversionApi;
165
-
166
- if ( !conversionApi.consumable.consume( data.item, evt.name ) ) {
167
- return;
168
- }
169
-
170
- const table = [ ...mapper.toViewElement( item ).getChildren() ].find( child => child.is( 'element', 'table' ) );
171
-
172
- if ( attributeNewValue ) {
173
- writer.setStyle( styleName, attributeNewValue, table );
174
- } else {
175
- writer.removeStyle( styleName, table );
176
- }
177
- } ) );
123
+ export function downcastTableAttribute(conversion, options) {
124
+ const { modelAttribute, styleName } = options;
125
+ conversion.for('downcast').add(dispatcher => dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi) => {
126
+ const { item, attributeNewValue } = data;
127
+ const { mapper, writer } = conversionApi;
128
+ if (!conversionApi.consumable.consume(data.item, evt.name)) {
129
+ return;
130
+ }
131
+ const table = [...mapper.toViewElement(item).getChildren()].find(child => child.is('element', 'table'));
132
+ if (attributeNewValue) {
133
+ writer.setStyle(styleName, attributeNewValue, table);
134
+ }
135
+ else {
136
+ writer.removeStyle(styleName, table);
137
+ }
138
+ }));
178
139
  }
179
-
180
- // Reduces the full top, right, bottom, left object to a single string if all sides are equal.
181
- function reduceBoxSidesValue( style ) {
182
- if ( !style ) {
183
- return;
184
- }
185
-
186
- const commonValue = [ 'top', 'right', 'bottom', 'left' ]
187
- .map( side => style[ side ] )
188
- .reduce( ( result, side ) => result == side ? result : null );
189
-
190
- return commonValue || style;
140
+ /**
141
+ * Reduces the full top, right, bottom, left object to a single string if all sides are equal.
142
+ * Returns original style otherwise.
143
+ */
144
+ function reduceBoxSidesValue(style) {
145
+ if (!style) {
146
+ return;
147
+ }
148
+ const sides = ['top', 'right', 'bottom', 'left'];
149
+ const allSidesDefined = sides.every(side => style[side]);
150
+ if (!allSidesDefined) {
151
+ return style;
152
+ }
153
+ const topSideStyle = style.top;
154
+ const allSidesEqual = sides.every(side => style[side] === topSideStyle);
155
+ if (!allSidesEqual) {
156
+ return style;
157
+ }
158
+ return topSideStyle;
191
159
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+ /**
6
+ * @module table/converters/upcasttable
7
+ */
8
+ import type { UpcastDispatcher } from 'ckeditor5/src/engine';
9
+ /**
10
+ * Returns a function that converts the table view representation:
11
+ *
12
+ * ```xml
13
+ * <figure class="table"><table>...</table></figure>
14
+ * ```
15
+ *
16
+ * to the model representation:
17
+ *
18
+ * ```xml
19
+ * <table></table>
20
+ * ```
21
+ */
22
+ export declare function upcastTableFigure(): (dispatcher: UpcastDispatcher) => void;
23
+ /**
24
+ * View table element to model table element conversion helper.
25
+ *
26
+ * This conversion helper converts the table element as well as table rows.
27
+ *
28
+ * @returns Conversion helper.
29
+ */
30
+ export default function upcastTable(): (dispatcher: UpcastDispatcher) => void;
31
+ /**
32
+ * A conversion helper that skips empty <tr> elements from upcasting at the beginning of the table.
33
+ *
34
+ * An empty row is considered a table model error but when handling clipboard data there could be rows that contain only row-spanned cells
35
+ * and empty TR-s are used to maintain the table structure (also {@link module:table/tablewalker~TableWalker} assumes that there are only
36
+ * rows that have related `tableRow` elements).
37
+ *
38
+ * *Note:* Only the first empty rows are removed because they have no meaning and it solves the issue
39
+ * of an improper table with all empty rows.
40
+ *
41
+ * @returns Conversion helper.
42
+ */
43
+ export declare function skipEmptyTableRow(): (dispatcher: UpcastDispatcher) => void;
44
+ /**
45
+ * A converter that ensures an empty paragraph is inserted in a table cell if no other content was converted.
46
+ *
47
+ * @returns Conversion helper.
48
+ */
49
+ export declare function ensureParagraphInTableCell(elementName: string): (dispatcher: UpcastDispatcher) => void;