roosterjs-content-model-api 0.21.1 → 0.22.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 (166) hide show
  1. package/lib/index.d.ts +0 -3
  2. package/lib/index.js +1 -7
  3. package/lib/index.js.map +1 -1
  4. package/lib/modelApi/list/setListType.js +25 -0
  5. package/lib/modelApi/list/setListType.js.map +1 -1
  6. package/lib/modelApi/selection/collapseTableSelection.d.ts +1 -2
  7. package/lib/modelApi/selection/collapseTableSelection.js +2 -2
  8. package/lib/modelApi/selection/collapseTableSelection.js.map +1 -1
  9. package/lib/modelApi/table/alignTableCell.js +2 -3
  10. package/lib/modelApi/table/alignTableCell.js.map +1 -1
  11. package/lib/modelApi/table/deleteTableColumn.js +6 -6
  12. package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
  13. package/lib/modelApi/table/deleteTableRow.js +2 -2
  14. package/lib/modelApi/table/deleteTableRow.js.map +1 -1
  15. package/lib/modelApi/table/insertTableColumn.js +6 -6
  16. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  17. package/lib/modelApi/table/insertTableRow.js +3 -3
  18. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  19. package/lib/modelApi/table/mergeTableCells.js +6 -5
  20. package/lib/modelApi/table/mergeTableCells.js.map +1 -1
  21. package/lib/modelApi/table/mergeTableColumn.js +3 -3
  22. package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
  23. package/lib/modelApi/table/mergeTableRow.js +3 -3
  24. package/lib/modelApi/table/mergeTableRow.js.map +1 -1
  25. package/lib/modelApi/table/splitTableCellHorizontally.js +3 -3
  26. package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  27. package/lib/modelApi/table/splitTableCellVertically.js +7 -5
  28. package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
  29. package/lib/publicApi/format/getFormatState.js +7 -1
  30. package/lib/publicApi/format/getFormatState.js.map +1 -1
  31. package/lib/publicApi/image/changeImage.js +1 -2
  32. package/lib/publicApi/image/changeImage.js.map +1 -1
  33. package/lib/publicApi/image/insertImage.js +1 -2
  34. package/lib/publicApi/image/insertImage.js.map +1 -1
  35. package/lib/publicApi/table/applyTableBorderFormat.js +29 -30
  36. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  37. package/lib/publicApi/table/editTable.js +1 -2
  38. package/lib/publicApi/table/editTable.js.map +1 -1
  39. package/lib/publicApi/table/setTableCellShade.js +1 -2
  40. package/lib/publicApi/table/setTableCellShade.js.map +1 -1
  41. package/lib-amd/index.d.ts +0 -3
  42. package/lib-amd/index.js +2 -5
  43. package/lib-amd/index.js.map +1 -1
  44. package/lib-amd/modelApi/list/setListType.js +25 -0
  45. package/lib-amd/modelApi/list/setListType.js.map +1 -1
  46. package/lib-amd/modelApi/selection/collapseTableSelection.d.ts +1 -2
  47. package/lib-amd/modelApi/selection/collapseTableSelection.js +2 -2
  48. package/lib-amd/modelApi/selection/collapseTableSelection.js.map +1 -1
  49. package/lib-amd/modelApi/table/alignTableCell.js +3 -3
  50. package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
  51. package/lib-amd/modelApi/table/deleteTableColumn.js +6 -6
  52. package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
  53. package/lib-amd/modelApi/table/deleteTableRow.js +2 -2
  54. package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
  55. package/lib-amd/modelApi/table/insertTableColumn.js +6 -6
  56. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  57. package/lib-amd/modelApi/table/insertTableRow.js +3 -3
  58. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  59. package/lib-amd/modelApi/table/mergeTableCells.js +6 -5
  60. package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
  61. package/lib-amd/modelApi/table/mergeTableColumn.js +3 -3
  62. package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
  63. package/lib-amd/modelApi/table/mergeTableRow.js +3 -3
  64. package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
  65. package/lib-amd/modelApi/table/splitTableCellHorizontally.js +3 -3
  66. package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  67. package/lib-amd/modelApi/table/splitTableCellVertically.js +7 -5
  68. package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
  69. package/lib-amd/publicApi/format/getFormatState.js +7 -1
  70. package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
  71. package/lib-amd/publicApi/image/changeImage.js +2 -2
  72. package/lib-amd/publicApi/image/changeImage.js.map +1 -1
  73. package/lib-amd/publicApi/image/insertImage.js +2 -2
  74. package/lib-amd/publicApi/image/insertImage.js.map +1 -1
  75. package/lib-amd/publicApi/table/applyTableBorderFormat.js +30 -30
  76. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  77. package/lib-amd/publicApi/table/editTable.js +2 -2
  78. package/lib-amd/publicApi/table/editTable.js.map +1 -1
  79. package/lib-amd/publicApi/table/setTableCellShade.js +2 -2
  80. package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
  81. package/lib-mjs/index.d.ts +0 -3
  82. package/lib-mjs/index.js +0 -3
  83. package/lib-mjs/index.js.map +1 -1
  84. package/lib-mjs/modelApi/list/setListType.js +25 -0
  85. package/lib-mjs/modelApi/list/setListType.js.map +1 -1
  86. package/lib-mjs/modelApi/selection/collapseTableSelection.d.ts +1 -2
  87. package/lib-mjs/modelApi/selection/collapseTableSelection.js +2 -2
  88. package/lib-mjs/modelApi/selection/collapseTableSelection.js.map +1 -1
  89. package/lib-mjs/modelApi/table/alignTableCell.js +2 -3
  90. package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
  91. package/lib-mjs/modelApi/table/deleteTableColumn.js +5 -5
  92. package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
  93. package/lib-mjs/modelApi/table/deleteTableRow.js +1 -1
  94. package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
  95. package/lib-mjs/modelApi/table/insertTableColumn.js +5 -5
  96. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  97. package/lib-mjs/modelApi/table/insertTableRow.js +2 -2
  98. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  99. package/lib-mjs/modelApi/table/mergeTableCells.js +5 -4
  100. package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
  101. package/lib-mjs/modelApi/table/mergeTableColumn.js +2 -2
  102. package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
  103. package/lib-mjs/modelApi/table/mergeTableRow.js +2 -2
  104. package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
  105. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +2 -2
  106. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  107. package/lib-mjs/modelApi/table/splitTableCellVertically.js +6 -4
  108. package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
  109. package/lib-mjs/publicApi/format/getFormatState.js +8 -2
  110. package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
  111. package/lib-mjs/publicApi/image/changeImage.js +1 -2
  112. package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
  113. package/lib-mjs/publicApi/image/insertImage.js +1 -2
  114. package/lib-mjs/publicApi/image/insertImage.js.map +1 -1
  115. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +29 -30
  116. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  117. package/lib-mjs/publicApi/table/editTable.js +1 -2
  118. package/lib-mjs/publicApi/table/editTable.js.map +1 -1
  119. package/lib-mjs/publicApi/table/setTableCellShade.js +1 -2
  120. package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
  121. package/package.json +4 -4
  122. package/lib/modelApi/domUtils/readFile.d.ts +0 -8
  123. package/lib/modelApi/domUtils/readFile.js +0 -24
  124. package/lib/modelApi/domUtils/readFile.js.map +0 -1
  125. package/lib/modelApi/table/getSelectedCells.d.ts +0 -14
  126. package/lib/modelApi/table/getSelectedCells.js +0 -32
  127. package/lib/modelApi/table/getSelectedCells.js.map +0 -1
  128. package/lib/publicApi/selection/hasSelectionInBlock.d.ts +0 -6
  129. package/lib/publicApi/selection/hasSelectionInBlock.js +0 -25
  130. package/lib/publicApi/selection/hasSelectionInBlock.js.map +0 -1
  131. package/lib/publicApi/selection/hasSelectionInBlockGroup.d.ts +0 -6
  132. package/lib/publicApi/selection/hasSelectionInBlockGroup.js +0 -18
  133. package/lib/publicApi/selection/hasSelectionInBlockGroup.js.map +0 -1
  134. package/lib/publicApi/selection/hasSelectionInSegment.d.ts +0 -6
  135. package/lib/publicApi/selection/hasSelectionInSegment.js +0 -13
  136. package/lib/publicApi/selection/hasSelectionInSegment.js.map +0 -1
  137. package/lib-amd/modelApi/domUtils/readFile.d.ts +0 -8
  138. package/lib-amd/modelApi/domUtils/readFile.js +0 -26
  139. package/lib-amd/modelApi/domUtils/readFile.js.map +0 -1
  140. package/lib-amd/modelApi/table/getSelectedCells.d.ts +0 -14
  141. package/lib-amd/modelApi/table/getSelectedCells.js +0 -33
  142. package/lib-amd/modelApi/table/getSelectedCells.js.map +0 -1
  143. package/lib-amd/publicApi/selection/hasSelectionInBlock.d.ts +0 -6
  144. package/lib-amd/publicApi/selection/hasSelectionInBlock.js +0 -25
  145. package/lib-amd/publicApi/selection/hasSelectionInBlock.js.map +0 -1
  146. package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.d.ts +0 -6
  147. package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.js +0 -19
  148. package/lib-amd/publicApi/selection/hasSelectionInBlockGroup.js.map +0 -1
  149. package/lib-amd/publicApi/selection/hasSelectionInSegment.d.ts +0 -6
  150. package/lib-amd/publicApi/selection/hasSelectionInSegment.js +0 -14
  151. package/lib-amd/publicApi/selection/hasSelectionInSegment.js.map +0 -1
  152. package/lib-mjs/modelApi/domUtils/readFile.d.ts +0 -8
  153. package/lib-mjs/modelApi/domUtils/readFile.js +0 -20
  154. package/lib-mjs/modelApi/domUtils/readFile.js.map +0 -1
  155. package/lib-mjs/modelApi/table/getSelectedCells.d.ts +0 -14
  156. package/lib-mjs/modelApi/table/getSelectedCells.js +0 -28
  157. package/lib-mjs/modelApi/table/getSelectedCells.js.map +0 -1
  158. package/lib-mjs/publicApi/selection/hasSelectionInBlock.d.ts +0 -6
  159. package/lib-mjs/publicApi/selection/hasSelectionInBlock.js +0 -22
  160. package/lib-mjs/publicApi/selection/hasSelectionInBlock.js.map +0 -1
  161. package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.d.ts +0 -6
  162. package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.js +0 -15
  163. package/lib-mjs/publicApi/selection/hasSelectionInBlockGroup.js.map +0 -1
  164. package/lib-mjs/publicApi/selection/hasSelectionInSegment.d.ts +0 -6
  165. package/lib-mjs/publicApi/selection/hasSelectionInSegment.js +0 -10
  166. package/lib-mjs/publicApi/selection/hasSelectionInSegment.js.map +0 -1
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-dom", "./getSelectedCells"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, getSelectedCells_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.splitTableCellVertically = void 0;
@@ -7,7 +7,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "./getSele
7
7
  * @internal
