@ckeditor/ckeditor5-table 48.4.0 → 48.5.0-alpha.1

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.
Files changed (151) hide show
  1. package/dist/index-editor.css.map +1 -1
  2. package/dist/index.js +110 -50
  3. package/dist/index.js.map +1 -1
  4. package/dist/tablecolumnresize/utils.d.ts +10 -1
  5. package/dist/translations/af.js +1 -1
  6. package/dist/translations/af.umd.js +5 -3
  7. package/dist/translations/ar.js +1 -1
  8. package/dist/translations/ar.umd.js +5 -3
  9. package/dist/translations/ast.js +1 -1
  10. package/dist/translations/ast.umd.js +5 -3
  11. package/dist/translations/az.js +1 -1
  12. package/dist/translations/az.umd.js +5 -3
  13. package/dist/translations/be.js +1 -1
  14. package/dist/translations/be.umd.js +5 -3
  15. package/dist/translations/bg.js +1 -1
  16. package/dist/translations/bg.umd.js +5 -3
  17. package/dist/translations/bn.js +1 -1
  18. package/dist/translations/bn.umd.js +5 -3
  19. package/dist/translations/bs.js +1 -1
  20. package/dist/translations/bs.umd.js +5 -3
  21. package/dist/translations/ca.js +1 -1
  22. package/dist/translations/ca.umd.js +5 -3
  23. package/dist/translations/cs.js +1 -1
  24. package/dist/translations/cs.umd.js +5 -3
  25. package/dist/translations/da.js +1 -1
  26. package/dist/translations/da.umd.js +5 -3
  27. package/dist/translations/de-ch.js +1 -1
  28. package/dist/translations/de-ch.umd.js +5 -3
  29. package/dist/translations/de.js +1 -1
  30. package/dist/translations/de.umd.js +5 -3
  31. package/dist/translations/el.js +1 -1
  32. package/dist/translations/el.umd.js +5 -3
  33. package/dist/translations/en-au.js +1 -1
  34. package/dist/translations/en-au.umd.js +5 -3
  35. package/dist/translations/en-gb.js +1 -1
  36. package/dist/translations/en-gb.umd.js +5 -3
  37. package/dist/translations/en.js +1 -1
  38. package/dist/translations/en.umd.js +5 -3
  39. package/dist/translations/eo.js +1 -1
  40. package/dist/translations/eo.umd.js +5 -3
  41. package/dist/translations/es-co.js +1 -1
  42. package/dist/translations/es-co.umd.js +5 -3
  43. package/dist/translations/es.js +1 -1
  44. package/dist/translations/es.umd.js +5 -3
  45. package/dist/translations/et.js +1 -1
  46. package/dist/translations/et.umd.js +5 -3
  47. package/dist/translations/eu.js +1 -1
  48. package/dist/translations/eu.umd.js +5 -3
  49. package/dist/translations/fa.js +1 -1
  50. package/dist/translations/fa.umd.js +5 -3
  51. package/dist/translations/fi.js +1 -1
  52. package/dist/translations/fi.umd.js +5 -3
  53. package/dist/translations/fr.js +1 -1
  54. package/dist/translations/fr.umd.js +5 -3
  55. package/dist/translations/gl.js +1 -1
  56. package/dist/translations/gl.umd.js +5 -3
  57. package/dist/translations/gu.js +1 -1
  58. package/dist/translations/gu.umd.js +5 -3
  59. package/dist/translations/he.js +1 -1
  60. package/dist/translations/he.umd.js +5 -3
  61. package/dist/translations/hi.js +1 -1
  62. package/dist/translations/hi.umd.js +5 -3
  63. package/dist/translations/hr.js +1 -1
  64. package/dist/translations/hr.umd.js +5 -3
  65. package/dist/translations/hu.js +1 -1
  66. package/dist/translations/hu.umd.js +5 -3
  67. package/dist/translations/hy.js +1 -1
  68. package/dist/translations/hy.umd.js +5 -3
  69. package/dist/translations/id.js +1 -1
  70. package/dist/translations/id.umd.js +5 -3
  71. package/dist/translations/it.js +1 -1
  72. package/dist/translations/it.umd.js +5 -3
  73. package/dist/translations/ja.js +1 -1
  74. package/dist/translations/ja.umd.js +5 -3
  75. package/dist/translations/jv.js +1 -1
  76. package/dist/translations/jv.umd.js +5 -3
  77. package/dist/translations/kk.js +1 -1
  78. package/dist/translations/kk.umd.js +5 -3
  79. package/dist/translations/km.js +1 -1
  80. package/dist/translations/km.umd.js +5 -3
  81. package/dist/translations/kn.js +1 -1
  82. package/dist/translations/kn.umd.js +5 -3
  83. package/dist/translations/ko.js +1 -1
  84. package/dist/translations/ko.umd.js +5 -3
  85. package/dist/translations/ku.js +1 -1
  86. package/dist/translations/ku.umd.js +5 -3
  87. package/dist/translations/lt.js +1 -1
  88. package/dist/translations/lt.umd.js +5 -3
  89. package/dist/translations/lv.js +1 -1
  90. package/dist/translations/lv.umd.js +5 -3
  91. package/dist/translations/ms.js +1 -1
  92. package/dist/translations/ms.umd.js +5 -3
  93. package/dist/translations/nb.js +1 -1
  94. package/dist/translations/nb.umd.js +5 -3
  95. package/dist/translations/ne.js +1 -1
  96. package/dist/translations/ne.umd.js +5 -3
  97. package/dist/translations/nl.js +1 -1
  98. package/dist/translations/nl.umd.js +5 -3
  99. package/dist/translations/no.js +1 -1
  100. package/dist/translations/no.umd.js +5 -3
  101. package/dist/translations/oc.js +1 -1
  102. package/dist/translations/oc.umd.js +5 -3
  103. package/dist/translations/pl.js +1 -1
  104. package/dist/translations/pl.umd.js +5 -3
  105. package/dist/translations/pt-br.js +1 -1
  106. package/dist/translations/pt-br.umd.js +5 -3
  107. package/dist/translations/pt.js +1 -1
  108. package/dist/translations/pt.umd.js +5 -3
  109. package/dist/translations/ro.js +1 -1
  110. package/dist/translations/ro.umd.js +5 -3
  111. package/dist/translations/ru.js +1 -1
  112. package/dist/translations/ru.umd.js +5 -3
  113. package/dist/translations/si.js +1 -1
  114. package/dist/translations/si.umd.js +5 -3
  115. package/dist/translations/sk.js +1 -1
  116. package/dist/translations/sk.umd.js +5 -3
  117. package/dist/translations/sl.js +1 -1
  118. package/dist/translations/sl.umd.js +5 -3
  119. package/dist/translations/sq.js +1 -1
  120. package/dist/translations/sq.umd.js +5 -3
  121. package/dist/translations/sr-latn.js +1 -1
  122. package/dist/translations/sr-latn.umd.js +5 -3
  123. package/dist/translations/sr.js +1 -1
  124. package/dist/translations/sr.umd.js +5 -3
  125. package/dist/translations/sv.js +1 -1
  126. package/dist/translations/sv.umd.js +5 -3
  127. package/dist/translations/th.js +1 -1
  128. package/dist/translations/th.umd.js +5 -3
  129. package/dist/translations/ti.js +1 -1
  130. package/dist/translations/ti.umd.js +5 -3
  131. package/dist/translations/tk.js +1 -1
  132. package/dist/translations/tk.umd.js +5 -3
  133. package/dist/translations/tr.js +1 -1
  134. package/dist/translations/tr.umd.js +5 -3
  135. package/dist/translations/tt.js +1 -1
  136. package/dist/translations/tt.umd.js +5 -3
  137. package/dist/translations/ug.js +1 -1
  138. package/dist/translations/ug.umd.js +5 -3
  139. package/dist/translations/uk.js +1 -1
  140. package/dist/translations/uk.umd.js +5 -3
  141. package/dist/translations/ur.js +1 -1
  142. package/dist/translations/ur.umd.js +5 -3
  143. package/dist/translations/uz.js +1 -1
  144. package/dist/translations/uz.umd.js +5 -3
  145. package/dist/translations/vi.js +1 -1
  146. package/dist/translations/vi.umd.js +5 -3
  147. package/dist/translations/zh-cn.js +1 -1
  148. package/dist/translations/zh-cn.umd.js +5 -3
  149. package/dist/translations/zh.js +1 -1
  150. package/dist/translations/zh.umd.js +5 -3
  151. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -960,7 +960,10 @@ function isEntireCellsLineHeader({ table, row, column }) {
960
960
  row,
961
961
  column
962
962
  });
