4
4
*/
5
5
6
6
/**
7
- * @module table/converters/table-post-fixer
7
+ * @module table/converters/table-layout- post-fixer
8
8
*/
9
9
10
10
import Position from '@ckeditor/ckeditor5-engine/src/model/position' ;
11
11
import { createEmptyTableCell , findAncestor , updateNumericAttribute } from './../commands/utils' ;
12
12
import TableWalker from './../tablewalker' ;
13
13
14
14
/**
15
- * Injects a table post-fixer into the model.
15
+ * Injects a table layout post-fixer into the model.
16
16
*
17
- * The role of the table post-fixer is to ensure that the table rows have the correct structure
17
+ * The role of the table layout post-fixer is to ensure that the table rows have the correct structure
18
18
* after a {@link module:engine/model/model~Model#change `change()`} block was executed.
19
19
*
20
20
* The correct structure means that:
21
21
*
22
22
* * All table rows have the same size.
23
23
* * None of a table cells that extend vertically beyond their section (either header or body).
24
+ * * A table cell has always at least one element as child.
24
25
*
25
26
* If the table structure is not correct, the post-fixer will automatically correct it in two steps:
26
27
*
@@ -35,12 +36,12 @@ import TableWalker from './../tablewalker';
35
36
*
36
37
* <table headingRows="1">
37
38
* <tableRow>
38
- * <tableCell rowspan="2">FOO</tableCell>
39
- * <tableCell colspan="2">BAR</tableCell>
39
+ * <tableCell rowspan="2"><paragraph> FOO</paragraph> </tableCell>
40
+ * <tableCell colspan="2"><paragraph> BAR</paragraph> </tableCell>
40
41
* </tableRow>
41
42
* <tableRow>
42
- * <tableCell>BAZ</tableCell>
43
- * <tableCell>XYZ</tableCell>
43
+ * <tableCell><paragraph> BAZ</paragraph> </tableCell>
44
+ * <tableCell><paragraph> XYZ</paragraph> </tableCell>
44
45
* </tableRow>
45
46
* </table>
46
47
*
@@ -55,8 +56,8 @@ import TableWalker from './../tablewalker';
55
56
* </thead>
56
57
* <tbody>
57
58
* <tr>
58
- * <td>BAZ<td>
59
- * <td>XYZ<td>
59
+ * <td>BAZ</ td>
60
+ * <td>XYZ</ td>
60
61
* </tr>
61
62
* </tbody>
62
63
* </table>
@@ -90,8 +91,8 @@ import TableWalker from './../tablewalker';
90
91
* </thead>
91
92
* <tbody>
92
93
* <tr>
93
- * <td>BAZ<td>
94
- * <td>XYZ<td>
94
+ * <td>BAZ</ td>
95
+ * <td>XYZ</ td>
95
96
* </tr>
96
97
* </tbody>
97
98
* </table>
@@ -113,8 +114,8 @@ import TableWalker from './../tablewalker';
113
114
* <td>12</td>
114
115
* </tr>
115
116
* <tr>
116
- * <td>21<td>
117
- * <td>22<td>
117
+ * <td>21</ td>
118
+ * <td>22</ td>
118
119
* </tr>
119
120
* </tbody>
120
121
* </table>
@@ -156,8 +157,8 @@ import TableWalker from './../tablewalker';
156
157
* <td>(empty, inserted by A)</td>
157
158
* </tr>
158
159
* <tr>
159
- * <td>21<td>
160
- * <td>22<td>
160
+ * <td>21</ td>
161
+ * <td>22</ td>
161
162
* <td>(empty, inserted by A)</td>
162
163
* </tr>
163
164
* <tr>
@@ -197,32 +198,31 @@ import TableWalker from './../tablewalker';
197
198
* <tr>
198
199
* <td>11</td>
199
200
* <td>12</td>
200
- * <td>(empty, inserted by a post-fixer after undo)<td>
201
+ * <td>(empty, inserted by a post-fixer after undo)</ td>
201
202
* </tr>
202
203
* <tr>
203
- * <td>21<td>
204
- * <td>22<td>
205
- * <td>(empty, inserted by a post-fixer after undo)<td>
204
+ * <td>21</ td>
205
+ * <td>22</ td>
206
+ * <td>(empty, inserted by a post-fixer after undo)</ td>
206
207
* </tr>
207
208
* <tr>
208
- * <td>(empty, inserted by B)<td>
209
- * <td>(empty, inserted by B)<td>
210
- * <td>(empty, inserted by a post-fixer)<td>
209
+ * <td>(empty, inserted by B)</ td>
210
+ * <td>(empty, inserted by B)</ td>
211
+ * <td>(empty, inserted by a post-fixer)</ td>
211
212
* </tr>
212
213
* </tbody>
213
214
* </table>
214
- *
215
215
* @param {module:engine/model/model~Model } model
216
216
*/
217
- export default function injectTablePostFixer ( model ) {
218
- model . document . registerPostFixer ( writer => tablePostFixer ( writer , model ) ) ;
217
+ export default function injectTableLayoutPostFixer ( model ) {
218
+ model . document . registerPostFixer ( writer => tableLayoutPostFixer ( writer , model ) ) ;
219
219
}
220
220
221
- // The table post-fixer.
221
+ // The table layout post-fixer.
222
222
//
223
223
// @param {module:engine/model/writer~Writer } writer
224
224
// @param {module:engine/model/model~Model } model
225
- function tablePostFixer ( writer , model ) {
225
+ function tableLayoutPostFixer ( writer , model ) {
226
226
const changes = model . document . differ . getChanges ( ) ;
227
227
228
228
let wasFixed = false ;
@@ -233,7 +233,6 @@ function tablePostFixer( writer, model ) {
233
233
for ( const entry of changes ) {
234
234
let table ;
235
235
236
- // Fix table on table insert.
237
236
if ( entry . name == 'table' && entry . type == 'insert' ) {
238
237
table = entry . position . nodeAfter ;
239
238
}
0 commit comments