roosterjs-content-model-api 9.24.0 → 9.26.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 (32) hide show
  1. package/README.md +3 -0
  2. package/lib/modelApi/table/clearSelectedCells.js +7 -5
  3. package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
  4. package/lib/modelApi/table/splitTableCellHorizontally.js +3 -1
  5. package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  6. package/lib/modelApi/table/splitTableCellVertically.js +3 -1
  7. package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
  8. package/lib/publicApi/format/getFormatState.js +1 -1
  9. package/lib/publicApi/format/getFormatState.js.map +1 -1
  10. package/lib/publicApi/utils/formatTableWithContentModel.js +2 -0
  11. package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  12. package/lib-amd/modelApi/table/clearSelectedCells.js +7 -5
  13. package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
  14. package/lib-amd/modelApi/table/splitTableCellHorizontally.js +3 -1
  15. package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  16. package/lib-amd/modelApi/table/splitTableCellVertically.js +3 -1
  17. package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
  18. package/lib-amd/publicApi/format/getFormatState.js +1 -1
  19. package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
  20. package/lib-amd/publicApi/utils/formatTableWithContentModel.js +2 -0
  21. package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  22. package/lib-mjs/modelApi/table/clearSelectedCells.js +7 -5
  23. package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
  24. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +3 -1
  25. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  26. package/lib-mjs/modelApi/table/splitTableCellVertically.js +3 -1
  27. package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
  28. package/lib-mjs/publicApi/format/getFormatState.js +1 -1
  29. package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
  30. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +2 -0
  31. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  32. package/package.json +3 -3
package/README.md CHANGED
@@ -51,6 +51,9 @@ There are also some extension packages to provide additional functionalities.
51
51
  1. [roosterjs-color-utils](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_color_utils.html):
52
52
  Provide color transformation utility to make editor work under dark mode.
53
53
 
54
+ 2. [roosterjs-content-model-markdown](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_content_model_types.html):
55
+ Defines public APIs to enable conversions between Markdown and ContentModel
56
+
54
57
  To be compatible with old (8.\*) versions, you can use `EditorAdapter` class from the following package which can act as a 8.\* Editor:
55
58
 
56
59
  1. [roosterjs-editor-adapter](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_adapter.html):
