@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-table",
3
- "version": "42.0.2",
3
+ "version": "43.0.0-alpha.0",
4
4
  "description": "Table feature for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -13,13 +13,13 @@
13
13
  "type": "module",
14
14
  "main": "src/index.js",
15
15
  "dependencies": {
16
- "ckeditor5": "42.0.2",
17
- "@ckeditor/ckeditor5-clipboard": "42.0.2",
18
- "@ckeditor/ckeditor5-core": "42.0.2",
19
- "@ckeditor/ckeditor5-engine": "42.0.2",
20
- "@ckeditor/ckeditor5-ui": "42.0.2",
21
- "@ckeditor/ckeditor5-utils": "42.0.2",
22
- "@ckeditor/ckeditor5-widget": "42.0.2",
16
+ "ckeditor5": "43.0.0-alpha.0",
17
+ "@ckeditor/ckeditor5-clipboard": "43.0.0-alpha.0",
18
+ "@ckeditor/ckeditor5-core": "43.0.0-alpha.0",
19
+ "@ckeditor/ckeditor5-engine": "43.0.0-alpha.0",
20
+ "@ckeditor/ckeditor5-ui": "43.0.0-alpha.0",
21
+ "@ckeditor/ckeditor5-utils": "43.0.0-alpha.0",
22
+ "@ckeditor/ckeditor5-widget": "43.0.0-alpha.0",
23
23
  "lodash-es": "4.17.21"
24
24
  },
25
25
  "author": "CKSource (http://cksource.com/)",
@@ -167,14 +167,7 @@ export default class TableCellPropertiesView extends View {
167
167
  });
168
168
  // Maintain continuous focus cycling over views that have focusable children and focus cyclers themselves.
169
169
  [this.borderColorInput, this.backgroundInput].forEach(view => {
170
- view.fieldView.focusCycler.on('forwardCycle', evt => {
171
- this._focusCycler.focusNext();
172
- evt.stop();
173
- });
174
- view.fieldView.focusCycler.on('backwardCycle', evt => {
175
- this._focusCycler.focusPrevious();
176
- evt.stop();
177
- });
170
+ this._focusCycler.chain(view.fieldView.focusCycler);
178
171
  });
179
172
  [
180
173
  this.borderStyleDropdown,
@@ -149,14 +149,7 @@ export default class TablePropertiesView extends View {
149
149
  });
150
150
  // Maintain continuous focus cycling over views that have focusable children and focus cyclers themselves.
151
151
  [this.borderColorInput, this.backgroundInput].forEach(view => {
152
- view.fieldView.focusCycler.on('forwardCycle', evt => {
153
- this._focusCycler.focusNext();
154
- evt.stop();
155
- });
156
- view.fieldView.focusCycler.on('backwardCycle', evt => {
157
- this._focusCycler.focusPrevious();
158
- evt.stop();
159
- });
152
+ this._focusCycler.chain(view.fieldView.focusCycler);
160
153
  });
161
154
  [
162
155
  this.borderStyleDropdown,
package/src/tableutils.js CHANGED
@@ -595,6 +595,11 @@ export default class TableUtils extends Plugin {
595
595
  if (colspan > 1) {
596
596
  newCellsAttributes.colspan = colspan;
597
597
  }
598
+ // Accumulator that stores distance from the last inserted cell span.
599
+ // It helps with evenly splitting larger cell spans (for example 10 cells collapsing into 3 cells).
600
+ // We split these cells into 3, 3, 4 cells and we have to call `createCells` only when distance between
601
+ // these cells is equal or greater than the new cells span size.
602
+ let distanceFromLastCellSpan = 0;
598
603
  for (const tableSlot of tableMap) {
599
604
  const { column, row } = tableSlot;
600
605
  // As both newly created cells and the split cell might have rowspan,
@@ -604,10 +609,17 @@ export default class TableUtils extends Plugin {
604
609
  const isAfterSplitCell = row >= splitCellRow + updatedSpan;
605
610
  // 2. Is on the same column.
606
611
  const isOnSameColumn = column === cellColumn;
607
- // 3. And it's row index is after previous cell height.
608
- const isInEvenlySplitRow = (row + splitCellRow + updatedSpan) % newCellsSpan === 0;
609
- if (isAfterSplitCell && isOnSameColumn && isInEvenlySplitRow) {
610
- createCells(1, writer, tableSlot.getPositionBefore(), newCellsAttributes);
612
+ // Reset distance from the last cell span if we are on the same column and we exceeded the new cells span size.
613
+ if (distanceFromLastCellSpan >= newCellsSpan && isOnSameColumn) {
614
+ distanceFromLastCellSpan = 0;
615
+ }
616
+ if (isAfterSplitCell && isOnSameColumn) {
617
+ // Create new cells only if the distance from the last cell span is equal or greater than the new cells span.
618
+ if (!distanceFromLastCellSpan) {
619
+ createCells(1, writer, tableSlot.getPositionBefore(), newCellsAttributes);
620
+ }
621
+ // Increase the distance from the last cell span.
622
+ distanceFromLastCellSpan++;
611
623
  }
612
624
  }
613
625
  }