8
8
  */
9
9
  function splitTableCellVertically(table) {
10
- var sel = (0, getSelectedCells_1.getSelectedCells)(table);
10
+ var sel = (0, roosterjs_content_model_core_1.getSelectedCells)(table);
11
11
  if (sel) {
12
12
  for (var rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {
13
13
  var row = table.rows[rowIndex];
@@ -17,10 +17,12 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "./getSele
17
17
  });
18
18
  delete row.cachedElement;
19
19
  if (belowRow === null || belowRow === void 0 ? void 0 : belowRow.cells.every(function (belowCell, colIndex) {
20
- return colIndex < sel.firstCol || colIndex > sel.lastCol || belowCell.spanAbove;
20
+ return colIndex < sel.firstColumn ||
21
+ colIndex > sel.lastColumn ||
22
+ belowCell.spanAbove;
21
23
  })) {
22
24
  belowRow.cells.forEach(function (belowCell, colIndex) {
23
- if (colIndex >= sel.firstCol && colIndex <= sel.lastCol) {
25
+ if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {
24
26
  belowCell.spanAbove = false;
25
27
  delete belowCell.cachedElement;
26
28
  }
@@ -35,7 +37,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "./getSele
35
37
  cells: row.cells.map(function (cell, colIndex) {
36
38
  var newCell = (0, roosterjs_content_model_dom_1.createTableCell)(cell.spanLeft, cell.spanAbove, cell.isHeader, cell.format);
37
39
  newCell.dataset = (0, tslib_1.__assign)({}, cell.dataset);
38
- if (colIndex < sel.firstCol || colIndex > sel.lastCol) {
40
+ if (colIndex < sel.firstColumn || colIndex > sel.lastColumn) {
39
41
  newCell.spanAbove = true;
40
42
  }
41
43
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;IAIA,IAAM,UAAU,GAAG,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAgB,wBAAwB,CAAC,KAAwB;QAC7D,IAAM,GAAG,GAAG,IAAA,mCAAgB,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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AAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,CACd,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,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;IA1DD,4DA0DC","sourcesContent":["import { createTableCell } from 'roosterjs-content-model-dom';\nimport { getSelectedCells } from './getSelectedCells';\nimport type { ContentModelTable, ContentModelTableRow } from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ContentModelTable) {\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(cell => {\n delete cell.cachedElement;\n });\n\n delete row.cachedElement;\n\n if (\n belowRow?.cells.every(\n (belowCell, colIndex) =>\n colIndex < sel.firstCol || colIndex > sel.lastCol || belowCell.spanAbove\n )\n ) {\n belowRow.cells.forEach((belowCell, colIndex) => {\n if (colIndex >= sel.firstCol && colIndex <= sel.lastCol) {\n belowCell.spanAbove = false;\n delete belowCell.cachedElement;\n }\n });\n\n delete belowRow.cachedElement;\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.firstCol || colIndex > sel.lastCol) {\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-content-model/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;IAIA,IAAM,UAAU,GAAG,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAgB,wBAAwB,CAAC,KAAwB;QAC7D,IAAM,GAAG,GAAG,IAAA,+CAAgB,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,UAAA,IAAI;oBAClB,OAAO,IAAI,CAAC,aAAa,CAAC;gBAC9B,CAAC,CAAC,CAAC;gBAEH,OAAO,GAAG,CAAC,aAAa,CAAC;gBAEzB,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;wBACz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GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;iBAC9C;aACJ;SACJ;IACL,CAAC;IA5DD,4DA4DC","sourcesContent":["import { createTableCell } from 'roosterjs-content-model-dom';\nimport { getSelectedCells } from 'roosterjs-content-model-core';\nimport type { ContentModelTable, ContentModelTableRow } from 'roosterjs-content-model-types';\n\nconst MIN_HEIGHT = 22;\n\n/**\n * @internal\n */\nexport function splitTableCellVertically(table: ContentModelTable) {\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(cell => {\n delete cell.cachedElement;\n });\n\n delete row.cachedElement;\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 belowCell.spanAbove = false;\n delete belowCell.cachedElement;\n }\n });\n\n delete belowRow.cachedElement;\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"]}
@@ -13,7 +13,13 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core", "../../mo
13
13
  child: reducedModelChildProcessor,
14
14
  },
15
15
  });
16
- var result = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, editor.getUndoState()), { isDarkMode: editor.isDarkMode(), zoomScale: editor.getZoomScale() });
16
+ var manager = editor.getSnapshotsManager();
17
+ var result = {
18
+ canUndo: manager.hasNewContent || manager.canMove(-1),
19
+ canRedo: manager.canMove(1),
20
+ isDarkMode: editor.isDarkMode(),
21
+ zoomScale: editor.getZoomScale(),
22
+ };
17
23
  (0, retrieveModelFormatState_1.retrieveModelFormatState)(model, pendingFormat, result);
18
24
  return result;
19
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAgBA;;;OAGG;IACH,SAAwB,cAAc,CAAC,MAAyB;QAC5D,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACpC,iBAAiB,EAAE;gBACf,KAAK,EAAE,0BAA0B;aACpC;SACJ,CAAC,CAAC;QACH,IAAM,MAAM,mDACL,MAAM,CAAC,YAAY,EAAE,KACxB,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,EAC/B,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,GACnC,CAAC;QAEF,IAAA,mDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAClB,CAAC;IAhBD,iCAgBC;IAaD;;;;;;;OAOG;IACH,SAAgB,0BAA0B,CACtC,KAA6B,EAC7B,MAAkB,EAClB,OAA2B;QAE3B,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACpB,IAAM,iBAAiB,GAAG,IAAA,mDAAoB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAClE,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,E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;gBAC/D,mGAAmG;gBACnG,0EAA0E;gBAC1E,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;aACzC;iBAAM;gBACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACrB;YAED,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;SAC1B;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,SAAS,aAAa,CAAC,MAAkB,EAAE,UAAgB;QACvD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAE9B,OAAO,KAAK,IAAI,KAAK,IAAI,UAAU,EAAE;YACjC,KAAK,EAAE,CAAC;YACR,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC","sourcesContent":["import { getSelectionRootNode } from 'roosterjs-content-model-core';\nimport { retrieveModelFormatState } from '../../modelApi/common/retrieveModelFormatState';\nimport type {\n IStandaloneEditor,\n ContentModelBlockGroup,\n ContentModelFormatState,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\nimport {\n getRegularSelectionOffsets,\n handleRegularSelection,\n isNodeOfType,\n processChildNode,\n} from 'roosterjs-content-model-dom';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n */\nexport default function getFormatState(editor: IStandaloneEditor): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const model = editor.createContentModel({\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n });\n const result: ContentModelFormatState = {\n ...editor.getUndoState(),\n isDarkMode: editor.isDarkMode(),\n zoomScale: editor.getZoomScale(),\n };\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n}\n\n/**\n * @internal\n */\ninterface FormatStateContext extends DomToModelContext {\n /**\n * An optional stack of parent elements to process. When provided, the child nodes of current parent element will be ignored,\n * but use the top element in this stack instead in childProcessor.\n */\n nodeStack?: Node[];\n}\n\n/**\n * @internal\n * Export for test only\n * In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create\n * content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.\n * This \"reduced\" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,\n * then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state\n */\nexport function reducedModelChildProcessor(\n group: ContentModelBlockGroup,\n parent: ParentNode,\n context: FormatStateContext\n) {\n if (!context.nodeStack) {\n const selectionRootNode = getSelectionRootNode(context.selection);\n context.nodeStack = selectionRootNode ? createNodeStack(parent, selectionRootNode) : [];\n }\n\n const stackChild = context.nodeStack.pop();\n\n if (stackChild) {\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, parent);\n\n // If selection is not on this node, skip getting node index to save some time since we don't need it here\n const index =\n nodeStartOffset >= 0 || nodeEndOffset >= 0 ? getChildIndex(parent, stackChild) : -1;\n\n if (index >= 0) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n }\n\n processChildNode(group, stackChild, context);\n\n if (index >= 0) {\n handleRegularSelection(index + 1, context, group, nodeStartOffset, nodeEndOffset);\n }\n } else {\n // No child node from node stack, that means we have reached the deepest node of selection.\n // Now we can use default child processor to perform full sub tree scanning for content model,\n // So that all selected node will be included.\n context.defaultElementProcessors.child(group, parent, context);\n }\n}\n\nfunction createNodeStack(root: Node, startNode: Node): Node[] {\n const result: Node[] = [];\n let node: Node | null = startNode;\n\n while (node && root != node && root.contains(node)) {\n if (isNodeOfType(node, 'ELEMENT_NODE') && node.tagName == 'TABLE') {\n // For table, we can't do a reduced model creation since we need to handle their cells and indexes,\n // so clean up whatever we already have, and just put table into the stack\n result.splice(0, result.length, node);\n } else {\n result.push(node);\n }\n\n node = node.parentNode;\n }\n\n return result;\n}\n\nfunction getChildIndex(parent: ParentNode, stackChild: Node) {\n let index = 0;\n let child = parent.firstChild;\n\n while (child && child != stackChild) {\n index++;\n child = child.nextSibling;\n }\n return index;\n}\n"]}
1
+ {"version":3,"file":"getFormatState.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/format/getFormatState.ts"],"names":[],"mappings":";;;;IAgBA;;;OAGG;IACH,SAAwB,cAAc,CAAC,MAAyB;QAC5D,IAAM,aAAa,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAChD,IAAM,KAAK,GAAG,MAAM,CAAC,kBAAkB,CAAC;YACpC,iBAAiB,EAAE;gBACf,KAAK,EAAE,0BAA0B;aACpC;SACJ,CAAC,CAAC;QACH,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;YAC/B,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE;SACnC,CAAC;QAEF,IAAA,mDAAwB,EAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;QAEvD,OAAO,MAAM,CAAC;IAClB,CAAC;IAlBD,iCAkBC;IAaD;;;;;;;OAOG;IACH,SAAgB,0BAA0B,CACtC,KAA6B,EAC7B,MAAkB,EAClB,OAA2B;QAE3B,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACpB,IAAM,iBAAiB,GAAG,IAAA,mDAAoB,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAClE,OAAO,CAAC,SAAS,GAAG,iBAAiB,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3F;QAED,IAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAE3C,IAAI,UAAU,EAAE;YACN,IAAA,KAA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zC;iBAAM;gBACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACrB;YAED,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;SAC1B;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,SAAS,aAAa,CAAC,MAAkB,EAAE,UAAgB;QACvD,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAE9B,OAAO,KAAK,IAAI,KAAK,IAAI,UAAU,EAAE;YACjC,KAAK,EAAE,CAAC;YACR,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;SAC7B;QACD,OAAO,KAAK,CAAC;IACjB,CAAC","sourcesContent":["import { getSelectionRootNode } from 'roosterjs-content-model-core';\nimport { retrieveModelFormatState } from '../../modelApi/common/retrieveModelFormatState';\nimport type {\n IStandaloneEditor,\n ContentModelBlockGroup,\n ContentModelFormatState,\n DomToModelContext,\n} from 'roosterjs-content-model-types';\n\nimport {\n getRegularSelectionOffsets,\n handleRegularSelection,\n isNodeOfType,\n processChildNode,\n} from 'roosterjs-content-model-dom';\n\n/**\n * Get current format state\n * @param editor The editor to get format from\n */\nexport default function getFormatState(editor: IStandaloneEditor): ContentModelFormatState {\n const pendingFormat = editor.getPendingFormat();\n const model = editor.createContentModel({\n processorOverride: {\n child: reducedModelChildProcessor,\n },\n });\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 zoomScale: editor.getZoomScale(),\n };\n\n retrieveModelFormatState(model, pendingFormat, result);\n\n return result;\n}\n\n/**\n * @internal\n */\ninterface FormatStateContext extends DomToModelContext {\n /**\n * An optional stack of parent elements to process. When provided, the child nodes of current parent element will be ignored,\n * but use the top element in this stack instead in childProcessor.\n */\n nodeStack?: Node[];\n}\n\n/**\n * @internal\n * Export for test only\n * In order to get format, we can still use the regular child processor. However, to improve performance, we don't need to create\n * content model for the whole doc, instead we only need to traverse the tree path that can arrive current selected node.\n * This \"reduced\" child processor will first create a node stack that stores DOM node from root to current common ancestor node of selection,\n * then use this stack as a faked DOM tree to create a reduced content model which we can use to retrieve format state\n */\nexport function reducedModelChildProcessor(\n group: ContentModelBlockGroup,\n parent: ParentNode,\n context: FormatStateContext\n) {\n if (!context.nodeStack) {\n const selectionRootNode = getSelectionRootNode(context.selection);\n context.nodeStack = selectionRootNode ? createNodeStack(parent, selectionRootNode) : [];\n }\n\n const stackChild = context.nodeStack.pop();\n\n if (stackChild) {\n const [nodeStartOffset, nodeEndOffset] = getRegularSelectionOffsets(context, parent);\n\n // If selection is not on this node, skip getting node index to save some time since we don't need it here\n const index =\n nodeStartOffset >= 0 || nodeEndOffset >= 0 ? getChildIndex(parent, stackChild) : -1;\n\n if (index >= 0) {\n handleRegularSelection(index, context, group, nodeStartOffset, nodeEndOffset);\n }\n\n processChildNode(group, stackChild, context);\n\n if (index >= 0) {\n handleRegularSelection(index + 1, context, group, nodeStartOffset, nodeEndOffset);\n }\n } else {\n // No child node from node stack, that means we have reached the deepest node of selection.\n // Now we can use default child processor to perform full sub tree scanning for content model,\n // So that all selected node will be included.\n context.defaultElementProcessors.child(group, parent, context);\n }\n}\n\nfunction createNodeStack(root: Node, startNode: Node): Node[] {\n const result: Node[] = [];\n let node: Node | null = startNode;\n\n while (node && root != node && root.contains(node)) {\n if (isNodeOfType(node, 'ELEMENT_NODE') && node.tagName == 'TABLE') {\n // For table, we can't do a reduced model creation since we need to handle their cells and indexes,\n // so clean up whatever we already have, and just put table into the stack\n result.splice(0, result.length, node);\n } else {\n result.push(node);\n }\n\n node = node.parentNode;\n }\n\n return result;\n}\n\nfunction getChildIndex(parent: ParentNode, stackChild: Node) {\n let index = 0;\n let child = parent.firstChild;\n\n while (child && child != stackChild) {\n index++;\n child = child.nextSibling;\n }\n return index;\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "../utils/formatImageWithContentModel", "../../modelApi/domUtils/readFile", "roosterjs-content-model-core"], function (require, exports, formatImageWithContentModel_1, readFile_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "../utils/formatImageWithContentModel", "roosterjs-content-model-core"], function (require, exports, formatImageWithContentModel_1, roosterjs_content_model_core_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  /**
@@ -9,7 +9,7 @@ define(["require", "exports", "../utils/formatImageWithContentModel", "../../mod
9
9
  function changeImage(editor, file) {
10
10
  editor.focus();
11
11
  var selection = editor.getDOMSelection();
12
- (0, readFile_1.readFile)(file, function (dataUrl) {
12
+ (0, roosterjs_content_model_core_1.readFile)(file, function (dataUrl) {
13
13
  if (dataUrl && !editor.isDisposed() && (selection === null || selection === void 0 ? void 0 : selection.type) === 'image') {
14
14
  (0, formatImageWithContentModel_1.default)(editor, 'changeImage', function (image) {
15
15
  var _a, _b;
@@ -1 +1 @@
1
- {"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;IAMA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,IAAU;QACrE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAA,mBAAQ,EAAC,IAAI,EAAE,UAAA,OAAO;YAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,OAAO,EAAE;gBAChE,IAAA,qCAA2B,EAAC,MAAM,EAAE,aAAa,EAAE,UAAC,KAAwB;;oBACxE,IAAM,WAAW,GAAG,MAAA,MAAA,IAAA,kDAAmB,EAAC,KAAK,CAAC,0CAAE,GAAG,mCAAI,EAAE,CAAC;oBAC1D,IAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;oBAE9B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;oBACpB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;oBACnB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;oBACxB,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;oBACzB,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;oBAEf,MAAM,CAAC,kBAAkB,qBAA4B;wBACjD,KAAK,EAAE,SAAS,CAAC,KAAK;wBACtB,WAAW,aAAA;wBACX,MAAM,EAAE,OAAO;wBACf,WAAW,aAAA;qBACd,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAzBD,8BAyBC","sourcesContent":["import formatImageWithContentModel from '../utils/formatImageWithContentModel';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport { readFile } from '../../modelApi/domUtils/readFile';\nimport { updateImageMetadata } from 'roosterjs-content-model-core';\nimport type { ContentModelImage, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Change the selected image src\n * @param editor The editor instance\n * @param file The image file\n */\nexport default function changeImage(editor: IStandaloneEditor, file: File) {\n editor.focus();\n\n const selection = editor.getDOMSelection();\n readFile(file, dataUrl => {\n if (dataUrl && !editor.isDisposed() && selection?.type === 'image') {\n formatImageWithContentModel(editor, 'changeImage', (image: ContentModelImage) => {\n const originalSrc = updateImageMetadata(image)?.src ?? '';\n const previousSrc = image.src;\n\n image.src = dataUrl;\n image.dataset = {};\n image.format.width = '';\n image.format.height = '';\n image.alt = '';\n\n editor.triggerPluginEvent(PluginEventType.EditImage, {\n image: selection.image,\n previousSrc,\n newSrc: dataUrl,\n originalSrc,\n });\n });\n }\n });\n}\n"]}
1
+ {"version":3,"file":"changeImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/changeImage.ts"],"names":[],"mappings":";;;IAKA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,IAAU;QACrE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAA,uCAAQ,EAAC,IAAI,EAAE,UAAA,OAAO;YAClB,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,OAAO,EAAE;gBAChE,IAAA,qCAA2B,EAAC,MAAM,EAAE,aAAa,EAAE,UAAC,KAAwB;;oBACxE,IAAM,WAAW,GAAG,MAAA,MAAA,IAAA,kDAAmB,EAAC,KAAK,CAAC,0CAAE,GAAG,mCAAI,EAAE,CAAC;oBAC1D,IAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC;oBAE9B,KAAK,CAAC,GAAG,GAAG,OAAO,CAAC;oBACpB,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;oBACnB,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;oBACxB,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;oBACzB,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC;oBAEf,MAAM,CAAC,kBAAkB,qBAA4B;wBACjD,KAAK,EAAE,SAAS,CAAC,KAAK;wBACtB,WAAW,aAAA;wBACX,MAAM,EAAE,OAAO;wBACf,WAAW,aAAA;qBACd,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAzBD,8BAyBC","sourcesContent":["import formatImageWithContentModel from '../utils/formatImageWithContentModel';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport { readFile, updateImageMetadata } from 'roosterjs-content-model-core';\nimport type { ContentModelImage, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Change the selected image src\n * @param editor The editor instance\n * @param file The image file\n */\nexport default function changeImage(editor: IStandaloneEditor, file: File) {\n editor.focus();\n\n const selection = editor.getDOMSelection();\n readFile(file, dataUrl => {\n if (dataUrl && !editor.isDisposed() && selection?.type === 'image') {\n formatImageWithContentModel(editor, 'changeImage', (image: ContentModelImage) => {\n const originalSrc = updateImageMetadata(image)?.src ?? '';\n const previousSrc = image.src;\n\n image.src = dataUrl;\n image.dataset = {};\n image.format.width = '';\n image.format.height = '';\n image.alt = '';\n\n editor.triggerPluginEvent(PluginEventType.EditImage, {\n image: selection.image,\n previousSrc,\n newSrc: dataUrl,\n originalSrc,\n });\n });\n }\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-model-core", "../../modelApi/domUtils/readFile"], function (require, exports, roosterjs_content_model_dom_1, roosterjs_content_model_core_1, readFile_1) {
1
+ define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  /**
@@ -12,7 +12,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-
12
12
  insertImageWithSrc(editor, imageFileOrSrc);
13
13
  }
14
14
  else {
15
- (0, readFile_1.readFile)(imageFileOrSrc, function (dataUrl) {
15
+ (0, roosterjs_content_model_core_1.readFile)(imageFileOrSrc, function (dataUrl) {
16
16
  if (dataUrl && !editor.isDisposed()) {
17
17
  insertImageWithSrc(editor, dataUrl);
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"insertImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/insertImage.ts"],"names":[],"mappings":";;;IAKA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,cAA6B;QACxF,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,OAAO,cAAc,IAAI,QAAQ,EAAE;YACnC,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;SAC9C;aAAM;YACH,IAAA,mBAAQ,EAAC,cAAc,EAAE,UAAA,OAAO;gBAC5B,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE;oBACjC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iBACvC;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAZD,8BAYC;IAED,SAAS,kBAAkB,CAAC,MAAyB,EAAE,GAAW;QAC9D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,KAAK,GAAG,IAAA,yCAAW,EAAC,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;YACxD,IAAM,GAAG,GAAG,IAAA,wDAA0B,GAAE,CAAC;YAEzC,IAAA,wCAAU,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACvB,IAAA,yCAAU,EAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;gBAC5B,WAAW,EAAE,UAAU;aAC1B,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QAChB,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC","sourcesContent":["import { addSegment, createContentModelDocument, createImage } from 'roosterjs-content-model-dom';\nimport { mergeModel } from 'roosterjs-content-model-core';\nimport { readFile } from '../../modelApi/domUtils/readFile';\nimport type { IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Insert an image into current selected position\n * @param editor The editor to operate on\n * @param file Image Blob file or source string\n */\nexport default function insertImage(editor: IStandaloneEditor, imageFileOrSrc: File | string) {\n editor.focus();\n\n if (typeof imageFileOrSrc == 'string') {\n insertImageWithSrc(editor, imageFileOrSrc);\n } else {\n readFile(imageFileOrSrc, dataUrl => {\n if (dataUrl && !editor.isDisposed()) {\n insertImageWithSrc(editor, dataUrl);\n }\n });\n }\n}\n\nfunction insertImageWithSrc(editor: IStandaloneEditor, src: string) {\n editor.formatContentModel(\n (model, context) => {\n const image = createImage(src, { backgroundColor: '' });\n const doc = createContentModelDocument();\n\n addSegment(doc, image);\n mergeModel(model, doc, context, {\n mergeFormat: 'mergeAll',\n });\n\n return true;\n },\n {\n apiName: 'insertImage',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"insertImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/image/insertImage.ts"],"names":[],"mappings":";;;IAIA;;;;OAIG;IACH,SAAwB,WAAW,CAAC,MAAyB,EAAE,cAA6B;QACxF,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,OAAO,cAAc,IAAI,QAAQ,EAAE;YACnC,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;SAC9C;aAAM;YACH,IAAA,uCAAQ,EAAC,cAAc,EAAE,UAAA,OAAO;gBAC5B,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE;oBACjC,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;iBACvC;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IAZD,8BAYC;IAED,SAAS,kBAAkB,CAAC,MAAyB,EAAE,GAAW;QAC9D,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,KAAK,GAAG,IAAA,yCAAW,EAAC,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;YACxD,IAAM,GAAG,GAAG,IAAA,wDAA0B,GAAE,CAAC;YAEzC,IAAA,wCAAU,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACvB,IAAA,yCAAU,EAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;gBAC5B,WAAW,EAAE,UAAU;aAC1B,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QAChB,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC","sourcesContent":["import { addSegment, createContentModelDocument, createImage } from 'roosterjs-content-model-dom';\nimport { mergeModel, readFile } from 'roosterjs-content-model-core';\nimport type { IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * Insert an image into current selected position\n * @param editor The editor to operate on\n * @param file Image Blob file or source string\n */\nexport default function insertImage(editor: IStandaloneEditor, imageFileOrSrc: File | string) {\n editor.focus();\n\n if (typeof imageFileOrSrc == 'string') {\n insertImageWithSrc(editor, imageFileOrSrc);\n } else {\n readFile(imageFileOrSrc, dataUrl => {\n if (dataUrl && !editor.isDisposed()) {\n insertImageWithSrc(editor, dataUrl);\n }\n });\n }\n}\n\nfunction insertImageWithSrc(editor: IStandaloneEditor, src: string) {\n editor.formatContentModel(\n (model, context) => {\n const image = createImage(src, { backgroundColor: '' });\n const doc = createContentModelDocument();\n\n addSegment(doc, image);\n mergeModel(model, doc, context, {\n mergeFormat: 'mergeAll',\n });\n\n return true;\n },\n {\n apiName: 'insertImage',\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, tslib_1, getSelectedCells_1, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  /**
@@ -11,7 +11,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
11
11
  editor.formatContentModel(function (model) {
12
12
  var _a = (0, tslib_1.__read)((0, roosterjs_content_model_core_1.getFirstSelectedTable)(model), 1), tableModel = _a[0];
13
13
  if (tableModel) {
14
- var sel = (0, getSelectedCells_1.getSelectedCells)(tableModel);
14
+ var sel = (0, roosterjs_content_model_core_1.getSelectedCells)(tableModel);
15
15
  var perimeter = {
16
16
  Top: false,
17
17
  Bottom: false,
@@ -67,7 +67,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
67
67
  'borderRight',
68
68
  ];
69
69
  for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
70
- for (var colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {
70
+ for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
71
71
  var cell = tableModel.rows[rowIndex].cells[colIndex];
72
72
  // Format cells - All borders
73
73
  applyBorderFormat(cell, borderFormat, allBorders);
@@ -82,7 +82,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
82
82
  case 'leftBorders':
83
83
  var leftBorder = ['borderLeft'];
84
84
  for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
85
- var cell = tableModel.rows[rowIndex].cells[sel.firstCol];
85
+ var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
86
86
  // Format cells - Left border
87
87
  applyBorderFormat(cell, borderFormat, leftBorder);
88
88
  }
@@ -92,7 +92,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
92
92
  case 'rightBorders':
93
93
  var rightBorder = ['borderRight'];
94
94
  for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
95
- var cell = tableModel.rows[rowIndex].cells[sel.lastCol];
95
+ var cell = tableModel.rows[rowIndex].cells[sel.lastColumn];
96
96
  // Format cells - Right border
97
97
  applyBorderFormat(cell, borderFormat, rightBorder);
98
98
  }
@@ -101,7 +101,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
101
101
  break;
102
102
  case 'topBorders':
103
103
  var topBorder = ['borderTop'];
104
- for (var colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {
104
+ for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
105
105
  var cell = tableModel.rows[sel.firstRow].cells[colIndex];
106
106
  // Format cells - Top border
107
107
  applyBorderFormat(cell, borderFormat, topBorder);
@@ -111,7 +111,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
111
111
  break;
112
112
  case 'bottomBorders':
113
113
  var bottomBorder = ['borderBottom'];
114
- for (var colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {
114
+ for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
115
115
  var cell = tableModel.rows[sel.lastRow].cells[colIndex];
116
116
  // Format cells - Bottom border
117
117
  applyBorderFormat(cell, borderFormat, bottomBorder);
@@ -121,7 +121,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
121
121
  break;
122
122
  case 'insideBorders':
123
123
  // Format cells - Inside borders
124
- var singleCol = sel.lastCol == sel.firstCol;
124
+ var singleCol = sel.lastColumn == sel.firstColumn;
125
125
  var singleRow = sel.lastRow == sel.firstRow;
126
126
  // Single cell selection
127
127
  if (singleCol && singleRow) {
@@ -129,41 +129,41 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
129
129
  }
130
130
  // Single column selection
131
131
  if (singleCol) {
132
- applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstCol], borderFormat, ['borderBottom']);
132
+ applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], borderFormat, ['borderBottom']);
133
133
  for (var rowIndex = sel.firstRow + 1; rowIndex <= sel.lastRow - 1; rowIndex++) {
134
- var cell = tableModel.rows[rowIndex].cells[sel.firstCol];
134
+ var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
135
135
  applyBorderFormat(cell, borderFormat, [
136
136
  'borderTop',
137
137
  'borderBottom',
138
138
  ]);
139
139
  }
140
- applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstCol], borderFormat, ['borderTop']);
140
+ applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstColumn], borderFormat, ['borderTop']);
141
141
  break;
142
142
  }
143
143
  // Single row selection
144
144
  if (singleRow) {
145
- applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstCol], borderFormat, ['borderRight']);
146
- for (var colIndex = sel.firstCol + 1; colIndex <= sel.lastCol - 1; colIndex++) {
145
+ applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], borderFormat, ['borderRight']);
146
+ for (var colIndex = sel.firstColumn + 1; colIndex <= sel.lastColumn - 1; colIndex++) {
147
147
  var cell = tableModel.rows[sel.firstRow].cells[colIndex];
148
148
  applyBorderFormat(cell, borderFormat, [
149
149
  'borderLeft',
150
150
  'borderRight',
151
151
  ]);
152
152
  }
153
- applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.lastCol], borderFormat, ['borderLeft']);
153
+ applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.lastColumn], borderFormat, ['borderLeft']);
154
154
  break;
155
155
  }
156
156
  // For multiple rows and columns selections
157
157
  // Top left cell
158
- applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstCol], borderFormat, ['borderBottom', 'borderRight']);
158
+ applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.firstColumn], borderFormat, ['borderBottom', 'borderRight']);
159
159
  // Top right cell
160
- applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.lastCol], borderFormat, ['borderBottom', 'borderLeft']);
160
+ applyBorderFormat(tableModel.rows[sel.firstRow].cells[sel.lastColumn], borderFormat, ['borderBottom', 'borderLeft']);
161
161
  // Bottom left cell
162
- applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstCol], borderFormat, ['borderTop', 'borderRight']);
162
+ applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.firstColumn], borderFormat, ['borderTop', 'borderRight']);
163
163
  // Bottom right cell
164
- applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.lastCol], borderFormat, ['borderTop', 'borderLeft']);
164
+ applyBorderFormat(tableModel.rows[sel.lastRow].cells[sel.lastColumn], borderFormat, ['borderTop', 'borderLeft']);
165
165
  // First row