@@ -10,16 +10,18 @@ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
10
10
  function clearSelectedCells(table, sel) {
11
11
  if (sel.firstColumn >= 0 &&
12
12
  sel.firstRow >= 0 &&
13
- sel.lastColumn < table.widths.length &&
14
- sel.lastRow < table.rows.length) {
13
+ sel.lastRow < table.rows.length &&
14
+ sel.lastColumn < table.rows[sel.lastRow].cells.length) {
15
15
  for (var i = sel.firstRow; i <= sel.lastRow; i++) {
16
16
  var row = table.rows[i];
17
17
  for (var j = sel.firstColumn; j <= sel.lastColumn; j++) {
18
18
  var cell = row.cells[j];
19
- if (cell.isSelected) {
20
- (0, roosterjs_content_model_dom_1.mutateBlock)(cell).isSelected = false;
19
+ if (cell) {
20
+ if (cell.isSelected) {
21
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cell).isSelected = false;
22
+ }
23
+ (0, roosterjs_content_model_dom_1.setSelection)(cell);
21
24
  }
22
- (0, roosterjs_content_model_dom_1.setSelection)(cell);
23
25
  }
24
26
  }
25
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAMxE;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;IAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;QACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;QACjB,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;QACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EACjC;QACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,IAAI,IAAI,CAAC,UAAU,EAAE;oBACjB,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;iBACxC;gBAED,IAAA,0CAAY,EAAC,IAAI,CAAC,CAAC;aACtB;SACJ;KACJ;AACL,CAAC;AAxBD,gDAwBC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastColumn < table.widths.length &&\n sel.lastRow < table.rows.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AAMxE;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;IAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;QACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;QACjB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;QAC/B,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,EACvD;QACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,IAAI,IAAI,EAAE;oBACN,IAAI,IAAI,CAAC,UAAU,EAAE;wBACjB,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;qBACxC;oBAED,IAAA,0CAAY,EAAC,IAAI,CAAC,CAAC;iBACtB;aACJ;SACJ;KACJ;AACL,CAAC;AA1BD,gDA0BC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastRow < table.rows.length &&\n sel.lastColumn < table.rows[sel.lastRow].cells.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell) {\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n }\n}\n"]}
@@ -28,7 +28,9 @@ function splitTableCellHorizontally(table) {
28
28
  table.rows.forEach(function (row, rowIndex) {
29
29
  var cell = row.cells[colIndex];
30
30
  if (cell) {
31
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
31
+ var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
32
+ delete mutableCell.format.width;
33
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
32
34
  newCell.dataset = (0, tslib_1.__assign)({}, cell.dataset);
33
35
  if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {
34
36
  newCell.spanLeft = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";;;;AAAA,2EAA6F;AAG7F,IA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,CAAC,QAAQ,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE;4BACnD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;yBAC3B;6BAAM;4BACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;yBACxC;wBACD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;wBAE3C,IAAA,yCAAW,EAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;qBACpC;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;gBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxD;;QA3CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;oBAAlE,QAAQ;SA4ChB;KACJ;AACL,CAAC;AAlDD,gEAkDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";;;;AAAA,2EAA6F;AAG7F,IAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;GAEG;AACH,SAAgB,0BAA0B,CAAC,KAAsC;IAC7E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;gCACI,QAAQ;YACb,IACI,KAAK,CAAC,IAAI,CAAC,KAAK,CACZ,UAAC,GAAG,EAAE,QAAQ;;gBACV,OAAA,QAAQ,GAAG,GAAG,CAAC,QAAQ;oBACvB,QAAQ,GAAG,GAAG,CAAC,OAAO;qBACtB,MAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,0CAAE,QAAQ,CAAA,CAAA;aAAA,CACxC,EACH;gBACE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,QAAQ;oBAC7B,IAAA,yCAAW,EAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAEjC,IAAI,QAAQ,IAAI,GAAG,C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,CAAC;gBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxD;;QA/CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;oBAAlE,QAAQ;SAgDhB;KACJ;AACL,CAAC;AAtDD,gEAsDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.width;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
@@ -31,7 +31,9 @@ function splitTableCellVertically(table) {
31
31
  format: (0, tslib_1.__assign)({}, row.format),
32
32
  height: newHeight,
33
33
  cells: row.cells.map(function (cell, colIndex) {
34
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
34
+ var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
35
+ delete mutableCell.format.height;
36
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
35
37
  newCell.dataset = (0, tslib_1.__assign)({}, cell.dataset);
36
38
  if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {
37
39
  newCell.spanAbove = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;AAAA,2EAA6F;AAM7F,IAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;GAEG;AACH,SAAgB,wBAAwB,CAAC,KAAsC;IAC3E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;QACL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAE1C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,yCAAW,CAAC,CAAC;YAE/B,IACI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC,KAAK,CACjB,UAAC,SAAS,EAAE,QAAQ;gBAChB,OAAA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AC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;aAC9C;SACJ;KACJ;AACL,CAAC;AArDD,4DAqDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;AAAA,2EAA6F;AAM7F,IAAM,UAAU,GAAG,EAAE,CA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,CAAC,UAAC,IAAI,EAAE,QAAQ;wBAChC,IAAM,WAAW,GAAG,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC;wBAEtC,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;wBAEjC,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,WAAW,CAAC,MAAM,CACrB,CAAC;wBAEF,OAAO,CAAC,OAAO,6BAAQ,IAAI,CAAC,OAAO,CAAE,CAAC;wBAEtC,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE;4BACzD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;yBAC5B;6BAAM;4BACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;yBACxC;wBAED,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;iBACL,CAAC;gBAEF,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;aAC9C;SACJ;KACJ;AACL,CAAC;AAzDD,4DAyDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.height;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
@@ -18,7 +18,7 @@ function getFormatState(editor, conflictSolution) {
18
18
  isDarkMode: editor.isDarkMode(),
19
19
  };
20
20
  editor.formatContentModel(function (model) {
21
- (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution);
21
+ (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution, editor.getDOMHelper());
22
22
  return false;
23
23
  }, undefined /*options*/, {
24
24
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;AAAA,+FAA8F;AAC9F,2EAAuE;AAGvE;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAEzE,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uDAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC;AA5BD,wCA4BC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;AAAA,+FAA8F;AAC9F,2EAAuE;AAOvE;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,IAAA,sDAAwB,EACpB,KAAK,EACL,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,MAAM,CAAC,YAAY,EAAE,CACxB,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,uDAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC;AAlCD,wCAkCC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ContentModelFormatState,\n ConflictFormatSolution,\n} from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(\n model,\n pendingFormat,\n result,\n conflictSolution,\n editor.getDOMHelper()\n );\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -38,6 +38,8 @@ function formatTableWithContentModel(editor, apiName, callback, selectionOverrid
38
38
  }, {
39
39
  apiName: apiName,
40
40
  selectionOverride: selectionOverride,
41
+ }, {
42
+ recalculateTableSize: 'selected',
41
43
  });
42
44
  }
43
45
  exports.formatTableWithContentModel = formatTableWithContentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,0GAAyG;AACzG,2EAUqC;AAOrC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;oBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;gBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,CACJ,CAAC;AACN,CAAC;AA3CD,kEA2CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;AAAA,0GAAyG;AACzG,2EAUqC;AAOrC;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;oBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;gBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC;AA9CD,kEA8CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
@@ -10,16 +10,18 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
10
10
  function clearSelectedCells(table, sel) {
11
11
  if (sel.firstColumn >= 0 &&
12
12
  sel.firstRow >= 0 &&
13
- sel.lastColumn < table.widths.length &&
14
- sel.lastRow < table.rows.length) {
13
+ sel.lastRow < table.rows.length &&
14
+ sel.lastColumn < table.rows[sel.lastRow].cells.length) {
15
15
  for (var i = sel.firstRow; i <= sel.lastRow; i++) {
16
16
  var row = table.rows[i];
17
17
  for (var j = sel.firstColumn; j <= sel.lastColumn; j++) {
18
18
  var cell = row.cells[j];
19
- if (cell.isSelected) {
20
- (0, roosterjs_content_model_dom_1.mutateBlock)(cell).isSelected = false;
19
+ if (cell) {
20
+ if (cell.isSelected) {
21
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cell).isSelected = false;
22
+ }
23
+ (0, roosterjs_content_model_dom_1.setSelection)(cell);
21
24
  }
22
- (0, roosterjs_content_model_dom_1.setSelection)(cell);
23
25
  }
24
26
  }
25
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":";;;;IAMA;;;;OAIG;IACH,SAAgB,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;QAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;YACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;YACjB,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;YACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EACjC;YACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;oBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAE1B,IAAI,IAAI,CAAC,UAAU,EAAE;wBACjB,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;qBACxC;oBAED,IAAA,0CAAY,EAAC,IAAI,CAAC,CAAC;iBACtB;aACJ;SACJ;IACL,CAAC;IAxBD,gDAwBC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastColumn < table.widths.length &&\n sel.lastRow < table.rows.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":";;;;IAMA;;;;OAIG;IACH,SAAgB,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;QAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;YACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;YACjB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;YAC/B,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,EACvD;YACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;oBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAE1B,IAAI,IAAI,EAAE;wBACN,IAAI,IAAI,CAAC,UAAU,EAAE;4BACjB,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;yBACxC;wBAED,IAAA,0CAAY,EAAC,IAAI,CAAC,CAAC;qBACtB;iBACJ;aACJ;SACJ;IACL,CAAC;IA1BD,gDA0BC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastRow < table.rows.length &&\n sel.lastColumn < table.rows[sel.lastRow].cells.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell) {\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n }\n}\n"]}
@@ -27,7 +27,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
27
27
  table.rows.forEach(function (row, rowIndex) {
28
28
  var cell = row.cells[colIndex];
29
29
  if (cell) {
30
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
30
+ var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
31
+ delete mutableCell.format.width;
32
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
31
33
  newCell.dataset = (0, tslib_1.__assign)({}, cell.dataset);
32
34
  if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {
33
35
  newCell.spanLeft = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";;;;IAGA,IAAM,SAAS,GAAG,EAAE,CAAC;IAErB;;OAEG;IACH,SAAgB,0BAA0B,CAAC,KAAsC;QAC7E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;oCACI,QAAQ;gBACb,IACI,KAAK,CAAC,IAAI,CAAC,KAAK,CACZ,UAAC,GAAG,EAAE,QAAQ;;oBACV,OAAA,QAAQ,GAAG,GAAG,CAAC,QAAQ;wBACvB,QAAQ,GAAG,GAAG,CAAC,OAAO;yBACtB,MAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,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AAC;oBAEH,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;oBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;iBACxD;;YA3CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;wBAAlE,QAAQ;aA4ChB;SACJ;IACL,CAAC;IAlDD,gEAkDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";;;;IAGA,IAAM,SAAS,GAAG,EAAE,CAAC;IAErB;;OAEG;IACH,SAAgB,0BAA0B,CAAC,KAAsC;QAC7E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;oCACI,QAAQ;gBACb,IACI,KAAK,CAAC,IAAI,CAAC,KAAK,CACZ,UAAC,GAAG,EAAE,QAAQ;;oBACV,OAAA,QAAQ,GAAG,GAAG,CAAC,QAAQ;wBACvB,QAAQ,GAAG,GAAG,CAAC,OAAO;yBACtB,MAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,0CAAE,QAAQ,CAAA,CAAA;iBAAA,CACxC,EACH;oBACE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,QAAQ;wBAC7B,IAAA,yCAAW,EAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAEjC,IAAI,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE;4BACrD,IAAA,yCAAW,EAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;yBACzD;oBACL,CAAC,CAAC,CAAC;iBACN;qBAAM;oBACH,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,QAAQ;wBAC7B,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;wBACjC,IAAI,IAAI,EAAE;4BACN,IAAM,WAAW,GAAG,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC;4BAEtC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;4BAEhC,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,WAAW,CAAC,MAAM,CACrB,CAAC;4BAEF,OAAO,CAAC,OAAO,6BAAQ,IAAI,CAAC,OAAO,CAAE,CAAC;4BAEtC,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE;gCACnD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;6BAC3B;iCAAM;gCACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;6BACxC;4BACD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;4BAE3C,IAAA,yCAAW,EAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;yBACpC;oBACL,CAAC,CAAC,CAAC;oBAEH,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;oBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;iBACxD;;YA/CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;wBAAlE,QAAQ;aAgDhB;SACJ;IACL,CAAC;IAtDD,gEAsDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.width;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
@@ -30,7 +30,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
30
30
  format: (0, tslib_1.__assign)({}, row.format),
31
31
  height: newHeight,
32
32
  cells: row.cells.map(function (cell, colIndex) {
33
- var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
33
+ var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
34
+ delete mutableCell.format.height;
35
+ var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
34
36
  newCell.dataset = (0, tslib_1.__assign)({}, cell.dataset);
35
37
  if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {
36
38
  newCell.spanAbove = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;IAMA,IAAM,UAAU,GAAG,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAgB,wBAAwB,CAAC,KAAsC;QAC3E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;gBAE1C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,yCAAW,CAAC,CAAC;gBAE/B,IACI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC,KAAK,CACjB,UAAC,SAAS,EAAE,QAAQ;oBAChB,OAAA,QAAQ,GAAG,GAAG,CAAC,WAAW;wBAC1B,QAAQ,GAAG,GAAG,CAAC,UAAU;wBACzB,SAAS,CAAC,SAAS;gBAFnB,CAEmB,CAC1B,EACH;oBACE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,SAAS,EAAE,QAAQ;wBACvC,IAAI,QAAQ,IAAI,GAAG,CAAC,WAAW,IAAI,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE;4BAC3D,IAAA,yCAAW,EAAC,SAAS,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC;yBAC5C;oBACL,CAAC,CAAC,CAAC;iBACN;qBAAM;oBACH,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;oBAC1D,IAAM,MAAM,GAAyB;wBACjC,MAAM,4BAAO,GAAG,CAAC,MAAM,CAAE;wBACzB,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,QAAQ;4BAChC,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CACd,CAAC;4BAEF,OAAO,CAAC,OAAO,6BAAQ,IAAI,CAAC,OAAO,CAAE,CAAC;4BAEtC,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE;gCACzD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;6BAC5B;iCAAM;gCACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;6BACxC;4BAED,OAAO,OAAO,CAAC;wBACnB,CAAC,CAAC;qBACL,CAAC;oBAEF,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;oBACvB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;iBAC9C;aACJ;SACJ;IACL,CAAC;IArDD,4DAqDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;IAMA,IAAM,UAAU,GAAG,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAgB,wBAAwB,CAAC,KAAsC;QAC3E,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CA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AAG,CAAC,WAAW,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE;gCACzD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;6BAC5B;iCAAM;gCACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;6BACxC;4BAED,OAAO,OAAO,CAAC;wBACnB,CAAC,CAAC;qBACL,CAAC;oBAEF,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;oBACvB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;iBAC9C;aACJ;SACJ;IACL,CAAC;IAzDD,4DAyDC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.height;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
@@ -17,7 +17,7 @@ define(["require", "exports", "../../modelApi/common/reducedModelChildProcessor"
17
17
  isDarkMode: editor.isDarkMode(),
18
18
  };
19
19
  editor.formatContentModel(function (model) {
20
- (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution);
20
+ (0, roosterjs_content_model_dom_1.retrieveModelFormatState)(model, pendingFormat, result, conflictSolution, editor.getDOMHelper());
21
21
  return false;
22
22
  }, undefined /*options*/, {
23
23
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;QAAnD,iCAAA,EAAA,2BAAmD;QAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC7C,IAAM,MAAM,GAA4B;YACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAClC,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,sDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;YAEzE,OAAO,KAAK,CAAC;QACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uDAA0B;aACpC;YACD,eAAe,EAAE,IAAI;SACxB,CACJ,CAAC;QAEF,OAAO,MAAM,CAAC;IAClB,CAAC;IA5BD,wCA4BC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,MAAe,EACf,gBAAmD;QAAnD,iCAAA,EAAA,2BAAmD;QAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC7C,IAAM,MAAM,GAA4B;YACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;SAClC,CAAC;QAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAA,sDAAwB,EACpB,KAAK,EACL,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,MAAM,CAAC,YAAY,EAAE,CACxB,CAAC;YAEF,OAAO,KAAK,CAAC;QACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;YACI,iBAAiB,EAAE;gBACf,KAAK,EAAE,uDAA0B;aACpC;YACD,eAAe,EAAE,IAAI;SACxB,CACJ,CAAC;QAEF,OAAO,MAAM,CAAC;IAClB,CAAC;IAlCD,wCAkCC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ContentModelFormatState,\n ConflictFormatSolution,\n} from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(\n model,\n pendingFormat,\n result,\n conflictSolution,\n editor.getDOMHelper()\n );\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -36,6 +36,8 @@ define(["require", "exports", "tslib", "../../modelApi/table/ensureFocusablePara
36
36
  }, {
37
37
  apiName: apiName,
38
38
  selectionOverride: selectionOverride,
39
+ }, {
40
+ recalculateTableSize: 'selected',
39
41
  });
40
42
  }
41
43
  exports.formatTableWithContentModel = formatTableWithContentModel;
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;IAkBA;;;;;;OAMG;IACH,SAAgB,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;QAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAA6B,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;YAEhE,IAAI,kBAAkB,EAAE;gBACpB,IAAM,UAAU,GAAG,IAAA,yCAAW,EAAC,kBAAkB,CAAC,CAAC;gBAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;gBAErB,IAAI,CAAC,IAAA,iDAAmB,EAAC,UAAU,CAAC,EAAE;oBAClC,IAAM,SAAS,GAAG,IAAA,mEAAgC,EAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;oBAE5E,IAAI,SAAS,EAAE;wBACX,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;wBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;wBACnC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;wBACnC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;qBAC/B;iBACJ;gBAED,IAAA,4CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;oBACzB,IAAA,8CAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;iBACjF;gBAED,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,SAAA;YACP,iBAAiB,mBAAA;SACpB,CACJ,CAAC;IACN,CAAC;IA3CD,kEA2CC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";;;;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esContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
@@ -7,16 +7,18 @@ import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';
7
7
  export function clearSelectedCells(table, sel) {
8
8
  if (sel.firstColumn >= 0 &&
9
9
  sel.firstRow >= 0 &&
10
- sel.lastColumn < table.widths.length &&
11
- sel.lastRow < table.rows.length) {
10
+ sel.lastRow < table.rows.length &&
11
+ sel.lastColumn < table.rows[sel.lastRow].cells.length) {
12
12
  for (var i = sel.firstRow; i <= sel.lastRow; i++) {
13
13
  var row = table.rows[i];
14
14
  for (var j = sel.firstColumn; j <= sel.lastColumn; j++) {
15
15
  var cell = row.cells[j];
16
- if (cell.isSelected) {
17
- mutateBlock(cell).isSelected = false;
16
+ if (cell) {
17
+ if (cell.isSelected) {
18
+ mutateBlock(cell).isSelected = false;
19
+ }
20
+ setSelection(cell);
18
21
  }
19
- setSelection(cell);
20
22
  }
21
23
  }
22
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAMxE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;IAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;QACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;QACjB,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;QACpC,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EACjC;QACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,IAAI,IAAI,CAAC,UAAU,EAAE;oBACjB,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;iBACxC;gBAED,YAAY,CAAC,IAAI,CAAC,CAAC;aACtB;SACJ;KACJ;AACL,CAAC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastColumn < table.widths.length &&\n sel.lastRow < table.rows.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"clearSelectedCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/clearSelectedCells.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAMxE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,KAAgC,EAChC,GAA8B;IAE9B,IACI,GAAG,CAAC,WAAW,IAAI,CAAC;QACpB,GAAG,CAAC,QAAQ,IAAI,CAAC;QACjB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM;QAC/B,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,EACvD;QACE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YAC9C,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAE1B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACpD,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAE1B,IAAI,IAAI,EAAE;oBACN,IAAI,IAAI,CAAC,UAAU,EAAE;wBACjB,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,CAAC;qBACxC;oBAED,YAAY,CAAC,IAAI,CAAC,CAAC;iBACtB;aACJ;SACJ;KACJ;AACL,CAAC","sourcesContent":["import { mutateBlock, setSelection } from 'roosterjs-content-model-dom';\nimport type {\n ReadonlyContentModelTable,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * Clear selection of a table.\n * @param table The table model where the selection is to be cleared\n * @param sel The selection coordinates to be cleared\n */\nexport function clearSelectedCells(\n table: ReadonlyContentModelTable,\n sel: TableSelectionCoordinates\n) {\n if (\n sel.firstColumn >= 0 &&\n sel.firstRow >= 0 &&\n sel.lastRow < table.rows.length &&\n sel.lastColumn < table.rows[sel.lastRow].cells.length\n ) {\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const row = table.rows[i];\n\n for (let j = sel.firstColumn; j <= sel.lastColumn; j++) {\n const cell = row.cells[j];\n\n if (cell) {\n if (cell.isSelected) {\n mutateBlock(cell).isSelected = false;\n }\n\n setSelection(cell);\n }\n }\n }\n }\n}\n"]}
@@ -25,7 +25,9 @@ export function splitTableCellHorizontally(table) {
25
25
  table.rows.forEach(function (row, rowIndex) {
26
26
  var cell = row.cells[colIndex];
27
27
  if (cell) {
28
- var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
28
+ var mutableCell = mutateBlock(cell);
29
+ delete mutableCell.format.width;
30
+ var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
29
31
  newCell.dataset = __assign({}, cell.dataset);
30
32
  if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {
31
33
  newCell.spanLeft = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG7F,IAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAsC;IAC7E,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;gCACI,QAAQ;YACb,IACI,KAAK,CAAC,IAAI,CAAC,KAAK,CACZ,UAAC,GAAG,EAAE,QAAQ;;gBACV,OAAA,QAAQ,GAAG,GAAG,CAAC,QAAQ;oBACvB,QAAQ,GAAG,GAAG,CAAC,OAAO;qBACtB,MAAA,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,0CAAE,QAAQ,CAAA,CAAA;aAAA,CACxC,EACH;gBACE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,QAAQ;oBAC7B,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAEjC,IAAI,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE;wBACrD,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;qBACzD;gBACL,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,QAAQ;oBAC7B,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBACjC,IAAI,IAAI,EAAE;wBACN,IAAM,OAAO,GAAG,eAAe,CAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CACd,CAAC;wBAEF,OAAO,CAAC,OAAO,gBAAQ,IAAI,CAAC,OAAO,CAAE,CAAC;wBAEtC,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE;4BACnD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;yBAC3B;6BAAM;4BACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;yBACxC;wBACD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;wBAE3C,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;qBACpC;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;gBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxD;;QA3CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;oBAAlE,QAAQ;SA4ChB;KACJ;AACL,CAAC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellHorizontally.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellHorizontally.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG7F,IAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;GAEG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAsC;IAC7E,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;gCACI,QAAQ;YACb,IACI,KAAK,CAAC,IAAI,CAAC,KAAK,CACZ,UAAC,GAAG,EAAE,QAAQ;;gBACV,OAAA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BACxC;wBACD,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;wBAE3C,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;qBACpC;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;gBAEjE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;aACxD;;QA/CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;oBAAlE,QAAQ;SAgDhB;KACJ;AACL,CAAC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let colIndex = sel.lastColumn; colIndex >= sel.firstColumn; colIndex--) {\n if (\n table.rows.every(\n (row, rowIndex) =>\n rowIndex < sel.firstRow ||\n rowIndex > sel.lastRow ||\n row.cells[colIndex + 1]?.spanLeft\n )\n ) {\n table.rows.forEach((row, rowIndex) => {\n mutateBlock(row.cells[colIndex]);\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n mutateBlock(row.cells[colIndex + 1]).spanLeft = false;\n }\n });\n } else {\n table.rows.forEach((row, rowIndex) => {\n const cell = row.cells[colIndex];\n if (cell) {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.width;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (rowIndex < sel.firstRow || rowIndex > sel.lastRow) {\n newCell.spanLeft = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n row.cells.splice(colIndex + 1, 0, newCell);\n\n mutateBlock(row.cells[colIndex]);\n }\n });\n\n const newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);\n\n table.widths.splice(colIndex, 1, newWidth, newWidth);\n }\n }\n }\n}\n"]}
@@ -28,7 +28,9 @@ export function splitTableCellVertically(table) {
28
28
  format: __assign({}, row.format),
29
29
  height: newHeight,
30
30
  cells: row.cells.map(function (cell, colIndex) {
31
- var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
31
+ var mutableCell = mutateBlock(cell);
32
+ delete mutableCell.format.height;
33
+ var newCell = createTableCell(cell.spanLeft, cell.spanAbove, cell.isHeader, mutableCell.format);
32
34
  newCell.dataset = __assign({}, cell.dataset);
33
35
  if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {
34
36
  newCell.spanAbove = true;
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM7F,IAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAsC;IAC3E,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;QACL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ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U,EAAE;4BACzD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;yBAC5B;6BAAM;4BACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;yBACxC;wBAED,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;iBACL,CAAC;gBAEF,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;aAC9C;SACJ;KACJ;AACL,CAAC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAM7F,IAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAsC;IAC3E,IAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,GAAG,EAAE;QACL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;YACnE,IAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAE1C,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAE/B,IACI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC,KAAK,CACjB,UAAC,SAAS,EAAE,QAAQ;gBAChB,OAAA,QAAQ,GAAG,GAAG,CAAC,WAAW;oBAC1B,QAAQ,GAAG,GAAG,CAAC,UAAU;oBACzB,SAAS,CAAC,SAAS;YAFnB,CAEmB,CAC1B,EACH;gBACE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,SAAS,EAAE,QAAQ;oBACvC,IAAI,QAAQ,IAAI,GAAG,CAAC,WAAW,IAAI,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE;wBAC3D,WAAW,CAAC,SAAS,CAAC,CAAC,SAAS,GAAG,KAAK,CAAC;qBAC5C;gBACL,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBAC1D,IAAM,MAAM,GAAyB;oBACjC,MAAM,eAAO,GAAG,CAAC,MAAM,CAAE;oBACzB,MAAM,EAAE,SAAS;oBACjB,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI,EAAE,QAAQ;wBAChC,IAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;wBAEtC,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;wBAEjC,IAAM,OAAO,GAAG,eAAe,CAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,WAAW,CAAC,MAAM,CACrB,CAAC;wBAEF,OAAO,CAAC,OAAO,gBAAQ,IAAI,CAAC,OAAO,CAAE,CAAC;wBAEtC,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE;4BACzD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;yBAC5B;6BAAM;4BACH,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;yBACxC;wBAED,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;iBACL,CAAC;gBAEF,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;gBACvB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;aAC9C;SACJ;KACJ;AACL,CAAC","sourcesContent":["import { createTableCell, getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTableRow,\n ShallowMutableContentModelTable,\n} from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {\n const row = table.rows[rowIndex];\n const belowRow = table.rows[rowIndex + 1];\n\n row.cells.forEach(mutateBlock);\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstColumn ||\n colIndex > sel.lastColumn ||\n belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {\n mutateBlock(belowCell).spanAbove = false;\n }\n });\n } else {\n const newHeight = Math.max((row.height /= 2), MIN_HEIGHT);\n const newRow: ContentModelTableRow = {\n format: { ...row.format },\n height: newHeight,\n cells: row.cells.map((cell, colIndex) => {\n const mutableCell = mutateBlock(cell);\n\n delete mutableCell.format.height;\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n mutableCell.format\n );\n\n newCell.dataset = { ...cell.dataset };\n\n if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {\n newCell.spanAbove = true;\n } else {\n newCell.isSelected = cell.isSelected;\n }\n\n return newCell;\n }),\n };\n\n row.height = newHeight;\n table.rows.splice(rowIndex + 1, 0, newRow);\n }\n }\n }\n}\n"]}
@@ -15,7 +15,7 @@ export function getFormatState(editor, conflictSolution) {
15
15
  isDarkMode: editor.isDarkMode(),
16
16
  };
17
17
  editor.formatContentModel(function (model) {
18
- retrieveModelFormatState(model, pendingFormat, result, conflictSolution);
18
+ retrieveModelFormatState(model, pendingFormat, result, conflictSolution, editor.getDOMHelper());
19
19
  return false;
20
20
  }, undefined /*options*/, {
21
21
  processorOverride: {
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAC;QAEzE,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,0BAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type { IEditor, ContentModelFormatState, ConflictFormatSolution } from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(model, pendingFormat, result, conflictSolution);\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAOvE;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC1B,MAAe,EACf,gBAAmD;IAAnD,iCAAA,EAAA,2BAAmD;IAEnD,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAChD,IAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,CAAC;IAC7C,IAAM,MAAM,GAA4B;QACpC,OAAO,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE;KAClC,CAAC;IAEF,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACD,wBAAwB,CACpB,KAAK,EACL,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,MAAM,CAAC,YAAY,EAAE,CACxB,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC,EACD,SAAS,CAAC,WAAW,EACrB;QACI,iBAAiB,EAAE;YACf,KAAK,EAAE,0BAA0B;SACpC;QACD,eAAe,EAAE,IAAI;KACxB,CACJ,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { reducedModelChildProcessor } from '../../modelApi/common/reducedModelChildProcessor';\nimport { retrieveModelFormatState } from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ContentModelFormatState,\n ConflictFormatSolution,\n} from 'roosterjs-content-model-types';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n * @param conflictSolution The strategy for handling format conflicts\n */\nexport function getFormatState(\n editor: IEditor,\n conflictSolution: ConflictFormatSolution = 'remove'\n): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const manager = editor.getSnapshotsManager();\n const result: ContentModelFormatState = {\n canUndo: manager.hasNewContent || manager.canMove(-1),\n canRedo: manager.canMove(1),\n isDarkMode: editor.isDarkMode(),\n };\n\n editor.formatContentModel(\n model => {\n retrieveModelFormatState(\n model,\n pendingFormat,\n result,\n conflictSolution,\n editor.getDOMHelper()\n );\n\n return false;\n },\n undefined /*options*/,\n {\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n tryGetFromCache: true,\n }\n );\n\n return result;\n}\n"]}
@@ -35,6 +35,8 @@ export function formatTableWithContentModel(editor, apiName, callback, selection
35
35
  }, {
36
36
  apiName: apiName,
37
37
  selectionOverride: selectionOverride,
38
+ }, {
39
+ recalculateTableSize: 'selected',
38
40
  });
39
41
  }
40
42
  //# sourceMappingURL=formatTableWithContentModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
package/package.json CHANGED
@@ -3,10 +3,10 @@
3
3
  "description": "Format API for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-dom": "^9.24.0",
7
- "roosterjs-content-model-types": "^9.24.0"
6
+ "roosterjs-content-model-dom": "^9.26.0",
7
+ "roosterjs-content-model-types": "^9.26.0"
8
8
  },
9
- "version": "9.24.0",
9
+ "version": "9.26.0",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",