963
- for (const { cell } of tableWalker) if (!isTableHeaderCellType(cell.getAttribute("tableCellType"))) return false;
963
+ for (const { cell } of tableWalker) {
964
+ const cellType = cell.getAttribute("tableCellType");
965
+ if (!isTableHeaderCellType(cellType)) return false;
966
+ }
964
967
  return true;
965
968
  }
966
969
  /**
@@ -1188,17 +1191,29 @@ function splitVertically(tableCell, columnIndex, splitColumn, writer) {
1188
1191
  function trimTableCellIfNeeded(tableCell, cellRow, cellColumn, limitRow, limitColumn, writer) {
1189
1192
  const colspan = parseInt(tableCell.getAttribute("colspan") || "1");
1190
1193
  const rowspan = parseInt(tableCell.getAttribute("rowspan") || "1");
1191
- if (cellColumn + colspan - 1 > limitColumn) updateNumericAttribute("colspan", limitColumn - cellColumn + 1, tableCell, writer, 1);
1192
- if (cellRow + rowspan - 1 > limitRow) updateNumericAttribute("rowspan", limitRow - cellRow + 1, tableCell, writer, 1);
1194
+ if (cellColumn + colspan - 1 > limitColumn) {
1195
+ const trimmedSpan = limitColumn - cellColumn + 1;
1196
+ updateNumericAttribute("colspan", trimmedSpan, tableCell, writer, 1);
1197
+ }
1198
+ if (cellRow + rowspan - 1 > limitRow) {
1199
+ const trimmedSpan = limitRow - cellRow + 1;
1200
+ updateNumericAttribute("rowspan", trimmedSpan, tableCell, writer, 1);
1201
+ }
1193
1202
  }
1194
1203
  /**
1195
1204
  * Sets proper heading attributes to a cropped table.
1196
1205
  */
