roosterjs-content-model-api 0.28.0 → 9.1.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 (305) hide show
  1. package/README.md +47 -37
  2. package/lib/index.d.ts +4 -0
  3. package/lib/index.js +10 -2
  4. package/lib/index.js.map +1 -1
  5. package/lib/modelApi/block/setModelAlignment.js +2 -2
  6. package/lib/modelApi/block/setModelAlignment.js.map +1 -1
  7. package/lib/modelApi/block/setModelDirection.js +5 -5
  8. package/lib/modelApi/block/setModelDirection.js.map +1 -1
  9. package/lib/modelApi/block/setModelIndentation.js +6 -7
  10. package/lib/modelApi/block/setModelIndentation.js.map +1 -1
  11. package/lib/modelApi/block/toggleModelBlockQuote.js +3 -4
  12. package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  13. package/lib/modelApi/common/clearModelFormat.js +6 -7
  14. package/lib/modelApi/common/clearModelFormat.js.map +1 -1
  15. package/lib/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
  16. package/lib/modelApi/common/reducedModelChildProcessor.js +64 -0
  17. package/lib/modelApi/common/reducedModelChildProcessor.js.map +1 -0
  18. package/lib/modelApi/entity/insertEntityModel.d.ts +2 -2
  19. package/lib/modelApi/entity/insertEntityModel.js +19 -10
  20. package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
  21. package/lib/modelApi/image/applyImageBorderFormat.js +1 -2
  22. package/lib/modelApi/image/applyImageBorderFormat.js.map +1 -1
  23. package/lib/modelApi/list/setListType.js +3 -4
  24. package/lib/modelApi/list/setListType.js.map +1 -1
  25. package/lib/modelApi/list/setModelListStartNumber.d.ts +7 -0
  26. package/lib/modelApi/list/setModelListStartNumber.js +22 -0
  27. package/lib/modelApi/list/setModelListStartNumber.js.map +1 -0
  28. package/lib/modelApi/list/setModelListStyle.d.ts +7 -0
  29. package/lib/modelApi/list/setModelListStyle.js +26 -0
  30. package/lib/modelApi/list/setModelListStyle.js.map +1 -0
  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.js +1 -2
  34. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  35. package/lib/modelApi/selection/adjustWordSelection.js +3 -4
  36. package/lib/modelApi/selection/adjustWordSelection.js.map +1 -1
  37. package/lib/modelApi/table/alignTableCell.js +3 -3
  38. package/lib/modelApi/table/alignTableCell.js.map +1 -1
  39. package/lib/modelApi/table/clearSelectedCells.d.ts +0 -1
  40. package/lib/modelApi/table/clearSelectedCells.js +2 -3
  41. package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
  42. package/lib/modelApi/table/deleteTableColumn.js +2 -2
  43. package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
  44. package/lib/modelApi/table/deleteTableRow.js +2 -2
  45. package/lib/modelApi/table/deleteTableRow.js.map +1 -1
  46. package/lib/modelApi/table/insertTableColumn.js +1 -2
  47. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  48. package/lib/modelApi/table/insertTableRow.js +1 -2
  49. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  50. package/lib/modelApi/table/mergeTableCells.js +2 -2
  51. package/lib/modelApi/table/mergeTableCells.js.map +1 -1
  52. package/lib/modelApi/table/mergeTableColumn.js +2 -2
  53. package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
  54. package/lib/modelApi/table/mergeTableRow.js +2 -2
  55. package/lib/modelApi/table/mergeTableRow.js.map +1 -1
  56. package/lib/modelApi/table/splitTableCellHorizontally.js +1 -2
  57. package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  58. package/lib/modelApi/table/splitTableCellVertically.js +1 -2
  59. package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
  60. package/lib/publicApi/entity/insertEntity.d.ts +3 -3
  61. package/lib/publicApi/entity/insertEntity.js +17 -11
  62. package/lib/publicApi/entity/insertEntity.js.map +1 -1
  63. package/lib/publicApi/format/getFormatState.js +11 -3
  64. package/lib/publicApi/format/getFormatState.js.map +1 -1
  65. package/lib/publicApi/image/changeImage.js +3 -3
  66. package/lib/publicApi/image/changeImage.js.map +1 -1
  67. package/lib/publicApi/image/insertImage.js +2 -3
  68. package/lib/publicApi/image/insertImage.js.map +1 -1
  69. package/lib/publicApi/link/adjustLinkSelection.js +3 -3
  70. package/lib/publicApi/link/adjustLinkSelection.js.map +1 -1
  71. package/lib/publicApi/link/insertLink.js +3 -4
  72. package/lib/publicApi/link/insertLink.js.map +1 -1
  73. package/lib/publicApi/link/removeLink.js +2 -2
  74. package/lib/publicApi/link/removeLink.js.map +1 -1
  75. package/lib/publicApi/list/setListStartNumber.js +2 -10
  76. package/lib/publicApi/list/setListStartNumber.js.map +1 -1
  77. package/lib/publicApi/list/setListStyle.js +2 -17
  78. package/lib/publicApi/list/setListStyle.js.map +1 -1
  79. package/lib/publicApi/segment/setBackgroundColor.js +1 -2
  80. package/lib/publicApi/segment/setBackgroundColor.js.map +1 -1
  81. package/lib/publicApi/segment/toggleBold.js +2 -2
  82. package/lib/publicApi/segment/toggleBold.js.map +1 -1
  83. package/lib/publicApi/table/applyTableBorderFormat.js +4 -5
  84. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  85. package/lib/publicApi/table/formatTable.js +4 -4
  86. package/lib/publicApi/table/formatTable.js.map +1 -1
  87. package/lib/publicApi/table/insertTable.js +6 -7
  88. package/lib/publicApi/table/insertTable.js.map +1 -1
  89. package/lib/publicApi/table/setTableCellShade.js +5 -5
  90. package/lib/publicApi/table/setTableCellShade.js.map +1 -1
  91. package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
  92. package/lib/publicApi/utils/formatInsertPointWithContentModel.js +127 -0
  93. package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
  94. package/lib/publicApi/utils/formatParagraphWithContentModel.js +2 -2
  95. package/lib/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  96. package/lib/publicApi/utils/formatSegmentWithContentModel.js +2 -2
  97. package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  98. package/lib/publicApi/utils/formatTableWithContentModel.js +5 -6
  99. package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  100. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +7 -0
  101. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +28 -0
  102. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -0
  103. package/lib-amd/index.d.ts +4 -0
  104. package/lib-amd/index.js +6 -2
  105. package/lib-amd/index.js.map +1 -1
  106. package/lib-amd/modelApi/block/setModelAlignment.js +2 -2
  107. package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
  108. package/lib-amd/modelApi/block/setModelDirection.js +5 -5
  109. package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
  110. package/lib-amd/modelApi/block/setModelIndentation.js +6 -6
  111. package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
  112. package/lib-amd/modelApi/block/toggleModelBlockQuote.js +3 -3
  113. package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  114. package/lib-amd/modelApi/common/clearModelFormat.js +7 -7
  115. package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
  116. package/lib-amd/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
  117. package/lib-amd/modelApi/common/reducedModelChildProcessor.js +64 -0
  118. package/lib-amd/modelApi/common/reducedModelChildProcessor.js.map +1 -0
  119. package/lib-amd/modelApi/entity/insertEntityModel.d.ts +2 -2
  120. package/lib-amd/modelApi/entity/insertEntityModel.js +20 -10
  121. package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
  122. package/lib-amd/modelApi/image/applyImageBorderFormat.js +2 -2
  123. package/lib-amd/modelApi/image/applyImageBorderFormat.js.map +1 -1
  124. package/lib-amd/modelApi/list/setListType.js +4 -4
  125. package/lib-amd/modelApi/list/setListType.js.map +1 -1
  126. package/lib-amd/modelApi/list/setModelListStartNumber.d.ts +7 -0
  127. package/lib-amd/modelApi/list/setModelListStartNumber.js +23 -0
  128. package/lib-amd/modelApi/list/setModelListStartNumber.js.map +1 -0
  129. package/lib-amd/modelApi/list/setModelListStyle.d.ts +7 -0
  130. package/lib-amd/modelApi/list/setModelListStyle.js +26 -0
  131. package/lib-amd/modelApi/list/setModelListStyle.js.map +1 -0
  132. package/lib-amd/modelApi/selection/adjustSegmentSelection.js +3 -3
  133. package/lib-amd/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  134. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js +2 -2
  135. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  136. package/lib-amd/modelApi/selection/adjustWordSelection.js +4 -4
  137. package/lib-amd/modelApi/selection/adjustWordSelection.js.map +1 -1
  138. package/lib-amd/modelApi/table/alignTableCell.js +3 -3
  139. package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
  140. package/lib-amd/modelApi/table/clearSelectedCells.d.ts +0 -1
  141. package/lib-amd/modelApi/table/clearSelectedCells.js +2 -3
  142. package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
  143. package/lib-amd/modelApi/table/deleteTableColumn.js +2 -2
  144. package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
  145. package/lib-amd/modelApi/table/deleteTableRow.js +2 -2
  146. package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
  147. package/lib-amd/modelApi/table/insertTableColumn.js +2 -2
  148. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  149. package/lib-amd/modelApi/table/insertTableRow.js +2 -2
  150. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  151. package/lib-amd/modelApi/table/mergeTableCells.js +2 -2
  152. package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
  153. package/lib-amd/modelApi/table/mergeTableColumn.js +2 -2
  154. package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
  155. package/lib-amd/modelApi/table/mergeTableRow.js +2 -2
  156. package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
  157. package/lib-amd/modelApi/table/splitTableCellHorizontally.js +2 -2
  158. package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  159. package/lib-amd/modelApi/table/splitTableCellVertically.js +2 -2
  160. package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
  161. package/lib-amd/publicApi/entity/insertEntity.d.ts +3 -3
  162. package/lib-amd/publicApi/entity/insertEntity.js +17 -11
  163. package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
  164. package/lib-amd/publicApi/format/getFormatState.js +10 -3
  165. package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
  166. package/lib-amd/publicApi/image/changeImage.js +3 -3
  167. package/lib-amd/publicApi/image/changeImage.js.map +1 -1
  168. package/lib-amd/publicApi/image/insertImage.js +3 -3
  169. package/lib-amd/publicApi/image/insertImage.js.map +1 -1
  170. package/lib-amd/publicApi/link/adjustLinkSelection.js +3 -3
  171. package/lib-amd/publicApi/link/adjustLinkSelection.js.map +1 -1
  172. package/lib-amd/publicApi/link/insertLink.js +4 -4
  173. package/lib-amd/publicApi/link/insertLink.js.map +1 -1
  174. package/lib-amd/publicApi/link/removeLink.js +2 -2
  175. package/lib-amd/publicApi/link/removeLink.js.map +1 -1
  176. package/lib-amd/publicApi/list/setListStartNumber.js +2 -10
  177. package/lib-amd/publicApi/list/setListStartNumber.js.map +1 -1
  178. package/lib-amd/publicApi/list/setListStyle.js +2 -16
  179. package/lib-amd/publicApi/list/setListStyle.js.map +1 -1
  180. package/lib-amd/publicApi/segment/setBackgroundColor.js +2 -2
  181. package/lib-amd/publicApi/segment/setBackgroundColor.js.map +1 -1
  182. package/lib-amd/publicApi/segment/toggleBold.js +2 -2
  183. package/lib-amd/publicApi/segment/toggleBold.js.map +1 -1
  184. package/lib-amd/publicApi/table/applyTableBorderFormat.js +5 -5
  185. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  186. package/lib-amd/publicApi/table/formatTable.js +4 -4
  187. package/lib-amd/publicApi/table/formatTable.js.map +1 -1
  188. package/lib-amd/publicApi/table/insertTable.js +6 -6
  189. package/lib-amd/publicApi/table/insertTable.js.map +1 -1
  190. package/lib-amd/publicApi/table/setTableCellShade.js +5 -5
  191. package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
  192. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
  193. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +127 -0
  194. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
  195. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js +2 -2
  196. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  197. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +2 -2
  198. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  199. package/lib-amd/publicApi/utils/formatTableWithContentModel.js +6 -6
  200. package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  201. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +7 -0
  202. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +29 -0
  203. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -0
  204. package/lib-mjs/index.d.ts +4 -0
  205. package/lib-mjs/index.js +4 -0
  206. package/lib-mjs/index.js.map +1 -1
  207. package/lib-mjs/modelApi/block/setModelAlignment.js +1 -1
  208. package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
  209. package/lib-mjs/modelApi/block/setModelDirection.js +1 -1
  210. package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
  211. package/lib-mjs/modelApi/block/setModelIndentation.js +1 -2
  212. package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
  213. package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +1 -2
  214. package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  215. package/lib-mjs/modelApi/common/clearModelFormat.js +1 -2
  216. package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
  217. package/lib-mjs/modelApi/common/reducedModelChildProcessor.d.ts +20 -0
  218. package/lib-mjs/modelApi/common/reducedModelChildProcessor.js +60 -0
  219. package/lib-mjs/modelApi/common/reducedModelChildProcessor.js.map +1 -0
  220. package/lib-mjs/modelApi/entity/insertEntityModel.d.ts +2 -2
  221. package/lib-mjs/modelApi/entity/insertEntityModel.js +18 -9
  222. package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
  223. package/lib-mjs/modelApi/image/applyImageBorderFormat.js +1 -2
  224. package/lib-mjs/modelApi/image/applyImageBorderFormat.js.map +1 -1
  225. package/lib-mjs/modelApi/list/setListType.js +1 -2
  226. package/lib-mjs/modelApi/list/setListType.js.map +1 -1
  227. package/lib-mjs/modelApi/list/setModelListStartNumber.d.ts +7 -0
  228. package/lib-mjs/modelApi/list/setModelListStartNumber.js +18 -0
  229. package/lib-mjs/modelApi/list/setModelListStartNumber.js.map +1 -0
  230. package/lib-mjs/modelApi/list/setModelListStyle.d.ts +7 -0
  231. package/lib-mjs/modelApi/list/setModelListStyle.js +22 -0
  232. package/lib-mjs/modelApi/list/setModelListStyle.js.map +1 -0
  233. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js +1 -1
  234. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  235. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +1 -2
  236. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  237. package/lib-mjs/modelApi/selection/adjustWordSelection.js +1 -2
  238. package/lib-mjs/modelApi/selection/adjustWordSelection.js.map +1 -1
  239. package/lib-mjs/modelApi/table/alignTableCell.js +1 -1
  240. package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
  241. package/lib-mjs/modelApi/table/clearSelectedCells.d.ts +0 -1
  242. package/lib-mjs/modelApi/table/clearSelectedCells.js +1 -2
  243. package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
  244. package/lib-mjs/modelApi/table/deleteTableColumn.js +1 -1
  245. package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
  246. package/lib-mjs/modelApi/table/deleteTableRow.js +1 -1
  247. package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
  248. package/lib-mjs/modelApi/table/insertTableColumn.js +1 -2
  249. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  250. package/lib-mjs/modelApi/table/insertTableRow.js +1 -2
  251. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  252. package/lib-mjs/modelApi/table/mergeTableCells.js +1 -1
  253. package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
  254. package/lib-mjs/modelApi/table/mergeTableColumn.js +1 -1
  255. package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
  256. package/lib-mjs/modelApi/table/mergeTableRow.js +1 -1
  257. package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
  258. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +1 -2
  259. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  260. package/lib-mjs/modelApi/table/splitTableCellVertically.js +1 -2
  261. package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
  262. package/lib-mjs/publicApi/entity/insertEntity.d.ts +3 -3
  263. package/lib-mjs/publicApi/entity/insertEntity.js +17 -11
  264. package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
  265. package/lib-mjs/publicApi/format/getFormatState.js +11 -3
  266. package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
  267. package/lib-mjs/publicApi/image/changeImage.js +1 -1
  268. package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
  269. package/lib-mjs/publicApi/image/insertImage.js +1 -2
  270. package/lib-mjs/publicApi/image/insertImage.js.map +1 -1
  271. package/lib-mjs/publicApi/link/adjustLinkSelection.js +1 -1
  272. package/lib-mjs/publicApi/link/adjustLinkSelection.js.map +1 -1
  273. package/lib-mjs/publicApi/link/insertLink.js +1 -2
  274. package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
  275. package/lib-mjs/publicApi/link/removeLink.js +1 -1
  276. package/lib-mjs/publicApi/link/removeLink.js.map +1 -1
  277. package/lib-mjs/publicApi/list/setListStartNumber.js +2 -10
  278. package/lib-mjs/publicApi/list/setListStartNumber.js.map +1 -1
  279. package/lib-mjs/publicApi/list/setListStyle.js +2 -17
  280. package/lib-mjs/publicApi/list/setListStyle.js.map +1 -1
  281. package/lib-mjs/publicApi/segment/setBackgroundColor.js +1 -2
  282. package/lib-mjs/publicApi/segment/setBackgroundColor.js.map +1 -1
  283. package/lib-mjs/publicApi/segment/toggleBold.js +1 -1
  284. package/lib-mjs/publicApi/segment/toggleBold.js.map +1 -1
  285. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +1 -2
  286. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  287. package/lib-mjs/publicApi/table/formatTable.js +1 -1
  288. package/lib-mjs/publicApi/table/formatTable.js.map +1 -1
  289. package/lib-mjs/publicApi/table/insertTable.js +1 -2
  290. package/lib-mjs/publicApi/table/insertTable.js.map +1 -1
  291. package/lib-mjs/publicApi/table/setTableCellShade.js +1 -1
  292. package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
  293. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +5 -0
  294. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +123 -0
  295. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -0
  296. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js +1 -1
  297. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  298. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +1 -1
  299. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  300. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +1 -2
  301. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  302. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +7 -0
  303. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +24 -0
  304. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -0
  305. package/package.json +4 -5
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "../../modelApi/list/setModelListStartNumber"], function (require, exports, setModelListStartNumber_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setListStartNumber = void 0;
@@ -10,15 +10,7 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
10
10
  function setListStartNumber(editor, value) {
11
11
  editor.focus();
12
12
  editor.formatContentModel(function (model) {
13
- var listItem = (0, roosterjs_content_model_core_1.getFirstSelectedListItem)(model);
14
- var level = listItem === null || listItem === void 0 ? void 0 : listItem.levels[(listItem === null || listItem === void 0 ? void 0 : listItem.levels.length) - 1];
15
- if (level) {
16
- level.format.startNumberOverride = value;
17
- return true;
18
- }
19
- else {
20
- return false;
21
- }
13
+ return (0, setModelListStartNumber_1.setModelListStartNumber)(model, value);
22
14
  }, {
23
15
  apiName: 'setListStartNumber',
24
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"setListStartNumber.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/list/setListStartNumber.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,KAAa;QAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAM,QAAQ,GAAG,IAAA,uDAAwB,EAAC,KAAK,CAAC,CAAC;YACjD,IAAM,KAAK,GAAG,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,MAAM,IAAG,CAAC,CAAC,CAAC;YAE5D,IAAI,KAAK,EAAE;gBACP,KAAK,CAAC,MAAM,CAAC,mBAAmB,GAAG,KAAK,CAAC;gBAEzC,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,oBAAoB;SAChC,CACJ,CAAC;IACN,CAAC;IApBD,gDAoBC","sourcesContent":["import { getFirstSelectedListItem } from 'roosterjs-content-model-core';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set start number of a list item\n * @param editor The editor to operate on\n * @param value The number to set to, must be equal or greater than 1\n */\nexport function setListStartNumber(editor: IEditor, value: number) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const listItem = getFirstSelectedListItem(model);\n const level = listItem?.levels[listItem?.levels.length - 1];\n\n if (level) {\n level.format.startNumberOverride = value;\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setListStartNumber',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"setListStartNumber.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/list/setListStartNumber.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,KAAa;QAC7D,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,OAAO,IAAA,iDAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC,EACD;YACI,OAAO,EAAE,oBAAoB;SAChC,CACJ,CAAC;IACN,CAAC;IAXD,gDAWC","sourcesContent":["import { setModelListStartNumber } from '../../modelApi/list/setModelListStartNumber';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set start number of a list item\n * @param editor The editor to operate on\n * @param value The number to set to, must be equal or greater than 1\n */\nexport function setListStartNumber(editor: IEditor, value: number) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n return setModelListStartNumber(model, value);\n },\n {\n apiName: 'setListStartNumber',\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "../../modelApi/list/findListItemsInSameThread", "roosterjs-content-model-core"], function (require, exports, findListItemsInSameThread_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "../../modelApi/list/setModelListStyle"], function (require, exports, setModelListStyle_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setListStyle = void 0;
@@ -10,21 +10,7 @@ define(["require", "exports", "../../modelApi/list/findListItemsInSameThread", "
10
10
  function setListStyle(editor, style) {
11
11
  editor.focus();
12
12
  editor.formatContentModel(function (model) {
13
- var listItem = (0, roosterjs_content_model_core_1.getFirstSelectedListItem)(model);
14
- if (listItem) {
15
- var listItems = (0, findListItemsInSameThread_1.findListItemsInSameThread)(model, listItem);
16
- var levelIndex_1 = listItem.levels.length - 1;
17
- listItems.forEach(function (listItem) {
18
- var level = listItem.levels[levelIndex_1];
19
- if (level) {
20
- (0, roosterjs_content_model_core_1.updateListMetadata)(level, function (metadata) { return Object.assign({}, metadata, style); });
21
- }
22
- });
23
- return true;
24
- }
25
- else {
26
- return false;
27
- }
13
+ return (0, setModelListStyle_1.setModelListStyle)(model, style);
28
14
  }, {
29
15
  apiName: 'setListStyle',
30
16
  });
@@ -1 +1 @@
1
- {"version":3,"file":"setListStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/list/setListStyle.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,YAAY,CAAC,MAAe,EAAE,KAAyB;QACnE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,IAAM,QAAQ,GAAG,IAAA,uDAAwB,EAAC,KAAK,CAAC,CAAC;YAEjD,IAAI,QAAQ,EAAE;gBACV,IAAM,SAAS,GAAG,IAAA,qDAAyB,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;gBAC7D,IAAM,YAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;gBAE9C,SAAS,CAAC,OAAO,CAAC,UAAA,QAAQ;oBACtB,IAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,YAAU,CAAC,CAAC;oBAE1C,IAAI,KAAK,EAAE;wBACP,IAAA,iDAAkB,EAAC,KAAK,EAAE,UAAA,QAAQ,IAAI,OAAA,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAlC,CAAkC,CAAC,CAAC;qBAC7E;gBACL,CAAC,CAAC,CAAC;gBAEH,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,cAAc;SAC1B,CACJ,CAAC;IACN,CAAC;IA5BD,oCA4BC","sourcesContent":["import { findListItemsInSameThread } from '../../modelApi/list/findListItemsInSameThread';\nimport { getFirstSelectedListItem, updateListMetadata } from 'roosterjs-content-model-core';\nimport type { IEditor, ListMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Set style of list items with in same thread of current item\n * @param editor The editor to operate on\n * @param style The target list item style to set\n */\nexport function setListStyle(editor: IEditor, style: ListMetadataFormat) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const listItem = getFirstSelectedListItem(model);\n\n if (listItem) {\n const listItems = findListItemsInSameThread(model, listItem);\n const levelIndex = listItem.levels.length - 1;\n\n listItems.forEach(listItem => {\n const level = listItem.levels[levelIndex];\n\n if (level) {\n updateListMetadata(level, metadata => Object.assign({}, metadata, style));\n }\n });\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setListStyle',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"setListStyle.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/list/setListStyle.ts"],"names":[],"mappings":";;;;IAGA;;;;OAIG;IACH,SAAgB,YAAY,CAAC,MAAe,EAAE,KAAyB;QACnE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACD,OAAO,IAAA,qCAAiB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC,EACD;YACI,OAAO,EAAE,cAAc;SAC1B,CACJ,CAAC;IACN,CAAC;IAXD,oCAWC","sourcesContent":["import { setModelListStyle } from '../../modelApi/list/setModelListStyle';\nimport type { IEditor, ListMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Set style of list items with in same thread of current item\n * @param editor The editor to operate on\n * @param style The target list item style to set\n */\nexport function setListStyle(editor: IEditor, style: ListMetadataFormat) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n return setModelListStyle(model, style);\n },\n {\n apiName: 'setListStyle',\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "roosterjs-content-model-dom", "../utils/formatSegmentWithContentModel", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_dom_1, formatSegmentWithContentModel_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "roosterjs-content-model-dom", "../utils/formatSegmentWithContentModel"], function (require, exports, roosterjs_content_model_dom_1, formatSegmentWithContentModel_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setBackgroundColor = void 0;
@@ -27,7 +27,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "../utils/formatSeg
27
27
  if (lastParagraph && lastSegmentIndex >= 0) {
28
28
  var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)((_a = lastParagraph.segments[lastSegmentIndex]) === null || _a === void 0 ? void 0 : _a.format);
29
29
  lastParagraph.segments.splice(lastSegmentIndex + 1, 0, marker);
30
- (0, roosterjs_content_model_core_1.setSelection)(model, marker, marker);
30
+ (0, roosterjs_content_model_dom_1.setSelection)(model, marker, marker);
31
31
  }
32
32
  });
33
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setBackgroundColor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setBackgroundColor.ts"],"names":[],"mappings":";;;;IAKA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,eAA8B;QAC9E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,aAAa,GAAiC,IAAI,CAAC;QACvD,IAAI,gBAAgB,GAAW,CAAC,CAAC,CAAC;QAElC,IAAA,6DAA6B,EACzB,MAAM,EACN,oBAAoB,EACpB,UAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS;YAC1B,IAAI,eAAe,KAAK,IAAI,EAAE;gBAC1B,OAAO,MAAM,CAAC,eAAe,CAAC;aACjC;iBAAM;gBACH,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;aAC5C;YAED,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBAClE,aAAa,GAAG,SAAS,CAAC;gBAC1B,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAC9D;QACL,CAAC,EACD,SAAS,CAAC,2BAA2B,EACrC,SAAS,CAAC,yBAAyB,EACnC,UAAA,KAAK;;YACD,IAAI,aAAa,IAAI,gBAAgB,IAAI,CAAC,EAAE;gBACxC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAChC,MAAA,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,0CAAE,MAAM,CACnD,CAAC;gBAEF,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;gBAC/D,IAAA,2CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;aACvC;QACL,CAAC,CACJ,CAAC;IACN,CAAC;IAlCD,gDAkCC","sourcesContent":["import { createSelectionMarker } from 'roosterjs-content-model-dom';\nimport { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport { setSelection } from 'roosterjs-content-model-core';\nimport type { ContentModelParagraph, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set background color\n * @param editor The editor to operate on\n * @param backgroundColor The color to set. Pass null to remove existing color.\n */\nexport function setBackgroundColor(editor: IEditor, backgroundColor: string | null) {\n editor.focus();\n\n let lastParagraph: ContentModelParagraph | null = null;\n let lastSegmentIndex: number = -1;\n\n formatSegmentWithContentModel(\n editor,\n 'setBackgroundColor',\n (format, _, segment, paragraph) => {\n if (backgroundColor === null) {\n delete format.backgroundColor;\n } else {\n format.backgroundColor = backgroundColor;\n }\n\n if (segment && paragraph && segment.segmentType != 'SelectionMarker') {\n lastParagraph = paragraph;\n lastSegmentIndex = lastParagraph.segments.indexOf(segment);\n }\n },\n undefined /*segmentHasStyleCallback*/,\n undefined /*includingFormatHolder*/,\n model => {\n if (lastParagraph && lastSegmentIndex >= 0) {\n const marker = createSelectionMarker(\n lastParagraph.segments[lastSegmentIndex]?.format\n );\n\n lastParagraph.segments.splice(lastSegmentIndex + 1, 0, marker);\n setSelection(model, marker, marker);\n }\n }\n );\n}\n"]}
1
+ {"version":3,"file":"setBackgroundColor.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/setBackgroundColor.ts"],"names":[],"mappings":";;;;IAIA;;;;OAIG;IACH,SAAgB,kBAAkB,CAAC,MAAe,EAAE,eAA8B;QAC9E,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAI,aAAa,GAAiC,IAAI,CAAC;QACvD,IAAI,gBAAgB,GAAW,CAAC,CAAC,CAAC;QAElC,IAAA,6DAA6B,EACzB,MAAM,EACN,oBAAoB,EACpB,UAAC,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,SAAS;YAC1B,IAAI,eAAe,KAAK,IAAI,EAAE;gBAC1B,OAAO,MAAM,CAAC,eAAe,CAAC;aACjC;iBAAM;gBACH,MAAM,CAAC,eAAe,GAAG,eAAe,CAAC;aAC5C;YAED,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,CAAC,WAAW,IAAI,iBAAiB,EAAE;gBAClE,aAAa,GAAG,SAAS,CAAC;gBAC1B,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAC9D;QACL,CAAC,EACD,SAAS,CAAC,2BAA2B,EACrC,SAAS,CAAC,yBAAyB,EACnC,UAAA,KAAK;;YACD,IAAI,aAAa,IAAI,gBAAgB,IAAI,CAAC,EAAE;gBACxC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAChC,MAAA,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,0CAAE,MAAM,CACnD,CAAC;gBAEF,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;gBAC/D,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;aACvC;QACL,CAAC,CACJ,CAAC;IACN,CAAC;IAlCD,gDAkCC","sourcesContent":["import { createSelectionMarker, setSelection } from 'roosterjs-content-model-dom';\nimport { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport type { ContentModelParagraph, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set background color\n * @param editor The editor to operate on\n * @param backgroundColor The color to set. Pass null to remove existing color.\n */\nexport function setBackgroundColor(editor: IEditor, backgroundColor: string | null) {\n editor.focus();\n\n let lastParagraph: ContentModelParagraph | null = null;\n let lastSegmentIndex: number = -1;\n\n formatSegmentWithContentModel(\n editor,\n 'setBackgroundColor',\n (format, _, segment, paragraph) => {\n if (backgroundColor === null) {\n delete format.backgroundColor;\n } else {\n format.backgroundColor = backgroundColor;\n }\n\n if (segment && paragraph && segment.segmentType != 'SelectionMarker') {\n lastParagraph = paragraph;\n lastSegmentIndex = lastParagraph.segments.indexOf(segment);\n }\n },\n undefined /*segmentHasStyleCallback*/,\n undefined /*includingFormatHolder*/,\n model => {\n if (lastParagraph && lastSegmentIndex >= 0) {\n const marker = createSelectionMarker(\n lastParagraph.segments[lastSegmentIndex]?.format\n );\n\n lastParagraph.segments.splice(lastSegmentIndex + 1, 0, marker);\n setSelection(model, marker, marker);\n }\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "../utils/formatSegmentWithContentModel", "roosterjs-content-model-core"], function (require, exports, formatSegmentWithContentModel_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "../utils/formatSegmentWithContentModel", "roosterjs-content-model-dom"], function (require, exports, formatSegmentWithContentModel_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.toggleBold = void 0;
@@ -12,7 +12,7 @@ define(["require", "exports", "../utils/formatSegmentWithContentModel", "rooster
12
12
  format.fontWeight = isTurningOn ? 'bold' : 'normal';
13
13
  }, function (format, _, paragraph) {
14
14
  var _a;
15
- return (0, roosterjs_content_model_core_1.isBold)(typeof format.fontWeight == 'undefined'
15
+ return (0, roosterjs_content_model_dom_1.isBold)(typeof format.fontWeight == 'undefined'
16
16
  ? (_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.decorator) === null || _a === void 0 ? void 0 : _a.format.fontWeight
17
17
  : format.fontWeight);
18
18
  });
@@ -1 +1 @@
1
- {"version":3,"file":"toggleBold.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/toggleBold.ts"],"names":[],"mappings":";;;;IAIA;;;OAGG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,YAAY,EACZ,UAAC,MAAM,EAAE,WAAW;YAChB,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;QACxD,CAAC,EACD,UAAC,MAAM,EAAE,CAAC,EAAE,SAAS;;YACjB,OAAA,IAAA,qCAAM,EACF,OAAO,MAAM,CAAC,UAAU,IAAI,WAAW;gBACnC,CAAC,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,0CAAE,MAAM,CAAC,UAAU;gBACzC,CAAC,CAAC,MAAM,CAAC,UAAU,CAC1B,CAAA;SAAA,CACR,CAAC;IACN,CAAC;IAhBD,gCAgBC","sourcesContent":["import { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport { isBold } from 'roosterjs-content-model-core';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Toggle bold style\n * @param editor The editor to operate on\n */\nexport function toggleBold(editor: IEditor) {\n editor.focus();\n\n formatSegmentWithContentModel(\n editor,\n 'toggleBold',\n (format, isTurningOn) => {\n format.fontWeight = isTurningOn ? 'bold' : 'normal';\n },\n (format, _, paragraph) =>\n isBold(\n typeof format.fontWeight == 'undefined'\n ? paragraph?.decorator?.format.fontWeight\n : format.fontWeight\n )\n );\n}\n"]}
1
+ {"version":3,"file":"toggleBold.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/segment/toggleBold.ts"],"names":[],"mappings":";;;;IAIA;;;OAGG;IACH,SAAgB,UAAU,CAAC,MAAe;QACtC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,IAAA,6DAA6B,EACzB,MAAM,EACN,YAAY,EACZ,UAAC,MAAM,EAAE,WAAW;YAChB,MAAM,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;QACxD,CAAC,EACD,UAAC,MAAM,EAAE,CAAC,EAAE,SAAS;;YACjB,OAAA,IAAA,oCAAM,EACF,OAAO,MAAM,CAAC,UAAU,IAAI,WAAW;gBACnC,CAAC,CAAC,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,0CAAE,MAAM,CAAC,UAAU;gBACzC,CAAC,CAAC,MAAM,CAAC,UAAU,CAC1B,CAAA;SAAA,CACR,CAAC;IACN,CAAC;IAhBD,gCAgBC","sourcesContent":["import { formatSegmentWithContentModel } from '../utils/formatSegmentWithContentModel';\nimport { isBold } from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Toggle bold style\n * @param editor The editor to operate on\n */\nexport function toggleBold(editor: IEditor) {\n editor.focus();\n\n formatSegmentWithContentModel(\n editor,\n 'toggleBold',\n (format, isTurningOn) => {\n format.fontWeight = isTurningOn ? 'bold' : 'normal';\n },\n (format, _, paragraph) =>\n isBold(\n typeof format.fontWeight == 'undefined'\n ? paragraph?.decorator?.format.fontWeight\n : format.fontWeight\n )\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.applyTableBorderFormat = void 0;
@@ -10,9 +10,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs
10
10
  */
11
11
  function applyTableBorderFormat(editor, border, operation) {
12
12
  editor.formatContentModel(function (model) {
13
- var _a = (0, tslib_1.__read)((0, roosterjs_content_model_core_1.getFirstSelectedTable)(model), 1), tableModel = _a[0];
13
+ var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), tableModel = _a[0];
14
14
  if (tableModel) {
15
- var sel = (0, roosterjs_content_model_core_1.getSelectedCells)(tableModel);
15
+ var sel = (0, roosterjs_content_model_dom_1.getSelectedCells)(tableModel);
16
16
  var perimeter = {
17
17
  Top: false,
18
18
  Bottom: false,
@@ -23,7 +23,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs
23
23
  var borderFormat = '';
24
24
  var format = tableModel.format;
25
25
  var width = border.width, style = border.style, color = border.color;
26
- var extractedBorder = (0, roosterjs_content_model_core_1.extractBorderValues)(format.borderTop);
26
+ var extractedBorder = (0, roosterjs_content_model_dom_1.extractBorderValues)(format.borderTop);
27
27
  var borderColor = extractedBorder.color;
28
28
  var borderWidth = extractedBorder.width;
29
29
  var borderStyle = extractedBorder.style;
@@ -243,7 +243,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom", "roosterjs
243
243
  positions.forEach(function (pos) {
244
244
  cell.format[pos] = borderFormat;
245
245
  });
246
- (0, roosterjs_content_model_core_1.updateTableCellMetadata)(cell, function (metadata) {
246
+ (0, roosterjs_content_model_dom_1.updateTableCellMetadata)(cell, function (metadata) {
247
247
  metadata = metadata || {};
248
248
  metadata.borderOverride = true;
249
249
  return metadata;
@@ -1 +1 @@
1
- {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.ts"],"names":[],"mappings":";;;;IAkCA;;;;;OAKG;IACH,SAAgB,sBAAsB,CAClC,MAAe,EACf,MAAc,EACd,SAA2B;QAE3B,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,IAAM,GAA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AAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAClE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;aACjF;SACJ;QACD,qBAAqB;QACrB,IAAI,SAAS,CAAC,KAAK,IAAI,GAAG,CAAC,UAAU,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;YACzE,KAAK,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBACnE,IAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;gBACjE,iBAAiB,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;aACjF;SACJ;IACL,CAAC","sourcesContent":["import { parseValueWithUnit } from 'roosterjs-content-model-dom';\nimport {\n extractBorderValues,\n getFirstSelectedTable,\n getSelectedCells,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type {\n IEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"applyTableBorderFormat.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/applyTableBorderFormat.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-content-model-dom';\nimport type {\n IEditor,\n Border,\n ContentModelTable,\n ContentModelTableCell,\n BorderOperations,\n TableSelectionCoordinates,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Border positions\n */\ntype BorderPositions = 'borderTop' | 'borderBottom' | 'borderLeft' | 'borderRight';\n\n/**\n * @internal\n * Perimeter of the table selection\n * Used to determine where to apply border to the cells adjacent to the selection.\n */\ntype Perimeter = {\n Top: boolean;\n Bottom: boolean;\n Left: boolean;\n Right: boolean;\n};\n\n/**\n * Operations to apply border\n * @param editor The editor instance\n * @param border The border to apply\n * @param operation The operation to apply\n */\nexport function applyTableBorderFormat(\n editor: IEditor,\n border: Border,\n operation: BorderOperations\n) {\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n const sel = getSelectedCells(tableModel);\n const perimeter: Perimeter = {\n Top: false,\n Bottom: false,\n Left: false,\n Right: false,\n };\n\n // Create border format with table format as backup\n let borderFormat = '';\n const format = tableModel.format;\n const { width, style, color } = border;\n const extractedBorder = extractBorderValues(format.borderTop);\n const borderColor = extractedBorder.color;\n const borderWidth = extractedBorder.width;\n const borderStyle = extractedBorder.style;\n\n if (width) {\n borderFormat = parseValueWithUnit(width) + 'px';\n } else if (borderWidth) {\n borderFormat = borderWidth;\n } else {\n borderFormat = '1px';\n }\n\n if (style) {\n borderFormat = `${borderFormat} ${style}`;\n } else if (borderStyle) {\n borderFormat = `${borderFormat} ${borderStyle}`;\n } else {\n borderFormat = `${borderFormat} solid`;\n }\n\n if (color) {\n borderFormat = `${borderFormat} ${color}`;\n } else if (borderColor) {\n borderFormat = `${borderFormat} ${borderColor}`;\n }\n\n // undefined is treated as Left to Right\n const isRtl = tableModel.format.direction == 'rtl';\n\n if (sel) {\n const operations: BorderOperations[] = [operation];\n while (operations.length) {\n switch (operations.pop()) {\n case 'noBorders':\n // Do All borders but with empty border format\n borderFormat = '';\n operations.push('allBorders');\n break;\n case 'allBorders':\n const allBorders: BorderPositions[] = [\n 'borderTop',\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[colIndex];\n // Format cells - All borders\n applyBorderFormat(cell, borderFormat, allBorders);\n }\n }\n\n // Format perimeter\n perimeter.Top = true;\n perimeter.Bottom = true;\n perimeter.Left = true;\n perimeter.Right = true;\n break;\n case 'leftBorders':\n const leftBorder: BorderPositions[] = ['borderLeft'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ];\n // Format cells - Left border\n applyBorderFormat(cell, borderFormat, leftBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Right = true) : (perimeter.Left = true);\n break;\n case 'rightBorders':\n const rightBorder: BorderPositions[] = ['borderRight'];\n for (\n let rowIndex = sel.firstRow;\n rowIndex <= sel.lastRow;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ];\n // Format cells - Right border\n applyBorderFormat(cell, borderFormat, rightBorder);\n }\n\n // Format perimeter\n isRtl ? (perimeter.Left = true) : (perimeter.Right = true);\n break;\n case 'topBorders':\n const topBorder: BorderPositions[] = ['borderTop'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n // Format cells - Top border\n applyBorderFormat(cell, borderFormat, topBorder);\n }\n\n // Format perimeter\n perimeter.Top = true;\n break;\n case 'bottomBorders':\n const bottomBorder: BorderPositions[] = ['borderBottom'];\n for (\n let colIndex = sel.firstColumn;\n colIndex <= sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n // Format cells - Bottom border\n applyBorderFormat(cell, borderFormat, bottomBorder);\n }\n\n // Format perimeter\n perimeter.Bottom = true;\n break;\n case 'insideBorders':\n // Format cells - Inside borders\n const singleCol = sel.lastColumn == sel.firstColumn;\n const singleRow = sel.lastRow == sel.firstRow;\n // Single cell selection\n if (singleCol && singleRow) {\n break;\n }\n // Single column selection\n if (singleCol) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[sel.firstColumn],\n borderFormat,\n ['borderBottom']\n );\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex <= sel.lastRow - 1;\n rowIndex++\n ) {\n const cell =\n tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[sel.firstColumn],\n borderFormat,\n ['borderTop']\n );\n break;\n }\n // Single row selection\n if (singleRow) {\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderRight']\n );\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex <= sel.lastColumn - 1;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderLeft',\n 'borderRight',\n ]);\n }\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderLeft']\n );\n break;\n }\n\n // For multiple rows and columns selections\n // Top left cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderBottom', 'borderRight']\n );\n // Top right cell\n applyBorderFormat(\n tableModel.rows[sel.firstRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderBottom', 'borderLeft']\n );\n // Bottom left cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.lastColumn : sel.firstColumn\n ],\n borderFormat,\n ['borderTop', 'borderRight']\n );\n // Bottom right cell\n applyBorderFormat(\n tableModel.rows[sel.lastRow].cells[\n isRtl ? sel.firstColumn : sel.lastColumn\n ],\n borderFormat,\n ['borderTop', 'borderLeft']\n );\n // First row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.firstRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderBottom',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // Last row\n for (\n let colIndex = sel.firstColumn + 1;\n colIndex < sel.lastColumn;\n colIndex++\n ) {\n const cell = tableModel.rows[sel.lastRow].cells[colIndex];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderLeft',\n 'borderRight',\n ]);\n }\n // First column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderLeft' : 'borderRight',\n ]);\n }\n // Last column\n for (\n let rowIndex = sel.firstRow + 1;\n rowIndex < sel.lastRow;\n rowIndex++\n ) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn];\n applyBorderFormat(cell, borderFormat, [\n 'borderTop',\n 'borderBottom',\n isRtl ? 'borderRight' : 'borderLeft',\n ]);\n }\n // Inner cells\n sel.firstColumn++;\n sel.firstRow++;\n sel.lastColumn--;\n sel.lastRow--;\n operations.push('allBorders');\n break;\n case 'outsideBorders':\n // Format cells - Outside borders\n operations.push('topBorders');\n operations.push('bottomBorders');\n operations.push('leftBorders');\n operations.push('rightBorders');\n break;\n default:\n break;\n }\n }\n\n //Format perimeter if necessary or possible\n modifyPerimeter(tableModel, sel, borderFormat, perimeter, isRtl);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'tableBorder',\n }\n );\n}\n\n/**\n * @internal\n * Apply border format to a cell\n * @param cell The cell to apply border format\n * @param borderFormat The border format to apply\n * @param positions The positions to apply\n */\nfunction applyBorderFormat(\n cell: ContentModelTableCell,\n borderFormat: string,\n positions: BorderPositions[]\n) {\n positions.forEach(pos => {\n cell.format[pos] = borderFormat;\n });\n\n updateTableCellMetadata(cell, metadata => {\n metadata = metadata || {};\n metadata.borderOverride = true;\n return metadata;\n });\n\n // Cell was modified, so delete cached element\n delete cell.cachedElement;\n}\n\n/**\n * @internal\n * Modify the perimeter of the table selection\n * @param tableModel The table model\n * @param sel The table selection\n * @param borderFormat The border format to apply\n * If borderFormat is empty, the border will be removed\n * @param perimeter Where in the perimeter to apply\n */\nfunction modifyPerimeter(\n tableModel: ContentModelTable,\n sel: TableSelectionCoordinates,\n borderFormat: string,\n perimeter: Perimeter,\n isRtl: boolean\n) {\n // Top of selection\n if (perimeter.Top && sel.firstRow - 1 >= 0) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.firstRow - 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderBottom']);\n }\n }\n // Bottom of selection\n if (perimeter.Bottom && sel.lastRow + 1 < tableModel.rows.length) {\n for (let colIndex = sel.firstColumn; colIndex <= sel.lastColumn; colIndex++) {\n const cell = tableModel.rows[sel.lastRow + 1].cells[colIndex];\n applyBorderFormat(cell, borderFormat, ['borderTop']);\n }\n }\n // Left of selection\n if (perimeter.Left && sel.firstColumn - 1 >= 0) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.firstColumn - 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderLeft' : 'borderRight']);\n }\n }\n // Right of selection\n if (perimeter.Right && sel.lastColumn + 1 < tableModel.rows[0].cells.length) {\n for (let rowIndex = sel.firstRow; rowIndex <= sel.lastRow; rowIndex++) {\n const cell = tableModel.rows[rowIndex].cells[sel.lastColumn + 1];\n applyBorderFormat(cell, borderFormat, [isRtl ? 'borderRight' : 'borderLeft']);\n }\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.formatTable = void 0;
@@ -11,12 +11,12 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core"], function
11
11
  function formatTable(editor, format, keepCellShade) {
12
12
  editor.focus();
13
13
  editor.formatContentModel(function (model) {
14
- var _a = (0, tslib_1.__read)((0, roosterjs_content_model_core_1.getFirstSelectedTable)(model), 1), tableModel = _a[0];
14
+ var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), tableModel = _a[0];
15
15
  if (tableModel) {
16
16
  // Wipe border metadata
17
17
  tableModel.rows.forEach(function (row) {
18
18
  row.cells.forEach(function (cell) {
19
- (0, roosterjs_content_model_core_1.updateTableCellMetadata)(cell, function (metadata) {
19
+ (0, roosterjs_content_model_dom_1.updateTableCellMetadata)(cell, function (metadata) {
20
20
  if (metadata) {
21
21
  delete metadata.borderOverride;
22
22
  }
@@ -24,7 +24,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core"], function
24
24
  });
25
25
  });
26
26
  });
27
- (0, roosterjs_content_model_core_1.applyTableFormat)(tableModel, format, keepCellShade);
27
+ (0, roosterjs_content_model_dom_1.applyTableFormat)(tableModel, format, keepCellShade);
28
28
  return true;
29
29
  }
30
30
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"formatTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts"],"names":[],"mappings":";;;;IAOA;;;;;OAKG;IACH,SAAgB,WAAW,CAAC,MAAe,EAAE,MAA2B,EAAE,aAAuB;QAC7F,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,uBAAuB;gBACvB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBACvB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAA,sDAAuB,EAAC,IAAI,EAAE,UAAA,QAAQ;4BAClC,IAAI,QAAQ,EAAE;gCACV,OAAO,QAAQ,CAAC,cAAc,CAAC;6BAClC;4BACD,OAAO,QAAQ,CAAC;wBACpB,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBACH,IAAA,+CAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;gBACpD,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC;IA7BD,kCA6BC","sourcesContent":["import {\n applyTableFormat,\n getFirstSelectedTable,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-core';\nimport type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Format current focused table with the given format\n * @param editor The editor instance\n * @param format The table format to apply\n * @param keepCellShade Whether keep existing shade color when apply format if there is a manually set shade color\n */\nexport function formatTable(editor: IEditor, format: TableMetadataFormat, keepCellShade?: boolean) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n // Wipe border metadata\n tableModel.rows.forEach(row => {\n row.cells.forEach(cell => {\n updateTableCellMetadata(cell, metadata => {\n if (metadata) {\n delete metadata.borderOverride;\n }\n return metadata;\n });\n });\n });\n applyTableFormat(tableModel, format, keepCellShade);\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'formatTable',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"formatTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/formatTable.ts"],"names":[],"mappings":";;;;IAOA;;;;;OAKG;IACH,SAAgB,WAAW,CAAC,MAAe,EAAE,MAA2B,EAAE,aAAuB;QAC7F,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAe,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAA1C,UAAU,QAAgC,CAAC;YAElD,IAAI,UAAU,EAAE;gBACZ,uBAAuB;gBACvB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBACvB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAA,qDAAuB,EAAC,IAAI,EAAE,UAAA,QAAQ;4BAClC,IAAI,QAAQ,EAAE;gCACV,OAAO,QAAQ,CAAC,cAAc,CAAC;6BAClC;4BACD,OAAO,QAAQ,CAAC;wBACpB,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBACH,IAAA,8CAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;gBACpD,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC;IA7BD,kCA6BC","sourcesContent":["import {\n applyTableFormat,\n getFirstSelectedTable,\n updateTableCellMetadata,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Format current focused table with the given format\n * @param editor The editor instance\n * @param format The table format to apply\n * @param keepCellShade Whether keep existing shade color when apply format if there is a manually set shade color\n */\nexport function formatTable(editor: IEditor, format: TableMetadataFormat, keepCellShade?: boolean) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [tableModel] = getFirstSelectedTable(model);\n\n if (tableModel) {\n // Wipe border metadata\n tableModel.rows.forEach(row => {\n row.cells.forEach(cell => {\n updateTableCellMetadata(cell, metadata => {\n if (metadata) {\n delete metadata.borderOverride;\n }\n return metadata;\n });\n });\n });\n applyTableFormat(tableModel, format, keepCellShade);\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'formatTable',\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "roosterjs-content-model-dom", "../../modelApi/table/createTableStructure", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_dom_1, createTableStructure_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "../../modelApi/table/createTableStructure", "roosterjs-content-model-dom"], function (require, exports, createTableStructure_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.insertTable = void 0;
@@ -15,15 +15,15 @@ define(["require", "exports", "roosterjs-content-model-dom", "../../modelApi/tab
15
15
  editor.focus();
16
16
  editor.formatContentModel(function (model, context) {
17
17
  var _a, _b, _c;
18
- var insertPosition = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context).insertPoint;
18
+ var insertPosition = (0, roosterjs_content_model_dom_1.deleteSelection)(model, [], context).insertPoint;
19
19
  if (insertPosition) {
20
20
  var doc = (0, roosterjs_content_model_dom_1.createContentModelDocument)();
21
21
  var table = (0, createTableStructure_1.createTableStructure)(doc, columns, rows);
22
- (0, roosterjs_content_model_core_1.normalizeTable)(table, editor.getPendingFormat() || insertPosition.marker.format);
22
+ (0, roosterjs_content_model_dom_1.normalizeTable)(table, editor.getPendingFormat() || insertPosition.marker.format);
23
23
  // Assign default vertical align
24
24
  format = format || { verticalAlign: 'top' };
25
- (0, roosterjs_content_model_core_1.applyTableFormat)(table, format);
26
- (0, roosterjs_content_model_core_1.mergeModel)(model, doc, context, {
25
+ (0, roosterjs_content_model_dom_1.applyTableFormat)(table, format);
26
+ (0, roosterjs_content_model_dom_1.mergeModel)(model, doc, context, {
27
27
  insertPosition: insertPosition,
28
28
  mergeFormat: 'mergeAll',
29
29
  });
@@ -31,7 +31,7 @@ define(["require", "exports", "roosterjs-content-model-dom", "../../modelApi/tab
31
31
  if ((firstBlock === null || firstBlock === void 0 ? void 0 : firstBlock.blockType) == 'Paragraph') {
32
32
  var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)((_c = firstBlock.segments[0]) === null || _c === void 0 ? void 0 : _c.format);
33
33
  firstBlock.segments.unshift(marker);
34
- (0, roosterjs_content_model_core_1.setSelection)(model, marker);
34
+ (0, roosterjs_content_model_dom_1.setSelection)(model, marker);
35
35
  }
36
36
  return true;
37
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"insertTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts"],"names":[],"mappings":";;;;IAWA;;;;;;;;OAQG;IACH,SAAgB,WAAW,CACvB,MAAe,EACf,OAAe,EACf,IAAY,EACZ,MAAqC;QAErC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,cAAc,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC;YAEvE,IAAI,cAAc,EAAE;gBAChB,IAAM,GAAG,GAAG,IAAA,wDAA0B,GAAE,CAAC;gBACzC,IAAM,KAAK,GAAG,IAAA,2CAAoB,EAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEvD,IAAA,6CAAc,EAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACjF,gCAAgC;gBAChC,MAAM,GAAG,MAAM,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;gBAC5C,IAAA,+CAAgB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAChC,IAAA,yCAAU,EAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;oBAC5B,cAAc,gBAAA;oBACd,WAAW,EAAE,UAAU;iBAC1B,CAAC,CAAC;gBAEH,IAAM,UAAU,GAAG,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAEtD,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,KAAI,WAAW,EAAE;oBACtC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,MAAA,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC;oBACrE,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACpC,IAAA,2CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;gBAED,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC;IA1CD,kCA0CC","sourcesContent":["import { createContentModelDocument, createSelectionMarker } from 'roosterjs-content-model-dom';\nimport { createTableStructure } from '../../modelApi/table/createTableStructure';\nimport {\n applyTableFormat,\n deleteSelection,\n mergeModel,\n normalizeTable,\n setSelection,\n} from 'roosterjs-content-model-core';\nimport type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Insert table into editor at current selection\n * @param editor The editor instance\n * @param columns Number of columns in table, it also controls the default table cell width:\n * if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px\n * @param rows Number of rows in table\n * @param format (Optional) The table format. If not passed, the default format will be applied:\n * background color: #FFF; border color: #ABABAB\n */\nexport function insertTable(\n editor: IEditor,\n columns: number,\n rows: number,\n format?: Partial<TableMetadataFormat>\n) {\n editor.focus();\n\n editor.formatContentModel(\n (model, context) => {\n const insertPosition = deleteSelection(model, [], context).insertPoint;\n\n if (insertPosition) {\n const doc = createContentModelDocument();\n const table = createTableStructure(doc, columns, rows);\n\n normalizeTable(table, editor.getPendingFormat() || insertPosition.marker.format);\n // Assign default vertical align\n format = format || { verticalAlign: 'top' };\n applyTableFormat(table, format);\n mergeModel(model, doc, context, {\n insertPosition,\n mergeFormat: 'mergeAll',\n });\n\n const firstBlock = table.rows[0]?.cells[0]?.blocks[0];\n\n if (firstBlock?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(firstBlock.segments[0]?.format);\n firstBlock.segments.unshift(marker);\n setSelection(model, marker);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'insertTable',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"insertTable.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/insertTable.ts"],"names":[],"mappings":";;;;IAYA;;;;;;;;OAQG;IACH,SAAgB,WAAW,CACvB,MAAe,EACf,OAAe,EACf,IAAY,EACZ,MAAqC;QAErC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,cAAc,GAAG,IAAA,6CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,WAAW,CAAC;YAEvE,IAAI,cAAc,EAAE;gBAChB,IAAM,GAAG,GAAG,IAAA,wDAA0B,GAAE,CAAC;gBACzC,IAAM,KAAK,GAAG,IAAA,2CAAoB,EAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEvD,IAAA,4CAAc,EAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,EAAE,IAAI,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACjF,gCAAgC;gBAChC,MAAM,GAAG,MAAM,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;gBAC5C,IAAA,8CAAgB,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;gBAChC,IAAA,wCAAU,EAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE;oBAC5B,cAAc,gBAAA;oBACd,WAAW,EAAE,UAAU;iBAC1B,CAAC,CAAC;gBAEH,IAAM,UAAU,GAAG,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,0CAAE,KAAK,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAEtD,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,SAAS,KAAI,WAAW,EAAE;oBACtC,IAAM,MAAM,GAAG,IAAA,mDAAqB,EAAC,MAAA,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAE,MAAM,CAAC,CAAC;oBACrE,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACpC,IAAA,0CAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;gBAED,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,aAAa;SACzB,CACJ,CAAC;IACN,CAAC;IA1CD,kCA0CC","sourcesContent":["import { createTableStructure } from '../../modelApi/table/createTableStructure';\nimport {\n createContentModelDocument,\n createSelectionMarker,\n applyTableFormat,\n deleteSelection,\n mergeModel,\n normalizeTable,\n setSelection,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor, TableMetadataFormat } from 'roosterjs-content-model-types';\n\n/**\n * Insert table into editor at current selection\n * @param editor The editor instance\n * @param columns Number of columns in table, it also controls the default table cell width:\n * if columns &lt;= 4, width = 120px; if columns &lt;= 6, width = 100px; else width = 70px\n * @param rows Number of rows in table\n * @param format (Optional) The table format. If not passed, the default format will be applied:\n * background color: #FFF; border color: #ABABAB\n */\nexport function insertTable(\n editor: IEditor,\n columns: number,\n rows: number,\n format?: Partial<TableMetadataFormat>\n) {\n editor.focus();\n\n editor.formatContentModel(\n (model, context) => {\n const insertPosition = deleteSelection(model, [], context).insertPoint;\n\n if (insertPosition) {\n const doc = createContentModelDocument();\n const table = createTableStructure(doc, columns, rows);\n\n normalizeTable(table, editor.getPendingFormat() || insertPosition.marker.format);\n // Assign default vertical align\n format = format || { verticalAlign: 'top' };\n applyTableFormat(table, format);\n mergeModel(model, doc, context, {\n insertPosition,\n mergeFormat: 'mergeAll',\n });\n\n const firstBlock = table.rows[0]?.cells[0]?.blocks[0];\n\n if (firstBlock?.blockType == 'Paragraph') {\n const marker = createSelectionMarker(firstBlock.segments[0]?.format);\n firstBlock.segments.unshift(marker);\n setSelection(model, marker);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'insertTable',\n }\n );\n}\n"]}
@@ -1,4 +1,4 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-core"], function (require, exports, tslib_1, roosterjs_content_model_core_1) {
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.setTableCellShade = void 0;
@@ -10,13 +10,13 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core"], function
10
10
  function setTableCellShade(editor, color) {
11
11
  editor.focus();
12
12
  editor.formatContentModel(function (model) {
13
- var _a = (0, tslib_1.__read)((0, roosterjs_content_model_core_1.getFirstSelectedTable)(model), 1), table = _a[0];
13
+ var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getFirstSelectedTable)(model), 1), table = _a[0];
14
14
  if (table) {
15
- (0, roosterjs_content_model_core_1.normalizeTable)(table);
15
+ (0, roosterjs_content_model_dom_1.normalizeTable)(table);
16
16
  table.rows.forEach(function (row) {
17
17
  return row.cells.forEach(function (cell) {
18
- if ((0, roosterjs_content_model_core_1.hasSelectionInBlockGroup)(cell)) {
19
- (0, roosterjs_content_model_core_1.setTableCellBackgroundColor)(cell, color, true /*isColorOverride*/);
18
+ if ((0, roosterjs_content_model_dom_1.hasSelectionInBlockGroup)(cell)) {
19
+ (0, roosterjs_content_model_dom_1.setTableCellBackgroundColor)(cell, color, true /*isColorOverride*/);
20
20
  }
21
21
  });
22
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAAC,MAAe,EAAE,KAAoB;QACnE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAU,IAAA,oDAAqB,EAAC,KAAK,CAAC,IAAA,EAArC,KAAK,QAAgC,CAAC;YAE7C,IAAI,KAAK,EAAE;gBACP,IAAA,6CAAc,EAAC,KAAK,CAAC,CAAC;gBAEtB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAI,IAAA,uDAAwB,EAAC,IAAI,CAAC,EAAE;4BAChC,IAAA,0DAA2B,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;yBACtE;oBACL,CAAC,CAAC;gBAJF,CAIE,CACL,CAAC;gBAEF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,mBAAmB;SAC/B,CACJ,CAAC;IACN,CAAC;IA3BD,8CA2BC","sourcesContent":["import {\n hasSelectionInBlockGroup,\n getFirstSelectedTable,\n normalizeTable,\n setTableCellBackgroundColor,\n} from 'roosterjs-content-model-core';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set table cell shade color\n * @param editor The editor instance\n * @param color The color to set. Pass null to remove existing shade color\n */\nexport function setTableCellShade(editor: IEditor, color: string | null) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [table] = getFirstSelectedTable(model);\n\n if (table) {\n normalizeTable(table);\n\n table.rows.forEach(row =>\n row.cells.forEach(cell => {\n if (hasSelectionInBlockGroup(cell)) {\n setTableCellBackgroundColor(cell, color, true /*isColorOverride*/);\n }\n })\n );\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setTableCellShade',\n }\n );\n}\n"]}
1
+ {"version":3,"file":"setTableCellShade.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/table/setTableCellShade.ts"],"names":[],"mappings":";;;;IAQA;;;;OAIG;IACH,SAAgB,iBAAiB,CAAC,MAAe,EAAE,KAAoB;QACnE,MAAM,CAAC,KAAK,EAAE,CAAC;QAEf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;YACK,IAAA,KAAA,oBAAU,IAAA,mDAAqB,EAAC,KAAK,CAAC,IAAA,EAArC,KAAK,QAAgC,CAAC;YAE7C,IAAI,KAAK,EAAE;gBACP,IAAA,4CAAc,EAAC,KAAK,CAAC,CAAC;gBAEtB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;oBAClB,OAAA,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,UAAA,IAAI;wBAClB,IAAI,IAAA,sDAAwB,EAAC,IAAI,CAAC,EAAE;4BAChC,IAAA,yDAA2B,EAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;yBACtE;oBACL,CAAC,CAAC;gBAJF,CAIE,CACL,CAAC;gBAEF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,OAAO,EAAE,mBAAmB;SAC/B,CACJ,CAAC;IACN,CAAC;IA3BD,8CA2BC","sourcesContent":["import {\n hasSelectionInBlockGroup,\n getFirstSelectedTable,\n normalizeTable,\n setTableCellBackgroundColor,\n} from 'roosterjs-content-model-dom';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Set table cell shade color\n * @param editor The editor instance\n * @param color The color to set. Pass null to remove existing shade color\n */\nexport function setTableCellShade(editor: IEditor, color: string | null) {\n editor.focus();\n\n editor.formatContentModel(\n model => {\n const [table] = getFirstSelectedTable(model);\n\n if (table) {\n normalizeTable(table);\n\n table.rows.forEach(row =>\n row.cells.forEach(cell => {\n if (hasSelectionInBlockGroup(cell)) {\n setTableCellBackgroundColor(cell, color, true /*isColorOverride*/);\n }\n })\n );\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName: 'setTableCellShade',\n }\n );\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { DOMInsertPoint, FormatContentModelOptions, IEditor, InsertPoint, ContentModelDocument, FormatContentModelContext } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function formatInsertPointWithContentModel(editor: IEditor, insertPoint: DOMInsertPoint, callback: (model: ContentModelDocument, context: FormatContentModelContext, insertPoint?: InsertPoint) => void, options?: FormatContentModelOptions): void;
@@ -0,0 +1,127 @@
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.formatInsertPointWithContentModel = void 0;
5
+ /**
6
+ * @internal
7
+ */
8
+ function formatInsertPointWithContentModel(editor, insertPoint, callback, options) {
9
+ var bundle = {
10
+ input: insertPoint,
11
+ };
12
+ editor.formatContentModel(function (model, context) {
13
+ callback(model, context, bundle.result);
14
+ if (bundle === null || bundle === void 0 ? void 0 : bundle.result) {
15
+ var _a = bundle.result, paragraph = _a.paragraph, marker = _a.marker;
16
+ var index = paragraph.segments.indexOf(marker);
17
+ if (index >= 0) {
18
+ paragraph.segments.splice(index, 1);
19
+ }
20
+ }
21
+ return true;
22
+ }, options, {
23
+ processorOverride: {
24
+ child: getShadowChildProcessor(bundle),
25
+ textWithSelection: getShadowTextProcessor(bundle),
26
+ },
27
+ tryGetFromCache: false,
28
+ });
29
+ }
30
+ exports.formatInsertPointWithContentModel = formatInsertPointWithContentModel;
31
+ function getShadowChildProcessor(bundle) {
32
+ return function (group, parent, context) {
33
+ var contextWithPath = context;
34
+ contextWithPath.path = contextWithPath.path || [];
35
+ var shouldShiftPath = false;
36
+ if (contextWithPath.path[0] != group) {
37
+ contextWithPath.path.unshift(group);
38
+ shouldShiftPath = true;
39
+ }
40
+ var offsets = getShadowSelectionOffsets(context, bundle, parent);
41
+ var index = 0;
42
+ for (var child = parent.firstChild; child; child = child.nextSibling) {
43
+ handleElementShadowSelection(bundle, index, context, group, offsets, parent);
44
+ (0, roosterjs_content_model_dom_1.processChildNode)(group, child, context);
45
+ index++;
46
+ }
47
+ handleElementShadowSelection(bundle, index, context, group, offsets, parent);
48
+ if (shouldShiftPath) {
49
+ contextWithPath.path.shift();
50
+ }
51
+ };
52
+ }
53
+ function handleElementShadowSelection(bundle, index, context, group, offsets, container) {
54
+ if (index == offsets[2] &&
55
+ (index <= offsets[0] || offsets[0] < 0) &&
56
+ (index < offsets[1] || offsets[1] < 0)) {
57
+ addSelectionMarker(group, context, container, index, bundle);
58
+ offsets[2] = -1;
59
+ }
60
+ if (index == offsets[0]) {
61
+ context.isInSelection = true;
62
+ addSelectionMarker(group, context, container, index);
63
+ }
64
+ if (index == offsets[2] && (index < offsets[1] || offsets[1] < 0)) {
65
+ addSelectionMarker(group, context, container, index, bundle);
66
+ offsets[2] = -1;
67
+ }
68
+ if (index == offsets[1]) {
69
+ addSelectionMarker(group, context, container, index);
70
+ context.isInSelection = false;
71
+ }
72
+ if (index == offsets[2]) {
73
+ addSelectionMarker(group, context, container, index, bundle);
74
+ }
75
+ }
76
+ var getShadowTextProcessor = function (bundle) { return function (group, textNode, context) {
77
+ var txt = textNode.nodeValue || '';
78
+ var offsets = getShadowSelectionOffsets(context, bundle, textNode);
79
+ var _a = (0, tslib_1.__read)(offsets, 3), start = _a[0], end = _a[1], shadow = _a[2];
80
+ var handleTextSelection = function (subtract, originalOffset, bundle) {
81
+ (0, roosterjs_content_model_dom_1.addTextSegment)(group, txt.substring(0, subtract), context);
82
+ addSelectionMarker(group, context, textNode, originalOffset, bundle);
83
+ offsets[0] -= subtract;
84
+ offsets[1] -= subtract;
85
+ offsets[2] = bundle ? -1 : offsets[2] - subtract;
86
+ txt = txt.substring(subtract);
87
+ };
88
+ if (offsets[2] >= 0 &&
89
+ (offsets[2] <= offsets[0] || offsets[0] < 0) &&
90
+ (offsets[2] < offsets[1] || offsets[1] < 0)) {
91
+ handleTextSelection(offsets[2], shadow, bundle);
92
+ }
93
+ if (offsets[0] >= 0) {
94
+ handleTextSelection(offsets[0], start);
95
+ context.isInSelection = true;
96
+ }
97
+ if (offsets[2] >= 0 && offsets[2] > offsets[0] && (offsets[2] < offsets[1] || offsets[1] < 0)) {
98
+ handleTextSelection(offsets[2], shadow, bundle);
99
+ }
100
+ if (offsets[1] >= 0) {
101
+ handleTextSelection(offsets[1], end);
102
+ context.isInSelection = false;
103
+ }
104
+ if (offsets[2] >= 0 && offsets[2] >= offsets[1]) {
105
+ handleTextSelection(offsets[2], shadow, bundle);
106
+ }
107
+ (0, roosterjs_content_model_dom_1.addTextSegment)(group, txt, context);
108
+ }; };
109
+ function addSelectionMarker(group, context, container, offset, bundle) {
110
+ var marker = (0, roosterjs_content_model_dom_1.buildSelectionMarker)(group, context, container, offset);
111
+ marker.isSelected = !bundle;
112
+ var para = (0, roosterjs_content_model_dom_1.addSegment)(group, marker, context.blockFormat, marker.format);
113
+ if (bundle && context.path) {
114
+ bundle.result = {
115
+ path: (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(context.path), false),
116
+ paragraph: para,
117
+ marker: marker,
118
+ };
119
+ }
120
+ }
121
+ function getShadowSelectionOffsets(context, bundle, currentContainer) {
122
+ var _a = (0, tslib_1.__read)((0, roosterjs_content_model_dom_1.getRegularSelectionOffsets)(context, currentContainer), 2), start = _a[0], end = _a[1];
123
+ var shadow = bundle.input.node == currentContainer ? bundle.input.offset : -1;
124
+ return [start, end, shadow];
125
+ }
126
+ });
127
+ //# sourceMappingURL=formatInsertPointWithContentModel.js.map