@ckeditor/ckeditor5-table 42.0.2 → 43.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.
package/dist/index.js CHANGED
@@ -3140,6 +3140,11 @@ import { isObject, debounce, isEqual, throttle } from 'lodash-es';
3140
3140
  if (colspan > 1) {
3141
3141
  newCellsAttributes.colspan = colspan;
3142
3142
  }
3143
+ // Accumulator that stores distance from the last inserted cell span.
3144
+ // It helps with evenly splitting larger cell spans (for example 10 cells collapsing into 3 cells).
3145
+ // We split these cells into 3, 3, 4 cells and we have to call `createCells` only when distance between
3146
+ // these cells is equal or greater than the new cells span size.
3147
+ let distanceFromLastCellSpan = 0;
3143
3148
  for (const tableSlot of tableMap){
3144
3149
  const { column, row } = tableSlot;
3145
3150
  // As both newly created cells and the split cell might have rowspan,
@@ -3149,10 +3154,17 @@ import { isObject, debounce, isEqual, throttle } from 'lodash-es';
3149
3154
  const isAfterSplitCell = row >= splitCellRow + updatedSpan;
3150
3155
  // 2. Is on the same column.
3151
3156
  const isOnSameColumn = column === cellColumn;
3152
- // 3. And it's row index is after previous cell height.
3153
- const isInEvenlySplitRow = (row + splitCellRow + updatedSpan) % newCellsSpan === 0;
3154
- if (isAfterSplitCell && isOnSameColumn && isInEvenlySplitRow) {
3155
- createCells(1, writer, tableSlot.getPositionBefore(), newCellsAttributes);
3157
+ // Reset distance from the last cell span if we are on the same column and we exceeded the new cells span size.
3158
+ if (distanceFromLastCellSpan >= newCellsSpan && isOnSameColumn) {
3159
+ distanceFromLastCellSpan = 0;
3160
+ }
3161
+ if (isAfterSplitCell && isOnSameColumn) {
3162
+ // Create new cells only if the distance from the last cell span is equal or greater than the new cells span.
3163
+ if (!distanceFromLastCellSpan) {
3164
+ createCells(1, writer, tableSlot.getPositionBefore(), newCellsAttributes);
3165
+ }
3166
+ // Increase the distance from the last cell span.
3167
+ distanceFromLastCellSpan++;
3156
3168
  }
3157
3169
  }
3158
3170
  }
@@ -7384,14 +7396,7 @@ function colorConfigToColorGridDefinitions(colorConfig) {
7384
7396
  this.borderColorInput,
7385
7397
  this.backgroundInput
7386
7398
  ].forEach((view)=>{
7387
- view.fieldView.focusCycler.on('forwardCycle', (evt)=>{
7388
- this._focusCycler.focusNext();
7389
- evt.stop();
7390
- });
7391
- view.fieldView.focusCycler.on('backwardCycle', (evt)=>{
7392
- this._focusCycler.focusPrevious();
7393
- evt.stop();
7394
- });
7399
+ this._focusCycler.chain(view.fieldView.focusCycler);
7395
7400
  });
7396
7401
  [
7397
7402
  this.borderStyleDropdown,
@@ -9686,14 +9691,7 @@ const FLOAT_VALUES_REG_EXP = /^(left|none|right)$/;
9686
9691
  this.borderColorInput,
9687
9692
  this.backgroundInput
9688
9693
  ].forEach((view)=>{
9689
- view.fieldView.focusCycler.on('forwardCycle', (evt)=>{
9690
- this._focusCycler.focusNext();
9691
- evt.stop();
9692
- });
9693
- view.fieldView.focusCycler.on('backwardCycle', (evt)=>{
9694
- this._focusCycler.focusPrevious();
9695
- evt.stop();
9696
- });
9694
+ this._focusCycler.chain(view.fieldView.focusCycler);
9697
9695
  });
9698
9696
  [
9699
9697
  this.borderStyleDropdown,