1197
1206
  function addHeadingsToCroppedTable(croppedTable, sourceTable, startRow, startColumn, writer) {
1198
1207
  const headingRows = parseInt(sourceTable.getAttribute("headingRows") || "0");
1199
- if (headingRows > 0) updateNumericAttribute("headingRows", headingRows - startRow, croppedTable, writer, 0);
1208
+ if (headingRows > 0) {
1209
+ const headingRowsInCrop = headingRows - startRow;
1210
+ updateNumericAttribute("headingRows", headingRowsInCrop, croppedTable, writer, 0);
1211
+ }
1200
1212
  const headingColumns = parseInt(sourceTable.getAttribute("headingColumns") || "0");
1201
- if (headingColumns > 0) updateNumericAttribute("headingColumns", headingColumns - startColumn, croppedTable, writer, 0);
1213
+ if (headingColumns > 0) {
1214
+ const headingColumnsInCrop = headingColumns - startColumn;
1215
+ updateNumericAttribute("headingColumns", headingColumnsInCrop, croppedTable, writer, 0);
1216
+ }
1202
1217
  }
1203
1218
  /**
1204
1219
  * Sets footer row attributes to a cropped table.
@@ -1760,13 +1775,11 @@ function getChangedResizedTables(model) {
1760
1775
  case "remove":
1761
1776
  referencePosition = ["tableRow", "tableCell"].includes(change.name) ? change.position : null;
1762
1777
  break;
1763
- case "attribute":
1764
- if (change.range.start.nodeAfter) referencePosition = [
1765
- "table",
1766
- "tableRow",
1767
- "tableCell"
1768
- ].includes(change.range.start.nodeAfter.name) ? change.range.start : null;
1769
- break;
1778
+ case "attribute": if (change.range.start.nodeAfter) referencePosition = [
1779
+ "table",
1780
+ "tableRow",
1781
+ "tableCell"
1782
+ ].includes(change.range.start.nodeAfter.name) ? change.range.start : null;
1770
1783
  }
1771
1784
  if (!referencePosition) continue;
1772
1785
  const tableNode = referencePosition.nodeAfter && referencePosition.nodeAfter.is("element", "table") ? referencePosition.nodeAfter : referencePosition.findAncestor("table");
@@ -1824,14 +1837,29 @@ function getElementWidthInPixels(domElement) {
1824
1837
  else return parseFloat(styles.width);
1825
1838
  }
1826
1839
  /**
1840
+ * Returns the width (in pixels) of a given DOM element's content that's actually available to its children -
1841
+ * with the element's own vertical scrollbar subtracted where that's still needed.
1842
+ *
1843
+ * @internal
1844
+ * @param domElement A DOM element.
1845
+ * @returns The width available to the element's children, in pixels.
1846
+ */
1847
+ function getContainerContentWidth(domElement) {
1848
+ const styles = global.window.getComputedStyle(domElement);
1849
+ const width = getElementWidthInPixels(domElement);
1850
+ if (styles.boxSizing !== "border-box") return width;
1851
+ return width - Math.max(domElement.offsetWidth - domElement.clientWidth - parseFloat(styles.borderLeftWidth) - parseFloat(styles.borderRightWidth), 0);
1852
+ }
1853
+ /**
1827
1854
  * Returns the inner pixel width of a given editing root, or `null` if the root has no
1828
1855
  * DOM element attached yet (e.g. it hasn't been rendered for the first time).
1829
1856
  *
1830
1857
  * @internal
1831
1858
  */
