|
@@ -342,13 +342,17 @@ export function removeEmptyColumns( table, tableUtils ) {
|
|
|
return cellsCount ? result : [ ...result, column ];
|
|
return cellsCount ? result : [ ...result, column ];
|
|
|
}, [] );
|
|
}, [] );
|
|
|
|
|
|
|
|
- // @if CK_DEBUG_TABLE // emptyColumns.length > 0 && console.log( `Removing empty columns: ${ emptyColumns.join( ', ' ) }.` );
|
|
|
|
|
|
|
+ if ( emptyColumns.length > 0 ) {
|
|
|
|
|
+ // Remove only last empty column because it will recurrently trigger removing empty rows.
|
|
|
|
|
+ const emptyColumn = emptyColumns[ emptyColumns.length - 1 ];
|
|
|
|
|
|
|
|
- emptyColumns.reverse().forEach( column => {
|
|
|
|
|
- tableUtils.removeColumns( table, { at: column } );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ // @if CK_DEBUG_TABLE // console.log( `Removing empty column: ${ emptyColumn }.` );
|
|
|
|
|
+ tableUtils.removeColumns( table, { at: emptyColumn } );
|
|
|
|
|
|
|
|
- return emptyColumns.length > 0;
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -380,10 +384,9 @@ export function removeEmptyColumns( table, tableUtils ) {
|
|
|
* @protected
|
|
* @protected
|
|
|
* @param {module:engine/model/element~Element} table
|
|
* @param {module:engine/model/element~Element} table
|
|
|
* @param {module:table/tableutils~TableUtils} tableUtils
|
|
* @param {module:table/tableutils~TableUtils} tableUtils
|
|
|
- * @param {module:engine/model/batch~Batch|null} [batch] Batch that should be used for removing empty rows.
|
|
|
|
|
* @returns {Boolean} True if removed some rows.
|
|
* @returns {Boolean} True if removed some rows.
|
|
|
*/
|
|
*/
|
|
|
-export function removeEmptyRows( table, tableUtils, batch ) {
|
|
|
|
|
|
|
+export function removeEmptyRows( table, tableUtils ) {
|
|
|
const emptyRows = [];
|
|
const emptyRows = [];
|
|
|
|
|
|
|
|
for ( let rowIndex = 0; rowIndex < table.childCount; rowIndex++ ) {
|
|
for ( let rowIndex = 0; rowIndex < table.childCount; rowIndex++ ) {
|
|
@@ -394,13 +397,17 @@ export function removeEmptyRows( table, tableUtils, batch ) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // @if CK_DEBUG_TABLE // emptyRows.length > 0 && console.log( `Removing empty rows: ${ emptyRows.join( ', ' ) }.` );
|
|
|
|
|
|
|
+ if ( emptyRows.length > 0 ) {
|
|
|
|
|
+ // Remove only last empty row because it will recurrently trigger removing empty columns.
|
|
|
|
|
+ const emptyRow = emptyRows[ emptyRows.length - 1 ];
|
|
|
|
|
|
|
|
- emptyRows.reverse().forEach( row => {
|
|
|
|
|
- tableUtils.removeRows( table, { at: row, batch } );
|
|
|
|
|
- } );
|
|
|
|
|
|
|
+ // @if CK_DEBUG_TABLE // console.log( `Removing empty row: ${ emptyRow }.` );
|
|
|
|
|
+ tableUtils.removeRows( table, { at: emptyRow } );
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return emptyRows.length > 0;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -428,14 +435,13 @@ export function removeEmptyRows( table, tableUtils, batch ) {
|
|
|
* @protected
|
|
* @protected
|
|
|
* @param {module:engine/model/element~Element} table
|
|
* @param {module:engine/model/element~Element} table
|
|
|
* @param {module:table/tableutils~TableUtils} tableUtils
|
|
* @param {module:table/tableutils~TableUtils} tableUtils
|
|
|
- * @param {module:engine/model/batch~Batch|null} [batch] Batch that should be used for removing empty rows.
|
|
|
|
|
*/
|
|
*/
|
|
|
-export function removeEmptyRowsColumns( table, tableUtils, batch ) {
|
|
|
|
|
|
|
+export function removeEmptyRowsColumns( table, tableUtils ) {
|
|
|
const removedColumns = removeEmptyColumns( table, tableUtils );
|
|
const removedColumns = removeEmptyColumns( table, tableUtils );
|
|
|
|
|
|
|
|
// If there was some columns removed then cleaning empty rows was already triggered.
|
|
// If there was some columns removed then cleaning empty rows was already triggered.
|
|
|
if ( !removedColumns ) {
|
|
if ( !removedColumns ) {
|
|
|
- removeEmptyRows( table, tableUtils, batch );
|
|
|
|
|
|
|
+ removeEmptyRows( table, tableUtils );
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|