roosterjs-content-model-api 9.59.0 → 9.60.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.
Files changed (37) hide show
  1. package/lib/modelApi/table/mergeTableCells.js +36 -2
  2. package/lib/modelApi/table/mergeTableCells.js.map +1 -1
  3. package/lib/modelApi/table/mergeTableColumn.js +1 -2
  4. package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
  5. package/lib/modelApi/table/mergeTableRow.js +1 -2
  6. package/lib/modelApi/table/mergeTableRow.js.map +1 -1
  7. package/lib/publicApi/table/applyTableBorderFormat.d.ts +1 -0
  8. package/lib/publicApi/table/applyTableBorderFormat.js +104 -26
  9. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  10. package/lib-amd/modelApi/table/mergeTableCells.js +37 -2
  11. package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
  12. package/lib-amd/modelApi/table/mergeTableColumn.js +2 -2
  13. package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
  14. package/lib-amd/modelApi/table/mergeTableRow.js +2 -2
  15. package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
  16. package/lib-amd/publicApi/table/applyTableBorderFormat.d.ts +1 -0
  17. package/lib-amd/publicApi/table/applyTableBorderFormat.js +104 -26
  18. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  19. package/lib-mjs/modelApi/table/mergeTableCells.js +36 -2
  20. package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
  21. package/lib-mjs/modelApi/table/mergeTableColumn.js +1 -2
  22. package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
  23. package/lib-mjs/modelApi/table/mergeTableRow.js +1 -2
  24. package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
  25. package/lib-mjs/publicApi/table/applyTableBorderFormat.d.ts +1 -0
  26. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +106 -28
  27. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  28. package/package.json +3 -3
  29. package/lib/modelApi/table/canMergeCells.d.ts +0 -5
  30. package/lib/modelApi/table/canMergeCells.js +0 -57
  31. package/lib/modelApi/table/canMergeCells.js.map +0 -1
  32. package/lib-amd/modelApi/table/canMergeCells.d.ts +0 -5
  33. package/lib-amd/modelApi/table/canMergeCells.js +0 -59
  34. package/lib-amd/modelApi/table/canMergeCells.js.map +0 -1
  35. package/lib-mjs/modelApi/table/canMergeCells.d.ts +0 -5
  36. package/lib-mjs/modelApi/table/canMergeCells.js +0 -53
  37. package/lib-mjs/modelApi/table/canMergeCells.js.map +0 -1
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canMergeCells = void 0;
4
- /**
5
- * @internal
6
- */
7
- function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
8
- var noSpanAbove = firstCol == lastCol ||
9
- rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
10
- var noSpanLeft = firstRow == lastRow ||
11
- rows.every(function (row, rowIndex) {
12
- return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
13
- });
14
- var noDifferentBelowSpan = rows[lastRow].cells
15
- .map(function (_, colIndex) {
16
- return colIndex >= firstCol && colIndex <= lastCol
17
- ? getBelowSpanCount(rows, lastRow, colIndex)
18
- : -1;
19
- })
20
- .every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
21
- var noDifferentRightSpan = rows
22
- .map(function (_, rowIndex) {
23
- return rowIndex >= firstRow && rowIndex <= lastRow
24
- ? getRightSpanCount(rows, rowIndex, lastCol)
25
- : -1;
26
- })
27
- .every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
28
- return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
29
- }
30
- exports.canMergeCells = canMergeCells;
31
- function getBelowSpanCount(rows, rowIndex, colIndex) {
32
- var _a, _b;
33
- var spanCount = 0;
34
- for (var row = rowIndex + 1; row < rows.length; row++) {
35
- if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
36
- spanCount++;
37
- }
38
- else {
39
- break;
40
- }
41
- }
42
- return spanCount;
43
- }
44
- function getRightSpanCount(rows, rowIndex, colIndex) {
45
- var _a, _b, _c;
46
- var spanCount = 0;
47
- for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
48
- if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
49
- spanCount++;
50
- }
51
- else {
52
- break;
53
- }
54
- }
55
- return spanCount;
56
- }
57
- //# sourceMappingURL=canMergeCells.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,aAAa,CACzB,IAAoC,EACpC,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;IAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CACtB,UAAC,IAAI,EAAE,QAAQ,IAAK,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAA5D,CAA4D,CACnF,CAAC;IACN,IAAM,UAAU,GACZ,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,KAAK,CACN,UAAC,GAAG,EAAE,QAAQ;YACV,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ;QAA1E,CAA0E,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C,0CAAE,SAAS,EAAE;YACvC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iBAAiB,CACtB,IAAoC,EACpC,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,CAAA,EAAE,GAAG,EAAE,EAAE;QACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;YACtC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function canMergeCells(\n rows: ReadonlyContentModelTableRow[],\n firstRow: number,\n firstCol: number,\n lastRow: number,\n lastCol: number\n): boolean {\n const noSpanAbove =\n firstCol == lastCol ||\n rows[firstRow].cells.every(\n (cell, colIndex) => colIndex < firstCol || colIndex > lastCol || !cell.spanAbove\n );\n const noSpanLeft =\n firstRow == lastRow ||\n rows.every(\n (row, rowIndex) =>\n rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft\n );\n\n const noDifferentBelowSpan = rows[lastRow].cells\n .map((_, colIndex) =>\n colIndex >= firstCol && colIndex <= lastCol\n ? getBelowSpanCount(rows, lastRow, colIndex)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstCol]);\n const noDifferentRightSpan = rows\n .map((_, rowIndex) =>\n rowIndex >= firstRow && rowIndex <= lastRow\n ? getRightSpanCount(rows, rowIndex, lastCol)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstRow]);\n\n return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;\n}\n\nfunction getBelowSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let row = rowIndex + 1; row < rows.length; row++) {\n if (rows[row]?.cells[colIndex]?.spanAbove) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n\nfunction getRightSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let col = colIndex + 1; col < rows[rowIndex]?.cells.length; col++) {\n if (rows[rowIndex]?.cells[col]?.spanLeft) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function canMergeCells(rows: ReadonlyContentModelTableRow[], firstRow: number, firstCol: number, lastRow: number, lastCol: number): boolean;
@@ -1,59 +0,0 @@
1
- define(["require", "exports"], function (require, exports) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.canMergeCells = void 0;
5
- /**
6
- * @internal
7
- */
8
- function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
9
- var noSpanAbove = firstCol == lastCol ||
10
- rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
11
- var noSpanLeft = firstRow == lastRow ||
12
- rows.every(function (row, rowIndex) {
13
- return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
14
- });
15
- var noDifferentBelowSpan = rows[lastRow].cells
16
- .map(function (_, colIndex) {
17
- return colIndex >= firstCol && colIndex <= lastCol
18
- ? getBelowSpanCount(rows, lastRow, colIndex)
19
- : -1;
20
- })
21
- .every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
22
- var noDifferentRightSpan = rows
23
- .map(function (_, rowIndex) {
24
- return rowIndex >= firstRow && rowIndex <= lastRow
25
- ? getRightSpanCount(rows, rowIndex, lastCol)
26
- : -1;
27
- })
28
- .every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
29
- return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
30
- }
31
- exports.canMergeCells = canMergeCells;
32
- function getBelowSpanCount(rows, rowIndex, colIndex) {
33
- var _a, _b;
34
- var spanCount = 0;
35
- for (var row = rowIndex + 1; row < rows.length; row++) {
36
- if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
37
- spanCount++;
38
- }
39
- else {
40
- break;
41
- }
42
- }
43
- return spanCount;
44
- }
45
- function getRightSpanCount(rows, rowIndex, colIndex) {
46
- var _a, _b, _c;
47
- var spanCount = 0;
48
- for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
49
- if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
50
- spanCount++;
51
- }
52
- else {
53
- break;
54
- }
55
- }
56
- return spanCount;
57
- }
58
- });
59
- //# sourceMappingURL=canMergeCells.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,aAAa,CACzB,IAAoC,EACpC,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;QAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;YACnB,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CACtB,UAAC,IAAI,EAAE,QAAQ,IAAK,OAAA,QAAQ,GAAG,QAAQ,IAAI,QAAQ,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EA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IAAoC,EACpC,QAAgB,EAChB,QAAgB;;QAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;YACnD,IAAI,MAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;gBACvC,SAAS,EAAE,CAAC;aACf;iBAAM;gBACH,MAAM;aACT;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,SAAS,iBAAiB,CACtB,IAAoC,EACpC,QAAgB,EAChB,QAAgB;;QAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,CAAA,EAAE,GAAG,EAAE,EAAE;YACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;gBACtC,SAAS,EAAE,CAAC;aACf;iBAAM;gBACH,MAAM;aACT;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC","sourcesContent":["import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function canMergeCells(\n rows: ReadonlyContentModelTableRow[],\n firstRow: number,\n firstCol: number,\n lastRow: number,\n lastCol: number\n): boolean {\n const noSpanAbove =\n firstCol == lastCol ||\n rows[firstRow].cells.every(\n (cell, colIndex) => colIndex < firstCol || colIndex > lastCol || !cell.spanAbove\n );\n const noSpanLeft =\n firstRow == lastRow ||\n rows.every(\n (row, rowIndex) =>\n rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft\n );\n\n const noDifferentBelowSpan = rows[lastRow].cells\n .map((_, colIndex) =>\n colIndex >= firstCol && colIndex <= lastCol\n ? getBelowSpanCount(rows, lastRow, colIndex)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstCol]);\n const noDifferentRightSpan = rows\n .map((_, rowIndex) =>\n rowIndex >= firstRow && rowIndex <= lastRow\n ? getRightSpanCount(rows, rowIndex, lastCol)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstRow]);\n\n return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;\n}\n\nfunction getBelowSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let row = rowIndex + 1; row < rows.length; row++) {\n if (rows[row]?.cells[colIndex]?.spanAbove) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n\nfunction getRightSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let col = colIndex + 1; col < rows[rowIndex]?.cells.length; col++) {\n if (rows[rowIndex]?.cells[col]?.spanLeft) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n"]}
@@ -1,5 +0,0 @@
1
- import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function canMergeCells(rows: ReadonlyContentModelTableRow[], firstRow: number, firstCol: number, lastRow: number, lastCol: number): boolean;
@@ -1,53 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- export function canMergeCells(rows, firstRow, firstCol, lastRow, lastCol) {
5
- var noSpanAbove = firstCol == lastCol ||
6
- rows[firstRow].cells.every(function (cell, colIndex) { return colIndex < firstCol || colIndex > lastCol || !cell.spanAbove; });
7
- var noSpanLeft = firstRow == lastRow ||
8
- rows.every(function (row, rowIndex) {
9
- return rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft;
10
- });
11
- var noDifferentBelowSpan = rows[lastRow].cells
12
- .map(function (_, colIndex) {
13
- return colIndex >= firstCol && colIndex <= lastCol
14
- ? getBelowSpanCount(rows, lastRow, colIndex)
15
- : -1;
16
- })
17
- .every(function (x, _, a) { return x < 0 || x == a[firstCol]; });
18
- var noDifferentRightSpan = rows
19
- .map(function (_, rowIndex) {
20
- return rowIndex >= firstRow && rowIndex <= lastRow
21
- ? getRightSpanCount(rows, rowIndex, lastCol)
22
- : -1;
23
- })
24
- .every(function (x, _, a) { return x < 0 || x == a[firstRow]; });
25
- return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;
26
- }
27
- function getBelowSpanCount(rows, rowIndex, colIndex) {
28
- var _a, _b;
29
- var spanCount = 0;
30
- for (var row = rowIndex + 1; row < rows.length; row++) {
31
- if ((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
32
- spanCount++;
33
- }
34
- else {
35
- break;
36
- }
37
- }
38
- return spanCount;
39
- }
40
- function getRightSpanCount(rows, rowIndex, colIndex) {
41
- var _a, _b, _c;
42
- var spanCount = 0;
43
- for (var col = colIndex + 1; col < ((_a = rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.length); col++) {
44
- if ((_c = (_b = rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[col]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
45
- spanCount++;
46
- }
47
- else {
48
- break;
49
- }
50
- }
51
- return spanCount;
52
- }
53
- //# sourceMappingURL=canMergeCells.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canMergeCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/canMergeCells.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,aAAa,CACzB,IAAoC,EACpC,QAAgB,EAChB,QAAgB,EAChB,OAAe,EACf,OAAe;IAEf,IAAM,WAAW,GACb,QAAQ,IAAI,OAAO;QACnB,IAAI,CAAC,QAAQ,CAAC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B,CAAyB,CAAC,CAAC;IAEnD,OAAO,WAAW,IAAI,UAAU,IAAI,oBAAoB,IAAI,oBAAoB,CAAC;AACrF,CAAC;AAED,SAAS,iBAAiB,CACtB,IAAoC,EACpC,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;QACnD,IAAI,MAAA,MAAA,IAAI,CAAC,GAAG,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;YACvC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iBAAiB,CACtB,IAAoC,EACpC,QAAgB,EAChB,QAAgB;;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAK,IAAI,GAAG,GAAG,QAAQ,GAAG,CAAC,EAAE,GAAG,IAAG,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,MAAM,CAAA,EAAE,GAAG,EAAE,EAAE;QACpE,IAAI,MAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,GAAG,CAAC,0CAAE,QAAQ,EAAE;YACtC,SAAS,EAAE,CAAC;SACf;aAAM;YACH,MAAM;SACT;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["import type { ReadonlyContentModelTableRow } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function canMergeCells(\n rows: ReadonlyContentModelTableRow[],\n firstRow: number,\n firstCol: number,\n lastRow: number,\n lastCol: number\n): boolean {\n const noSpanAbove =\n firstCol == lastCol ||\n rows[firstRow].cells.every(\n (cell, colIndex) => colIndex < firstCol || colIndex > lastCol || !cell.spanAbove\n );\n const noSpanLeft =\n firstRow == lastRow ||\n rows.every(\n (row, rowIndex) =>\n rowIndex < firstRow || rowIndex > lastRow || !row.cells[firstCol].spanLeft\n );\n\n const noDifferentBelowSpan = rows[lastRow].cells\n .map((_, colIndex) =>\n colIndex >= firstCol && colIndex <= lastCol\n ? getBelowSpanCount(rows, lastRow, colIndex)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstCol]);\n const noDifferentRightSpan = rows\n .map((_, rowIndex) =>\n rowIndex >= firstRow && rowIndex <= lastRow\n ? getRightSpanCount(rows, rowIndex, lastCol)\n : -1\n )\n .every((x, _, a) => x < 0 || x == a[firstRow]);\n\n return noSpanAbove && noSpanLeft && noDifferentBelowSpan && noDifferentRightSpan;\n}\n\nfunction getBelowSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let row = rowIndex + 1; row < rows.length; row++) {\n if (rows[row]?.cells[colIndex]?.spanAbove) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n\nfunction getRightSpanCount(\n rows: ReadonlyContentModelTableRow[],\n rowIndex: number,\n colIndex: number\n) {\n let spanCount = 0;\n\n for (let col = colIndex + 1; col < rows[rowIndex]?.cells.length; col++) {\n if (rows[rowIndex]?.cells[col]?.spanLeft) {\n spanCount++;\n } else {\n break;\n }\n }\n\n return spanCount;\n}\n"]}