166
- for (var colIndex = sel.firstCol + 1; colIndex < sel.lastCol; colIndex++) {
166
+ for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
167
167
  var cell = tableModel.rows[sel.firstRow].cells[colIndex];
168
168
  applyBorderFormat(cell, borderFormat, [
169
169
  'borderBottom',
@@ -172,7 +172,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
172
172
  ]);
173
173
  }
174
174
  // Last row
175
- for (var colIndex = sel.firstCol + 1; colIndex < sel.lastCol; colIndex++) {
175
+ for (var colIndex = sel.firstColumn + 1; colIndex < sel.lastColumn; colIndex++) {
176
176
  var cell = tableModel.rows[sel.lastRow].cells[colIndex];
177
177
  applyBorderFormat(cell, borderFormat, [
178
178
  'borderTop',
@@ -182,7 +182,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
182
182
  }
183
183
  // First column
184
184
  for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
185
- var cell = tableModel.rows[rowIndex].cells[sel.firstCol];
185
+ var cell = tableModel.rows[rowIndex].cells[sel.firstColumn];
186
186
  applyBorderFormat(cell, borderFormat, [
187
187
  'borderTop',
188
188
  'borderBottom',
@@ -191,7 +191,7 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
191
191
  }
192
192
  // Last column
193
193
  for (var rowIndex = sel.firstRow + 1; rowIndex < sel.lastRow; rowIndex++) {
194
- var cell = tableModel.rows[rowIndex].cells[sel.lastCol];
194
+ var cell = tableModel.rows[rowIndex].cells[sel.lastColumn];
195
195
  applyBorderFormat(cell, borderFormat, [
196
196
  'borderTop',
197
197
  'borderBottom',
@@ -199,9 +199,9 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
199
199
  ]);
200
200
  }
201
201
  // Inner cells
202
- sel.firstCol++;
202
+ sel.firstColumn++;
203
203
  sel.firstRow++;
204
- sel.lastCol--;
204
+ sel.lastColumn--;
205
205
  sel.lastRow--;
206
206
  operations.push('allBorders');
207
207
  break;
@@ -260,29 +260,29 @@ define(["require", "exports", "tslib", "../../modelApi/table/getSelectedCells",
260
260
  function modifyPerimeter(tableModel, sel, borderFormat, perimeter) {
261
261
  // Top of selection
262
262
  if (perimeter.Top && sel.firstRow - 1 >= 0) {
263
- for (var colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {
263
+ for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
264
264
  var cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];
265
265
  applyBorderFormat(cell, borderFormat, ['borderBottom']);
266
266
  }
267
267
  }
268
268
  // Bottom of selection
269
269
  if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {
270
- for (var colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {
270
+ for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
271
271
  var cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];
272
272
  applyBorderFormat(cell, borderFormat, ['borderTop']);
273
273
  }
274
274
  }
275
275
  // Left of selection
276
- if (perimeter.Left && sel.firstCol - 1 >= 0) {
276
+ if (perimeter.Left && sel.firstColumn - 1 >= 0) {
277
277
  for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
278
- var cell = tableModel.rows[rowIndex].cells[sel.firstCol - 1];
278
+ var cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];
279
279
  applyBorderFormat(cell, borderFormat, ['borderRight']);
280
280
  }
281
281
  }
282
282
  // Right of selection
283
- if (perimeter.Right && sel.lastCol + 1 < tableModel.rows[0].cells.length) {
283
+ if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {
284
284
  for (var rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {
285
- var cell = tableModel.rows[rowIndex].cells[sel.lastCol + 1];
285
+ var cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];
286
286
  applyBorderFormat(cell, borderFormat, ['borderLeft']);
287
287
  }
288
288
  }
@@ -1 +1 @@
1
- {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;IAkCA;;;;;OAKG;IACH,SAAwB,sBAAsB,CAC1C,MAAyB,EACzB,MAAc,EACd,SAA2B;QAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,IAAM,GAAG,GAAG,IAAA,mCAAgB,EAAC,UAAU,CAAC,CAAC;gBACzC,IAAM,SAAS,GAAc;oBACzB,GAAG,EAAE,KAAK;oBACV,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,KAAK;iBACf,CAAC;gBAEF,mDAAmD;gBACnD,IAAI,YAAY,GAAG,EAAE,CAAC;gBACtB,IAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;gBACzB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,KAAK,GAAY,MAAM,MAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;gBACvC,IAAM,eAAe,GAAG,IAAA,kDAAmB,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9D,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAE1C,IAAI,KAAK,EAAE;oBACP,YAAY,GAAG,IAAA,gDAAkB,EAAC,KAAK,CAAC,GAAG,IAAI,CAAC;iBACnD;qBAAM,IAAI,WAAW,EAAE;oBACpB,YAAY,GAAG,WAAW,CAAC;iBAC9B;qBAAM;oBACH,YAAY,GAAG,KA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AAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;gBAC9D,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;aACzD;SACJ;IACL,CAAC","sourcesContent":["import { getSelectedCells } from '../../modelApi/table/getSelectedCells';\nimport { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getFirstSelectedTable,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n IStandaloneEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n} from 'roosterjs-content-model-types';\nimport type { TableSelectionCoordinates } from '../../modelApi/table/getSelectedCells';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport default function applyTableBorderFormat(\n editor: IStandaloneEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstCol;\n colIndex <= sel.lastCol;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstCol];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n perimeter.Left = true;\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastCol];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n perimeter.Right = true;\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstCol;\n colIndex <= sel.lastCol;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstCol;\n colIndex <= sel.lastCol;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastCol == sel.firstCol;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstCol],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstCol];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstCol],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstCol],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstCol + 1;\n colIndex <= sel.lastCol - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastCol],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstCol],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastCol],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstCol],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.lastCol],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstCol + 1;\n colIndex < sel.lastCol;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstCol + 1;\n colIndex < sel.lastCol;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstCol];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastCol];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstCol++;\n sel.firstRow++;\n sel.lastCol--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstCol; colIndex <= sel.lastCol; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstCol - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstCol - 1];\n applyBorderFormat(cell, borderFormat, ['borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastCol + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastCol + 1];\n applyBorderFormat(cell, borderFormat, ['borderLeft']);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;IAkCA;;;;;OAKG;IACH,SAAwB,sBAAsB,CAC1C,MAAyB,EACzB,MAAc,EACd,SAA2B;QAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,IAAM,GAAG,GAAG,IAAA,+CAAgB,EAAC,UAAU,CAAC,CAAC;gBACzC,IAAM,SAAS,GAAc;oBACzB,GAAG,EAAE,KAAK;oBACV,MAAM,EAAE,KAAK;oBACb,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,KAAK;iBACf,CAAC;gBAEF,mDAAmD;gBACnD,IAAI,YAAY,GAAG,EAAE,CAAC;gBACtB,IAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;gBACzB,IAAA,KAAK,GAAmB,MAAM,MAAzB,EAAE,KAAK,GAAY,MAAM,MAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;gBACvC,IAAM,eAAe,GAAG,IAAA,kDAAmB,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC9D,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAC1C,IAAM,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC;gBAE1C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;QACD,qBAAqB;QACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gBACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;aACzD;SACJ;IACL,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n IStandaloneEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport default function applyTableBorderFormat(\n editor: IStandaloneEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n perimeter.Left = true;\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n perimeter.Right = true;\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastColumn],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.lastColumn],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.lastColumn],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, ['borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, ['borderLeft']);\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "../selection/hasSelectionInBlock", "../../modelApi/table/alignTable", "../../modelApi/table/deleteTable", "../../modelApi/table/deleteTableColumn", "../../modelApi/table/deleteTableRow", "../../modelApi/table/ensureFocusableParagraphForTable", "../../modelApi/table/insertTableColumn", "../../modelApi/table/insertTableRow", "../../modelApi/table/mergeTableCells", "../../modelApi/table/mergeTableColumn", "../../modelApi/table/mergeTableRow", "../../modelApi/table/splitTableCellHorizontally", "../../modelApi/table/splitTableCellVertically", "roosterjs-content-model-core", "../../modelApi/table/alignTableCell", "roosterjs-content-model-dom"], function (require, exports, tslib_1, hasSelectionInBlock_1, alignTable_1, deleteTable_1, deleteTableColumn_1, deleteTableRow_1, ensureFocusableParagraphForTable_1, insertTableColumn_1, insertTableRow_1, mergeTableCells_1, mergeTableColumn_1, mergeTableRow_1, splitTableCellHorizontally_1, splitTableCellVertically_1, roosterjs_content_model_core_1, alignTableCell_1, roosterjs_content_model_dom_1) {
1
+ define(["require", "exports", "tslib", "../../modelApi/table/alignTable", "../../modelApi/table/deleteTable", "../../modelApi/table/deleteTableColumn", "../../modelApi/table/deleteTableRow", "../../modelApi/table/ensureFocusableParagraphForTable", "../../modelApi/table/insertTableColumn", "../../modelApi/table/insertTableRow", "../../modelApi/table/mergeTableCells", "../../modelApi/table/mergeTableColumn", "../../modelApi/table/mergeTableRow", "../../modelApi/table/splitTableCellHorizontally", "../../modelApi/table/splitTableCellVertically", "roosterjs-content-model-core", "../../modelApi/table/alignTableCell", "roosterjs-content-model-dom"], function (require, exports, tslib_1, alignTable_1, deleteTable_1, deleteTableColumn_1, deleteTableRow_1, ensureFocusableParagraphForTable_1, insertTableColumn_1, insertTableRow_1, mergeTableCells_1, mergeTableColumn_1, mergeTableRow_1, splitTableCellHorizontally_1, splitTableCellVertically_1, roosterjs_content_model_core_1, alignTableCell_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  /**
@@ -62,7 +62,7 @@ define(["require", "exports", "tslib", "../selection/hasSelectionInBlock", "../.
62
62
  (0, splitTableCellVertically_1.splitTableCellVertically)(tableModel);
63
63
  break;
64
64
  }
65
- if (!(0, hasSelectionInBlock_1.default)(tableModel)) {
65
+ if (!(0, roosterjs_content_model_core_1.hasSelectionInBlock)(tableModel)) {
66
66
  var paragraph = (0, ensureFocusableParagraphForTable_1.ensureFocusableParagraphForTable)(model, path, tableModel);
67
67
  if (paragraph) {
68
68
  var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)(model.format);
@@ -1 +1 @@
1
- {"version":3,"file":"editTable.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/editTable.ts"],"names":[],"mappings":";;;IA8BA;;;;OAIG;IACH,SAAwB,SAAS,CAAC,MAAyB,EAAE,SAAyB;QAClF,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAqB,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAAhD,UAAU,QAAA,EAAE,IAAI,QAAgC,CAAC;YAExD,IAAI,UAAU,EAAE;gBACZ,QAAQ,SAAS,EAAE;oBACf,KAAK,eAAe,CAAC;oBACrB,KAAK,iBAAiB,CAAC;oBACvB,KAAK,gB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IAAA,mDAAwB,EAAC,UAAU,CAAC,CAAC;wBACrC,MAAM;iBACb;gBAED,IAAI,CAAC,IAAA,6BAAmB,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,2CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;qBAC/B;iBACJ;gBAED,IAAA,6CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;oBACzB,IAAA,+CAAgB,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,EAAE,WAAW;SACvB,CACJ,CAAC;IACN,CAAC;IAjGD,4BAiGC","sourcesContent":["import hasSelectionInBlock from '../selection/hasSelectionInBlock';\nimport { alignTable } from '../../modelApi/table/alignTable';\nimport { deleteTable } from '../../modelApi/table/deleteTable';\nimport { deleteTableColumn } from '../../modelApi/table/deleteTableColumn';\nimport { deleteTableRow } from '../../modelApi/table/deleteTableRow';\nimport { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport { insertTableColumn } from '../../modelApi/table/insertTableColumn';\nimport { insertTableRow } from '../../modelApi/table/insertTableRow';\nimport { mergeTableCells } from '../../modelApi/table/mergeTableCells';\nimport { mergeTableColumn } from '../../modelApi/table/mergeTableColumn';\nimport { mergeTableRow } from '../../modelApi/table/mergeTableRow';\nimport { splitTableCellHorizontally } from '../../modelApi/table/splitTableCellHorizontally';\nimport { splitTableCellVertically } from '../../modelApi/table/splitTableCellVertically';\nimport {\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n} from 'roosterjs-content-model-core';\nimport type { TableOperation, IStandaloneEditor } from 'roosterjs-content-model-types';\nimport {\n alignTableCellHorizontally,\n alignTableCellVertically,\n} from '../../modelApi/table/alignTableCell';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\n\n/**\n * Format current focused table with the given format\n * @param editor The editor instance\n * @param operation The table operation to apply\n */\nexport default function editTable(editor: IStandaloneEditor, operation: TableOperation) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [tableModel, path] = getFirstSelectedTable(model);\n\n if (tableModel) {\n switch (operation) {\n case 'alignCellLeft':\n case 'alignCellCenter':\n case 'alignCellRight':\n alignTableCellHorizontally(tableModel, operation);\n break;\n case 'alignCellTop':\n case 'alignCellMiddle':\n case 'alignCellBottom':\n alignTableCellVertically(tableModel, operation);\n break;\n case 'alignCenter':\n case 'alignLeft':\n case 'alignRight':\n alignTable(tableModel, operation);\n break;\n\n case 'deleteColumn':\n deleteTableColumn(tableModel);\n break;\n\n case 'deleteRow':\n deleteTableRow(tableModel);\n break;\n\n case 'deleteTable':\n deleteTable(tableModel);\n break;\n\n case 'insertAbove':\n case 'insertBelow':\n insertTableRow(tableModel, operation);\n break;\n\n case 'insertLeft':\n case 'insertRight':\n insertTableColumn(tableModel, operation);\n break;\n\n case 'mergeAbove':\n case 'mergeBelow':\n mergeTableRow(tableModel, operation);\n break;\n\n case 'mergeCells':\n mergeTableCells(tableModel);\n break;\n\n case 'mergeLeft':\n case 'mergeRight':\n mergeTableColumn(tableModel, operation);\n break;\n\n case 'splitHorizontally':\n splitTableCellHorizontally(tableModel);\n break;\n\n case 'splitVertically':\n splitTableCellVertically(tableModel);\n break;\n }\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: 'editTable',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"editTable.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-api/lib/publicApi/table/editTable.ts"],"names":[],"mappings":";;;IA+BA;;;;OAIG;IACH,SAAwB,SAAS,CAAC,MAAyB,EAAE,SAAyB;QAClF,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAqB,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAAhD,UAAU,QAAA,EAAE,IAAI,QAAgC,CAAC;YAExD,IAAI,UAAU,EAAE;gBACZ,QAAQ,SAAS,EAAE;oBACf,KAAK,eAAe,CAAC;oBACrB,KAAK,iBAAiB,CAAC;oBACvB,KAAK,gBAAgB;wBACjB,IAAA,2CAA0B,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;wBAClD,MAAM;oBACV,KAAK,cAAc,CAAC;oBACpB,KAAK,iBAAiB,CAAC;oBACvB,KAAK,iBAAiB;wBAClB,IAAA,yCAAwB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;wBAChD,MAAM;oBACV,KAAK,aAAa,CAAC;oBACnB,KAAK,WAAW,CAAC;oBACjB,KAAK,YAAY;wBACb,IAAA,uBAAU,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;wBAClC,MAAM;oBAEV,KAAK,cAAc;wBACf,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AuB,EAAC,SAAS,CAAC,CAAC;wBACnC,IAAA,2CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;qBAC/B;iBACJ;gBAED,IAAA,6CAAc,EAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAEzC,IAAI,IAAA,yCAAW,EAAC,UAAU,CAAC,EAAE;oBACzB,IAAA,+CAAgB,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,EAAE,WAAW;SACvB,CACJ,CAAC;IACN,CAAC;IAjGD,4BAiGC","sourcesContent":["import { alignTable } from '../../modelApi/table/alignTable';\nimport { deleteTable } from '../../modelApi/table/deleteTable';\nimport { deleteTableColumn } from '../../modelApi/table/deleteTableColumn';\nimport { deleteTableRow } from '../../modelApi/table/deleteTableRow';\nimport { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport { insertTableColumn } from '../../modelApi/table/insertTableColumn';\nimport { insertTableRow } from '../../modelApi/table/insertTableRow';\nimport { mergeTableCells } from '../../modelApi/table/mergeTableCells';\nimport { mergeTableColumn } from '../../modelApi/table/mergeTableColumn';\nimport { mergeTableRow } from '../../modelApi/table/mergeTableRow';\nimport { splitTableCellHorizontally } from '../../modelApi/table/splitTableCellHorizontally';\nimport { splitTableCellVertically } from '../../modelApi/table/splitTableCellVertically';\n\nimport {\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n} from 'roosterjs-content-model-core';\nimport type { TableOperation, IStandaloneEditor } from 'roosterjs-content-model-types';\nimport {\n alignTableCellHorizontally,\n alignTableCellVertically,\n} from '../../modelApi/table/alignTableCell';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\n\n/**\n * Format current focused table with the given format\n * @param editor The editor instance\n * @param operation The table operation to apply\n */\nexport default function editTable(editor: IStandaloneEditor, operation: TableOperation) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [tableModel, path] = getFirstSelectedTable(model);\n\n if (tableModel) {\n switch (operation) {\n case 'alignCellLeft':\n case 'alignCellCenter':\n case 'alignCellRight':\n alignTableCellHorizontally(tableModel, operation);\n break;\n case 'alignCellTop':\n case 'alignCellMiddle':\n case 'alignCellBottom':\n alignTableCellVertically(tableModel, operation);\n break;\n case 'alignCenter':\n case 'alignLeft':\n case 'alignRight':\n alignTable(tableModel, operation);\n break;\n\n case 'deleteColumn':\n deleteTableColumn(tableModel);\n break;\n\n case 'deleteRow':\n deleteTableRow(tableModel);\n break;\n\n case 'deleteTable':\n deleteTable(tableModel);\n break;\n\n case 'insertAbove':\n case 'insertBelow':\n insertTableRow(tableModel, operation);\n break;\n\n case 'insertLeft':\n case 'insertRight':\n insertTableColumn(tableModel, operation);\n break;\n\n case 'mergeAbove':\n case 'mergeBelow':\n mergeTableRow(tableModel, operation);\n break;\n\n case 'mergeCells':\n mergeTableCells(tableModel);\n break;\n\n case 'mergeLeft':\n case 'mergeRight':\n mergeTableColumn(tableModel, operation);\n break;\n\n case 'splitHorizontally':\n splitTableCellHorizontally(tableModel);\n break;\n\n case 'splitVertically':\n splitTableCellVertically(tableModel);\n break;\n }\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: 'editTable',\n }\n );\n}\n"]}