1832
- function getEditableWidth(editor, rootName) {
1859
+ function getEditableContentWidth(editor, rootName) {
1833
1860
  const domRoot = editor.editing.view.getDomRoot(rootName);
1834
- return domRoot ? getElementWidthInPixels(domRoot) : null;
1861
+ if (!domRoot) return null;
1862
+ return getContainerContentWidth(domRoot);
1835
1863
  }
1836
1864
  /**
1837
1865
  * Returns the column indexes on the left and right edges of a cell. They differ if the cell spans
@@ -2122,7 +2150,8 @@ var TableUtils = class extends Plugin {
2122
2150
  getCellLocation(tableCell) {
2123
2151
  const tableRow = tableCell.parent;
2124
2152
  const table = tableRow.parent;
2125
- const tableWalker = new TableWalker(table, { row: table.getChildIndex(tableRow) });
2153
+ const rowIndex = table.getChildIndex(tableRow);
2154
+ const tableWalker = new TableWalker(table, { row: rowIndex });
2126
2155
  for (const { cell, row, column } of tableWalker) if (cell === tableCell) return {
2127
2156
  row,
2128
2157
  column
@@ -2907,7 +2936,8 @@ var TableUtils = class extends Plugin {
2907
2936
  * @returns Returns an object with the `first` and `last` table column indexes.
2908
2937
  */
2909
2938
  getColumnIndexes(tableCells) {
2910
- const indexes = [...new TableWalker(tableCells[0].findAncestor("table"))].filter((entry) => tableCells.includes(entry.cell)).map((entry) => entry.column);
2939
+ const table = tableCells[0].findAncestor("table");
2940
+ const indexes = [...new TableWalker(table)].filter((entry) => tableCells.includes(entry.cell)).map((entry) => entry.column);
2911
2941
  return this._getFirstLastIndexesObject(indexes);
2912
2942
  }
2913
2943
  /**
@@ -3079,7 +3109,10 @@ function adjustHeadingColumns(table, removedColumnIndexes, writer) {
3079
3109
  */
3080
3110
  function updateHeadingRows(table, { first, last }, writer) {
3081
3111
  const headingRows = table.getAttribute("headingRows") || 0;
3082
- if (first < headingRows) updateNumericAttribute("headingRows", last < headingRows ? headingRows - (last - first + 1) : first, table, writer, 0);
3112
+ if (first < headingRows) {
3113
+ const newRows = last < headingRows ? headingRows - (last - first + 1) : first;
3114
+ updateNumericAttribute("headingRows", newRows, table, writer, 0);
3115
+ }
3083
3116
  }
3084
3117
  /**
3085
3118
  * Calculates a new footer rows value for removing rows from footer section.
@@ -3088,7 +3121,10 @@ function updateFooterRows(table, totalRows, { first, last }, writer) {
3088
3121
  if (!table.hasAttribute("footerRows")) return;
3089
3122
  const footerRows = table.getAttribute("footerRows");
3090
3123
  const footerIndex = totalRows - footerRows;
3091
- if (last >= footerIndex) updateNumericAttribute("footerRows", first >= footerIndex ? footerRows - (last - first + 1) : totalRows - 1 - last, table, writer, 0);
3124
+ if (last >= footerIndex) {
3125
+ const newRows = first >= footerIndex ? footerRows - (last - first + 1) : totalRows - 1 - last;
3126
+ updateNumericAttribute("footerRows", newRows, table, writer, 0);
3127
+ }
3092
3128
  }
3093
3129
  /**
3094
3130
  * Finds cells that will be:
@@ -3341,10 +3377,14 @@ function downcastRow() {
3341
3377
  */
3342
3378
  function downcastCell(options) {
3343
3379
  return (tableCell, { writer }) => {
3344
- if (options.cellTypeEnabled?.()) return createCellElement(writer, isTableHeaderCellType(tableCell.getAttribute("tableCellType")) ? "th" : "td");
3380
+ if (options.cellTypeEnabled?.()) {
3381
+ const tableCellType = tableCell.getAttribute("tableCellType");
3382
+ return createCellElement(writer, isTableHeaderCellType(tableCellType) ? "th" : "td");
3383
+ }
3345
3384
  const tableRow = tableCell.parent;
3346
3385
  const table = tableRow.parent;
3347
- const tableWalker = new TableWalker(table, { row: table.getChildIndex(tableRow) });
3386
+ const rowIndex = table.getChildIndex(tableRow);
3387
+ const tableWalker = new TableWalker(table, { row: rowIndex });
3348
3388
  const headingRows = table.getAttribute("headingRows") || 0;
3349
3389
  const headingColumns = table.getAttribute("headingColumns") || 0;
3350
3390
  let result = null;
@@ -3884,7 +3924,8 @@ var MergeCellCommand = class extends Command {
3884
3924
  writer.setAttribute(spanAttribute, cellSpan + cellToMergeSpan, cellToExpand);
3885
3925
  writer.setSelection(writer.createRangeIn(cellToExpand));
3886
3926
  const tableUtils = this.editor.plugins.get("TableUtils");
3887
- removeEmptyRowsColumns(removedTableCellRow.findAncestor("table"), tableUtils);
3927
+ const table = removedTableCellRow.findAncestor("table");
3928
+ removeEmptyRowsColumns(table, tableUtils);
3888
3929
  });
3889
3930
  }
3890
3931
  /**
@@ -4386,7 +4427,8 @@ var MergeCellsCommand = class extends Command {
4386
4427
  updateNumericAttribute("colspan", mergeWidth, firstTableCell, writer);
4387
4428
  updateNumericAttribute("rowspan", mergeHeight, firstTableCell, writer);
4388
4429
  for (const tableCell of selectedTableCells) mergeTableCells(tableCell, firstTableCell, writer);
4389
- removeEmptyRowsColumns(firstTableCell.findAncestor("table"), tableUtils);
4430
+ const table = firstTableCell.findAncestor("table");
4431
+ removeEmptyRowsColumns(table, tableUtils);
4390
4432
  writer.setSelection(firstTableCell, "in");
4391
4433
  });
4392
4434
  }
@@ -5000,7 +5042,8 @@ function fixTableSections(tableUtils, writer, table) {
5000
5042
  const footerRows = table.getAttribute("footerRows") || 0;
5001
5043
  const rows = tableUtils.getRows(table);
5002
5044
  if (headingRows + footerRows > rows) {
5003
- updateNumericAttribute("footerRows", Math.max(0, rows - headingRows), table, writer, 0);
5045
+ const value = Math.max(0, rows - headingRows);
5046
+ updateNumericAttribute("footerRows", value, table, writer, 0);
5004
5047
  return true;
5005
5048
  }
5006
5049
  return false;
@@ -6631,9 +6674,7 @@ var TableKeyboard = class extends Plugin {
6631
6674
  case "right":
6632
6675
  column += currentCellInfo.cellWidth;
6633
6676
  break;
6634
- case "down":
6635
- row += currentCellInfo.cellHeight;
6636
- break;
6677
+ case "down": row += currentCellInfo.cellHeight;
6637
6678
  }
6638
6679
  if (row < 0 || row > lastRow || column < 0 && row <= 0 || column > lastColumn && row >= lastRow) {
6639
6680
  model.change((writer) => {
@@ -7989,12 +8030,13 @@ var TableCellPropertiesView = class extends View {
7989
8030
  const t = this.t;
7990
8031
  const backgroundRowLabel = new LabelView(locale);
7991
8032
  backgroundRowLabel.text = t("Background");
7992
- const backgroundInput = new LabeledFieldView(locale, getLabeledColorInputCreator({
8033
+ const colorInputCreator = getLabeledColorInputCreator({
7993
8034
  colorConfig: this.options.backgroundColors,
7994
8035
  columns: 5,
7995
8036
  defaultColorValue: this.options.defaultTableCellProperties.backgroundColor,
7996
8037
  colorPickerConfig: this.options.colorPickerConfig
7997
- }));
8038
+ });
8039
+ const backgroundInput = new LabeledFieldView(locale, colorInputCreator);
7998
8040
  backgroundInput.set({
7999
8041
  label: t("Color"),
8000
8042
  class: "ck-table-cell-properties-form__background"
@@ -9737,8 +9779,9 @@ function enableCellTypeProperty(editor) {
9737
9779
  const { writer } = conversionApi;
9738
9780
  const { modelRange } = data;
9739
9781
  const modelElement = modelRange?.start.nodeAfter;
9740
- if (modelElement?.is("element", "table") && modelElement.getAttribute("tableType") === "layout") {
9741
- for (const { cell } of new TableWalker(modelElement)) if (isTableHeaderCellType(cell.getAttribute("tableCellType"))) {
9782
+ if (modelElement?.is("element", "table") && modelElement.getAttribute("tableType") === "layout") for (const { cell } of new TableWalker(modelElement)) {
9783
+ const tableCellType = cell.getAttribute("tableCellType");
9784
+ if (isTableHeaderCellType(tableCellType)) {
9742
9785
  writer.setAttribute("tableType", "content", modelElement);
9743
9786
  break;
9744
9787
  }
@@ -9774,9 +9817,7 @@ function enableCellTypeProperty(editor) {
9774
9817
  case "row":
9775
9818
  writer.setAttribute("tableCellType", "header-row", modelElement);
9776
9819
  break;
9777
- case "col":
9778
- writer.setAttribute("tableCellType", "header-column", modelElement);
9779
- break;
9820
+ case "col": writer.setAttribute("tableCellType", "header-column", modelElement);
9780
9821
  }
9781
9822
  });
9782
9823
  });
@@ -9816,7 +9857,8 @@ function enableCellTypeProperty(editor) {
9816
9857
  }
9817
9858
  for (const tableCell of cellsToReconvert) {
9818
9859
  const viewElement = editing.mapper.toViewElement(tableCell);
9819
- const expectedElementName = isTableHeaderCellType(tableCell.getAttribute("tableCellType")) ? "th" : "td";
9860
+ const cellType = tableCell.getAttribute("tableCellType");
9861
+ const expectedElementName = isTableHeaderCellType(cellType) ? "th" : "td";
9820
9862
  if (viewElement?.name !== expectedElementName) editing.reconvertItem(tableCell);
9821
9863
  }
9822
9864
  });
@@ -9971,7 +10013,8 @@ var TableLayoutUI = class extends Plugin {
9971
10013
  if (!editor.plugins.has("TablePropertiesUI")) return;
9972
10014
  const tablePropertiesUI = plugins.get("TablePropertiesUI");
9973
10015
  ui.componentFactory.add("tableProperties", (locale) => {
9974
- const splitButtonView = new SplitButtonView(locale, tablePropertiesUI._createTablePropertiesButton());
10016
+ const baseButton = tablePropertiesUI._createTablePropertiesButton();
10017
+ const splitButtonView = new SplitButtonView(locale, baseButton);
9975
10018
  return createTableTypeDropdown(editor, splitButtonView);
9976
10019
  });
9977
10020
  }
@@ -9988,7 +10031,8 @@ function createTableTypeDropdown(editor, dropdownButton) {
9988
10031
  const locale = editor.locale;
9989
10032
  const tableTypeCommand = editor.commands.get("tableType");
9990
10033
  const dropdownView = createDropdown(locale, dropdownButton);
9991
- addListToDropdown(dropdownView, createTableLayoutTypeDropdownItems(editor), {
10034
+ const itemsDefinitions = createTableLayoutTypeDropdownItems(editor);
10035
+ addListToDropdown(dropdownView, itemsDefinitions, {
9992
10036
  ariaLabel: t("Table type options"),
9993
10037
  role: "menu"
9994
10038
  });
@@ -10639,7 +10683,8 @@ var TableColumnResizeEditing = class extends Plugin {
10639
10683
  const hasMoreColumns = currentColumnsDelta > 0;
10640
10684
  const currentColumnIndex = plugin._tableUtilsPlugin.getCellLocation(cell).column;
10641
10685
  if (hasMoreColumns) {
10642
- const columnWidthsToInsert = createFilledArray(currentColumnsDelta, isPixelMode ? 40 : getColumnMinWidthAsPercentage(table, plugin.editor));
10686
+ const insertedColumnWidth = isPixelMode ? 40 : getColumnMinWidthAsPercentage(table, plugin.editor);
10687
+ const columnWidthsToInsert = createFilledArray(currentColumnsDelta, insertedColumnWidth);
10643
10688
  widths.splice(currentColumnIndex, 0, ...columnWidthsToInsert);
10644
10689
  } else {
10645
10690
  const removedColumnWidths = widths.splice(currentColumnIndex, Math.abs(currentColumnsDelta));
@@ -10858,7 +10903,8 @@ var TableColumnResizeEditing = class extends Plugin {
10858
10903
  const tableWalker = new TableWalker(modelTable);
10859
10904
  for (const cellSlot of tableWalker) {
10860
10905
  const viewCell = editor.editing.mapper.toViewElement(cellSlot.cell);
10861
- const domCellWidth = getDomCellOuterWidth(editor.editing.view.domConverter.mapViewToDom(viewCell));
10906
+ const domCell = editor.editing.view.domConverter.mapViewToDom(viewCell);
10907
+ const domCellWidth = getDomCellOuterWidth(domCell);
10862
10908
  if (!columnWidthsInPx[cellSlot.column] || domCellWidth < columnWidthsInPx[cellSlot.column]) columnWidthsInPx[cellSlot.column] = toPrecision(domCellWidth);
10863
10909
  }
10864
10910
  return columnWidthsInPx;
@@ -10892,7 +10938,8 @@ var TableColumnResizeEditing = class extends Plugin {
10892
10938
  viewWriter.addClass("ck-table-resized", viewTable);
10893
10939
  viewWriter.addClass("ck-table-column-resizer__active", resizingData.elements.viewResizer);
10894
10940
  if (resizingData.flags.isPixelMode) return `${toPrecision(parseFloat(resizingData.elements.modelTable.getAttribute("tableWidth")))}px`;
10895
- return `${toPrecision(Math.max(resizingData.widths.tableWidth, resizingData.widths.viewFigureWidth) / resizingData.widths.viewFigureParentWidth * 100)}%`;
10941
+ const figureWidth = Math.max(resizingData.widths.tableWidth, resizingData.widths.viewFigureWidth);
10942
+ return `${toPrecision(figureWidth / resizingData.widths.viewFigureParentWidth * 100)}%`;
10896
10943
  }
10897
10944
  }
10898
10945
  /**
@@ -10921,7 +10968,7 @@ var TableColumnResizeEditing = class extends Plugin {
10921
10968
  const { columnPosition, flags: { isRightEdge, isTableCentered, isLtrContent, isPixelMode, isTableWidthWithinContainerAtDragStart, isTableScrollAllowed }, elements: { modelTable, viewFigure, viewLeftColumn, viewRightColumn, viewResizer }, widths: { viewFigureParentWidth, tableWidth, leftColumnWidth, rightColumnWidth } } = this._resizingData;
10922
10969
  const dxLowerBound = -leftColumnWidth + 40;
10923
10970
  const isTableScrollActive = !!(plugins.has("TableScrollEditing") ? plugins.get("TableScrollEditing") : null) && isTableScrollAllowed;
10924
- const containerWidth = getEditableWidth(this.editor, modelTable.root.rootName);
10971
+ const containerWidth = getEditableContentWidth(this.editor, modelTable.root.rootName);
10925
10972
  let dxUpperBound;
10926
10973
  if (isRightEdge) dxUpperBound = isTableScrollActive ? Infinity : viewFigureParentWidth - tableWidth;
10927
10974
  else dxUpperBound = rightColumnWidth - 40;
@@ -10942,7 +10989,10 @@ var TableColumnResizeEditing = class extends Plugin {
10942
10989
  dx = newTableWidth - tableWidth;
10943
10990
  } else dx = rawDx * (ltrSign * (isCenteredRightEdge ? 2 : 1));
10944
10991
  dx = clamp(dx, Math.min(dxLowerBound, 0), Math.max(dxUpperBound, 0));
10945
- if (isTableScrollActive && isRightEdge) dx = clamp(applyContainerWidthResistance(tableWidth + dx, containerWidth) - tableWidth, Math.min(dxLowerBound, 0), Math.max(dxUpperBound, 0));
10992
+ if (isTableScrollActive && isRightEdge) {
10993
+ const resistedTableWidth = applyContainerWidthResistance(tableWidth + dx, containerWidth);
10994
+ dx = clamp(resistedTableWidth - tableWidth, Math.min(dxLowerBound, 0), Math.max(dxUpperBound, 0));
10995
+ }
10946
10996
  if (dx === 0) return;
10947
10997
  this.editor.editing.view.change((writer) => {
10948
10998
  const toWidthValue = (widthInPx, basisInPx) => isPixelMode ? `${toPrecision(widthInPx)}px` : `${toPrecision(widthInPx * 100 / basisInPx)}%`;
@@ -11008,7 +11058,7 @@ var TableColumnResizeEditing = class extends Plugin {
11008
11058
  const editor = this.editor;
11009
11059
  const columnPosition = domEventData.domEvent.clientX;
11010
11060
  const viewResizer = domEventData.target;
11011
- const viewLeftCell = viewResizer.findAncestor("td") || viewResizer.findAncestor("th");
11061
+ const viewLeftCell = viewResizer.findAncestor((element) => element.is("element", "td") || element.is("element", "th"));
11012
11062
  const modelLeftCell = editor.editing.mapper.toModelElement(viewLeftCell);
11013
11063
  const modelTable = modelLeftCell.findAncestor("table");
11014
11064
  const leftColumnIndex = getColumnEdgesIndexes(modelLeftCell, this._tableUtilsPlugin).rightEdge;
@@ -11027,12 +11077,13 @@ var TableColumnResizeEditing = class extends Plugin {
11027
11077
  const viewColgroup = [...viewTable.getChildren()].find((viewCol) => viewCol.is("element", "colgroup"));
11028
11078
  const viewLeftColumn = viewColgroup.getChild(leftColumnIndex);
11029
11079
  const viewRightColumn = isRightEdge ? void 0 : viewColgroup.getChild(leftColumnIndex + 1);
11030
- const viewFigureParentWidth = getElementWidthInPixels(editor.editing.view.domConverter.mapViewToDom(viewFigure.parent));
11080
+ const domFigureParent = editor.editing.view.domConverter.mapViewToDom(viewFigure.parent);
11081
+ const viewFigureParentWidth = getContainerContentWidth(domFigureParent);
11031
11082
  const viewFigureWidth = getElementWidthInPixels(editor.editing.view.domConverter.mapViewToDom(viewFigure));
11032
11083
  const tableWidth = getTableWidthInPixels(modelTable, editor);
11033
11084
  const leftColumnWidth = columnWidths[leftColumnIndex];
11034
11085
  const rightColumnWidth = isRightEdge ? void 0 : columnWidths[leftColumnIndex + 1];
11035
- const isTableWidthWithinContainerAtDragStart = tableWidth <= getEditableWidth(editor, modelTable.root.rootName);
11086
+ const isTableWidthWithinContainerAtDragStart = tableWidth <= getEditableContentWidth(editor, modelTable.root.rootName);
11036
11087
  const tableScrollPlugin = editor.plugins.has("TableScrollEditing") ? editor.plugins.get("TableScrollEditing") : null;
11037
11088
  return {
11038
11089
  columnPosition,
@@ -11444,14 +11495,22 @@ function upcastLayoutTable(editor, preferredExternalTableType) {
11444
11495
  dispatcher.on("element:table", (evt, data, conversionApi) => {
11445
11496
  const { viewItem, modelRange } = data;
11446
11497
  if (modelRange) {
11447
- conversionApi.writer.setAttribute("tableType", resolveTableType(viewItem, preferredExternalTableType), modelRange);
11448
- conversionApi.consumable.consume(viewItem, { classes: ["layout-table"] });
11449
- conversionApi.consumable.consume(viewItem, { classes: ["content-table"] });
11498
+ const resolvedType = resolveTableType(viewItem, preferredExternalTableType);
11499
+ conversionApi.writer.setAttribute("tableType", resolvedType, modelRange);
11500
+ consumeViewTableClasses(conversionApi.consumable, viewItem);
11501
+ if (resolvedType === "content" && viewItem.parent?.is("element", "figure")) consumeViewTableClasses(conversionApi.consumable, viewItem.parent);
11450
11502
  }
11451
11503
  }, { priority: "low" });
11452
11504
  };
11453
11505
  }
11454
11506
  /**
11507
+ * Consume all possible classes that determine type of table on provided view item.
11508
+ */
11509
+ function consumeViewTableClasses(consumable, viewItem) {
11510
+ consumable.consume(viewItem, { classes: ["layout-table"] });
11511
+ consumable.consume(viewItem, { classes: ["content-table"] });
11512
+ }
11513
+ /**
11455
11514
  * Model table container element to view table element conversion helper.
11456
11515
  *
11457
11516
  * @returns Conversion helper.
@@ -12605,12 +12664,13 @@ var TablePropertiesView = class extends View {
12605
12664
  const t = this.t;
12606
12665
  const backgroundRowLabel = new LabelView(locale);
12607
12666
  backgroundRowLabel.text = t("Background");
12608
- const backgroundInput = new LabeledFieldView(locale, getLabeledColorInputCreator({
12667
+ const backgroundInputCreator = getLabeledColorInputCreator({
12609
12668
  colorConfig: this.options.backgroundColors,
12610
12669
  columns: 5,
12611
12670
  defaultColorValue: this.options.defaultTableProperties.backgroundColor,
12612
12671
  colorPickerConfig: this.options.colorPickerConfig
12613
- }));
12672
+ });
12673
+ const backgroundInput = new LabeledFieldView(locale, backgroundInputCreator);
12614
12674
  backgroundInput.set({
12615
12675
  label: t("Color"),
12616
12676
  class: "ck-table-properties-form__background"
@@ -13727,7 +13787,7 @@ var TableScrollEditing = class extends Plugin {
13727
13787
  */
13728
13788
  _updateTableScrollOverflowState(table, tableWidthOverride) {
13729
13789
  const { editor } = this;
13730
- const containerWidth = getEditableWidth(editor, table.root.rootName);
13790
+ const containerWidth = getEditableContentWidth(editor, table.root.rootName);
13731
13791
  if (containerWidth === null) return;
13732
13792
  const viewFigure = editor.editing.mapper.toViewElement(table);
13733
13793
  if (!viewFigure) return;