|
|
@@ -19,19 +19,19 @@ import TableWalker from './../tablewalker';
|
|
|
* The correct structure means that:
|
|
|
*
|
|
|
* * All table rows have the same size.
|
|
|
- * * None of a table cells that extend vertically beyond their section (either header or body).
|
|
|
- * * A table cell has always at least one element as child.
|
|
|
+ * * None of the table cells extend vertically beyond their section (either header or body).
|
|
|
+ * * A table cell has always at least one element as a child.
|
|
|
*
|
|
|
* If the table structure is not correct, the post-fixer will automatically correct it in two steps:
|
|
|
*
|
|
|
- * 1. It will clip table cells that extends beyond it section.
|
|
|
- * 2. It will add empty table cells to those rows which are narrower then the widest table row.
|
|
|
+ * 1. It will clip table cells that extend beyond their section.
|
|
|
+ * 2. It will add empty table cells to the rows that are narrower than the widest table row.
|
|
|
*
|
|
|
* ## Clipping overlapping table cells
|
|
|
*
|
|
|
- * Such situation may occur when pasting a table (or part of a table) to the editor from external sources.
|
|
|
+ * Such situation may occur when pasting a table (or a part of a table) to the editor from external sources.
|
|
|
*
|
|
|
- * For example, see the following table which has the cell (FOO) with the rowspan attribute (2):
|
|
|
+ * For example, see the following table which has a cell (FOO) with the rowspan attribute (2):
|
|
|
*
|
|
|
* <table headingRows="1">
|
|
|
* <tableRow>
|
|
|
@@ -44,7 +44,7 @@ import TableWalker from './../tablewalker';
|
|
|
* </tableRow>
|
|
|
* </table>
|
|
|
*
|
|
|
- * will be rendered in the view as:
|
|
|
+ * It will be rendered in the view as:
|
|
|
*
|
|
|
* <table>
|
|
|
* <thead>
|
|
|
@@ -61,22 +61,22 @@ import TableWalker from './../tablewalker';
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * In the above example the table will be rendered as a table with two rows - one in the header and second one in the body.
|
|
|
- * The table cell (FOO) cannot span over multiple rows as it would expand from the header to the body section.
|
|
|
- * The `rowspan` attribute must be changed to (1). The value (1) is a default value of the `rowspan` attribute
|
|
|
+ * In the above example the table will be rendered as a table with two rows: one in the header and second one in the body.
|
|
|
+ * The table cell (FOO) cannot span over multiple rows as it would extend from the header to the body section.
|
|
|
+ * The `rowspan` attribute must be changed to (1). The value (1) is the default value of the `rowspan` attribute
|
|
|
* so the `rowspan` attribute will be removed from the model.
|
|
|
*
|
|
|
- * The table cell with BAZ contents will be in the first column of the table.
|
|
|
+ * The table cell with BAZ in the content will be in the first column of the table.
|
|
|
*
|
|
|
* ## Adding missing table cells
|
|
|
*
|
|
|
- * The table post-fixer will insert empty table cells to equalize table rows sizes (number of columns).
|
|
|
- * The size of a table row is calculated by counting column spans of table cells - both horizontal (from the same row) and
|
|
|
- * vertical (from rows above).
|
|
|
+ * The table post-fixer will insert empty table cells to equalize table row sizes (the number of columns).
|
|
|
+ * The size of a table row is calculated by counting column spans of table cells, both horizontal (from the same row) and
|
|
|
+ * vertical (from the rows above).
|
|
|
*
|
|
|
- * In the above example, the table row in the body section of the table is narrower then the row from the header - it has two cells
|
|
|
- * with the default colspan (1). The header row has one cell with colspan (1) and second with colspan (2).
|
|
|
- * The table cell (FOO) does not expand beyond the head section (and as such will be fixed in the first step of this post-fixer).
|
|
|
+ * In the above example, the table row in the body section of the table is narrower then the row from the header: it has two cells
|
|
|
+ * with the default colspan (1). The header row has one cell with colspan (1) and the second with colspan (2).
|
|
|
+ * The table cell (FOO) does not extend beyond the head section (and as such will be fixed in the first step of this post-fixer).
|
|
|
* The post-fixer will add a missing table cell to the row in the body section of the table.
|
|
|
*
|
|
|
* The table from the above example will be fixed and rendered to the view as below:
|
|
|
@@ -96,15 +96,15 @@ import TableWalker from './../tablewalker';
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * ## Collaboration & Undo - Expectations vs post-fixer results
|
|
|
+ * ## Collaboration and undo - Expectations vs post-fixer results
|
|
|
*
|
|
|
- * The table post-fixer only ensures proper structure without deeper analysis of the nature of a change. As such, it might lead
|
|
|
- * to a structure which was not intended by the user changes. In particular, it will also fix undo steps (in conjunction with collaboration)
|
|
|
- * in which editor content might not return to the original state.
|
|
|
+ * The table post-fixer only ensures proper structure without a deeper analysis of the nature of the change. As such, it might lead
|
|
|
+ * to a structure which was not intended by the user. In particular, it will also fix undo steps (in conjunction with collaboration)
|
|
|
+ * in which the editor content might not return to the original state.
|
|
|
*
|
|
|
- * This will usually happen when one or more users changes size of the table.
|
|
|
+ * This will usually happen when one or more users change the size of the table.
|
|
|
*
|
|
|
- * As en example see a table below:
|
|
|
+ * As an example see the table below:
|
|
|
*
|
|
|
* <table>
|
|
|
* <tbody>
|
|
|
@@ -119,11 +119,11 @@ import TableWalker from './../tablewalker';
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * and user actions:
|
|
|
+ * and the user actions:
|
|
|
*
|
|
|
- * 1. Both user have table with two rows and two columns.
|
|
|
- * 2. User A adds a column at the end of the table - this will insert empty table cells to two rows.
|
|
|
- * 3. User B adds a row at the end of the table- this will insert a row with two empty table cells.
|
|
|
+ * 1. Both users have a table with two rows and two columns.
|
|
|
+ * 2. User A adds a column at the end of the table. This will insert empty table cells to two rows.
|
|
|
+ * 3. User B adds a row at the end of the table. This will insert a row with two empty table cells.
|
|
|
* 4. Both users will have a table as below:
|
|
|
*
|
|
|
*
|
|
|
@@ -146,7 +146,7 @@ import TableWalker from './../tablewalker';
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * The last row is shorter then others so table post-fixer will add empty row to tha last row:
|
|
|
+ * The last row is shorter then others so the table post-fixer will add an empty row to the last row:
|
|
|
*
|
|
|
* <table>
|
|
|
* <tbody>
|
|
|
@@ -163,14 +163,14 @@ import TableWalker from './../tablewalker';
|
|
|
* <tr>
|
|
|
* <td>(empty, inserted by B)</td>
|
|
|
* <td>(empty, inserted by B)</td>
|
|
|
- * <td>(empty, inserted by a post-fixer)</td>
|
|
|
+ * <td>(empty, inserted by the post-fixer)</td>
|
|
|
* </tr>
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * Unfortunately undo doesn't know the nature of changes and depending which user will apply post-fixer changes undoing them might lead to
|
|
|
- * broken table. If User B will undo inserting column to a table the undo engine will undo only operations of
|
|
|
- * inserting empty cells to rows from initial table state (row 1 & 2) but the cell in post-fixed row will remain:
|
|
|
+ * Unfortunately undo does not know the nature of the changes and depending on which user applies the post-fixer changes, undoing them
|
|
|
+ * might lead to a broken table. If User B undoes inserting the column to the table, the undo engine will undo only the operations of
|
|
|
+ * inserting empty cells to rows from the initial table state (row 1 and 2) but the cell in the post-fixed row will remain:
|
|
|
*
|
|
|
* <table>
|
|
|
* <tbody>
|
|
|
@@ -190,7 +190,7 @@ import TableWalker from './../tablewalker';
|
|
|
* </tbody>
|
|
|
* </table>
|
|
|
*
|
|
|
- * After undo the table post-fixer will detect that two rows are shorter then other and will fix table to:
|
|
|
+ * After undo, the table post-fixer will detect that two rows are shorter than others and will fix the table to:
|
|
|
*
|
|
|
* <table>
|
|
|
* <tbody>
|
|
|
@@ -260,11 +260,11 @@ function tableLayoutPostFixer( writer, model ) {
|
|
|
return wasFixed;
|
|
|
}
|
|
|
|
|
|
-// Fixes the invalid value of the rowspan attribute because a table cell cannot vertically extend beyond the table section it belongs to.
|
|
|
+// Fixes the invalid value of the `rowspan` attribute because a table cell cannot vertically extend beyond the table section it belongs to.
|
|
|
//
|
|
|
// @param {module:engine/model/element~Element} table
|
|
|
// @param {module:engine/model/writer~Writer} writer
|
|
|
-// @returns {Boolean} Returns true if table was fixed.
|
|
|
+// @returns {Boolean} Returns `true` if the table was fixed.
|
|
|
function fixTableCellsRowspan( table, writer ) {
|
|
|
let wasFixed = false;
|
|
|
|
|
|
@@ -285,7 +285,7 @@ function fixTableCellsRowspan( table, writer ) {
|
|
|
//
|
|
|
// @param {module:engine/model/element~Element} table
|
|
|
// @param {module:engine/model/writer~Writer} writer
|
|
|
-// @returns {Boolean} Returns true if table was fixed.
|
|
|
+// @returns {Boolean} Returns `true` if the table was fixed.
|
|
|
function fixTableRowsSizes( table, writer ) {
|
|
|
let wasFixed = false;
|
|
|
|
|
|
@@ -313,8 +313,8 @@ function fixTableRowsSizes( table, writer ) {
|
|
|
return wasFixed;
|
|
|
}
|
|
|
|
|
|
-// Searches for the table cells that extends beyond the table section to which they belong to. It will return an array of objects
|
|
|
-// that holds table cells to be trimmed and correct value of a rowspan attribute to set.
|
|
|
+// Searches for table cells that extend beyond the table section to which they belong to. It will return an array of objects
|
|
|
+// that stores table cells to be trimmed and the correct value of the `rowspan` attribute to set.
|
|
|
//
|
|
|
// @param {module:engine/model/element~Element} table
|
|
|
// @returns {Array.<{{cell, rowspan}}>}
|
|
|
@@ -364,7 +364,7 @@ function getRowsLengths( table ) {
|
|
|
return lengths;
|
|
|
}
|
|
|
|
|
|
-// Checks if the differ entry for an attribute change is one of table's attributes.
|
|
|
+// Checks if the differ entry for an attribute change is one of the table's attributes.
|
|
|
//
|
|
|
// @param entry
|
|
|
// @returns {Boolean}
|