roosterjs-content-model-api 9.4.0 → 9.5.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 (350) hide show
  1. package/README.md +10 -10
  2. package/lib/modelApi/block/setModelAlignment.d.ts +2 -2
  3. package/lib/modelApi/block/setModelAlignment.js +3 -2
  4. package/lib/modelApi/block/setModelAlignment.js.map +1 -1
  5. package/lib/modelApi/block/setModelDirection.d.ts +2 -2
  6. package/lib/modelApi/block/setModelDirection.js +8 -6
  7. package/lib/modelApi/block/setModelDirection.js.map +1 -1
  8. package/lib/modelApi/block/setModelIndentation.js +1 -1
  9. package/lib/modelApi/block/setModelIndentation.js.map +1 -1
  10. package/lib/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
  11. package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  12. package/lib/modelApi/common/clearModelFormat.d.ts +2 -2
  13. package/lib/modelApi/common/clearModelFormat.js +19 -10
  14. package/lib/modelApi/common/clearModelFormat.js.map +1 -1
  15. package/lib/modelApi/common/wrapBlock.d.ts +4 -4
  16. package/lib/modelApi/common/wrapBlock.js +11 -7
  17. package/lib/modelApi/common/wrapBlock.js.map +1 -1
  18. package/lib/modelApi/entity/insertEntityModel.d.ts +2 -2
  19. package/lib/modelApi/entity/insertEntityModel.js +1 -1
  20. package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
  21. package/lib/modelApi/list/setListType.d.ts +2 -2
  22. package/lib/modelApi/list/setListType.js +12 -11
  23. package/lib/modelApi/list/setListType.js.map +1 -1
  24. package/lib/modelApi/list/setModelListStartNumber.d.ts +2 -2
  25. package/lib/modelApi/list/setModelListStartNumber.js +1 -1
  26. package/lib/modelApi/list/setModelListStartNumber.js.map +1 -1
  27. package/lib/modelApi/list/setModelListStyle.d.ts +2 -2
  28. package/lib/modelApi/list/setModelListStyle.js +1 -1
  29. package/lib/modelApi/list/setModelListStyle.js.map +1 -1
  30. package/lib/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
  31. package/lib/modelApi/selection/adjustSegmentSelection.js +3 -3
  32. package/lib/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  33. package/lib/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
  34. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js +14 -12
  35. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  36. package/lib/modelApi/selection/adjustWordSelection.d.ts +2 -2
  37. package/lib/modelApi/selection/adjustWordSelection.js +1 -1
  38. package/lib/modelApi/selection/adjustWordSelection.js.map +1 -1
  39. package/lib/modelApi/selection/collapseTableSelection.d.ts +2 -2
  40. package/lib/modelApi/selection/collapseTableSelection.js +1 -1
  41. package/lib/modelApi/selection/collapseTableSelection.js.map +1 -1
  42. package/lib/modelApi/table/alignTable.d.ts +2 -2
  43. package/lib/modelApi/table/alignTable.js +0 -1
  44. package/lib/modelApi/table/alignTable.js.map +1 -1
  45. package/lib/modelApi/table/alignTableCell.d.ts +3 -3
  46. package/lib/modelApi/table/alignTableCell.js +3 -4
  47. package/lib/modelApi/table/alignTableCell.js.map +1 -1
  48. package/lib/modelApi/table/clearSelectedCells.d.ts +2 -2
  49. package/lib/modelApi/table/clearSelectedCells.js +3 -1
  50. package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
  51. package/lib/modelApi/table/deleteTable.d.ts +2 -2
  52. package/lib/modelApi/table/deleteTable.js +0 -1
  53. package/lib/modelApi/table/deleteTable.js.map +1 -1
  54. package/lib/modelApi/table/deleteTableColumn.d.ts +2 -2
  55. package/lib/modelApi/table/deleteTableColumn.js +1 -1
  56. package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
  57. package/lib/modelApi/table/deleteTableRow.d.ts +2 -2
  58. package/lib/modelApi/table/deleteTableRow.js +3 -3
  59. package/lib/modelApi/table/deleteTableRow.js.map +1 -1
  60. package/lib/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
  61. package/lib/modelApi/table/ensureFocusableParagraphForTable.js +2 -2
  62. package/lib/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  63. package/lib/modelApi/table/insertTableColumn.d.ts +2 -2
  64. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  65. package/lib/modelApi/table/insertTableRow.d.ts +2 -2
  66. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  67. package/lib/modelApi/table/mergeTableCells.d.ts +2 -2
  68. package/lib/modelApi/table/mergeTableCells.js +3 -4
  69. package/lib/modelApi/table/mergeTableCells.js.map +1 -1
  70. package/lib/modelApi/table/mergeTableColumn.d.ts +2 -2
  71. package/lib/modelApi/table/mergeTableColumn.js +5 -7
  72. package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
  73. package/lib/modelApi/table/mergeTableRow.d.ts +2 -2
  74. package/lib/modelApi/table/mergeTableRow.js +5 -8
  75. package/lib/modelApi/table/mergeTableRow.js.map +1 -1
  76. package/lib/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
  77. package/lib/modelApi/table/splitTableCellHorizontally.js +3 -4
  78. package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  79. package/lib/modelApi/table/splitTableCellVertically.d.ts +2 -2
  80. package/lib/modelApi/table/splitTableCellVertically.js +2 -7
  81. package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
  82. package/lib/publicApi/entity/insertEntity.js.map +1 -1
  83. package/lib/publicApi/image/adjustImageSelection.js +5 -2
  84. package/lib/publicApi/image/adjustImageSelection.js.map +1 -1
  85. package/lib/publicApi/link/adjustLinkSelection.js +1 -1
  86. package/lib/publicApi/link/adjustLinkSelection.js.map +1 -1
  87. package/lib/publicApi/link/insertLink.js +1 -1
  88. package/lib/publicApi/link/insertLink.js.map +1 -1
  89. package/lib/publicApi/link/removeLink.js +1 -1
  90. package/lib/publicApi/link/removeLink.js.map +1 -1
  91. package/lib/publicApi/segment/applySegmentFormat.d.ts +1 -1
  92. package/lib/publicApi/segment/applySegmentFormat.js.map +1 -1
  93. package/lib/publicApi/segment/changeFontSize.js.map +1 -1
  94. package/lib/publicApi/segment/setBackgroundColor.js.map +1 -1
  95. package/lib/publicApi/segment/setFontSize.d.ts +2 -2
  96. package/lib/publicApi/segment/setFontSize.js.map +1 -1
  97. package/lib/publicApi/table/applyTableBorderFormat.js +5 -6
  98. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  99. package/lib/publicApi/table/formatTable.js +1 -1
  100. package/lib/publicApi/table/formatTable.js.map +1 -1
  101. package/lib/publicApi/table/setTableCellShade.js +1 -1
  102. package/lib/publicApi/table/setTableCellShade.js.map +1 -1
  103. package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
  104. package/lib/publicApi/utils/formatInsertPointWithContentModel.js +5 -5
  105. package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  106. package/lib/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
  107. package/lib/publicApi/utils/formatParagraphWithContentModel.js +1 -1
  108. package/lib/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  109. package/lib/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
  110. package/lib/publicApi/utils/formatSegmentWithContentModel.js +1 -1
  111. package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  112. package/lib/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
  113. package/lib/publicApi/utils/formatTableWithContentModel.js +3 -2
  114. package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  115. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
  116. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +8 -8
  117. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  118. package/lib-amd/modelApi/block/setModelAlignment.d.ts +2 -2
  119. package/lib-amd/modelApi/block/setModelAlignment.js +3 -2
  120. package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
  121. package/lib-amd/modelApi/block/setModelDirection.d.ts +2 -2
  122. package/lib-amd/modelApi/block/setModelDirection.js +8 -6
  123. package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
  124. package/lib-amd/modelApi/block/setModelIndentation.js +1 -1
  125. package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
  126. package/lib-amd/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
  127. package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  128. package/lib-amd/modelApi/common/clearModelFormat.d.ts +2 -2
  129. package/lib-amd/modelApi/common/clearModelFormat.js +19 -10
  130. package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
  131. package/lib-amd/modelApi/common/wrapBlock.d.ts +4 -4
  132. package/lib-amd/modelApi/common/wrapBlock.js +11 -7
  133. package/lib-amd/modelApi/common/wrapBlock.js.map +1 -1
  134. package/lib-amd/modelApi/entity/insertEntityModel.d.ts +2 -2
  135. package/lib-amd/modelApi/entity/insertEntityModel.js +1 -1
  136. package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
  137. package/lib-amd/modelApi/list/setListType.d.ts +2 -2
  138. package/lib-amd/modelApi/list/setListType.js +12 -11
  139. package/lib-amd/modelApi/list/setListType.js.map +1 -1
  140. package/lib-amd/modelApi/list/setModelListStartNumber.d.ts +2 -2
  141. package/lib-amd/modelApi/list/setModelListStartNumber.js +1 -1
  142. package/lib-amd/modelApi/list/setModelListStartNumber.js.map +1 -1
  143. package/lib-amd/modelApi/list/setModelListStyle.d.ts +2 -2
  144. package/lib-amd/modelApi/list/setModelListStyle.js +1 -1
  145. package/lib-amd/modelApi/list/setModelListStyle.js.map +1 -1
  146. package/lib-amd/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
  147. package/lib-amd/modelApi/selection/adjustSegmentSelection.js +3 -3
  148. package/lib-amd/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  149. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
  150. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js +14 -12
  151. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  152. package/lib-amd/modelApi/selection/adjustWordSelection.d.ts +2 -2
  153. package/lib-amd/modelApi/selection/adjustWordSelection.js +1 -1
  154. package/lib-amd/modelApi/selection/adjustWordSelection.js.map +1 -1
  155. package/lib-amd/modelApi/selection/collapseTableSelection.d.ts +2 -2
  156. package/lib-amd/modelApi/selection/collapseTableSelection.js +1 -1
  157. package/lib-amd/modelApi/selection/collapseTableSelection.js.map +1 -1
  158. package/lib-amd/modelApi/table/alignTable.d.ts +2 -2
  159. package/lib-amd/modelApi/table/alignTable.js +0 -1
  160. package/lib-amd/modelApi/table/alignTable.js.map +1 -1
  161. package/lib-amd/modelApi/table/alignTableCell.d.ts +3 -3
  162. package/lib-amd/modelApi/table/alignTableCell.js +3 -4
  163. package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
  164. package/lib-amd/modelApi/table/clearSelectedCells.d.ts +2 -2
  165. package/lib-amd/modelApi/table/clearSelectedCells.js +3 -1
  166. package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
  167. package/lib-amd/modelApi/table/deleteTable.d.ts +2 -2
  168. package/lib-amd/modelApi/table/deleteTable.js +0 -1
  169. package/lib-amd/modelApi/table/deleteTable.js.map +1 -1
  170. package/lib-amd/modelApi/table/deleteTableColumn.d.ts +2 -2
  171. package/lib-amd/modelApi/table/deleteTableColumn.js +1 -1
  172. package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
  173. package/lib-amd/modelApi/table/deleteTableRow.d.ts +2 -2
  174. package/lib-amd/modelApi/table/deleteTableRow.js +3 -3
  175. package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
  176. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
  177. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js +2 -2
  178. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  179. package/lib-amd/modelApi/table/insertTableColumn.d.ts +2 -2
  180. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  181. package/lib-amd/modelApi/table/insertTableRow.d.ts +2 -2
  182. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  183. package/lib-amd/modelApi/table/mergeTableCells.d.ts +2 -2
  184. package/lib-amd/modelApi/table/mergeTableCells.js +3 -4
  185. package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
  186. package/lib-amd/modelApi/table/mergeTableColumn.d.ts +2 -2
  187. package/lib-amd/modelApi/table/mergeTableColumn.js +5 -7
  188. package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
  189. package/lib-amd/modelApi/table/mergeTableRow.d.ts +2 -2
  190. package/lib-amd/modelApi/table/mergeTableRow.js +5 -8
  191. package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
  192. package/lib-amd/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
  193. package/lib-amd/modelApi/table/splitTableCellHorizontally.js +3 -4
  194. package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  195. package/lib-amd/modelApi/table/splitTableCellVertically.d.ts +2 -2
  196. package/lib-amd/modelApi/table/splitTableCellVertically.js +2 -7
  197. package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
  198. package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
  199. package/lib-amd/publicApi/image/adjustImageSelection.js +5 -3
  200. package/lib-amd/publicApi/image/adjustImageSelection.js.map +1 -1
  201. package/lib-amd/publicApi/link/adjustLinkSelection.js +1 -1
  202. package/lib-amd/publicApi/link/adjustLinkSelection.js.map +1 -1
  203. package/lib-amd/publicApi/link/insertLink.js +1 -1
  204. package/lib-amd/publicApi/link/insertLink.js.map +1 -1
  205. package/lib-amd/publicApi/link/removeLink.js +1 -1
  206. package/lib-amd/publicApi/link/removeLink.js.map +1 -1
  207. package/lib-amd/publicApi/segment/applySegmentFormat.d.ts +1 -1
  208. package/lib-amd/publicApi/segment/applySegmentFormat.js.map +1 -1
  209. package/lib-amd/publicApi/segment/changeFontSize.js.map +1 -1
  210. package/lib-amd/publicApi/segment/setBackgroundColor.js.map +1 -1
  211. package/lib-amd/publicApi/segment/setFontSize.d.ts +2 -2
  212. package/lib-amd/publicApi/segment/setFontSize.js.map +1 -1
  213. package/lib-amd/publicApi/table/applyTableBorderFormat.js +5 -6
  214. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  215. package/lib-amd/publicApi/table/formatTable.js +1 -1
  216. package/lib-amd/publicApi/table/formatTable.js.map +1 -1
  217. package/lib-amd/publicApi/table/setTableCellShade.js +1 -1
  218. package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
  219. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
  220. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +5 -5
  221. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  222. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
  223. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js +1 -1
  224. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  225. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
  226. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +1 -1
  227. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  228. package/lib-amd/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
  229. package/lib-amd/publicApi/utils/formatTableWithContentModel.js +3 -2
  230. package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  231. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
  232. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +8 -8
  233. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  234. package/lib-mjs/modelApi/block/setModelAlignment.d.ts +2 -2
  235. package/lib-mjs/modelApi/block/setModelAlignment.js +4 -3
  236. package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
  237. package/lib-mjs/modelApi/block/setModelDirection.d.ts +2 -2
  238. package/lib-mjs/modelApi/block/setModelDirection.js +9 -7
  239. package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
  240. package/lib-mjs/modelApi/block/setModelIndentation.js +1 -1
  241. package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
  242. package/lib-mjs/modelApi/block/toggleModelBlockQuote.d.ts +2 -2
  243. package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  244. package/lib-mjs/modelApi/common/clearModelFormat.d.ts +2 -2
  245. package/lib-mjs/modelApi/common/clearModelFormat.js +20 -11
  246. package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
  247. package/lib-mjs/modelApi/common/wrapBlock.d.ts +4 -4
  248. package/lib-mjs/modelApi/common/wrapBlock.js +12 -8
  249. package/lib-mjs/modelApi/common/wrapBlock.js.map +1 -1
  250. package/lib-mjs/modelApi/entity/insertEntityModel.d.ts +2 -2
  251. package/lib-mjs/modelApi/entity/insertEntityModel.js +1 -1
  252. package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
  253. package/lib-mjs/modelApi/list/setListType.d.ts +2 -2
  254. package/lib-mjs/modelApi/list/setListType.js +13 -12
  255. package/lib-mjs/modelApi/list/setListType.js.map +1 -1
  256. package/lib-mjs/modelApi/list/setModelListStartNumber.d.ts +2 -2
  257. package/lib-mjs/modelApi/list/setModelListStartNumber.js +2 -2
  258. package/lib-mjs/modelApi/list/setModelListStartNumber.js.map +1 -1
  259. package/lib-mjs/modelApi/list/setModelListStyle.d.ts +2 -2
  260. package/lib-mjs/modelApi/list/setModelListStyle.js +2 -2
  261. package/lib-mjs/modelApi/list/setModelListStyle.js.map +1 -1
  262. package/lib-mjs/modelApi/selection/adjustSegmentSelection.d.ts +2 -2
  263. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js +3 -3
  264. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  265. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.d.ts +2 -2
  266. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +15 -13
  267. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  268. package/lib-mjs/modelApi/selection/adjustWordSelection.d.ts +2 -2
  269. package/lib-mjs/modelApi/selection/adjustWordSelection.js +2 -2
  270. package/lib-mjs/modelApi/selection/adjustWordSelection.js.map +1 -1
  271. package/lib-mjs/modelApi/selection/collapseTableSelection.d.ts +2 -2
  272. package/lib-mjs/modelApi/selection/collapseTableSelection.js +2 -2
  273. package/lib-mjs/modelApi/selection/collapseTableSelection.js.map +1 -1
  274. package/lib-mjs/modelApi/table/alignTable.d.ts +2 -2
  275. package/lib-mjs/modelApi/table/alignTable.js +0 -1
  276. package/lib-mjs/modelApi/table/alignTable.js.map +1 -1
  277. package/lib-mjs/modelApi/table/alignTableCell.d.ts +3 -3
  278. package/lib-mjs/modelApi/table/alignTableCell.js +4 -5
  279. package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
  280. package/lib-mjs/modelApi/table/clearSelectedCells.d.ts +2 -2
  281. package/lib-mjs/modelApi/table/clearSelectedCells.js +4 -2
  282. package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
  283. package/lib-mjs/modelApi/table/deleteTable.d.ts +2 -2
  284. package/lib-mjs/modelApi/table/deleteTable.js +0 -1
  285. package/lib-mjs/modelApi/table/deleteTable.js.map +1 -1
  286. package/lib-mjs/modelApi/table/deleteTableColumn.d.ts +2 -2
  287. package/lib-mjs/modelApi/table/deleteTableColumn.js +2 -2
  288. package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
  289. package/lib-mjs/modelApi/table/deleteTableRow.d.ts +2 -2
  290. package/lib-mjs/modelApi/table/deleteTableRow.js +4 -4
  291. package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
  292. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.d.ts +2 -2
  293. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js +3 -3
  294. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  295. package/lib-mjs/modelApi/table/insertTableColumn.d.ts +2 -2
  296. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  297. package/lib-mjs/modelApi/table/insertTableRow.d.ts +2 -2
  298. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  299. package/lib-mjs/modelApi/table/mergeTableCells.d.ts +2 -2
  300. package/lib-mjs/modelApi/table/mergeTableCells.js +4 -5
  301. package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
  302. package/lib-mjs/modelApi/table/mergeTableColumn.d.ts +2 -2
  303. package/lib-mjs/modelApi/table/mergeTableColumn.js +6 -8
  304. package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
  305. package/lib-mjs/modelApi/table/mergeTableRow.d.ts +2 -2
  306. package/lib-mjs/modelApi/table/mergeTableRow.js +6 -9
  307. package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
  308. package/lib-mjs/modelApi/table/splitTableCellHorizontally.d.ts +2 -2
  309. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +4 -5
  310. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  311. package/lib-mjs/modelApi/table/splitTableCellVertically.d.ts +2 -2
  312. package/lib-mjs/modelApi/table/splitTableCellVertically.js +3 -8
  313. package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
  314. package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
  315. package/lib-mjs/publicApi/image/adjustImageSelection.js +5 -2
  316. package/lib-mjs/publicApi/image/adjustImageSelection.js.map +1 -1
  317. package/lib-mjs/publicApi/link/adjustLinkSelection.js +1 -1
  318. package/lib-mjs/publicApi/link/adjustLinkSelection.js.map +1 -1
  319. package/lib-mjs/publicApi/link/insertLink.js +1 -1
  320. package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
  321. package/lib-mjs/publicApi/link/removeLink.js +1 -1
  322. package/lib-mjs/publicApi/link/removeLink.js.map +1 -1
  323. package/lib-mjs/publicApi/segment/applySegmentFormat.d.ts +1 -1
  324. package/lib-mjs/publicApi/segment/applySegmentFormat.js.map +1 -1
  325. package/lib-mjs/publicApi/segment/changeFontSize.js.map +1 -1
  326. package/lib-mjs/publicApi/segment/setBackgroundColor.js.map +1 -1
  327. package/lib-mjs/publicApi/segment/setFontSize.d.ts +2 -2
  328. package/lib-mjs/publicApi/segment/setFontSize.js.map +1 -1
  329. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +6 -7
  330. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  331. package/lib-mjs/publicApi/table/formatTable.js +2 -2
  332. package/lib-mjs/publicApi/table/formatTable.js.map +1 -1
  333. package/lib-mjs/publicApi/table/setTableCellShade.js +2 -2
  334. package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
  335. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +6 -6
  336. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +6 -6
  337. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  338. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.d.ts +2 -2
  339. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js +1 -1
  340. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  341. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.d.ts +2 -2
  342. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +1 -1
  343. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  344. package/lib-mjs/publicApi/utils/formatTableWithContentModel.d.ts +2 -2
  345. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +4 -3
  346. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  347. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +2 -2
  348. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +9 -9
  349. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  350. package/package.json +3 -3
@@ -7,7 +7,6 @@ define(["require", "exports"], function (require, exports) {
7
7
  */
8
8
  function deleteTable(table) {
9
9
  table.rows = [];
10
- delete table.cachedElement;
11
10
  }
12
11
  exports.deleteTable = deleteTable;
13
12
  });
@@ -1 +1 @@
1
- {"version":3,"file":"deleteTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTable.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,WAAW,CAAC,KAAwB;QAChD,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,aAAa,CAAC;IAC/B,CAAC;IAHD,kCAGC","sourcesContent":["import type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTable(table: ContentModelTable) {\n table.rows = [];\n delete table.cachedElement;\n}\n"]}
1
+ {"version":3,"file":"deleteTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTable.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACH,SAAgB,WAAW,CAAC,KAAsC;QAC9D,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IACpB,CAAC;IAFD,kCAEC","sourcesContent":["import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTable(table: ShallowMutableContentModelTable) {\n table.rows = [];\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function deleteTableColumn(table: ContentModelTable): void;
5
+ export declare function deleteTableColumn(table: ShallowMutableContentModelTable): void;
@@ -11,7 +11,7 @@ define(["require", "exports", "../selection/collapseTableSelection", "roosterjs-
11
11
  for (var rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {
12
12
  var cellInNextCol = table.rows[rowIndex].cells[sel.lastColumn + 1];
13
13
  if (cellInNextCol) {
14
- cellInNextCol.spanLeft =
14
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cellInNextCol).spanLeft =
15
15
  cellInNextCol.spanLeft && table.rows[rowIndex].cells[sel.firstColumn].spanLeft;
16
16
  }
17
17
  table.rows[rowIndex].cells.splice(sel.firstColumn, sel.lastColumn - sel.firstColumn + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"deleteTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTableColumn.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,iBAAiB,CAAC,KAAwB;QACtD,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBAC7D,IAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gBAErE,IAAI,aAAa,EAAE;oBACf,aAAa,CAAC,QAAQ;wBAClB,aAAa,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC;iBACtF;gBAED,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7B,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,WAAW,GAAG,CAAC,CACvC,CAAC;aACL;YAED,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;YAC3E,IAAA,+CAAsB,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;IACL,CAAC;IArBD,8CAqBC","sourcesContent":["import { collapseTableSelection } from '../selection/collapseTableSelection';\nimport { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTableColumn(table: ContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {\n const cellInNextCol = table.rows[rowIndex].cells[sel.lastColumn + 1];\n\n if (cellInNextCol) {\n cellInNextCol.spanLeft =\n cellInNextCol.spanLeft && table.rows[rowIndex].cells[sel.firstColumn].spanLeft;\n }\n\n table.rows[rowIndex].cells.splice(\n sel.firstColumn,\n sel.lastColumn - sel.firstColumn + 1\n );\n }\n\n table.widths.splice(sel.firstColumn, sel.lastColumn - sel.firstColumn + 1);\n collapseTableSelection(table.rows, sel);\n }\n}\n"]}
1
+ {"version":3,"file":"deleteTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTableColumn.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,iBAAiB,CAAC,KAAsC;QACpE,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,IAAI,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBAC7D,IAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gBAErE,IAAI,aAAa,EAAE;oBACf,IAAA,yCAAW,EAAC,aAAa,CAAC,CAAC,QAAQ;wBAC/B,aAAa,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC;iBACtF;gBAED,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,MAAM,CAC7B,GAAG,CAAC,WAAW,EACf,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,WAAW,GAAG,CAAC,CACvC,CAAC;aACL;YAED,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;YAC3E,IAAA,+CAAsB,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;IACL,CAAC;IArBD,8CAqBC","sourcesContent":["import { collapseTableSelection } from '../selection/collapseTableSelection';\nimport { getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTableColumn(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex++) {\n const cellInNextCol = table.rows[rowIndex].cells[sel.lastColumn + 1];\n\n if (cellInNextCol) {\n mutateBlock(cellInNextCol).spanLeft =\n cellInNextCol.spanLeft && table.rows[rowIndex].cells[sel.firstColumn].spanLeft;\n }\n\n table.rows[rowIndex].cells.splice(\n sel.firstColumn,\n sel.lastColumn - sel.firstColumn + 1\n );\n }\n\n table.widths.splice(sel.firstColumn, sel.lastColumn - sel.firstColumn + 1);\n collapseTableSelection(table.rows, sel);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function deleteTableRow(table: ContentModelTable): void;
5
+ export declare function deleteTableRow(table: ShallowMutableContentModelTable): void;
@@ -10,9 +10,9 @@ define(["require", "exports", "../selection/collapseTableSelection", "roosterjs-
10
10
  if (sel) {
11
11
  table.rows[sel.firstRow].cells.forEach(function (cell, colIndex) {
12
12
  var _a;
13
- var cellInNextRow = (_a = table.rows[sel.lastRow + 1]) === null || _a === void 0 ? void 0 : _a.cells[colIndex];
14
- if (cellInNextRow) {
15
- cellInNextRow.spanAbove = cellInNextRow.spanAbove && cell.spanAbove;
13
+ var cellInNextCell = (_a = table.rows[sel.lastRow + 1]) === null || _a === void 0 ? void 0 : _a.cells[colIndex];
14
+ if (cellInNextCell) {
15
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cellInNextCell).spanAbove = cellInNextCell.spanAbove && cell.spanAbove;
16
16
  }
17
17
  });
18
18
  table.rows.splice(sel.firstRow, sel.lastRow - sel.firstRow + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"deleteTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTableRow.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,cAAc,CAAC,KAAwB;QACnD,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,QAAQ;;gBAClD,IAAM,aAAa,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAEnE,IAAI,aAAa,EAAE;oBACf,aAAa,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;iBACvE;YACL,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAEhE,IAAA,+CAAsB,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;IACL,CAAC;IAhBD,wCAgBC","sourcesContent":["import { collapseTableSelection } from '../selection/collapseTableSelection';\nimport { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTableRow(table: ContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n table.rows[sel.firstRow].cells.forEach((cell, colIndex) => {\n const cellInNextRow = table.rows[sel.lastRow + 1]?.cells[colIndex];\n\n if (cellInNextRow) {\n cellInNextRow.spanAbove = cellInNextRow.spanAbove && cell.spanAbove;\n }\n });\n\n table.rows.splice(sel.firstRow, sel.lastRow - sel.firstRow + 1);\n\n collapseTableSelection(table.rows, sel);\n }\n}\n"]}
1
+ {"version":3,"file":"deleteTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/deleteTableRow.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,cAAc,CAAC,KAAsC;QACjE,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,GAAG,EAAE;YACL,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,QAAQ;;gBAClD,IAAM,cAAc,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAEpE,IAAI,cAAc,EAAE;oBAChB,IAAA,yCAAW,EAAC,cAAc,CAAC,CAAC,SAAS,GAAG,cAAc,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;iBACtF;YACL,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAEhE,IAAA,+CAAsB,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;IACL,CAAC;IAhBD,wCAgBC","sourcesContent":["import { collapseTableSelection } from '../selection/collapseTableSelection';\nimport { getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function deleteTableRow(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (sel) {\n table.rows[sel.firstRow].cells.forEach((cell, colIndex) => {\n const cellInNextCell = table.rows[sel.lastRow + 1]?.cells[colIndex];\n\n if (cellInNextCell) {\n mutateBlock(cellInNextCell).spanAbove = cellInNextCell.spanAbove && cell.spanAbove;\n }\n });\n\n table.rows.splice(sel.firstRow, sel.lastRow - sel.firstRow + 1);\n\n collapseTableSelection(table.rows, sel);\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
- import type { ContentModelBlockGroup, ContentModelDocument, ContentModelParagraph, ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ContentModelParagraph, ReadonlyContentModelBlockGroup, ReadonlyContentModelDocument, ReadonlyContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  * After edit table, it maybe in a abnormal state, e.g. selected table cell is removed, or all rows are removed causes no place to put cursor.
5
5
  * We need to make sure table is in normal state, and there is a place to put cursor.
6
6
  * @returns a new paragraph that can but put focus in, or undefined if not needed
7
7
  */
8
- export declare function ensureFocusableParagraphForTable(model: ContentModelDocument, path: ContentModelBlockGroup[], table: ContentModelTable): ContentModelParagraph | undefined;
8
+ export declare function ensureFocusableParagraphForTable(model: ReadonlyContentModelDocument, path: ReadonlyContentModelBlockGroup[], table: ReadonlyContentModelTable): ContentModelParagraph | undefined;
@@ -18,7 +18,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
18
18
  if (!paragraph) {
19
19
  // If there is not a paragraph under this cell, create one
20
20
  paragraph = createEmptyParagraph(model);
21
- firstCell.blocks.push(paragraph);
21
+ (0, roosterjs_content_model_dom_1.mutateBlock)(firstCell).blocks.push(paragraph);
22
22
  }
23
23
  }
24
24
  else {
@@ -31,7 +31,7 @@ define(["require", "exports", "roosterjs-content-model-dom"], function (require,
31
31
  while ((parent_1 = path.shift())) {
32
32
  var index = (_b = parent_1.blocks.indexOf(block)) !== null && _b !== void 0 ? _b : -1;
33
33
  if (parent_1 && index >= 0) {
34
- parent_1.blocks.splice(index, 1, paragraph);
34
+ (0, roosterjs_content_model_dom_1.mutateBlock)(parent_1).blocks.splice(index, 1, paragraph);
35
35
  }
36
36
  if (parent_1.blockGroupType == 'FormatContainer' &&
37
37
  parent_1.blocks.length == 1 &&
@@ -1 +1 @@
1
- {"version":3,"file":"ensureFocusableParagraphForTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/ensureFocusableParagraphForTable.ts"],"names":[],"mappings":";;;;IASA;;;;;OAKG;IACH,SAAgB,gCAAgC,CAC5C,KAA2B,EAC3B,IAA8B,EAC9B,KAAwB;;QAExB,IAAI,SAA4C,CAAC;QACjD,IAAM,SAAS,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAApB,CAAoB,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAE9E,IAAI,SAAS,EAAE;YACX,kDAAkD;YAClD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAC/B,UAAC,KAAK,IAAqC,OAAA,KAAK,CAAC,SAAS,IAAI,WAAW,EAA9B,CAA8B,CAC5E,CAAC,CAAC,CAAC,CAAC;YAEL,IAAI,CAAC,SAAS,EAAE;gBACZ,0DAA0D;gBAC1D,SAAS,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBACxC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACpC;SACJ;aAAM;YACH,4GAA4G;YAC5G,IAAI,KAAK,GAAsB,KAAK,CAAC;YACrC,IAAI,QAA0C,CAAC;YAC/C,SAAS,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAExC,2GAA2G;YAC3G,wGAAwG;YACxG,OAAO,CAAC,QAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE;gBAC5B,IAAM,KAAK,GAAG,MAAA,QAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,mCAAI,CAAC,CAAC,CAAC;gBAEjD,IAAI,QAAM,IAAI,KAAK,IAAI,CAAC,EAAE;oBACtB,QAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;iBAC7C;gBAED,IACI,QAAM,CAAC,cAAc,IAAI,iBAAiB;oBAC1C,QAAM,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC;oBACzB,QAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,EAC/B;oBACE,2FAA2F;oBAC3F,KAAK,GAAG,QAAM,CAAC;iBAClB;qBAAM;oBACH,kEAAkE;oBAClE,MAAM;iBACT;aACJ;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAjDD,4EAiDC;IAED,SAAS,oBAAoB,CAAC,KAA2B;QACrD,IAAM,OAAO,GAAG,IAAA,6CAAe,EAAC,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/F,IAAM,EAAE,GAAG,IAAA,sCAAQ,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE1B,OAAO,OAAO,CAAC;IACnB,CAAC","sourcesContent":["import { createBr, createParagraph } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelTable,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * After edit table, it maybe in a abnormal state, e.g. selected table cell is removed, or all rows are removed causes no place to put cursor.\n * We need to make sure table is in normal state, and there is a place to put cursor.\n * @returns a new paragraph that can but put focus in, or undefined if not needed\n */\nexport function ensureFocusableParagraphForTable(\n model: ContentModelDocument,\n path: ContentModelBlockGroup[],\n table: ContentModelTable\n): ContentModelParagraph | undefined {\n let paragraph: ContentModelParagraph | undefined;\n const firstCell = table.rows.filter(row => row.cells.length > 0)[0]?.cells[0];\n\n if (firstCell) {\n // When there is a valid cell to put focus, use it\n paragraph = firstCell.blocks.filter(\n (block): block is ContentModelParagraph => block.blockType == 'Paragraph'\n )[0];\n\n if (!paragraph) {\n // If there is not a paragraph under this cell, create one\n paragraph = createEmptyParagraph(model);\n firstCell.blocks.push(paragraph);\n }\n } else {\n // No table cell at all, which means the whole table is deleted. So we need to remove it from content model.\n let block: ContentModelBlock = table;\n let parent: ContentModelBlockGroup | undefined;\n paragraph = createEmptyParagraph(model);\n\n // If the table is the only block of its parent and parent is a FormatContainer, remove the parent as well.\n // We need to do this in a loop in case there are multiple layer of FormatContainer that match this case\n while ((parent = path.shift())) {\n const index = parent.blocks.indexOf(block) ?? -1;\n\n if (parent && index >= 0) {\n parent.blocks.splice(index, 1, paragraph);\n }\n\n if (\n parent.blockGroupType == 'FormatContainer' &&\n parent.blocks.length == 1 &&\n parent.blocks[0] == paragraph\n ) {\n // If the new paragraph is the only child of parent format container, unwrap parent as well\n block = parent;\n } else {\n // Otherwise, just stop here and keep processing the new paragraph\n break;\n }\n }\n }\n\n return paragraph;\n}\n\nfunction createEmptyParagraph(model: ContentModelDocument) {\n const newPara = createParagraph(false /*isImplicit*/, undefined /*blockFormat*/, model.format);\n const br = createBr(model.format);\n\n newPara.segments.push(br);\n\n return newPara;\n}\n"]}
1
+ {"version":3,"file":"ensureFocusableParagraphForTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/ensureFocusableParagraphForTable.ts"],"names":[],"mappings":";;;;IASA;;;;;OAKG;IACH,SAAgB,gCAAgC,CAC5C,KAAmC,EACnC,IAAsC,EACtC,KAAgC;;QAEhC,IAAI,SAA4C,CAAC;QACjD,IAAM,SAAS,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAApB,CAAoB,CAAC,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAE9E,IAAI,SAAS,EAAE;YACX,kDAAkD;YAClD,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAC/B,UAAC,KAAK,IAAqC,OAAA,KAAK,CAAC,SAAS,IAAI,WAAW,EAA9B,CAA8B,CAC5E,CAAC,CAAC,CAAC,CAAC;YAEL,IAAI,CAAC,SAAS,EAAE;gBACZ,0DAA0D;gBAC1D,SAAS,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBACxC,IAAA,yCAAW,EAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aACjD;SACJ;aAAM;YACH,4GAA4G;YAC5G,IAAI,KAAK,GAA8B,KAAK,CAAC;YAC7C,IAAI,QAAkD,CAAC;YACvD,SAAS,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAExC,2GAA2G;YAC3G,wGAAwG;YACxG,OAAO,CAAC,QAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE;gBAC5B,IAAM,KAAK,GAAG,MAAA,QAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,mCAAI,CAAC,CAAC,CAAC;gBAEjD,IAAI,QAAM,IAAI,KAAK,IAAI,CAAC,EAAE;oBACtB,IAAA,yCAAW,EAAC,QAAM,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;iBAC1D;gBAED,IACI,QAAM,CAAC,cAAc,IAAI,iBAAiB;oBAC1C,QAAM,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC;oBACzB,QAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,SAAS,EAC/B;oBACE,2FAA2F;oBAC3F,KAAK,GAAG,QAAM,CAAC;iBAClB;qBAAM;oBACH,kEAAkE;oBAClE,MAAM;iBACT;aACJ;SACJ;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;IAjDD,4EAiDC;IAED,SAAS,oBAAoB,CAAC,KAAmC;QAC7D,IAAM,OAAO,GAAG,IAAA,6CAAe,EAAC,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/F,IAAM,EAAE,GAAG,IAAA,sCAAQ,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAElC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE1B,OAAO,OAAO,CAAC;IACnB,CAAC","sourcesContent":["import { createBr, createParagraph, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n ReadonlyContentModelBlock,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelTable,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * After edit table, it maybe in a abnormal state, e.g. selected table cell is removed, or all rows are removed causes no place to put cursor.\n * We need to make sure table is in normal state, and there is a place to put cursor.\n * @returns a new paragraph that can but put focus in, or undefined if not needed\n */\nexport function ensureFocusableParagraphForTable(\n model: ReadonlyContentModelDocument,\n path: ReadonlyContentModelBlockGroup[],\n table: ReadonlyContentModelTable\n): ContentModelParagraph | undefined {\n let paragraph: ContentModelParagraph | undefined;\n const firstCell = table.rows.filter(row => row.cells.length > 0)[0]?.cells[0];\n\n if (firstCell) {\n // When there is a valid cell to put focus, use it\n paragraph = firstCell.blocks.filter(\n (block): block is ContentModelParagraph => block.blockType == 'Paragraph'\n )[0];\n\n if (!paragraph) {\n // If there is not a paragraph under this cell, create one\n paragraph = createEmptyParagraph(model);\n mutateBlock(firstCell).blocks.push(paragraph);\n }\n } else {\n // No table cell at all, which means the whole table is deleted. So we need to remove it from content model.\n let block: ReadonlyContentModelBlock = table;\n let parent: ReadonlyContentModelBlockGroup | undefined;\n paragraph = createEmptyParagraph(model);\n\n // If the table is the only block of its parent and parent is a FormatContainer, remove the parent as well.\n // We need to do this in a loop in case there are multiple layer of FormatContainer that match this case\n while ((parent = path.shift())) {\n const index = parent.blocks.indexOf(block) ?? -1;\n\n if (parent && index >= 0) {\n mutateBlock(parent).blocks.splice(index, 1, paragraph);\n }\n\n if (\n parent.blockGroupType == 'FormatContainer' &&\n parent.blocks.length == 1 &&\n parent.blocks[0] == paragraph\n ) {\n // If the new paragraph is the only child of parent format container, unwrap parent as well\n block = parent;\n } else {\n // Otherwise, just stop here and keep processing the new paragraph\n break;\n }\n }\n }\n\n return paragraph;\n}\n\nfunction createEmptyParagraph(model: ReadonlyContentModelDocument) {\n const newPara = createParagraph(false /*isImplicit*/, undefined /*blockFormat*/, model.format);\n const br = createBr(model.format);\n\n newPara.segments.push(br);\n\n return newPara;\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { ContentModelTable, TableHorizontalInsertOperation } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable, TableHorizontalInsertOperation } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Insert a column to the table
4
4
  * @param table The table model where the column is to be inserted
5
5
  * @param operation The operation to be performed
6
6
  */
7
- export declare function insertTableColumn(table: ContentModelTable, operation: TableHorizontalInsertOperation): void;
7
+ export declare function insertTableColumn(table: ShallowMutableContentModelTable, operation: TableHorizontalInsertOperation): void;
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,iBAAiB,CAC7B,KAAwB,EACxB,SAAyC;QAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAE1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,MAAM,CAAC,MAAM,CACf,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;aACL;SACJ;IACL,CAAC;IA/BD,8CA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableColumn.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,iBAAiB,CAC7B,KAAsC,EACtC,SAAyC;QAEzC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE;gBACrD,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;oBAEtE,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;oBACF,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;oBAE1B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,MAAM,CAAC,MAAM,CACf,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,EACjD,CAAC,EACD,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAC9D,CAAC;aACL;SACJ;IACL,CAAC;IA/BD,8CA+BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a column to the table\n * @param table The table model where the column is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertLeft = operation == 'insertLeft';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel?.firstColumn; i <= sel.lastColumn; i++) {\n table.rows.forEach(row => {\n const cell = row.cells[insertLeft ? sel.firstColumn : sel.lastColumn];\n\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n newCell.isSelected = true;\n\n row.cells.splice(insertLeft ? sel.firstColumn : sel.lastColumn + 1, 0, newCell);\n });\n table.widths.splice(\n insertLeft ? sel.firstColumn : sel.lastColumn + 1,\n 0,\n table.widths[insertLeft ? sel.firstColumn : sel.lastColumn]\n );\n }\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { ContentModelTable, TableVerticalInsertOperation } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable, TableVerticalInsertOperation } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * Insert a row to the table
4
4
  * @param table The table model where the row is to be inserted
5
5
  * @param operation The operation to be performed
6
6
  */
7
- export declare function insertTableRow(table: ContentModelTable, operation: TableVerticalInsertOperation): void;
7
+ export declare function insertTableRow(table: ShallowMutableContentModelTable, operation: TableVerticalInsertOperation): void;
@@ -1 +1 @@
1
- {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,cAAc,CAAC,KAAwB,EAAE,SAAuC;QAC5F,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;QAE/C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;oBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;oBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;wBACF,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;wBAC1B,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACF,MAAM,EAAE,SAAS,CAAC,MAAM;iBAC3B,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IA1BD,wCA0BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(table: ContentModelTable, operation: TableVerticalInsertOperation) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"insertTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/insertTableRow.ts"],"names":[],"mappings":";;;;IAOA;;;;OAIG;IACH,SAAgB,cAAc,CAC1B,KAAsC,EACtC,SAAuC;QAEvC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,WAAW,GAAG,SAAS,IAAI,aAAa,CAAC;QAE/C,IAAI,GAAG,EAAE;YACL,IAAA,uCAAkB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAE/B,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAEvE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE;oBAC/D,MAAM,4BAAO,SAAS,CAAC,MAAM,CAAE;oBAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,UAAA,IAAI;wBAC3B,IAAM,OAAO,GAAG,IAAA,6CAAe,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,OAAO,CACf,CAAC;wBACF,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;wBAC1B,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACF,MAAM,EAAE,SAAS,CAAC,MAAM;iBAC3B,CAAC,CAAC;aACN;SACJ;IACL,CAAC;IA9BD,wCA8BC","sourcesContent":["import { clearSelectedCells } from './clearSelectedCells';\nimport { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalInsertOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * Insert a row to the table\n * @param table The table model where the row is to be inserted\n * @param operation The operation to be performed\n */\nexport function insertTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalInsertOperation\n) {\n const sel = getSelectedCells(table);\n const insertAbove = operation == 'insertAbove';\n\n if (sel) {\n clearSelectedCells(table, sel);\n\n for (let i = sel.firstRow; i <= sel.lastRow; i++) {\n const sourceRow = table.rows[insertAbove ? sel.firstRow : sel.lastRow];\n\n table.rows.splice(insertAbove ? sel.firstRow : sel.lastRow + 1, 0, {\n format: { ...sourceRow.format },\n cells: sourceRow.cells.map(cell => {\n const newCell = createTableCell(\n cell.spanLeft,\n cell.spanAbove,\n cell.isHeader,\n cell.format,\n cell.dataset\n );\n newCell.isSelected = true;\n return newCell;\n }),\n height: sourceRow.height,\n });\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function mergeTableCells(table: ContentModelTable): void;
5
+ export declare function mergeTableCells(table: ShallowMutableContentModelTable): void;
@@ -13,12 +13,11 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
13
13
  for (var colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {
14
14
  var cell = table.rows[rowIndex].cells[colIndex];
15
15
  if (cell) {
16
- cell.spanLeft = colIndex > sel.firstColumn;
17
- cell.spanAbove = rowIndex > sel.firstRow;
18
- delete cell.cachedElement;
16
+ var mutableCell = (0, roosterjs_content_model_dom_1.mutateBlock)(cell);
17
+ mutableCell.spanLeft = colIndex > sel.firstColumn;
18
+ mutableCell.spanAbove = rowIndex > sel.firstRow;
19
19
  }
20
20
  }
21
- delete table.rows[rowIndex].cachedElement;
22
21
  }
23
22
  }
24
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTableCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableCells.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,eAAe,CAAC,KAAwB;QACpD,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IACI,GAAG;YACH,IAAA,6BAAa,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,EACvF;YACE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;oBACzE,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAElD,IAAI,IAAI,EAAE;wBACN,IAAI,CAAC,QAAQ,GAAG,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC;wBAC3C,IAAI,CAAC,SAAS,GAAG,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;wBAEzC,OAAO,IAAI,CAAC,aAAa,CAAC;qBAC7B;iBACJ;gBAED,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;aAC7C;SACJ;IACL,CAAC;IAtBD,0CAsBC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableCells(table: ContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (\n sel &&\n canMergeCells(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)\n ) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[rowIndex].cells[colIndex];\n\n if (cell) {\n cell.spanLeft = colIndex > sel.firstColumn;\n cell.spanAbove = rowIndex > sel.firstRow;\n\n delete cell.cachedElement;\n }\n }\n\n delete table.rows[rowIndex].cachedElement;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"mergeTableCells.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableCells.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,eAAe,CAAC,KAAsC;QAClE,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QAEpC,IACI,GAAG;YACH,IAAA,6BAAa,EAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,EACvF;YACE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;oBACzE,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAElD,IAAI,IAAI,EAAE;wBACN,IAAM,WAAW,GAAG,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC;wBAEtC,WAAW,CAAC,QAAQ,GAAG,QAAQ,GAAG,GAAG,CAAC,WAAW,CAAC;wBAClD,WAAW,CAAC,SAAS,GAAG,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;qBACnD;iBACJ;aACJ;SACJ;IACL,CAAC;IApBD,0CAoBC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableCells(table: ShallowMutableContentModelTable) {\n const sel = getSelectedCells(table);\n\n if (\n sel &&\n canMergeCells(table.rows, sel.firstRow, sel.firstColumn, sel.lastRow, sel.lastColumn)\n ) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[rowIndex].cells[colIndex];\n\n if (cell) {\n const mutableCell = mutateBlock(cell);\n\n mutableCell.spanLeft = colIndex > sel.firstColumn;\n mutableCell.spanAbove = rowIndex > sel.firstRow;\n }\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable, TableHorizontalMergeOperation } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable, TableHorizontalMergeOperation } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function mergeTableColumn(table: ContentModelTable, operation: TableHorizontalMergeOperation): void;
5
+ export declare function mergeTableColumn(table: ShallowMutableContentModelTable, operation: TableHorizontalMergeOperation): void;
@@ -16,19 +16,17 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
16
16
  var cell = (_a = table.rows[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[mergingColIndex];
17
17
  if (cell &&
18
18
  (0, canMergeCells_1.canMergeCells)(table.rows, rowIndex, mergingColIndex - 1, rowIndex, mergingColIndex)) {
19
- cell.spanLeft = true;
19
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanLeft = true;
20
20
  var newSelectedCol = mergingColIndex;
21
21
  while ((_c = (_b = table.rows[rowIndex]) === null || _b === void 0 ? void 0 : _b.cells[newSelectedCol]) === null || _c === void 0 ? void 0 : _c.spanLeft) {
22
- delete table.rows[rowIndex].cells[newSelectedCol].cachedElement;
22
+ (0, roosterjs_content_model_dom_1.mutateBlock)(table.rows[rowIndex].cells[newSelectedCol]);
23
23
  newSelectedCol--;
24
24
  }
25
- if ((_d = table.rows[rowIndex]) === null || _d === void 0 ? void 0 : _d.cells[newSelectedCol]) {
26
- table.rows[rowIndex].cells[newSelectedCol].isSelected = true;
27
- delete table.rows[rowIndex].cells[newSelectedCol].cachedElement;
25
+ var newCell = (_d = table.rows[rowIndex]) === null || _d === void 0 ? void 0 : _d.cells[newSelectedCol];
26
+ if (newCell) {
27
+ (0, roosterjs_content_model_dom_1.mutateBlock)(newCell).isSelected = true;
28
28
  }
29
- delete cell.cachedElement;
30
29
  }
31
- delete table.rows[rowIndex].cachedElement;
32
30
  }
33
31
  }
34
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableColumn.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACH,SAAgB,gBAAgB,CAC5B,KAAwB,EACxB,SAAwC;;QAExC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,SAAS,GAAG,SAAS,IAAI,WAAW,CAAC;QAE3C,IAAI,GAAG,EAAE;YACL,IAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;YAEzE,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;gBACrE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;oBACnE,IAAM,IAAI,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,eAAe,CAAC,CAAC;oBAE1D,IACI,IAAI;wBACJ,IAAA,6BAAa,EACT,KAAK,CAAC,IAAI,EACV,QAAQ,EACR,eAAe,GAAG,CAAC,EACnB,QAAQ,EACR,eAAe,CAClB,EACH;wBACE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;wBAErB,IAAI,cAAc,GAAG,eAAe,CAAC;wBAErC,OAAO,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,cAAc,CAAC,0CAAE,QAAQ,EAAE;4BAC1D,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC;4BAChE,cAAc,EAAE,CAAC;yBACpB;wBAED,IAAI,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,cAAc,CAAC,EAAE;4BAC7C,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;4BAE7D,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC;yBACnE;wBAED,OAAO,IAAI,CAAC,aAAa,CAAC;qBAC7B;oBAED,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;iBAC7C;aACJ;SACJ;IACL,CAAC;IA9CD,4CA8CC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelTable,\n TableHorizontalMergeOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableColumn(\n table: ContentModelTable,\n operation: TableHorizontalMergeOperation\n) {\n const sel = getSelectedCells(table);\n const mergeLeft = operation == 'mergeLeft';\n\n if (sel) {\n const mergingColIndex = mergeLeft ? sel.firstColumn : sel.lastColumn + 1;\n\n if (mergingColIndex > 0 && mergingColIndex < table.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = table.rows[rowIndex]?.cells[mergingColIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n rowIndex,\n mergingColIndex - 1,\n rowIndex,\n mergingColIndex\n )\n ) {\n cell.spanLeft = true;\n\n let newSelectedCol = mergingColIndex;\n\n while (table.rows[rowIndex]?.cells[newSelectedCol]?.spanLeft) {\n delete table.rows[rowIndex].cells[newSelectedCol].cachedElement;\n newSelectedCol--;\n }\n\n if (table.rows[rowIndex]?.cells[newSelectedCol]) {\n table.rows[rowIndex].cells[newSelectedCol].isSelected = true;\n\n delete table.rows[rowIndex].cells[newSelectedCol].cachedElement;\n }\n\n delete cell.cachedElement;\n }\n\n delete table.rows[rowIndex].cachedElement;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"mergeTableColumn.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableColumn.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACH,SAAgB,gBAAgB,CAC5B,KAAsC,EACtC,SAAwC;;QAExC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,SAAS,GAAG,SAAS,IAAI,WAAW,CAAC;QAE3C,IAAI,GAAG,EAAE;YACL,IAAM,eAAe,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC;YAEzE,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;gBACrE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;oBACnE,IAAM,IAAI,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,eAAe,CAAC,CAAC;oBAE1D,IACI,IAAI;wBACJ,IAAA,6BAAa,EACT,KAAK,CAAC,IAAI,EACV,QAAQ,EACR,eAAe,GAAG,CAAC,EACnB,QAAQ,EACR,eAAe,CAClB,EACH;wBACE,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;wBAElC,IAAI,cAAc,GAAG,eAAe,CAAC;wBAErC,OAAO,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,cAAc,CAAC,0CAAE,QAAQ,EAAE;4BAC1D,IAAA,yCAAW,EAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;4BACxD,cAAc,EAAE,CAAC;yBACpB;wBAED,IAAM,OAAO,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,KAAK,CAAC,cAAc,CAAC,CAAC;wBAC5D,IAAI,OAAO,EAAE;4BACT,IAAA,yCAAW,EAAC,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;yBAC1C;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IAzCD,4CAyCC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableHorizontalMergeOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableColumn(\n table: ShallowMutableContentModelTable,\n operation: TableHorizontalMergeOperation\n) {\n const sel = getSelectedCells(table);\n const mergeLeft = operation == 'mergeLeft';\n\n if (sel) {\n const mergingColIndex = mergeLeft ? sel.firstColumn : sel.lastColumn + 1;\n\n if (mergingColIndex > 0 && mergingColIndex < table.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = table.rows[rowIndex]?.cells[mergingColIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n rowIndex,\n mergingColIndex - 1,\n rowIndex,\n mergingColIndex\n )\n ) {\n mutateBlock(cell).spanLeft = true;\n\n let newSelectedCol = mergingColIndex;\n\n while (table.rows[rowIndex]?.cells[newSelectedCol]?.spanLeft) {\n mutateBlock(table.rows[rowIndex].cells[newSelectedCol]);\n newSelectedCol--;\n }\n\n const newCell = table.rows[rowIndex]?.cells[newSelectedCol];\n if (newCell) {\n mutateBlock(newCell).isSelected = true;\n }\n }\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable, TableVerticalMergeOperation } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable, TableVerticalMergeOperation } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function mergeTableRow(table: ContentModelTable, operation: TableVerticalMergeOperation): void;
5
+ export declare function mergeTableRow(table: ShallowMutableContentModelTable, operation: TableVerticalMergeOperation): void;
@@ -16,19 +16,16 @@ define(["require", "exports", "./canMergeCells", "roosterjs-content-model-dom"],
16
16
  var cell = table.rows[mergingRowIndex].cells[colIndex];
17
17
  if (cell &&
18
18
  (0, canMergeCells_1.canMergeCells)(table.rows, mergingRowIndex - 1, colIndex, mergingRowIndex, colIndex)) {
19
- cell.spanAbove = true;
19
+ (0, roosterjs_content_model_dom_1.mutateBlock)(cell).spanAbove = true;
20
20
  var newSelectedRow = mergingRowIndex;
21
21
  while ((_b = (_a = table.rows[newSelectedRow]) === null || _a === void 0 ? void 0 : _a.cells[colIndex]) === null || _b === void 0 ? void 0 : _b.spanAbove) {
22
- delete table.rows[newSelectedRow].cells[colIndex].cachedElement;
23
- delete table.rows[newSelectedRow].cachedElement;
22
+ (0, roosterjs_content_model_dom_1.mutateBlock)(table.rows[newSelectedRow].cells[colIndex]);
24
23
  newSelectedRow--;
25
24
  }
26
- if ((_c = table.rows[newSelectedRow]) === null || _c === void 0 ? void 0 : _c.cells[colIndex]) {
27
- table.rows[newSelectedRow].cells[colIndex].isSelected = true;
28
- delete table.rows[newSelectedRow].cells[colIndex].cachedElement;
29
- delete table.rows[newSelectedRow].cachedElement;
25
+ var newCell = (_c = table.rows[newSelectedRow]) === null || _c === void 0 ? void 0 : _c.cells[colIndex];
26
+ if (newCell) {
27
+ (0, roosterjs_content_model_dom_1.mutateBlock)(newCell).isSelected = true;
30
28
  }
31
- delete cell.cachedElement;
32
29
  }
33
30
  }
34
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableRow.ts"],"names":[],"mappings":";;;;IAIA;;OAEG;IACH,SAAgB,aAAa,CAAC,KAAwB,EAAE,SAAsC;;QAC1F,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAM,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;YAEpE,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5D,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;oBACzE,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAEzD,IACI,IAAI;wBACJ,IAAA,6BAAa,EACT,KAAK,CAAC,IAAI,EACV,eAAe,GAAG,CAAC,EACnB,QAAQ,EACR,eAAe,EACf,QAAQ,CACX,EACH;wBACE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;wBAEtB,IAAI,cAAc,GAAG,eAAe,CAAC;wBAErC,OAAO,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;4BAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;4BAChE,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC;4BAChD,cAAc,EAAE,CAAC;yBACpB;wBAED,IAAI,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,EAAE;4BAC7C,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;4BAE7D,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;4BAChE,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,aAAa,CAAC;yBACnD;wBAED,OAAO,IAAI,CAAC,aAAa,CAAC;qBAC7B;iBACJ;aACJ;SACJ;IACL,CAAC;IA3CD,sCA2CC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable, TableVerticalMergeOperation } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableRow(table: ContentModelTable, operation: TableVerticalMergeOperation) {\n const sel = getSelectedCells(table);\n const mergeAbove = operation == 'mergeAbove';\n\n if (sel) {\n const mergingRowIndex = mergeAbove ? sel.firstRow : sel.lastRow + 1;\n\n if (mergingRowIndex > 0 && mergingRowIndex < table.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[mergingRowIndex].cells[colIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n mergingRowIndex - 1,\n colIndex,\n mergingRowIndex,\n colIndex\n )\n ) {\n cell.spanAbove = true;\n\n let newSelectedRow = mergingRowIndex;\n\n while (table.rows[newSelectedRow]?.cells[colIndex]?.spanAbove) {\n delete table.rows[newSelectedRow].cells[colIndex].cachedElement;\n delete table.rows[newSelectedRow].cachedElement;\n newSelectedRow--;\n }\n\n if (table.rows[newSelectedRow]?.cells[colIndex]) {\n table.rows[newSelectedRow].cells[colIndex].isSelected = true;\n\n delete table.rows[newSelectedRow].cells[colIndex].cachedElement;\n delete table.rows[newSelectedRow].cachedElement;\n }\n\n delete cell.cachedElement;\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"mergeTableRow.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/mergeTableRow.ts"],"names":[],"mappings":";;;;IAOA;;OAEG;IACH,SAAgB,aAAa,CACzB,KAAsC,EACtC,SAAsC;;QAEtC,IAAM,GAAG,GAAG,IAAA,8CAAgB,EAAC,KAAK,CAAC,CAAC;QACpC,IAAM,UAAU,GAAG,SAAS,IAAI,YAAY,CAAC;QAE7C,IAAI,GAAG,EAAE;YACL,IAAM,eAAe,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;YAEpE,IAAI,eAAe,GAAG,CAAC,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;gBAC5D,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,WAAW,EAAE,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE;oBACzE,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;oBAEzD,IACI,IAAI;wBACJ,IAAA,6BAAa,EACT,KAAK,CAAC,IAAI,EACV,eAAe,GAAG,CAAC,EACnB,QAAQ,EACR,eAAe,EACf,QAAQ,CACX,EACH;wBACE,IAAA,yCAAW,EAAC,IAAI,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC;wBAEnC,IAAI,cAAc,GAAG,eAAe,CAAC;wBAErC,OAAO,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,0CAAE,SAAS,EAAE;4BAC3D,IAAA,yCAAW,EAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;4BACxD,cAAc,EAAE,CAAC;yBACpB;wBAED,IAAM,OAAO,GAAG,MAAA,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;wBAE5D,IAAI,OAAO,EAAE;4BACT,IAAA,yCAAW,EAAC,OAAO,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC;yBAC1C;qBACJ;iBACJ;aACJ;SACJ;IACL,CAAC;IA1CD,sCA0CC","sourcesContent":["import { canMergeCells } from './canMergeCells';\nimport { getSelectedCells, mutateBlock } from 'roosterjs-content-model-dom';\nimport type {\n ShallowMutableContentModelTable,\n TableVerticalMergeOperation,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function mergeTableRow(\n table: ShallowMutableContentModelTable,\n operation: TableVerticalMergeOperation\n) {\n const sel = getSelectedCells(table);\n const mergeAbove = operation == 'mergeAbove';\n\n if (sel) {\n const mergingRowIndex = mergeAbove ? sel.firstRow : sel.lastRow + 1;\n\n if (mergingRowIndex > 0 && mergingRowIndex < table.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = table.rows[mergingRowIndex].cells[colIndex];\n\n if (\n cell &&\n canMergeCells(\n table.rows,\n mergingRowIndex - 1,\n colIndex,\n mergingRowIndex,\n colIndex\n )\n ) {\n mutateBlock(cell).spanAbove = true;\n\n let newSelectedRow = mergingRowIndex;\n\n while (table.rows[newSelectedRow]?.cells[colIndex]?.spanAbove) {\n mutateBlock(table.rows[newSelectedRow].cells[colIndex]);\n newSelectedRow--;\n }\n\n const newCell = table.rows[newSelectedRow]?.cells[colIndex];\n\n if (newCell) {\n mutateBlock(newCell).isSelected = true;\n }\n }\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function splitTableCellHorizontally(table: ContentModelTable): void;
5
+ export declare function splitTableCellHorizontally(table: ShallowMutableContentModelTable): void;
@@ -17,10 +17,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
17
17
  ((_a = row.cells[colIndex + 1]) === null || _a === void 0 ? void 0 : _a.spanLeft);
18
18
  })) {
19
19
  table.rows.forEach(function (row, rowIndex) {
20
- delete row.cells[colIndex].cachedElement;
20
+ (0, roosterjs_content_model_dom_1.mutateBlock)(row.cells[colIndex]);
21
21
  if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {
22
- row.cells[colIndex + 1].spanLeft = false;
23
- delete row.cells[colIndex + 1].cachedElement;
22
+ (0, roosterjs_content_model_dom_1.mutateBlock)(row.cells[colIndex + 1]).spanLeft = false;
24
23
  }
25
24
  });
26
25
  }
@@ -37,7 +36,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
37
36
  newCell.isSelected = cell.isSelected;
38
37
  }
39
38
  row.cells.splice(colIndex + 1, 0, newCell);
40
- delete row.cells[colIndex].cachedElement;
39
+ (0, roosterjs_content_model_dom_1.mutateBlock)(row.cells[colIndex]);
41
40
  }
42
41
  });
43
42
  var newWidth = Math.max(table.widths[colIndex] / 2, MIN_WIDTH);
@@ -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,KAAwB;QAC/D,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,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;wBAEzC,IAAI,QAAQ,IAAI,GAAG,CAAC,QAAQ,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE;4BACrD,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC;4BACzC,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC;yBAChD;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,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,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,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC;yBAC5C;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;;YA5CL,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE;wBAAlE,QAAQ;aA6ChB;SACJ;IACL,CAAC;IAnDD,gEAmDC","sourcesContent":["import { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\nimport type { ContentModelTable } from 'roosterjs-content-model-types';\n\nconst MIN_WIDTH = 30;\n\n/**\n * @internal\n */\nexport function splitTableCellHorizontally(table: ContentModelTable) {\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 delete row.cells[colIndex].cachedElement;\n\n if (rowIndex >= sel.firstRow && rowIndex <= sel.lastRow) {\n row.cells[colIndex + 1].spanLeft = false;\n delete row.cells[colIndex + 1].cachedElement;\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 delete row.cells[colIndex].cachedElement;\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,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,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;;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,5 +1,5 @@
1
- import type { ContentModelTable } from 'roosterjs-content-model-types';
1
+ import type { ShallowMutableContentModelTable } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function splitTableCellVertically(table: ContentModelTable): void;
5
+ export declare function splitTableCellVertically(table: ShallowMutableContentModelTable): void;
@@ -12,10 +12,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
12
12
  for (var rowIndex = sel.lastRow; rowIndex >= sel.firstRow; rowIndex--) {
13
13
  var row = table.rows[rowIndex];
14
14
  var belowRow = table.rows[rowIndex + 1];
15
- row.cells.forEach(function (cell) {
16
- delete cell.cachedElement;
17
- });
18
- delete row.cachedElement;
15
+ row.cells.forEach(roosterjs_content_model_dom_1.mutateBlock);
19
16
  if (belowRow === null || belowRow === void 0 ? void 0 : belowRow.cells.every(function (belowCell, colIndex) {
20
17
  return colIndex < sel.firstColumn ||
21
18
  colIndex > sel.lastColumn ||
@@ -23,11 +20,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
23
20
  })) {
24
21
  belowRow.cells.forEach(function (belowCell, colIndex) {
25
22
  if (colIndex >= sel.firstColumn && colIndex <= sel.lastColumn) {
26
- belowCell.spanAbove = false;
27
- delete belowCell.cachedElement;
23
+ (0, roosterjs_content_model_dom_1.mutateBlock)(belowCell).spanAbove = false;
28
24
  }
29
25
  });
30
- delete belowRow.cachedElement;
31
26
  }
32
27
  else {
33
28
  var newHeight = Math.max((row.height /= 2), MIN_HEIGHT);
@@ -1 +1 @@
1
- {"version":3,"file":"splitTableCellVertically.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/modelApi/table/splitTableCellVertically.ts"],"names":[],"mappings":";;;;IAGA,IAAM,UAAU,GAAG,EAAE,CAAC;IAEtB;;OAEG;IACH,SAAgB,wBAAwB,CAAC,KAAwB;QAC7D,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,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;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,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC;4BAC5B,OAAO,SAAS,CAAC,aAAa,CAAC;yBAClC;oBACL,CAAC,CAAC,CAAC;oBAEH,OAAO,QAAQ,CAAC,aAAa,CAAC;iBACjC;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;IA5DD,4DA4DC","sourcesContent":["import { createTableCell, getSelectedCells } from 'roosterjs-content-model-dom';\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"]}
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 +1 @@
1
- {"version":3,"file":"insertEntity.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/entity/insertEntity.ts"],"names":[],"mappings":";;;;IAqBA,IAAM,cAAc,GAAG,KAAK,CAAC;IAC7B,IAAM,eAAe,GAAG,MAAM,CAAC;IAwC/B,SAAgB,YAAY,CACxB,MAAe,EACf,IAAY,EACZ,OAAgB,EAChB,QAAgD,EAChD,OAA6B;QAEvB,IAAA,KACF,OAAO,IAAI,EAAE,EADT,WAAW,iBAAA,EAAE,gBAAgB,sBAAA,EAAE,cAAc,oBAAA,EAAE,gBAAgB,sBAAA,EAAE,kBAAkB,wBAC1E,CAAC;QAClB,IAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACtC,IAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QACnF,IAAM,OAAO,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAEzE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC;QAEtD,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;SACxD;QAED,IAAI,WAAW,EAAE;YACb,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SACpC;QAED,IAAM,WAAW,GAAG,IAAA,0CAAY,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAE7F,IAAI,CAAC,gBAAgB,EAAE;YACnB,MAAM,CAAC,YAAY,EAAE,CAAC;SACzB;QAED,IAAM,aAAa,GAA8B;YAC7C,YAAY,EAAE,0CAAY,CAAC,YAAY;YACvC,aAAa,EAAE,cAAM,OAAA,CAAC;gBAClB,OAAO,SAAA;gBACP,IAAI,MAAA;gBACJ,EAAE,EAAE,EAAE;gBACN,UAAU,EAAE,IAAI;aACnB,CAAC,EALmB,CAKnB;YACF,OAAO,EAAE,cAAc;SAC1B,CAAC;QAEF,IAAM,QAAQ,GAAG,UACb,KAA2B,EAC3B,OAAkC,EAClC,WAAyB;YAEzB,IAAA,qCAAiB,EACb,KAAK,EACL,WAAW,EACX,OAAO,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAChD,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,WAAW,CACd,CAAC;YAEF,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;YAE7B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAChC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAEtC,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF,IAAI,OAAO,QAAQ,IAAI,QAAQ,EAAE;YAC7B,IAAA,qEAAiC,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;SAChF;aAAM;YACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;SACtD;QAED,IAAI,CAAC,gBAAgB,EAAE;YACnB,IAAI,WAAW,SAAyB,CAAC;YAEzC,IAAI,kBAAkB,EAAE;gBACpB,IAAM,MAAM,GAAG,IAAA,+CAAiB,EAAC,OAAO,CAAC,CAAC;gBAClC,IAAA,EAAE,GAAiB,MAAM,GAAvB,EAAE,UAAU,GAAK,MAAM,WAAX,CAAY;gBAElC,WAAW;oBACP,EAAE,IAAI,UAAU;wBACZ,CAAC,CAAC;4BACI,EAAE,EAAE,EAAE;4BACN,IAAI,EAAE,UAAU;4BAChB,KAAK,EAAE,kBAAkB;yBAC5B;wBACH,CAAC,CAAC,SAAS,CAAC;aACvB;YAED,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;SACpC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;IA3FD,oCA2FC","sourcesContent":["import { formatInsertPointWithContentModel } from '../utils/formatInsertPointWithContentModel';\nimport { insertEntityModel } from '../../modelApi/entity/insertEntityModel';\nimport {\n ChangeSource,\n createEntity,\n normalizeContentModel,\n parseEntityFormat,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelEntity,\n InsertEntityPosition,\n InsertEntityOptions,\n IEditor,\n EntityState,\n DOMInsertPoint,\n FormatContentModelOptions,\n ContentModelDocument,\n FormatContentModelContext,\n InsertPoint,\n} from 'roosterjs-content-model-types';\n\nconst BlockEntityTag = 'div';\nconst InlineEntityTag = 'span';\n\n/**\n * Insert an entity into editor\n * @param editor The editor object\n * @param type Type of entity\n * @param isBlock True to insert a block entity, false to insert an inline entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: boolean,\n position: 'focus' | 'begin' | 'end' | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\n/**\n * Insert a block entity into editor\n * @param editor The editor object\n * @param type Type of entity\n * @param isBlock Must be true for a block entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: true,\n position: InsertEntityPosition | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: boolean,\n position?: InsertEntityPosition | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null {\n const { contentNode, focusAfterEntity, wrapperDisplay, skipUndoSnapshot, initialEntityState } =\n options || {};\n const document = editor.getDocument();\n const wrapper = document.createElement(isBlock ? BlockEntityTag : InlineEntityTag);\n const display = wrapperDisplay ?? (isBlock ? undefined : 'inline-block');\n\n wrapper.style.setProperty('display', display || null);\n\n if (display == undefined && isBlock) {\n wrapper.style.setProperty('width', '100%');\n wrapper.style.setProperty('display', 'inline-block');\n }\n\n if (contentNode) {\n wrapper.appendChild(contentNode);\n }\n\n const entityModel = createEntity(wrapper, true /* isReadonly */, undefined /*format*/, type);\n\n if (!skipUndoSnapshot) {\n editor.takeSnapshot();\n }\n\n const formatOptions: FormatContentModelOptions = {\n changeSource: ChangeSource.InsertEntity,\n getChangeData: () => ({\n wrapper,\n type,\n id: '',\n isReadonly: true,\n }),\n apiName: 'insertEntity',\n };\n\n const callback = (\n model: ContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => {\n insertEntityModel(\n model,\n entityModel,\n typeof position == 'string' ? position : 'focus',\n isBlock,\n focusAfterEntity,\n context,\n insertPoint\n );\n\n normalizeContentModel(model);\n\n context.skipUndoSnapshot = true;\n context.newEntities.push(entityModel);\n\n return true;\n };\n\n if (typeof position == 'object') {\n formatInsertPointWithContentModel(editor, position, callback, formatOptions);\n } else {\n editor.formatContentModel(callback, formatOptions);\n }\n\n if (!skipUndoSnapshot) {\n let entityState: EntityState | undefined;\n\n if (initialEntityState) {\n const format = parseEntityFormat(wrapper);\n const { id, entityType } = format;\n\n entityState =\n id && entityType\n ? {\n id: id,\n type: entityType,\n state: initialEntityState,\n }\n : undefined;\n }\n\n editor.takeSnapshot(entityState);\n }\n\n return entityModel;\n}\n"]}
1
+ {"version":3,"file":"insertEntity.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/entity/insertEntity.ts"],"names":[],"mappings":";;;;IAqBA,IAAM,cAAc,GAAG,KAAK,CAAC;IAC7B,IAAM,eAAe,GAAG,MAAM,CAAC;IAwC/B,SAAgB,YAAY,CACxB,MAAe,EACf,IAAY,EACZ,OAAgB,EAChB,QAAgD,EAChD,OAA6B;QAEvB,IAAA,KACF,OAAO,IAAI,EAAE,EADT,WAAW,iBAAA,EAAE,gBAAgB,sBAAA,EAAE,cAAc,oBAAA,EAAE,gBAAgB,sBAAA,EAAE,kBAAkB,wBAC1E,CAAC;QAClB,IAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACtC,IAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;QACnF,IAAM,OAAO,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QAEzE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC;QAEtD,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;SACxD;QAED,IAAI,WAAW,EAAE;YACb,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SACpC;QAED,IAAM,WAAW,GAAG,IAAA,0CAAY,EAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAE7F,IAAI,CAAC,gBAAgB,EAAE;YACnB,MAAM,CAAC,YAAY,EAAE,CAAC;SACzB;QAED,IAAM,aAAa,GAA8B;YAC7C,YAAY,EAAE,0CAAY,CAAC,YAAY;YACvC,aAAa,EAAE,cAAM,OAAA,CAAC;gBAClB,OAAO,SAAA;gBACP,IAAI,MAAA;gBACJ,EAAE,EAAE,EAAE;gBACN,UAAU,EAAE,IAAI;aACnB,CAAC,EALmB,CAKnB;YACF,OAAO,EAAE,cAAc;SAC1B,CAAC;QAEF,IAAM,QAAQ,GAAG,UACb,KAAyC,EACzC,OAAkC,EAClC,WAAyB;YAEzB,IAAA,qCAAiB,EACb,KAAK,EACL,WAAW,EACX,OAAO,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAChD,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,WAAW,CACd,CAAC;YAEF,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;YAE7B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAChC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAEtC,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF,IAAI,OAAO,QAAQ,IAAI,QAAQ,EAAE;YAC7B,IAAA,qEAAiC,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;SAChF;aAAM;YACH,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;SACtD;QAED,IAAI,CAAC,gBAAgB,EAAE;YACnB,IAAI,WAAW,SAAyB,CAAC;YAEzC,IAAI,kBAAkB,EAAE;gBACpB,IAAM,MAAM,GAAG,IAAA,+CAAiB,EAAC,OAAO,CAAC,CAAC;gBAClC,IAAA,EAAE,GAAiB,MAAM,GAAvB,EAAE,UAAU,GAAK,MAAM,WAAX,CAAY;gBAElC,WAAW;oBACP,EAAE,IAAI,UAAU;wBACZ,CAAC,CAAC;4BACI,EAAE,EAAE,EAAE;4BACN,IAAI,EAAE,UAAU;4BAChB,KAAK,EAAE,kBAAkB;yBAC5B;wBACH,CAAC,CAAC,SAAS,CAAC;aACvB;YAED,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;SACpC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;IA3FD,oCA2FC","sourcesContent":["import { formatInsertPointWithContentModel } from '../utils/formatInsertPointWithContentModel';\nimport { insertEntityModel } from '../../modelApi/entity/insertEntityModel';\nimport {\n ChangeSource,\n createEntity,\n normalizeContentModel,\n parseEntityFormat,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelEntity,\n InsertEntityPosition,\n InsertEntityOptions,\n IEditor,\n EntityState,\n DOMInsertPoint,\n FormatContentModelOptions,\n FormatContentModelContext,\n InsertPoint,\n ShallowMutableContentModelDocument,\n} from 'roosterjs-content-model-types';\n\nconst BlockEntityTag = 'div';\nconst InlineEntityTag = 'span';\n\n/**\n * Insert an entity into editor\n * @param editor The editor object\n * @param type Type of entity\n * @param isBlock True to insert a block entity, false to insert an inline entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: boolean,\n position: 'focus' | 'begin' | 'end' | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\n/**\n * Insert a block entity into editor\n * @param editor The editor object\n * @param type Type of entity\n * @param isBlock Must be true for a block entity\n * @param position Position of the entity to insert. It can be\n * Value of InsertEntityPosition: see InsertEntityPosition\n * selectionRangeEx: Use this range instead of current focus position to insert. After insert, focus will be moved to\n * the beginning of this range (when focusAfterEntity is not set to true) or after the new entity (when focusAfterEntity is set to true)\n * @param options Move options to insert. See InsertEntityOptions\n */\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: true,\n position: InsertEntityPosition | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null;\n\nexport function insertEntity(\n editor: IEditor,\n type: string,\n isBlock: boolean,\n position?: InsertEntityPosition | DOMInsertPoint,\n options?: InsertEntityOptions\n): ContentModelEntity | null {\n const { contentNode, focusAfterEntity, wrapperDisplay, skipUndoSnapshot, initialEntityState } =\n options || {};\n const document = editor.getDocument();\n const wrapper = document.createElement(isBlock ? BlockEntityTag : InlineEntityTag);\n const display = wrapperDisplay ?? (isBlock ? undefined : 'inline-block');\n\n wrapper.style.setProperty('display', display || null);\n\n if (display == undefined && isBlock) {\n wrapper.style.setProperty('width', '100%');\n wrapper.style.setProperty('display', 'inline-block');\n }\n\n if (contentNode) {\n wrapper.appendChild(contentNode);\n }\n\n const entityModel = createEntity(wrapper, true /* isReadonly */, undefined /*format*/, type);\n\n if (!skipUndoSnapshot) {\n editor.takeSnapshot();\n }\n\n const formatOptions: FormatContentModelOptions = {\n changeSource: ChangeSource.InsertEntity,\n getChangeData: () => ({\n wrapper,\n type,\n id: '',\n isReadonly: true,\n }),\n apiName: 'insertEntity',\n };\n\n const callback = (\n model: ShallowMutableContentModelDocument,\n context: FormatContentModelContext,\n insertPoint?: InsertPoint\n ) => {\n insertEntityModel(\n model,\n entityModel,\n typeof position == 'string' ? position : 'focus',\n isBlock,\n focusAfterEntity,\n context,\n insertPoint\n );\n\n normalizeContentModel(model);\n\n context.skipUndoSnapshot = true;\n context.newEntities.push(entityModel);\n\n return true;\n };\n\n if (typeof position == 'object') {\n formatInsertPointWithContentModel(editor, position, callback, formatOptions);\n } else {\n editor.formatContentModel(callback, formatOptions);\n }\n\n if (!skipUndoSnapshot) {\n let entityState: EntityState | undefined;\n\n if (initialEntityState) {\n const format = parseEntityFormat(wrapper);\n const { id, entityType } = format;\n\n entityState =\n id && entityType\n ? {\n id: id,\n type: entityType,\n state: initialEntityState,\n }\n : undefined;\n }\n\n editor.takeSnapshot(entityState);\n }\n\n return entityModel;\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "../../modelApi/selection/adjustSegmentSelection"], function (require, exports, adjustSegmentSelection_1) {
1
+ define(["require", "exports", "../../modelApi/selection/adjustSegmentSelection", "roosterjs-content-model-dom"], function (require, exports, adjustSegmentSelection_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.adjustImageSelection = void 0;
@@ -9,9 +9,11 @@ define(["require", "exports", "../../modelApi/selection/adjustSegmentSelection"]
9
9
  function adjustImageSelection(editor) {
10
10
  var image = null;
11
11
  editor.formatContentModel(function (model) {
12
- return (0, adjustSegmentSelection_1.adjustSegmentSelection)(model, function (target) {
12
+ return (0, adjustSegmentSelection_1.adjustSegmentSelection)(model, function (target, paragraph) {
13
13
  if (target.isSelected && target.segmentType == 'Image') {
14
- image = target;
14
+ (0, roosterjs_content_model_dom_1.mutateSegment)(paragraph, target, function (segment) {
15
+ image = segment;
16
+ });
15
17
  return true;
16
18
  }
17
19
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"adjustImageSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/image/adjustImageSelection.ts"],"names":[],"mappings":";;;;IAGA;;;OAGG;IACH,SAAgB,oBAAoB,CAAC,MAAe;QAChD,IAAI,KAAK,GAA6B,IAAI,CAAC;QAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,OAAA,IAAA,+CAAsB,EAClB,KAAK,EACL,UAAA,MAAM;gBACF,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,IAAI,OAAO,EAAE;oBACpD,KAAK,GAAG,MAAM,CAAC;oBACf,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD,UAAC,MAAM,EAAE,GAAG,IAAK,OAAA,MAAM,IAAI,GAAG,EAAb,CAAa,CACjC;QAXD,CAWC,EACL;YACI,OAAO,EAAE,sBAAsB;SAClC,CACJ,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAvBD,oDAuBC","sourcesContent":["import { adjustSegmentSelection } from '../../modelApi/selection/adjustSegmentSelection';\nimport type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Adjust selection to make sure select an image if any\n * @return Content Model Image object if an image is select, or null\n */\nexport function adjustImageSelection(editor: IEditor): ContentModelImage | null {\n let image: ContentModelImage | null = null;\n\n editor.formatContentModel(\n model =>\n adjustSegmentSelection(\n model,\n target => {\n if (target.isSelected && target.segmentType == 'Image') {\n image = target;\n return true;\n } else {\n return false;\n }\n },\n (target, ref) => target == ref\n ),\n {\n apiName: 'adjustImageSelection',\n }\n );\n\n return image;\n}\n"]}
1
+ {"version":3,"file":"adjustImageSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/image/adjustImageSelection.ts"],"names":[],"mappings":";;;;IAIA;;;OAGG;IACH,SAAgB,oBAAoB,CAAC,MAAe;QAChD,IAAI,KAAK,GAA6B,IAAI,CAAC;QAE3C,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,OAAA,IAAA,+CAAsB,EAClB,KAAK,EACL,UAAC,MAAM,EAAE,SAAS;gBACd,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,WAAW,IAAI,OAAO,EAAE;oBACpD,IAAA,2CAAa,EAAC,SAAS,EAAE,MAAM,EAAE,UAAA,OAAO;wBACpC,KAAK,GAAG,OAAO,CAAC;oBACpB,CAAC,CAAC,CAAC;oBACH,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD,UAAC,MAAM,EAAE,GAAG,IAAK,OAAA,MAAM,IAAI,GAAG,EAAb,CAAa,CACjC;QAbD,CAaC,EACL;YACI,OAAO,EAAE,sBAAsB;SAClC,CACJ,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAzBD,oDAyBC","sourcesContent":["import { adjustSegmentSelection } from '../../modelApi/selection/adjustSegmentSelection';\nimport { mutateSegment } from 'roosterjs-content-model-dom';\nimport type { ContentModelImage, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Adjust selection to make sure select an image if any\n * @return Content Model Image object if an image is select, or null\n */\nexport function adjustImageSelection(editor: IEditor): ContentModelImage | null {\n let image: ContentModelImage | null = null;\n\n editor.formatContentModel(\n model =>\n adjustSegmentSelection(\n model,\n (target, paragraph) => {\n if (target.isSelected && target.segmentType == 'Image') {\n mutateSegment(paragraph, target, segment => {\n image = segment;\n });\n return true;\n } else {\n return false;\n }\n },\n (target, ref) => target == ref\n ),\n {\n apiName: 'adjustImageSelection',\n }\n );\n\n return image;\n}\n"]}
@@ -12,7 +12,7 @@ define(["require", "exports", "../../modelApi/selection/adjustSegmentSelection",
12
12
  editor.formatContentModel(function (model) {
13
13
  var _a, _b;
14
14
  var changed = (0, adjustSegmentSelection_1.adjustSegmentSelection)(model, function (target) { return !!target.isSelected && !!target.link; }, function (target, ref) { return !!target.link && target.link.format.href == ref.link.format.href; });
15
- var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/);
15
+ var segments = (0, roosterjs_content_model_dom_1.getSelectedSegments)(model, false /*includingFormatHolder*/, true /*mutate*/);
16
16
  var firstSegment = segments[0];
17
17
  if (segments.length == 1 && firstSegment.segmentType == 'SelectionMarker') {
18
18
  segments = (0, adjustWordSelection_1.adjustWordSelection)(model, firstSegment);
@@ -1 +1 @@
1
- {"version":3,"file":"adjustLinkSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/adjustLinkSelection.ts"],"names":[],"mappings":";;;;IAKA;;;OAGG;IACH,SAAgB,mBAAmB,CAAC,MAAe;QAC/C,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,GAAkB,IAAI,CAAC;QAE9B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;;YACD,IAAI,OAAO,GAAG,IAAA,+CAAsB,EAChC,KAAK,EACL,UAAA,MAAM,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAApC,CAAoC,EAC9C,UAAC,MAAM,EAAE,GAAG,IAAK,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,IAAK,CAAC,MAAM,CAAC,IAAI,EAAjE,CAAiE,CACrF,CAAC;YACF,IAAI,QAAQ,GAAG,IAAA,iDAAmB,EAAC,KAAK,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;YAC3E,IAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEjC,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,YAAY,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBACvE,QAAQ,GAAG,IAAA,yCAAmB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;gBAEpD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrB,OAAO,GAAG,IAAI,CAAC;oBACf,IAAA,0CAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;iBACnE;aACJ;YAED,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAvC,CAAuC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3E,GAAG,GAAG,CAAA,MAAA,MAAA,QAAQ,CAAC,CAAC,CAAC,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,KAAI,IAAI,CAAC;YAE7C,OAAO,OAAO,CAAC;QACnB,CAAC,EACD;YACI,OAAO,EAAE,qBAAqB;SACjC,CACJ,CAAC;QAEF,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;IAlCD,kDAkCC","sourcesContent":["import { adjustSegmentSelection } from '../../modelApi/selection/adjustSegmentSelection';\nimport { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegments, setSelection } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Adjust selection to make sure select a hyperlink if any, or a word if original selection is collapsed\n * @return A combination of existing link display text and url if any. If there is no existing link, return selected text and null\n */\nexport function adjustLinkSelection(editor: IEditor): [string, string | null] {\n let text = '';\n let url: string | null = null;\n\n editor.formatContentModel(\n model => {\n let changed = adjustSegmentSelection(\n model,\n target => !!target.isSelected && !!target.link,\n (target, ref) => !!target.link && target.link.format.href == ref.link!.format.href\n );\n let segments = getSelectedSegments(model, false /*includingFormatHolder*/);\n const firstSegment = segments[0];\n\n if (segments.length == 1 && firstSegment.segmentType == 'SelectionMarker') {\n segments = adjustWordSelection(model, firstSegment);\n\n if (segments.length > 1) {\n changed = true;\n setSelection(model, segments[0], segments[segments.length - 1]);\n }\n }\n\n text = segments.map(x => (x.segmentType == 'Text' ? x.text : '')).join('');\n url = segments[0]?.link?.format.href || null;\n\n return changed;\n },\n {\n apiName: 'adjustLinkSelection',\n }\n );\n\n return [text, url];\n}\n"]}
1
+ {"version":3,"file":"adjustLinkSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/link/adjustLinkSelection.ts"],"names":[],"mappings":";;;;IAKA;;;OAGG;IACH,SAAgB,mBAAmB,CAAC,MAAe;QAC/C,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,GAAG,GAAkB,IAAI,CAAC;QAE9B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;;YACD,IAAI,OAAO,GAAG,IAAA,+CAAsB,EAChC,KAAK,EACL,UAAA,MAAM,IAAI,OAAA,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,EAApC,CAAoC,EAC9C,UAAC,MAAM,EAAE,GAAG,IAAK,OAAA,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,IAAK,CAAC,MAAM,CAAC,IAAI,EAAjE,CAAiE,CACrF,CAAC;YACF,IAAI,QAAQ,GAAG,IAAA,iDAAmB,EAC9B,KAAK,EACL,KAAK,CAAC,yBAAyB,EAC/B,IAAI,CAAC,UAAU,CAClB,CAAC;YACF,IAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEjC,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,YAAY,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBACvE,QAAQ,GAAG,IAAA,yCAAmB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;gBAEpD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrB,OAAO,GAAG,IAAI,CAAC;oBACf,IAAA,0CAAY,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;iBACnE;aACJ;YAED,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAvC,CAAuC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3E,GAAG,GAAG,CAAA,MAAA,MAAA,QAAQ,CAAC,CAAC,CAAC,0CAAE,IAAI,0CAAE,MAAM,CAAC,IAAI,KAAI,IAAI,CAAC;YAE7C,OAAO,OAAO,CAAC;QACnB,CAAC,EACD;YACI,OAAO,EAAE,qBAAqB;SACjC,CACJ,CAAC;QAEF,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACvB,CAAC;IAtCD,kDAsCC","sourcesContent":["import { adjustSegmentSelection } from '../../modelApi/selection/adjustSegmentSelection';\nimport { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { getSelectedSegments, setSelection } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Adjust selection to make sure select a hyperlink if any, or a word if original selection is collapsed\n * @return A combination of existing link display text and url if any. If there is no existing link, return selected text and null\n */\nexport function adjustLinkSelection(editor: IEditor): [string, string | null] {\n let text = '';\n let url: string | null = null;\n\n editor.formatContentModel(\n model => {\n let changed = adjustSegmentSelection(\n model,\n target => !!target.isSelected && !!target.link,\n (target, ref) => !!target.link && target.link.format.href == ref.link!.format.href\n );\n let segments = getSelectedSegments(\n model,\n false /*includingFormatHolder*/,\n true /*mutate*/\n );\n const firstSegment = segments[0];\n\n if (segments.length == 1 && firstSegment.segmentType == 'SelectionMarker') {\n segments = adjustWordSelection(model, firstSegment);\n\n if (segments.length > 1) {\n changed = true;\n setSelection(model, segments[0], segments[segments.length - 1]);\n }\n }\n\n text = segments.map(x => (x.segmentType == 'Text' ? x.text : '')).join('');\n url = segments[0]?.link?.format.href || null;\n\n return changed;\n },\n {\n apiName: 'adjustLinkSelection',\n }\n );\n\n return [text, url];\n}\n"]}