roosterjs-content-model-api 9.45.0 → 9.45.2

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 (829) hide show
  1. package/lib/index.d.ts +63 -63
  2. package/lib/index.js +131 -131
  3. package/lib/index.js.map +1 -1
  4. package/lib/modelApi/block/setModelAlignment.d.ts +5 -5
  5. package/lib/modelApi/block/setModelAlignment.js +65 -65
  6. package/lib/modelApi/block/setModelAlignment.js.map +1 -1
  7. package/lib/modelApi/block/setModelDirection.d.ts +5 -5
  8. package/lib/modelApi/block/setModelDirection.js +113 -113
  9. package/lib/modelApi/block/setModelDirection.js.map +1 -1
  10. package/lib/modelApi/block/setModelIndentation.d.ts +8 -8
  11. package/lib/modelApi/block/setModelIndentation.js +158 -158
  12. package/lib/modelApi/block/setModelIndentation.js.map +1 -1
  13. package/lib/modelApi/block/splitSelectedParagraphByBr.d.ts +7 -7
  14. package/lib/modelApi/block/splitSelectedParagraphByBr.js +71 -71
  15. package/lib/modelApi/block/splitSelectedParagraphByBr.js.map +1 -1
  16. package/lib/modelApi/block/toggleModelBlockQuote.d.ts +5 -5
  17. package/lib/modelApi/block/toggleModelBlockQuote.js +53 -53
  18. package/lib/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  19. package/lib/modelApi/common/adjustIndentation.d.ts +13 -13
  20. package/lib/modelApi/common/adjustIndentation.js +114 -114
  21. package/lib/modelApi/common/adjustIndentation.js.map +1 -1
  22. package/lib/modelApi/common/clearModelFormat.d.ts +5 -5
  23. package/lib/modelApi/common/clearModelFormat.js +143 -143
  24. package/lib/modelApi/common/clearModelFormat.js.map +1 -1
  25. package/lib/modelApi/common/queryContentModelBlocks.d.ts +10 -10
  26. package/lib/modelApi/common/queryContentModelBlocks.js +87 -87
  27. package/lib/modelApi/common/queryContentModelBlocks.js.map +1 -1
  28. package/lib/modelApi/common/reducedModelChildProcessor.d.ts +20 -20
  29. package/lib/modelApi/common/reducedModelChildProcessor.js +63 -63
  30. package/lib/modelApi/common/reducedModelChildProcessor.js.map +1 -1
  31. package/lib/modelApi/common/wrapBlock.d.ts +16 -16
  32. package/lib/modelApi/common/wrapBlock.js +52 -52
  33. package/lib/modelApi/common/wrapBlock.js.map +1 -1
  34. package/lib/modelApi/entity/insertEntityModel.d.ts +5 -5
  35. package/lib/modelApi/entity/insertEntityModel.js +105 -105
  36. package/lib/modelApi/entity/insertEntityModel.js.map +1 -1
  37. package/lib/modelApi/image/applyImageBorderFormat.d.ts +5 -5
  38. package/lib/modelApi/image/applyImageBorderFormat.js +57 -57
  39. package/lib/modelApi/image/applyImageBorderFormat.js.map +1 -1
  40. package/lib/modelApi/link/getLinkUrl.d.ts +5 -5
  41. package/lib/modelApi/link/getLinkUrl.js +28 -28
  42. package/lib/modelApi/link/getLinkUrl.js.map +1 -1
  43. package/lib/modelApi/link/matchLink.d.ts +12 -12
  44. package/lib/modelApi/link/matchLink.js +93 -93
  45. package/lib/modelApi/link/matchLink.js.map +1 -1
  46. package/lib/modelApi/link/promoteLink.d.ts +20 -20
  47. package/lib/modelApi/link/promoteLink.js +54 -54
  48. package/lib/modelApi/link/promoteLink.js.map +1 -1
  49. package/lib/modelApi/list/findListItemsInSameThread.d.ts +13 -13
  50. package/lib/modelApi/list/findListItemsInSameThread.js +113 -113
  51. package/lib/modelApi/list/findListItemsInSameThread.js.map +1 -1
  52. package/lib/modelApi/list/getListAnnounceData.d.ts +7 -7
  53. package/lib/modelApi/list/getListAnnounceData.js +68 -68
  54. package/lib/modelApi/list/getListAnnounceData.js.map +1 -1
  55. package/lib/modelApi/list/setListType.d.ts +8 -8
  56. package/lib/modelApi/list/setListType.js +121 -117
  57. package/lib/modelApi/list/setListType.js.map +1 -1
  58. package/lib/modelApi/list/setModelListStartNumber.d.ts +7 -7
  59. package/lib/modelApi/list/setModelListStartNumber.js +21 -21
  60. package/lib/modelApi/list/setModelListStartNumber.js.map +1 -1
  61. package/lib/modelApi/list/setModelListStyle.d.ts +7 -7
  62. package/lib/modelApi/list/setModelListStyle.js +25 -25
  63. package/lib/modelApi/list/setModelListStyle.js.map +1 -1
  64. package/lib/modelApi/selection/adjustSegmentSelection.d.ts +5 -5
  65. package/lib/modelApi/selection/adjustSegmentSelection.js +47 -47
  66. package/lib/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  67. package/lib/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -6
  68. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js +56 -56
  69. package/lib/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  70. package/lib/modelApi/selection/adjustWordSelection.d.ts +8 -8
  71. package/lib/modelApi/selection/adjustWordSelection.js +123 -123
  72. package/lib/modelApi/selection/adjustWordSelection.js.map +1 -1
  73. package/lib/modelApi/selection/collapseTableSelection.d.ts +5 -5
  74. package/lib/modelApi/selection/collapseTableSelection.js +16 -16
  75. package/lib/modelApi/selection/collapseTableSelection.js.map +1 -1
  76. package/lib/modelApi/table/alignTable.d.ts +5 -5
  77. package/lib/modelApi/table/alignTable.js +11 -11
  78. package/lib/modelApi/table/alignTable.js.map +1 -1
  79. package/lib/modelApi/table/alignTableCell.d.ts +9 -9
  80. package/lib/modelApi/table/alignTableCell.js +67 -57
  81. package/lib/modelApi/table/alignTableCell.js.map +1 -1
  82. package/lib/modelApi/table/canMergeCells.d.ts +5 -5
  83. package/lib/modelApi/table/canMergeCells.js +56 -56
  84. package/lib/modelApi/table/canMergeCells.js.map +1 -1
  85. package/lib/modelApi/table/clearSelectedCells.d.ts +7 -7
  86. package/lib/modelApi/table/clearSelectedCells.js +29 -29
  87. package/lib/modelApi/table/clearSelectedCells.js.map +1 -1
  88. package/lib/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  89. package/lib/modelApi/table/copyPreviousCellSegmentFormat.js +24 -0
  90. package/lib/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  91. package/lib/modelApi/table/createTableStructure.d.ts +5 -5
  92. package/lib/modelApi/table/createTableStructure.js +19 -19
  93. package/lib/modelApi/table/createTableStructure.js.map +1 -1
  94. package/lib/modelApi/table/deleteTable.d.ts +5 -5
  95. package/lib/modelApi/table/deleteTable.js +10 -10
  96. package/lib/modelApi/table/deleteTable.js.map +1 -1
  97. package/lib/modelApi/table/deleteTableColumn.d.ts +5 -5
  98. package/lib/modelApi/table/deleteTableColumn.js +24 -24
  99. package/lib/modelApi/table/deleteTableColumn.js.map +1 -1
  100. package/lib/modelApi/table/deleteTableRow.d.ts +5 -5
  101. package/lib/modelApi/table/deleteTableRow.js +23 -23
  102. package/lib/modelApi/table/deleteTableRow.js.map +1 -1
  103. package/lib/modelApi/table/ensureFocusableParagraphForTable.d.ts +8 -8
  104. package/lib/modelApi/table/ensureFocusableParagraphForTable.js +56 -56
  105. package/lib/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  106. package/lib/modelApi/table/insertTableColumn.d.ts +7 -7
  107. package/lib/modelApi/table/insertTableColumn.js +29 -27
  108. package/lib/modelApi/table/insertTableColumn.js.map +1 -1
  109. package/lib/modelApi/table/insertTableRow.d.ts +7 -7
  110. package/lib/modelApi/table/insertTableRow.js +33 -31
  111. package/lib/modelApi/table/insertTableRow.js.map +1 -1
  112. package/lib/modelApi/table/mergeTableCells.d.ts +5 -5
  113. package/lib/modelApi/table/mergeTableCells.js +25 -25
  114. package/lib/modelApi/table/mergeTableCells.js.map +1 -1
  115. package/lib/modelApi/table/mergeTableColumn.d.ts +5 -5
  116. package/lib/modelApi/table/mergeTableColumn.js +35 -35
  117. package/lib/modelApi/table/mergeTableColumn.js.map +1 -1
  118. package/lib/modelApi/table/mergeTableRow.d.ts +5 -5
  119. package/lib/modelApi/table/mergeTableRow.js +35 -35
  120. package/lib/modelApi/table/mergeTableRow.js.map +1 -1
  121. package/lib/modelApi/table/splitTableCellHorizontally.d.ts +5 -5
  122. package/lib/modelApi/table/splitTableCellHorizontally.js +54 -54
  123. package/lib/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  124. package/lib/modelApi/table/splitTableCellVertically.d.ts +5 -5
  125. package/lib/modelApi/table/splitTableCellVertically.js +53 -53
  126. package/lib/modelApi/table/splitTableCellVertically.js.map +1 -1
  127. package/lib/publicApi/block/setAlignment.d.ts +7 -7
  128. package/lib/publicApi/block/setAlignment.js +16 -16
  129. package/lib/publicApi/block/setAlignment.js.map +1 -1
  130. package/lib/publicApi/block/setDirection.d.ts +7 -7
  131. package/lib/publicApi/block/setDirection.js +16 -16
  132. package/lib/publicApi/block/setDirection.js.map +1 -1
  133. package/lib/publicApi/block/setHeadingLevel.d.ts +7 -7
  134. package/lib/publicApi/block/setHeadingLevel.js +50 -50
  135. package/lib/publicApi/block/setHeadingLevel.js.map +1 -1
  136. package/lib/publicApi/block/setIndentation.d.ts +8 -8
  137. package/lib/publicApi/block/setIndentation.js +21 -21
  138. package/lib/publicApi/block/setIndentation.js.map +1 -1
  139. package/lib/publicApi/block/setParagraphMargin.d.ts +9 -9
  140. package/lib/publicApi/block/setParagraphMargin.js +33 -33
  141. package/lib/publicApi/block/setParagraphMargin.js.map +1 -1
  142. package/lib/publicApi/block/setSpacing.d.ts +7 -7
  143. package/lib/publicApi/block/setSpacing.js +21 -21
  144. package/lib/publicApi/block/setSpacing.js.map +1 -1
  145. package/lib/publicApi/block/toggleBlockQuote.d.ts +9 -9
  146. package/lib/publicApi/block/toggleBlockQuote.js +39 -39
  147. package/lib/publicApi/block/toggleBlockQuote.js.map +1 -1
  148. package/lib/publicApi/entity/insertEntity.d.ts +25 -25
  149. package/lib/publicApi/entity/insertEntity.js +67 -67
  150. package/lib/publicApi/entity/insertEntity.js.map +1 -1
  151. package/lib/publicApi/format/clearFormat.d.ts +6 -6
  152. package/lib/publicApi/format/clearFormat.js +34 -34
  153. package/lib/publicApi/format/clearFormat.js.map +1 -1
  154. package/lib/publicApi/format/getFormatState.d.ts +7 -7
  155. package/lib/publicApi/format/getFormatState.js +31 -31
  156. package/lib/publicApi/format/getFormatState.js.map +1 -1
  157. package/lib/publicApi/image/adjustImageSelection.d.ts +6 -6
  158. package/lib/publicApi/image/adjustImageSelection.js +29 -29
  159. package/lib/publicApi/image/adjustImageSelection.js.map +1 -1
  160. package/lib/publicApi/image/changeImage.d.ts +7 -7
  161. package/lib/publicApi/image/changeImage.js +35 -35
  162. package/lib/publicApi/image/changeImage.js.map +1 -1
  163. package/lib/publicApi/image/insertImage.d.ts +7 -7
  164. package/lib/publicApi/image/insertImage.js +38 -38
  165. package/lib/publicApi/image/insertImage.js.map +1 -1
  166. package/lib/publicApi/image/setImageAltText.d.ts +8 -8
  167. package/lib/publicApi/image/setImageAltText.js +17 -17
  168. package/lib/publicApi/image/setImageAltText.js.map +1 -1
  169. package/lib/publicApi/image/setImageBorder.d.ts +9 -9
  170. package/lib/publicApi/image/setImageBorder.js +19 -19
  171. package/lib/publicApi/image/setImageBorder.js.map +1 -1
  172. package/lib/publicApi/image/setImageBoxShadow.d.ts +8 -8
  173. package/lib/publicApi/image/setImageBoxShadow.js +29 -29
  174. package/lib/publicApi/image/setImageBoxShadow.js.map +1 -1
  175. package/lib/publicApi/link/adjustLinkSelection.d.ts +6 -6
  176. package/lib/publicApi/link/adjustLinkSelection.js +34 -34
  177. package/lib/publicApi/link/adjustLinkSelection.js.map +1 -1
  178. package/lib/publicApi/link/insertLink.d.ts +15 -15
  179. package/lib/publicApi/link/insertLink.js +120 -120
  180. package/lib/publicApi/link/insertLink.js.map +1 -1
  181. package/lib/publicApi/link/removeLink.d.ts +8 -8
  182. package/lib/publicApi/link/removeLink.js +32 -32
  183. package/lib/publicApi/link/removeLink.js.map +1 -1
  184. package/lib/publicApi/list/setListStartNumber.d.ts +7 -7
  185. package/lib/publicApi/list/setListStartNumber.js +18 -18
  186. package/lib/publicApi/list/setListStartNumber.js.map +1 -1
  187. package/lib/publicApi/list/setListStyle.d.ts +7 -7
  188. package/lib/publicApi/list/setListStyle.js +18 -18
  189. package/lib/publicApi/list/setListStyle.js.map +1 -1
  190. package/lib/publicApi/list/toggleBullet.d.ts +9 -9
  191. package/lib/publicApi/list/toggleBullet.js +22 -22
  192. package/lib/publicApi/list/toggleBullet.js.map +1 -1
  193. package/lib/publicApi/list/toggleNumbering.d.ts +9 -9
  194. package/lib/publicApi/list/toggleNumbering.js +22 -22
  195. package/lib/publicApi/list/toggleNumbering.js.map +1 -1
  196. package/lib/publicApi/segment/applySegmentFormat.d.ts +7 -7
  197. package/lib/publicApi/segment/applySegmentFormat.js +23 -23
  198. package/lib/publicApi/segment/applySegmentFormat.js.map +1 -1
  199. package/lib/publicApi/segment/changeCapitalization.d.ts +10 -10
  200. package/lib/publicApi/segment/changeCapitalization.js +49 -49
  201. package/lib/publicApi/segment/changeCapitalization.js.map +1 -1
  202. package/lib/publicApi/segment/changeFontSize.d.ts +8 -8
  203. package/lib/publicApi/segment/changeFontSize.js +63 -63
  204. package/lib/publicApi/segment/changeFontSize.js.map +1 -1
  205. package/lib/publicApi/segment/setBackgroundColor.d.ts +7 -7
  206. package/lib/publicApi/segment/setBackgroundColor.js +35 -35
  207. package/lib/publicApi/segment/setBackgroundColor.js.map +1 -1
  208. package/lib/publicApi/segment/setFontName.d.ts +7 -7
  209. package/lib/publicApi/segment/setFontName.js +19 -19
  210. package/lib/publicApi/segment/setFontName.js.map +1 -1
  211. package/lib/publicApi/segment/setFontSize.d.ts +12 -12
  212. package/lib/publicApi/segment/setFontSize.js +33 -33
  213. package/lib/publicApi/segment/setFontSize.js.map +1 -1
  214. package/lib/publicApi/segment/setTextColor.d.ts +7 -7
  215. package/lib/publicApi/segment/setTextColor.js +26 -26
  216. package/lib/publicApi/segment/setTextColor.js.map +1 -1
  217. package/lib/publicApi/segment/splitTextSegment.d.ts +10 -10
  218. package/lib/publicApi/segment/splitTextSegment.js +30 -30
  219. package/lib/publicApi/segment/splitTextSegment.js.map +1 -1
  220. package/lib/publicApi/segment/toggleBold.d.ts +6 -6
  221. package/lib/publicApi/segment/toggleBold.js +27 -27
  222. package/lib/publicApi/segment/toggleBold.js.map +1 -1
  223. package/lib/publicApi/segment/toggleCode.d.ts +6 -6
  224. package/lib/publicApi/segment/toggleCode.js +28 -28
  225. package/lib/publicApi/segment/toggleCode.js.map +1 -1
  226. package/lib/publicApi/segment/toggleItalic.d.ts +6 -6
  227. package/lib/publicApi/segment/toggleItalic.js +21 -21
  228. package/lib/publicApi/segment/toggleItalic.js.map +1 -1
  229. package/lib/publicApi/segment/toggleStrikethrough.d.ts +6 -6
  230. package/lib/publicApi/segment/toggleStrikethrough.js +15 -15
  231. package/lib/publicApi/segment/toggleStrikethrough.js.map +1 -1
  232. package/lib/publicApi/segment/toggleSubscript.d.ts +6 -6
  233. package/lib/publicApi/segment/toggleSubscript.js +15 -15
  234. package/lib/publicApi/segment/toggleSubscript.js.map +1 -1
  235. package/lib/publicApi/segment/toggleSuperscript.d.ts +6 -6
  236. package/lib/publicApi/segment/toggleSuperscript.js +15 -15
  237. package/lib/publicApi/segment/toggleSuperscript.js.map +1 -1
  238. package/lib/publicApi/segment/toggleUnderline.d.ts +6 -6
  239. package/lib/publicApi/segment/toggleUnderline.js +24 -24
  240. package/lib/publicApi/segment/toggleUnderline.js.map +1 -1
  241. package/lib/publicApi/table/applyTableBorderFormat.d.ts +8 -8
  242. package/lib/publicApi/table/applyTableBorderFormat.js +297 -297
  243. package/lib/publicApi/table/applyTableBorderFormat.js.map +1 -1
  244. package/lib/publicApi/table/editTable.d.ts +7 -7
  245. package/lib/publicApi/table/editTable.js +95 -95
  246. package/lib/publicApi/table/editTable.js.map +1 -1
  247. package/lib/publicApi/table/formatTable.d.ts +8 -8
  248. package/lib/publicApi/table/formatTable.js +38 -38
  249. package/lib/publicApi/table/formatTable.js.map +1 -1
  250. package/lib/publicApi/table/insertTable.d.ts +12 -12
  251. package/lib/publicApi/table/insertTable.js +76 -76
  252. package/lib/publicApi/table/insertTable.js.map +1 -1
  253. package/lib/publicApi/table/setTableCellShade.d.ts +7 -7
  254. package/lib/publicApi/table/setTableCellShade.js +32 -32
  255. package/lib/publicApi/table/setTableCellShade.js.map +1 -1
  256. package/lib/publicApi/utils/createEditorContextForEntity.d.ts +8 -8
  257. package/lib/publicApi/utils/createEditorContextForEntity.js +29 -29
  258. package/lib/publicApi/utils/createEditorContextForEntity.js.map +1 -1
  259. package/lib/publicApi/utils/formatImageWithContentModel.d.ts +8 -8
  260. package/lib/publicApi/utils/formatImageWithContentModel.js +18 -18
  261. package/lib/publicApi/utils/formatImageWithContentModel.js.map +1 -1
  262. package/lib/publicApi/utils/formatInsertPointWithContentModel.d.ts +9 -9
  263. package/lib/publicApi/utils/formatInsertPointWithContentModel.js +130 -130
  264. package/lib/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  265. package/lib/publicApi/utils/formatParagraphWithContentModel.d.ts +8 -8
  266. package/lib/publicApi/utils/formatParagraphWithContentModel.js +23 -23
  267. package/lib/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  268. package/lib/publicApi/utils/formatSegmentWithContentModel.d.ts +11 -11
  269. package/lib/publicApi/utils/formatSegmentWithContentModel.js +117 -117
  270. package/lib/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  271. package/lib/publicApi/utils/formatTableWithContentModel.d.ts +9 -9
  272. package/lib/publicApi/utils/formatTableWithContentModel.js +46 -46
  273. package/lib/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  274. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +8 -8
  275. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +34 -34
  276. package/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  277. package/lib-amd/index.d.ts +63 -63
  278. package/lib-amd/index.js +69 -69
  279. package/lib-amd/index.js.map +1 -1
  280. package/lib-amd/modelApi/block/setModelAlignment.d.ts +5 -5
  281. package/lib-amd/modelApi/block/setModelAlignment.js +64 -64
  282. package/lib-amd/modelApi/block/setModelAlignment.js.map +1 -1
  283. package/lib-amd/modelApi/block/setModelDirection.d.ts +5 -5
  284. package/lib-amd/modelApi/block/setModelDirection.js +112 -112
  285. package/lib-amd/modelApi/block/setModelDirection.js.map +1 -1
  286. package/lib-amd/modelApi/block/setModelIndentation.d.ts +8 -8
  287. package/lib-amd/modelApi/block/setModelIndentation.js +154 -154
  288. package/lib-amd/modelApi/block/setModelIndentation.js.map +1 -1
  289. package/lib-amd/modelApi/block/splitSelectedParagraphByBr.d.ts +7 -7
  290. package/lib-amd/modelApi/block/splitSelectedParagraphByBr.js +71 -71
  291. package/lib-amd/modelApi/block/splitSelectedParagraphByBr.js.map +1 -1
  292. package/lib-amd/modelApi/block/toggleModelBlockQuote.d.ts +5 -5
  293. package/lib-amd/modelApi/block/toggleModelBlockQuote.js +52 -52
  294. package/lib-amd/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  295. package/lib-amd/modelApi/common/adjustIndentation.d.ts +13 -13
  296. package/lib-amd/modelApi/common/adjustIndentation.js +114 -114
  297. package/lib-amd/modelApi/common/adjustIndentation.js.map +1 -1
  298. package/lib-amd/modelApi/common/clearModelFormat.d.ts +5 -5
  299. package/lib-amd/modelApi/common/clearModelFormat.js +142 -142
  300. package/lib-amd/modelApi/common/clearModelFormat.js.map +1 -1
  301. package/lib-amd/modelApi/common/queryContentModelBlocks.d.ts +10 -10
  302. package/lib-amd/modelApi/common/queryContentModelBlocks.js +87 -87
  303. package/lib-amd/modelApi/common/queryContentModelBlocks.js.map +1 -1
  304. package/lib-amd/modelApi/common/reducedModelChildProcessor.d.ts +20 -20
  305. package/lib-amd/modelApi/common/reducedModelChildProcessor.js +63 -63
  306. package/lib-amd/modelApi/common/reducedModelChildProcessor.js.map +1 -1
  307. package/lib-amd/modelApi/common/wrapBlock.d.ts +16 -16
  308. package/lib-amd/modelApi/common/wrapBlock.js +52 -52
  309. package/lib-amd/modelApi/common/wrapBlock.js.map +1 -1
  310. package/lib-amd/modelApi/entity/insertEntityModel.d.ts +5 -5
  311. package/lib-amd/modelApi/entity/insertEntityModel.js +105 -105
  312. package/lib-amd/modelApi/entity/insertEntityModel.js.map +1 -1
  313. package/lib-amd/modelApi/image/applyImageBorderFormat.d.ts +5 -5
  314. package/lib-amd/modelApi/image/applyImageBorderFormat.js +58 -58
  315. package/lib-amd/modelApi/image/applyImageBorderFormat.js.map +1 -1
  316. package/lib-amd/modelApi/link/getLinkUrl.d.ts +5 -5
  317. package/lib-amd/modelApi/link/getLinkUrl.js +29 -29
  318. package/lib-amd/modelApi/link/getLinkUrl.js.map +1 -1
  319. package/lib-amd/modelApi/link/matchLink.d.ts +12 -12
  320. package/lib-amd/modelApi/link/matchLink.js +93 -93
  321. package/lib-amd/modelApi/link/matchLink.js.map +1 -1
  322. package/lib-amd/modelApi/link/promoteLink.d.ts +20 -20
  323. package/lib-amd/modelApi/link/promoteLink.js +54 -54
  324. package/lib-amd/modelApi/link/promoteLink.js.map +1 -1
  325. package/lib-amd/modelApi/list/findListItemsInSameThread.d.ts +13 -13
  326. package/lib-amd/modelApi/list/findListItemsInSameThread.js +115 -115
  327. package/lib-amd/modelApi/list/findListItemsInSameThread.js.map +1 -1
  328. package/lib-amd/modelApi/list/getListAnnounceData.d.ts +7 -7
  329. package/lib-amd/modelApi/list/getListAnnounceData.js +68 -68
  330. package/lib-amd/modelApi/list/getListAnnounceData.js.map +1 -1
  331. package/lib-amd/modelApi/list/setListType.d.ts +8 -8
  332. package/lib-amd/modelApi/list/setListType.js +120 -116
  333. package/lib-amd/modelApi/list/setListType.js.map +1 -1
  334. package/lib-amd/modelApi/list/setModelListStartNumber.d.ts +7 -7
  335. package/lib-amd/modelApi/list/setModelListStartNumber.js +22 -22
  336. package/lib-amd/modelApi/list/setModelListStartNumber.js.map +1 -1
  337. package/lib-amd/modelApi/list/setModelListStyle.d.ts +7 -7
  338. package/lib-amd/modelApi/list/setModelListStyle.js +25 -25
  339. package/lib-amd/modelApi/list/setModelListStyle.js.map +1 -1
  340. package/lib-amd/modelApi/selection/adjustSegmentSelection.d.ts +5 -5
  341. package/lib-amd/modelApi/selection/adjustSegmentSelection.js +48 -48
  342. package/lib-amd/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  343. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -6
  344. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js +56 -56
  345. package/lib-amd/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  346. package/lib-amd/modelApi/selection/adjustWordSelection.d.ts +8 -8
  347. package/lib-amd/modelApi/selection/adjustWordSelection.js +123 -123
  348. package/lib-amd/modelApi/selection/adjustWordSelection.js.map +1 -1
  349. package/lib-amd/modelApi/selection/collapseTableSelection.d.ts +5 -5
  350. package/lib-amd/modelApi/selection/collapseTableSelection.js +17 -17
  351. package/lib-amd/modelApi/selection/collapseTableSelection.js.map +1 -1
  352. package/lib-amd/modelApi/table/alignTable.d.ts +5 -5
  353. package/lib-amd/modelApi/table/alignTable.js +13 -13
  354. package/lib-amd/modelApi/table/alignTable.js.map +1 -1
  355. package/lib-amd/modelApi/table/alignTableCell.d.ts +9 -9
  356. package/lib-amd/modelApi/table/alignTableCell.js +68 -58
  357. package/lib-amd/modelApi/table/alignTableCell.js.map +1 -1
  358. package/lib-amd/modelApi/table/canMergeCells.d.ts +5 -5
  359. package/lib-amd/modelApi/table/canMergeCells.js +58 -58
  360. package/lib-amd/modelApi/table/canMergeCells.js.map +1 -1
  361. package/lib-amd/modelApi/table/clearSelectedCells.d.ts +7 -7
  362. package/lib-amd/modelApi/table/clearSelectedCells.js +30 -30
  363. package/lib-amd/modelApi/table/clearSelectedCells.js.map +1 -1
  364. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  365. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.js +25 -0
  366. package/lib-amd/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  367. package/lib-amd/modelApi/table/createTableStructure.d.ts +5 -5
  368. package/lib-amd/modelApi/table/createTableStructure.js +20 -20
  369. package/lib-amd/modelApi/table/createTableStructure.js.map +1 -1
  370. package/lib-amd/modelApi/table/deleteTable.d.ts +5 -5
  371. package/lib-amd/modelApi/table/deleteTable.js +12 -12
  372. package/lib-amd/modelApi/table/deleteTable.js.map +1 -1
  373. package/lib-amd/modelApi/table/deleteTableColumn.d.ts +5 -5
  374. package/lib-amd/modelApi/table/deleteTableColumn.js +24 -24
  375. package/lib-amd/modelApi/table/deleteTableColumn.js.map +1 -1
  376. package/lib-amd/modelApi/table/deleteTableRow.d.ts +5 -5
  377. package/lib-amd/modelApi/table/deleteTableRow.js +23 -23
  378. package/lib-amd/modelApi/table/deleteTableRow.js.map +1 -1
  379. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.d.ts +8 -8
  380. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js +57 -57
  381. package/lib-amd/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  382. package/lib-amd/modelApi/table/insertTableColumn.d.ts +7 -7
  383. package/lib-amd/modelApi/table/insertTableColumn.js +28 -27
  384. package/lib-amd/modelApi/table/insertTableColumn.js.map +1 -1
  385. package/lib-amd/modelApi/table/insertTableRow.d.ts +7 -7
  386. package/lib-amd/modelApi/table/insertTableRow.js +31 -30
  387. package/lib-amd/modelApi/table/insertTableRow.js.map +1 -1
  388. package/lib-amd/modelApi/table/mergeTableCells.d.ts +5 -5
  389. package/lib-amd/modelApi/table/mergeTableCells.js +25 -25
  390. package/lib-amd/modelApi/table/mergeTableCells.js.map +1 -1
  391. package/lib-amd/modelApi/table/mergeTableColumn.d.ts +5 -5
  392. package/lib-amd/modelApi/table/mergeTableColumn.js +35 -35
  393. package/lib-amd/modelApi/table/mergeTableColumn.js.map +1 -1
  394. package/lib-amd/modelApi/table/mergeTableRow.d.ts +5 -5
  395. package/lib-amd/modelApi/table/mergeTableRow.js +35 -35
  396. package/lib-amd/modelApi/table/mergeTableRow.js.map +1 -1
  397. package/lib-amd/modelApi/table/splitTableCellHorizontally.d.ts +5 -5
  398. package/lib-amd/modelApi/table/splitTableCellHorizontally.js +54 -54
  399. package/lib-amd/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  400. package/lib-amd/modelApi/table/splitTableCellVertically.d.ts +5 -5
  401. package/lib-amd/modelApi/table/splitTableCellVertically.js +53 -53
  402. package/lib-amd/modelApi/table/splitTableCellVertically.js.map +1 -1
  403. package/lib-amd/publicApi/block/setAlignment.d.ts +7 -7
  404. package/lib-amd/publicApi/block/setAlignment.js +17 -17
  405. package/lib-amd/publicApi/block/setAlignment.js.map +1 -1
  406. package/lib-amd/publicApi/block/setDirection.d.ts +7 -7
  407. package/lib-amd/publicApi/block/setDirection.js +17 -17
  408. package/lib-amd/publicApi/block/setDirection.js.map +1 -1
  409. package/lib-amd/publicApi/block/setHeadingLevel.d.ts +7 -7
  410. package/lib-amd/publicApi/block/setHeadingLevel.js +51 -51
  411. package/lib-amd/publicApi/block/setHeadingLevel.js.map +1 -1
  412. package/lib-amd/publicApi/block/setIndentation.d.ts +8 -8
  413. package/lib-amd/publicApi/block/setIndentation.js +22 -22
  414. package/lib-amd/publicApi/block/setIndentation.js.map +1 -1
  415. package/lib-amd/publicApi/block/setParagraphMargin.d.ts +9 -9
  416. package/lib-amd/publicApi/block/setParagraphMargin.js +33 -33
  417. package/lib-amd/publicApi/block/setParagraphMargin.js.map +1 -1
  418. package/lib-amd/publicApi/block/setSpacing.d.ts +7 -7
  419. package/lib-amd/publicApi/block/setSpacing.js +22 -22
  420. package/lib-amd/publicApi/block/setSpacing.js.map +1 -1
  421. package/lib-amd/publicApi/block/toggleBlockQuote.d.ts +9 -9
  422. package/lib-amd/publicApi/block/toggleBlockQuote.js +39 -39
  423. package/lib-amd/publicApi/block/toggleBlockQuote.js.map +1 -1
  424. package/lib-amd/publicApi/entity/insertEntity.d.ts +25 -25
  425. package/lib-amd/publicApi/entity/insertEntity.js +66 -66
  426. package/lib-amd/publicApi/entity/insertEntity.js.map +1 -1
  427. package/lib-amd/publicApi/format/clearFormat.d.ts +6 -6
  428. package/lib-amd/publicApi/format/clearFormat.js +34 -34
  429. package/lib-amd/publicApi/format/clearFormat.js.map +1 -1
  430. package/lib-amd/publicApi/format/getFormatState.d.ts +7 -7
  431. package/lib-amd/publicApi/format/getFormatState.js +31 -31
  432. package/lib-amd/publicApi/format/getFormatState.js.map +1 -1
  433. package/lib-amd/publicApi/image/adjustImageSelection.d.ts +6 -6
  434. package/lib-amd/publicApi/image/adjustImageSelection.js +29 -29
  435. package/lib-amd/publicApi/image/adjustImageSelection.js.map +1 -1
  436. package/lib-amd/publicApi/image/changeImage.d.ts +7 -7
  437. package/lib-amd/publicApi/image/changeImage.js +35 -35
  438. package/lib-amd/publicApi/image/changeImage.js.map +1 -1
  439. package/lib-amd/publicApi/image/insertImage.d.ts +7 -7
  440. package/lib-amd/publicApi/image/insertImage.js +39 -39
  441. package/lib-amd/publicApi/image/insertImage.js.map +1 -1
  442. package/lib-amd/publicApi/image/setImageAltText.d.ts +8 -8
  443. package/lib-amd/publicApi/image/setImageAltText.js +18 -18
  444. package/lib-amd/publicApi/image/setImageAltText.js.map +1 -1
  445. package/lib-amd/publicApi/image/setImageBorder.d.ts +9 -9
  446. package/lib-amd/publicApi/image/setImageBorder.js +19 -19
  447. package/lib-amd/publicApi/image/setImageBorder.js.map +1 -1
  448. package/lib-amd/publicApi/image/setImageBoxShadow.d.ts +8 -8
  449. package/lib-amd/publicApi/image/setImageBoxShadow.js +30 -30
  450. package/lib-amd/publicApi/image/setImageBoxShadow.js.map +1 -1
  451. package/lib-amd/publicApi/link/adjustLinkSelection.d.ts +6 -6
  452. package/lib-amd/publicApi/link/adjustLinkSelection.js +33 -33
  453. package/lib-amd/publicApi/link/adjustLinkSelection.js.map +1 -1
  454. package/lib-amd/publicApi/link/insertLink.d.ts +15 -15
  455. package/lib-amd/publicApi/link/insertLink.js +118 -118
  456. package/lib-amd/publicApi/link/insertLink.js.map +1 -1
  457. package/lib-amd/publicApi/link/removeLink.d.ts +8 -8
  458. package/lib-amd/publicApi/link/removeLink.js +32 -32
  459. package/lib-amd/publicApi/link/removeLink.js.map +1 -1
  460. package/lib-amd/publicApi/list/setListStartNumber.d.ts +7 -7
  461. package/lib-amd/publicApi/list/setListStartNumber.js +19 -19
  462. package/lib-amd/publicApi/list/setListStartNumber.js.map +1 -1
  463. package/lib-amd/publicApi/list/setListStyle.d.ts +7 -7
  464. package/lib-amd/publicApi/list/setListStyle.js +19 -19
  465. package/lib-amd/publicApi/list/setListStyle.js.map +1 -1
  466. package/lib-amd/publicApi/list/toggleBullet.d.ts +9 -9
  467. package/lib-amd/publicApi/list/toggleBullet.js +23 -23
  468. package/lib-amd/publicApi/list/toggleBullet.js.map +1 -1
  469. package/lib-amd/publicApi/list/toggleNumbering.d.ts +9 -9
  470. package/lib-amd/publicApi/list/toggleNumbering.js +23 -23
  471. package/lib-amd/publicApi/list/toggleNumbering.js.map +1 -1
  472. package/lib-amd/publicApi/segment/applySegmentFormat.d.ts +7 -7
  473. package/lib-amd/publicApi/segment/applySegmentFormat.js +24 -24
  474. package/lib-amd/publicApi/segment/applySegmentFormat.js.map +1 -1
  475. package/lib-amd/publicApi/segment/changeCapitalization.d.ts +10 -10
  476. package/lib-amd/publicApi/segment/changeCapitalization.js +50 -50
  477. package/lib-amd/publicApi/segment/changeCapitalization.js.map +1 -1
  478. package/lib-amd/publicApi/segment/changeFontSize.d.ts +8 -8
  479. package/lib-amd/publicApi/segment/changeFontSize.js +62 -62
  480. package/lib-amd/publicApi/segment/changeFontSize.js.map +1 -1
  481. package/lib-amd/publicApi/segment/setBackgroundColor.d.ts +7 -7
  482. package/lib-amd/publicApi/segment/setBackgroundColor.js +35 -35
  483. package/lib-amd/publicApi/segment/setBackgroundColor.js.map +1 -1
  484. package/lib-amd/publicApi/segment/setFontName.d.ts +7 -7
  485. package/lib-amd/publicApi/segment/setFontName.js +20 -20
  486. package/lib-amd/publicApi/segment/setFontName.js.map +1 -1
  487. package/lib-amd/publicApi/segment/setFontSize.d.ts +12 -12
  488. package/lib-amd/publicApi/segment/setFontSize.js +34 -34
  489. package/lib-amd/publicApi/segment/setFontSize.js.map +1 -1
  490. package/lib-amd/publicApi/segment/setTextColor.d.ts +7 -7
  491. package/lib-amd/publicApi/segment/setTextColor.js +27 -27
  492. package/lib-amd/publicApi/segment/setTextColor.js.map +1 -1
  493. package/lib-amd/publicApi/segment/splitTextSegment.d.ts +10 -10
  494. package/lib-amd/publicApi/segment/splitTextSegment.js +30 -30
  495. package/lib-amd/publicApi/segment/splitTextSegment.js.map +1 -1
  496. package/lib-amd/publicApi/segment/toggleBold.d.ts +6 -6
  497. package/lib-amd/publicApi/segment/toggleBold.js +27 -27
  498. package/lib-amd/publicApi/segment/toggleBold.js.map +1 -1
  499. package/lib-amd/publicApi/segment/toggleCode.d.ts +6 -6
  500. package/lib-amd/publicApi/segment/toggleCode.js +28 -28
  501. package/lib-amd/publicApi/segment/toggleCode.js.map +1 -1
  502. package/lib-amd/publicApi/segment/toggleItalic.d.ts +6 -6
  503. package/lib-amd/publicApi/segment/toggleItalic.js +22 -22
  504. package/lib-amd/publicApi/segment/toggleItalic.js.map +1 -1
  505. package/lib-amd/publicApi/segment/toggleStrikethrough.d.ts +6 -6
  506. package/lib-amd/publicApi/segment/toggleStrikethrough.js +16 -16
  507. package/lib-amd/publicApi/segment/toggleStrikethrough.js.map +1 -1
  508. package/lib-amd/publicApi/segment/toggleSubscript.d.ts +6 -6
  509. package/lib-amd/publicApi/segment/toggleSubscript.js +16 -16
  510. package/lib-amd/publicApi/segment/toggleSubscript.js.map +1 -1
  511. package/lib-amd/publicApi/segment/toggleSuperscript.d.ts +6 -6
  512. package/lib-amd/publicApi/segment/toggleSuperscript.js +16 -16
  513. package/lib-amd/publicApi/segment/toggleSuperscript.js.map +1 -1
  514. package/lib-amd/publicApi/segment/toggleUnderline.d.ts +6 -6
  515. package/lib-amd/publicApi/segment/toggleUnderline.js +25 -25
  516. package/lib-amd/publicApi/segment/toggleUnderline.js.map +1 -1
  517. package/lib-amd/publicApi/table/applyTableBorderFormat.d.ts +8 -8
  518. package/lib-amd/publicApi/table/applyTableBorderFormat.js +297 -297
  519. package/lib-amd/publicApi/table/applyTableBorderFormat.js.map +1 -1
  520. package/lib-amd/publicApi/table/editTable.d.ts +7 -7
  521. package/lib-amd/publicApi/table/editTable.js +84 -84
  522. package/lib-amd/publicApi/table/editTable.js.map +1 -1
  523. package/lib-amd/publicApi/table/formatTable.d.ts +8 -8
  524. package/lib-amd/publicApi/table/formatTable.js +38 -38
  525. package/lib-amd/publicApi/table/formatTable.js.map +1 -1
  526. package/lib-amd/publicApi/table/insertTable.d.ts +12 -12
  527. package/lib-amd/publicApi/table/insertTable.js +74 -74
  528. package/lib-amd/publicApi/table/insertTable.js.map +1 -1
  529. package/lib-amd/publicApi/table/setTableCellShade.d.ts +7 -7
  530. package/lib-amd/publicApi/table/setTableCellShade.js +32 -32
  531. package/lib-amd/publicApi/table/setTableCellShade.js.map +1 -1
  532. package/lib-amd/publicApi/utils/createEditorContextForEntity.d.ts +8 -8
  533. package/lib-amd/publicApi/utils/createEditorContextForEntity.js +30 -30
  534. package/lib-amd/publicApi/utils/createEditorContextForEntity.js.map +1 -1
  535. package/lib-amd/publicApi/utils/formatImageWithContentModel.d.ts +8 -8
  536. package/lib-amd/publicApi/utils/formatImageWithContentModel.js +19 -19
  537. package/lib-amd/publicApi/utils/formatImageWithContentModel.js.map +1 -1
  538. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.d.ts +9 -9
  539. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js +130 -130
  540. package/lib-amd/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  541. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.d.ts +8 -8
  542. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js +23 -23
  543. package/lib-amd/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  544. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.d.ts +11 -11
  545. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js +115 -115
  546. package/lib-amd/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  547. package/lib-amd/publicApi/utils/formatTableWithContentModel.d.ts +9 -9
  548. package/lib-amd/publicApi/utils/formatTableWithContentModel.js +45 -45
  549. package/lib-amd/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  550. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +8 -8
  551. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +35 -35
  552. package/lib-amd/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  553. package/lib-mjs/index.d.ts +63 -63
  554. package/lib-mjs/index.js +63 -63
  555. package/lib-mjs/index.js.map +1 -1
  556. package/lib-mjs/modelApi/block/setModelAlignment.d.ts +5 -5
  557. package/lib-mjs/modelApi/block/setModelAlignment.js +61 -61
  558. package/lib-mjs/modelApi/block/setModelAlignment.js.map +1 -1
  559. package/lib-mjs/modelApi/block/setModelDirection.d.ts +5 -5
  560. package/lib-mjs/modelApi/block/setModelDirection.js +109 -109
  561. package/lib-mjs/modelApi/block/setModelDirection.js.map +1 -1
  562. package/lib-mjs/modelApi/block/setModelIndentation.d.ts +8 -8
  563. package/lib-mjs/modelApi/block/setModelIndentation.js +154 -154
  564. package/lib-mjs/modelApi/block/setModelIndentation.js.map +1 -1
  565. package/lib-mjs/modelApi/block/splitSelectedParagraphByBr.d.ts +7 -7
  566. package/lib-mjs/modelApi/block/splitSelectedParagraphByBr.js +67 -67
  567. package/lib-mjs/modelApi/block/splitSelectedParagraphByBr.js.map +1 -1
  568. package/lib-mjs/modelApi/block/toggleModelBlockQuote.d.ts +5 -5
  569. package/lib-mjs/modelApi/block/toggleModelBlockQuote.js +49 -49
  570. package/lib-mjs/modelApi/block/toggleModelBlockQuote.js.map +1 -1
  571. package/lib-mjs/modelApi/common/adjustIndentation.d.ts +13 -13
  572. package/lib-mjs/modelApi/common/adjustIndentation.js +109 -109
  573. package/lib-mjs/modelApi/common/adjustIndentation.js.map +1 -1
  574. package/lib-mjs/modelApi/common/clearModelFormat.d.ts +5 -5
  575. package/lib-mjs/modelApi/common/clearModelFormat.js +139 -139
  576. package/lib-mjs/modelApi/common/clearModelFormat.js.map +1 -1
  577. package/lib-mjs/modelApi/common/queryContentModelBlocks.d.ts +10 -10
  578. package/lib-mjs/modelApi/common/queryContentModelBlocks.js +83 -83
  579. package/lib-mjs/modelApi/common/queryContentModelBlocks.js.map +1 -1
  580. package/lib-mjs/modelApi/common/reducedModelChildProcessor.d.ts +20 -20
  581. package/lib-mjs/modelApi/common/reducedModelChildProcessor.js +59 -59
  582. package/lib-mjs/modelApi/common/reducedModelChildProcessor.js.map +1 -1
  583. package/lib-mjs/modelApi/common/wrapBlock.d.ts +16 -16
  584. package/lib-mjs/modelApi/common/wrapBlock.js +47 -47
  585. package/lib-mjs/modelApi/common/wrapBlock.js.map +1 -1
  586. package/lib-mjs/modelApi/entity/insertEntityModel.d.ts +5 -5
  587. package/lib-mjs/modelApi/entity/insertEntityModel.js +101 -101
  588. package/lib-mjs/modelApi/entity/insertEntityModel.js.map +1 -1
  589. package/lib-mjs/modelApi/image/applyImageBorderFormat.d.ts +5 -5
  590. package/lib-mjs/modelApi/image/applyImageBorderFormat.js +53 -53
  591. package/lib-mjs/modelApi/image/applyImageBorderFormat.js.map +1 -1
  592. package/lib-mjs/modelApi/link/getLinkUrl.d.ts +5 -5
  593. package/lib-mjs/modelApi/link/getLinkUrl.js +24 -24
  594. package/lib-mjs/modelApi/link/getLinkUrl.js.map +1 -1
  595. package/lib-mjs/modelApi/link/matchLink.d.ts +12 -12
  596. package/lib-mjs/modelApi/link/matchLink.js +89 -89
  597. package/lib-mjs/modelApi/link/matchLink.js.map +1 -1
  598. package/lib-mjs/modelApi/link/promoteLink.d.ts +20 -20
  599. package/lib-mjs/modelApi/link/promoteLink.js +49 -49
  600. package/lib-mjs/modelApi/link/promoteLink.js.map +1 -1
  601. package/lib-mjs/modelApi/list/findListItemsInSameThread.d.ts +13 -13
  602. package/lib-mjs/modelApi/list/findListItemsInSameThread.js +109 -109
  603. package/lib-mjs/modelApi/list/findListItemsInSameThread.js.map +1 -1
  604. package/lib-mjs/modelApi/list/getListAnnounceData.d.ts +7 -7
  605. package/lib-mjs/modelApi/list/getListAnnounceData.js +64 -64
  606. package/lib-mjs/modelApi/list/getListAnnounceData.js.map +1 -1
  607. package/lib-mjs/modelApi/list/setListType.d.ts +8 -8
  608. package/lib-mjs/modelApi/list/setListType.js +117 -113
  609. package/lib-mjs/modelApi/list/setListType.js.map +1 -1
  610. package/lib-mjs/modelApi/list/setModelListStartNumber.d.ts +7 -7
  611. package/lib-mjs/modelApi/list/setModelListStartNumber.js +17 -17
  612. package/lib-mjs/modelApi/list/setModelListStartNumber.js.map +1 -1
  613. package/lib-mjs/modelApi/list/setModelListStyle.d.ts +7 -7
  614. package/lib-mjs/modelApi/list/setModelListStyle.js +21 -21
  615. package/lib-mjs/modelApi/list/setModelListStyle.js.map +1 -1
  616. package/lib-mjs/modelApi/selection/adjustSegmentSelection.d.ts +5 -5
  617. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js +43 -43
  618. package/lib-mjs/modelApi/selection/adjustSegmentSelection.js.map +1 -1
  619. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.d.ts +6 -6
  620. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js +52 -52
  621. package/lib-mjs/modelApi/selection/adjustTrailingSpaceSelection.js.map +1 -1
  622. package/lib-mjs/modelApi/selection/adjustWordSelection.d.ts +8 -8
  623. package/lib-mjs/modelApi/selection/adjustWordSelection.js +119 -119
  624. package/lib-mjs/modelApi/selection/adjustWordSelection.js.map +1 -1
  625. package/lib-mjs/modelApi/selection/collapseTableSelection.d.ts +5 -5
  626. package/lib-mjs/modelApi/selection/collapseTableSelection.js +12 -12
  627. package/lib-mjs/modelApi/selection/collapseTableSelection.js.map +1 -1
  628. package/lib-mjs/modelApi/table/alignTable.d.ts +5 -5
  629. package/lib-mjs/modelApi/table/alignTable.js +7 -7
  630. package/lib-mjs/modelApi/table/alignTable.js.map +1 -1
  631. package/lib-mjs/modelApi/table/alignTableCell.d.ts +9 -9
  632. package/lib-mjs/modelApi/table/alignTableCell.js +62 -52
  633. package/lib-mjs/modelApi/table/alignTableCell.js.map +1 -1
  634. package/lib-mjs/modelApi/table/canMergeCells.d.ts +5 -5
  635. package/lib-mjs/modelApi/table/canMergeCells.js +52 -52
  636. package/lib-mjs/modelApi/table/canMergeCells.js.map +1 -1
  637. package/lib-mjs/modelApi/table/clearSelectedCells.d.ts +7 -7
  638. package/lib-mjs/modelApi/table/clearSelectedCells.js +25 -25
  639. package/lib-mjs/modelApi/table/clearSelectedCells.js.map +1 -1
  640. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.d.ts +5 -0
  641. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.js +20 -0
  642. package/lib-mjs/modelApi/table/copyPreviousCellSegmentFormat.js.map +1 -0
  643. package/lib-mjs/modelApi/table/createTableStructure.d.ts +5 -5
  644. package/lib-mjs/modelApi/table/createTableStructure.js +15 -15
  645. package/lib-mjs/modelApi/table/createTableStructure.js.map +1 -1
  646. package/lib-mjs/modelApi/table/deleteTable.d.ts +5 -5
  647. package/lib-mjs/modelApi/table/deleteTable.js +6 -6
  648. package/lib-mjs/modelApi/table/deleteTable.js.map +1 -1
  649. package/lib-mjs/modelApi/table/deleteTableColumn.d.ts +5 -5
  650. package/lib-mjs/modelApi/table/deleteTableColumn.js +20 -20
  651. package/lib-mjs/modelApi/table/deleteTableColumn.js.map +1 -1
  652. package/lib-mjs/modelApi/table/deleteTableRow.d.ts +5 -5
  653. package/lib-mjs/modelApi/table/deleteTableRow.js +19 -19
  654. package/lib-mjs/modelApi/table/deleteTableRow.js.map +1 -1
  655. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.d.ts +8 -8
  656. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js +52 -52
  657. package/lib-mjs/modelApi/table/ensureFocusableParagraphForTable.js.map +1 -1
  658. package/lib-mjs/modelApi/table/insertTableColumn.d.ts +7 -7
  659. package/lib-mjs/modelApi/table/insertTableColumn.js +25 -23
  660. package/lib-mjs/modelApi/table/insertTableColumn.js.map +1 -1
  661. package/lib-mjs/modelApi/table/insertTableRow.d.ts +7 -7
  662. package/lib-mjs/modelApi/table/insertTableRow.js +29 -27
  663. package/lib-mjs/modelApi/table/insertTableRow.js.map +1 -1
  664. package/lib-mjs/modelApi/table/mergeTableCells.d.ts +5 -5
  665. package/lib-mjs/modelApi/table/mergeTableCells.js +21 -21
  666. package/lib-mjs/modelApi/table/mergeTableCells.js.map +1 -1
  667. package/lib-mjs/modelApi/table/mergeTableColumn.d.ts +5 -5
  668. package/lib-mjs/modelApi/table/mergeTableColumn.js +31 -31
  669. package/lib-mjs/modelApi/table/mergeTableColumn.js.map +1 -1
  670. package/lib-mjs/modelApi/table/mergeTableRow.d.ts +5 -5
  671. package/lib-mjs/modelApi/table/mergeTableRow.js +31 -31
  672. package/lib-mjs/modelApi/table/mergeTableRow.js.map +1 -1
  673. package/lib-mjs/modelApi/table/splitTableCellHorizontally.d.ts +5 -5
  674. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js +50 -50
  675. package/lib-mjs/modelApi/table/splitTableCellHorizontally.js.map +1 -1
  676. package/lib-mjs/modelApi/table/splitTableCellVertically.d.ts +5 -5
  677. package/lib-mjs/modelApi/table/splitTableCellVertically.js +49 -49
  678. package/lib-mjs/modelApi/table/splitTableCellVertically.js.map +1 -1
  679. package/lib-mjs/publicApi/block/setAlignment.d.ts +7 -7
  680. package/lib-mjs/publicApi/block/setAlignment.js +12 -12
  681. package/lib-mjs/publicApi/block/setAlignment.js.map +1 -1
  682. package/lib-mjs/publicApi/block/setDirection.d.ts +7 -7
  683. package/lib-mjs/publicApi/block/setDirection.js +12 -12
  684. package/lib-mjs/publicApi/block/setDirection.js.map +1 -1
  685. package/lib-mjs/publicApi/block/setHeadingLevel.d.ts +7 -7
  686. package/lib-mjs/publicApi/block/setHeadingLevel.js +46 -46
  687. package/lib-mjs/publicApi/block/setHeadingLevel.js.map +1 -1
  688. package/lib-mjs/publicApi/block/setIndentation.d.ts +8 -8
  689. package/lib-mjs/publicApi/block/setIndentation.js +17 -17
  690. package/lib-mjs/publicApi/block/setIndentation.js.map +1 -1
  691. package/lib-mjs/publicApi/block/setParagraphMargin.d.ts +9 -9
  692. package/lib-mjs/publicApi/block/setParagraphMargin.js +29 -29
  693. package/lib-mjs/publicApi/block/setParagraphMargin.js.map +1 -1
  694. package/lib-mjs/publicApi/block/setSpacing.d.ts +7 -7
  695. package/lib-mjs/publicApi/block/setSpacing.js +17 -17
  696. package/lib-mjs/publicApi/block/setSpacing.js.map +1 -1
  697. package/lib-mjs/publicApi/block/toggleBlockQuote.d.ts +9 -9
  698. package/lib-mjs/publicApi/block/toggleBlockQuote.js +35 -35
  699. package/lib-mjs/publicApi/block/toggleBlockQuote.js.map +1 -1
  700. package/lib-mjs/publicApi/entity/insertEntity.d.ts +25 -25
  701. package/lib-mjs/publicApi/entity/insertEntity.js +63 -63
  702. package/lib-mjs/publicApi/entity/insertEntity.js.map +1 -1
  703. package/lib-mjs/publicApi/format/clearFormat.d.ts +6 -6
  704. package/lib-mjs/publicApi/format/clearFormat.js +30 -30
  705. package/lib-mjs/publicApi/format/clearFormat.js.map +1 -1
  706. package/lib-mjs/publicApi/format/getFormatState.d.ts +7 -7
  707. package/lib-mjs/publicApi/format/getFormatState.js +27 -27
  708. package/lib-mjs/publicApi/format/getFormatState.js.map +1 -1
  709. package/lib-mjs/publicApi/image/adjustImageSelection.d.ts +6 -6
  710. package/lib-mjs/publicApi/image/adjustImageSelection.js +25 -25
  711. package/lib-mjs/publicApi/image/adjustImageSelection.js.map +1 -1
  712. package/lib-mjs/publicApi/image/changeImage.d.ts +7 -7
  713. package/lib-mjs/publicApi/image/changeImage.js +31 -31
  714. package/lib-mjs/publicApi/image/changeImage.js.map +1 -1
  715. package/lib-mjs/publicApi/image/insertImage.d.ts +7 -7
  716. package/lib-mjs/publicApi/image/insertImage.js +34 -34
  717. package/lib-mjs/publicApi/image/insertImage.js.map +1 -1
  718. package/lib-mjs/publicApi/image/setImageAltText.d.ts +8 -8
  719. package/lib-mjs/publicApi/image/setImageAltText.js +13 -13
  720. package/lib-mjs/publicApi/image/setImageAltText.js.map +1 -1
  721. package/lib-mjs/publicApi/image/setImageBorder.d.ts +9 -9
  722. package/lib-mjs/publicApi/image/setImageBorder.js +15 -15
  723. package/lib-mjs/publicApi/image/setImageBorder.js.map +1 -1
  724. package/lib-mjs/publicApi/image/setImageBoxShadow.d.ts +8 -8
  725. package/lib-mjs/publicApi/image/setImageBoxShadow.js +25 -25
  726. package/lib-mjs/publicApi/image/setImageBoxShadow.js.map +1 -1
  727. package/lib-mjs/publicApi/link/adjustLinkSelection.d.ts +6 -6
  728. package/lib-mjs/publicApi/link/adjustLinkSelection.js +30 -30
  729. package/lib-mjs/publicApi/link/adjustLinkSelection.js.map +1 -1
  730. package/lib-mjs/publicApi/link/insertLink.d.ts +15 -15
  731. package/lib-mjs/publicApi/link/insertLink.js +116 -116
  732. package/lib-mjs/publicApi/link/insertLink.js.map +1 -1
  733. package/lib-mjs/publicApi/link/removeLink.d.ts +8 -8
  734. package/lib-mjs/publicApi/link/removeLink.js +28 -28
  735. package/lib-mjs/publicApi/link/removeLink.js.map +1 -1
  736. package/lib-mjs/publicApi/list/setListStartNumber.d.ts +7 -7
  737. package/lib-mjs/publicApi/list/setListStartNumber.js +14 -14
  738. package/lib-mjs/publicApi/list/setListStartNumber.js.map +1 -1
  739. package/lib-mjs/publicApi/list/setListStyle.d.ts +7 -7
  740. package/lib-mjs/publicApi/list/setListStyle.js +14 -14
  741. package/lib-mjs/publicApi/list/setListStyle.js.map +1 -1
  742. package/lib-mjs/publicApi/list/toggleBullet.d.ts +9 -9
  743. package/lib-mjs/publicApi/list/toggleBullet.js +18 -18
  744. package/lib-mjs/publicApi/list/toggleBullet.js.map +1 -1
  745. package/lib-mjs/publicApi/list/toggleNumbering.d.ts +9 -9
  746. package/lib-mjs/publicApi/list/toggleNumbering.js +18 -18
  747. package/lib-mjs/publicApi/list/toggleNumbering.js.map +1 -1
  748. package/lib-mjs/publicApi/segment/applySegmentFormat.d.ts +7 -7
  749. package/lib-mjs/publicApi/segment/applySegmentFormat.js +19 -19
  750. package/lib-mjs/publicApi/segment/applySegmentFormat.js.map +1 -1
  751. package/lib-mjs/publicApi/segment/changeCapitalization.d.ts +10 -10
  752. package/lib-mjs/publicApi/segment/changeCapitalization.js +45 -45
  753. package/lib-mjs/publicApi/segment/changeCapitalization.js.map +1 -1
  754. package/lib-mjs/publicApi/segment/changeFontSize.d.ts +8 -8
  755. package/lib-mjs/publicApi/segment/changeFontSize.js +59 -59
  756. package/lib-mjs/publicApi/segment/changeFontSize.js.map +1 -1
  757. package/lib-mjs/publicApi/segment/setBackgroundColor.d.ts +7 -7
  758. package/lib-mjs/publicApi/segment/setBackgroundColor.js +31 -31
  759. package/lib-mjs/publicApi/segment/setBackgroundColor.js.map +1 -1
  760. package/lib-mjs/publicApi/segment/setFontName.d.ts +7 -7
  761. package/lib-mjs/publicApi/segment/setFontName.js +15 -15
  762. package/lib-mjs/publicApi/segment/setFontName.js.map +1 -1
  763. package/lib-mjs/publicApi/segment/setFontSize.d.ts +12 -12
  764. package/lib-mjs/publicApi/segment/setFontSize.js +28 -28
  765. package/lib-mjs/publicApi/segment/setFontSize.js.map +1 -1
  766. package/lib-mjs/publicApi/segment/setTextColor.d.ts +7 -7
  767. package/lib-mjs/publicApi/segment/setTextColor.js +22 -22
  768. package/lib-mjs/publicApi/segment/setTextColor.js.map +1 -1
  769. package/lib-mjs/publicApi/segment/splitTextSegment.d.ts +10 -10
  770. package/lib-mjs/publicApi/segment/splitTextSegment.js +26 -26
  771. package/lib-mjs/publicApi/segment/splitTextSegment.js.map +1 -1
  772. package/lib-mjs/publicApi/segment/toggleBold.d.ts +6 -6
  773. package/lib-mjs/publicApi/segment/toggleBold.js +23 -23
  774. package/lib-mjs/publicApi/segment/toggleBold.js.map +1 -1
  775. package/lib-mjs/publicApi/segment/toggleCode.d.ts +6 -6
  776. package/lib-mjs/publicApi/segment/toggleCode.js +24 -24
  777. package/lib-mjs/publicApi/segment/toggleCode.js.map +1 -1
  778. package/lib-mjs/publicApi/segment/toggleItalic.d.ts +6 -6
  779. package/lib-mjs/publicApi/segment/toggleItalic.js +17 -17
  780. package/lib-mjs/publicApi/segment/toggleItalic.js.map +1 -1
  781. package/lib-mjs/publicApi/segment/toggleStrikethrough.d.ts +6 -6
  782. package/lib-mjs/publicApi/segment/toggleStrikethrough.js +11 -11
  783. package/lib-mjs/publicApi/segment/toggleStrikethrough.js.map +1 -1
  784. package/lib-mjs/publicApi/segment/toggleSubscript.d.ts +6 -6
  785. package/lib-mjs/publicApi/segment/toggleSubscript.js +11 -11
  786. package/lib-mjs/publicApi/segment/toggleSubscript.js.map +1 -1
  787. package/lib-mjs/publicApi/segment/toggleSuperscript.d.ts +6 -6
  788. package/lib-mjs/publicApi/segment/toggleSuperscript.js +11 -11
  789. package/lib-mjs/publicApi/segment/toggleSuperscript.js.map +1 -1
  790. package/lib-mjs/publicApi/segment/toggleUnderline.d.ts +6 -6
  791. package/lib-mjs/publicApi/segment/toggleUnderline.js +20 -20
  792. package/lib-mjs/publicApi/segment/toggleUnderline.js.map +1 -1
  793. package/lib-mjs/publicApi/table/applyTableBorderFormat.d.ts +8 -8
  794. package/lib-mjs/publicApi/table/applyTableBorderFormat.js +293 -293
  795. package/lib-mjs/publicApi/table/applyTableBorderFormat.js.map +1 -1
  796. package/lib-mjs/publicApi/table/editTable.d.ts +7 -7
  797. package/lib-mjs/publicApi/table/editTable.js +91 -91
  798. package/lib-mjs/publicApi/table/editTable.js.map +1 -1
  799. package/lib-mjs/publicApi/table/formatTable.d.ts +8 -8
  800. package/lib-mjs/publicApi/table/formatTable.js +34 -34
  801. package/lib-mjs/publicApi/table/formatTable.js.map +1 -1
  802. package/lib-mjs/publicApi/table/insertTable.d.ts +12 -12
  803. package/lib-mjs/publicApi/table/insertTable.js +72 -72
  804. package/lib-mjs/publicApi/table/insertTable.js.map +1 -1
  805. package/lib-mjs/publicApi/table/setTableCellShade.d.ts +7 -7
  806. package/lib-mjs/publicApi/table/setTableCellShade.js +28 -28
  807. package/lib-mjs/publicApi/table/setTableCellShade.js.map +1 -1
  808. package/lib-mjs/publicApi/utils/createEditorContextForEntity.d.ts +8 -8
  809. package/lib-mjs/publicApi/utils/createEditorContextForEntity.js +25 -25
  810. package/lib-mjs/publicApi/utils/createEditorContextForEntity.js.map +1 -1
  811. package/lib-mjs/publicApi/utils/formatImageWithContentModel.d.ts +8 -8
  812. package/lib-mjs/publicApi/utils/formatImageWithContentModel.js +14 -14
  813. package/lib-mjs/publicApi/utils/formatImageWithContentModel.js.map +1 -1
  814. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.d.ts +9 -9
  815. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js +126 -126
  816. package/lib-mjs/publicApi/utils/formatInsertPointWithContentModel.js.map +1 -1
  817. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.d.ts +8 -8
  818. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js +19 -19
  819. package/lib-mjs/publicApi/utils/formatParagraphWithContentModel.js.map +1 -1
  820. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.d.ts +11 -11
  821. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js +113 -113
  822. package/lib-mjs/publicApi/utils/formatSegmentWithContentModel.js.map +1 -1
  823. package/lib-mjs/publicApi/utils/formatTableWithContentModel.d.ts +9 -9
  824. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js +42 -42
  825. package/lib-mjs/publicApi/utils/formatTableWithContentModel.js.map +1 -1
  826. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.d.ts +8 -8
  827. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js +30 -30
  828. package/lib-mjs/publicApi/utils/formatTextSegmentBeforeSelectionMarker.js.map +1 -1
  829. package/package.json +3 -3
@@ -1,114 +1,114 @@
1
- import { __read } from "tslib";
2
- import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';
3
- import { createEditorContextForEntity } from './createEditorContextForEntity';
4
- import { contentModelToDom, createDomToModelContext, createModelToDomContext, domToContentModel, getSelectedSegmentsAndParagraphs, mergeTextSegments, } from 'roosterjs-content-model-dom';
5
- /**
6
- * Invoke a callback to format the selected segment using Content Model
7
- * @param editor The editor object
8
- * @param apiName Name of API this calling this function. This is mostly for logging.
9
- * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.
10
- * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format
11
- * @param includingFormatHolder True to also include format holder of list item when search selected segments
12
- * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree
13
- */
14
- export function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
15
- editor.formatContentModel(function (model, context) {
16
- var segmentAndParagraphs = getSelectedSegmentsAndParagraphs(model, !!includingFormatHolder, true /*includingEntity*/, true /*mutate*/);
17
- var isCollapsedSelection = segmentAndParagraphs.length >= 1 &&
18
- segmentAndParagraphs.every(function (x) { return x[0].segmentType == 'SelectionMarker'; });
19
- // 1. adjust selection to a word if selection is collapsed
20
- if (isCollapsedSelection) {
21
- var para_1 = segmentAndParagraphs[0][1];
22
- var path_1 = segmentAndParagraphs[0][2];
23
- segmentAndParagraphs = adjustWordSelection(model, segmentAndParagraphs[0][0]).map(function (x) { return [x, para_1, path_1]; });
24
- if (segmentAndParagraphs.length > 1) {
25
- isCollapsedSelection = false;
26
- }
27
- }
28
- // 2. expand selection for entities if any
29
- var formatsAndSegments = [];
30
- var modelsFromEntities = [];
31
- segmentAndParagraphs.forEach(function (item) {
32
- if (item[0].segmentType == 'Entity') {
33
- expandEntitySelections(editor, item[0], formatsAndSegments, modelsFromEntities, item[1]);
34
- }
35
- else {
36
- formatsAndSegments.push([item[0].format, item[0], item[1]]);
37
- }
38
- });
39
- // 3. check if we should turn format on (when not all selection has the required format already)
40
- // or off (all selections already have the required format)
41
- var isTurningOff = segmentHasStyleCallback
42
- ? formatsAndSegments.every(function (_a) {
43
- var _b = __read(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
44
- return segmentHasStyleCallback(format, segment, paragraph);
45
- })
46
- : false;
47
- // 4. invoke the callback function to apply the format
48
- formatsAndSegments.forEach(function (_a) {
49
- var _b = __read(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
50
- toggleStyleCallback(format, !isTurningOff, segment, paragraph);
51
- });
52
- // 5. after format is applied to all selections, invoke another callback to do some clean up before write the change back
53
- afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model, isTurningOff, context);
54
- // 6. finally merge segments if possible, to avoid fragmentation
55
- formatsAndSegments.forEach(function (_a) {
56
- var _b = __read(_a, 3), _ = _b[0], __ = _b[1], paragraph = _b[2];
57
- if (paragraph) {
58
- mergeTextSegments(paragraph);
59
- }
60
- });
61
- // 7. Write back models that we got from entities (if any)
62
- writeBackEntities(editor, modelsFromEntities);
63
- // 8. if the selection is still collapsed, it means we didn't actually applied format, set a pending format so it can be applied when user type
64
- // otherwise, write back to editor
65
- if (isCollapsedSelection) {
66
- context.newPendingFormat = segmentAndParagraphs[0][0].format;
67
- editor.focus();
68
- return false;
69
- }
70
- else {
71
- return formatsAndSegments.length > 0;
72
- }
73
- }, {
74
- apiName: apiName,
75
- });
76
- }
77
- function expandEntitySelections(editor, entity, formatsAndSegments, modelsFromEntities, paragraph) {
78
- var _a = entity.entityFormat, id = _a.id, type = _a.entityType, isReadonly = _a.isReadonly;
79
- if (id && type) {
80
- var formattableRoots = [];
81
- var entityOperationEventData = {
82
- entity: { id: id, type: type, isReadonly: !!isReadonly, wrapper: entity.wrapper },
83
- operation: 'beforeFormat',
84
- formattableRoots: formattableRoots,
85
- };
86
- editor.triggerEvent('entityOperation', entityOperationEventData);
87
- formattableRoots.forEach(function (root) {
88
- if (entity.wrapper.contains(root.element)) {
89
- var editorContext = createEditorContextForEntity(editor, entity);
90
- var context = createDomToModelContext(editorContext, root.domToModelOptions);
91
- // Treat everything as selected since the parent entity is selected
92
- context.isInSelection = true;
93
- var model = domToContentModel(root.element, context);
94
- var selections = getSelectedSegmentsAndParagraphs(model, false /*includingFormatHolder*/, false /*includingEntity*/, true /*mutate*/);
95
- selections.forEach(function (item) {
96
- formatsAndSegments.push([item[0].format, item[0], item[1]]);
97
- });
98
- modelsFromEntities.push([entity, root, model]);
99
- }
100
- });
101
- if (formattableRoots.length > 0) {
102
- formatsAndSegments.push([entity.format, entity, paragraph]);
103
- }
104
- }
105
- }
106
- function writeBackEntities(editor, modelsFromEntities) {
107
- modelsFromEntities.forEach(function (_a) {
108
- var _b = __read(_a, 3), entity = _b[0], root = _b[1], model = _b[2];
109
- var editorContext = createEditorContextForEntity(editor, entity);
110
- var modelToDomContext = createModelToDomContext(editorContext, root.modelToDomOptions);
111
- contentModelToDom(editor.getDocument(), root.element, model, modelToDomContext);
112
- });
113
- }
1
+ import { __read } from "tslib";
2
+ import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';
3
+ import { createEditorContextForEntity } from './createEditorContextForEntity';
4
+ import { contentModelToDom, createDomToModelContext, createModelToDomContext, domToContentModel, getSelectedSegmentsAndParagraphs, mergeTextSegments, } from 'roosterjs-content-model-dom';
5
+ /**
6
+ * Invoke a callback to format the selected segment using Content Model
7
+ * @param editor The editor object
8
+ * @param apiName Name of API this calling this function. This is mostly for logging.
9
+ * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.
10
+ * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format
11
+ * @param includingFormatHolder True to also include format holder of list item when search selected segments
12
+ * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree
13
+ */
14
+ export function formatSegmentWithContentModel(editor, apiName, toggleStyleCallback, segmentHasStyleCallback, includingFormatHolder, afterFormatCallback) {
15
+ editor.formatContentModel(function (model, context) {
16
+ var segmentAndParagraphs = getSelectedSegmentsAndParagraphs(model, !!includingFormatHolder, true /*includingEntity*/, true /*mutate*/);
17
+ var isCollapsedSelection = segmentAndParagraphs.length >= 1 &&
18
+ segmentAndParagraphs.every(function (x) { return x[0].segmentType == 'SelectionMarker'; });
19
+ // 1. adjust selection to a word if selection is collapsed
20
+ if (isCollapsedSelection) {
21
+ var para_1 = segmentAndParagraphs[0][1];
22
+ var path_1 = segmentAndParagraphs[0][2];
23
+ segmentAndParagraphs = adjustWordSelection(model, segmentAndParagraphs[0][0]).map(function (x) { return [x, para_1, path_1]; });
24
+ if (segmentAndParagraphs.length > 1) {
25
+ isCollapsedSelection = false;
26
+ }
27
+ }
28
+ // 2. expand selection for entities if any
29
+ var formatsAndSegments = [];
30
+ var modelsFromEntities = [];
31
+ segmentAndParagraphs.forEach(function (item) {
32
+ if (item[0].segmentType == 'Entity') {
33
+ expandEntitySelections(editor, item[0], formatsAndSegments, modelsFromEntities, item[1]);
34
+ }
35
+ else {
36
+ formatsAndSegments.push([item[0].format, item[0], item[1]]);
37
+ }
38
+ });
39
+ // 3. check if we should turn format on (when not all selection has the required format already)
40
+ // or off (all selections already have the required format)
41
+ var isTurningOff = segmentHasStyleCallback
42
+ ? formatsAndSegments.every(function (_a) {
43
+ var _b = __read(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
44
+ return segmentHasStyleCallback(format, segment, paragraph);
45
+ })
46
+ : false;
47
+ // 4. invoke the callback function to apply the format
48
+ formatsAndSegments.forEach(function (_a) {
49
+ var _b = __read(_a, 3), format = _b[0], segment = _b[1], paragraph = _b[2];
50
+ toggleStyleCallback(format, !isTurningOff, segment, paragraph);
51
+ });
52
+ // 5. after format is applied to all selections, invoke another callback to do some clean up before write the change back
53
+ afterFormatCallback === null || afterFormatCallback === void 0 ? void 0 : afterFormatCallback(model, isTurningOff, context);
54
+ // 6. finally merge segments if possible, to avoid fragmentation
55
+ formatsAndSegments.forEach(function (_a) {
56
+ var _b = __read(_a, 3), _ = _b[0], __ = _b[1], paragraph = _b[2];
57
+ if (paragraph) {
58
+ mergeTextSegments(paragraph);
59
+ }
60
+ });
61
+ // 7. Write back models that we got from entities (if any)
62
+ writeBackEntities(editor, modelsFromEntities);
63
+ // 8. if the selection is still collapsed, it means we didn't actually applied format, set a pending format so it can be applied when user type
64
+ // otherwise, write back to editor
65
+ if (isCollapsedSelection) {
66
+ context.newPendingFormat = segmentAndParagraphs[0][0].format;
67
+ editor.focus();
68
+ return false;
69
+ }
70
+ else {
71
+ return formatsAndSegments.length > 0;
72
+ }
73
+ }, {
74
+ apiName: apiName,
75
+ });
76
+ }
77
+ function expandEntitySelections(editor, entity, formatsAndSegments, modelsFromEntities, paragraph) {
78
+ var _a = entity.entityFormat, id = _a.id, type = _a.entityType, isReadonly = _a.isReadonly;
79
+ if (id && type) {
80
+ var formattableRoots = [];
81
+ var entityOperationEventData = {
82
+ entity: { id: id, type: type, isReadonly: !!isReadonly, wrapper: entity.wrapper },
83
+ operation: 'beforeFormat',
84
+ formattableRoots: formattableRoots,
85
+ };
86
+ editor.triggerEvent('entityOperation', entityOperationEventData);
87
+ formattableRoots.forEach(function (root) {
88
+ if (entity.wrapper.contains(root.element)) {
89
+ var editorContext = createEditorContextForEntity(editor, entity);
90
+ var context = createDomToModelContext(editorContext, root.domToModelOptions);
91
+ // Treat everything as selected since the parent entity is selected
92
+ context.isInSelection = true;
93
+ var model = domToContentModel(root.element, context);
94
+ var selections = getSelectedSegmentsAndParagraphs(model, false /*includingFormatHolder*/, false /*includingEntity*/, true /*mutate*/);
95
+ selections.forEach(function (item) {
96
+ formatsAndSegments.push([item[0].format, item[0], item[1]]);
97
+ });
98
+ modelsFromEntities.push([entity, root, model]);
99
+ }
100
+ });
101
+ if (formattableRoots.length > 0) {
102
+ formatsAndSegments.push([entity.format, entity, paragraph]);
103
+ }
104
+ }
105
+ }
106
+ function writeBackEntities(editor, modelsFromEntities) {
107
+ modelsFromEntities.forEach(function (_a) {
108
+ var _b = __read(_a, 3), entity = _b[0], root = _b[1], model = _b[2];
109
+ var editorContext = createEditorContextForEntity(editor, entity);
110
+ var modelToDomContext = createModelToDomContext(editorContext, root.modelToDomOptions);
111
+ contentModelToDom(editor.getDocument(), root.element, model, modelToDomContext);
112
+ });
113
+ }
114
114
  //# sourceMappingURL=formatSegmentWithContentModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,gCAAgC,EAChC,iBAAiB,GACpB,MAAM,6BAA6B,CAAC;AAcrC;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CACzC,MAAe,EACf,OAAe,EACf,mBAKS,EACT,uBAIY,EACZ,qBAA+B,EAC/B,mBAIS;IAET,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;QACX,IAAI,oBAAoB,GAAG,gCAAgC,CACvD,KAAK,EACL,CAAC,CAAC,qBAAqB,EACvB,IAAI,CAAC,mBAAmB,EACxB,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,oBAAoB,GACpB,oBAAoB,CAAC,MAAM,IAAI,CAAC;YAChC,oBAAoB,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAArC,C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I,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;aAClD;QACL,CAAC,CAAC,CAAC;QACH,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,kBAAkB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;SAC/D;KACJ;AACL,CAAC;AAED,SAAS,iBAAiB,CACtB,MAAe,EACf,kBAAiF;IAEjF,kBAAkB,CAAC,OAAO,CAAC,UAAC,EAAqB;YAArB,KAAA,aAAqB,EAApB,MAAM,QAAA,EAAE,IAAI,QAAA,EAAE,KAAK,QAAA;QAC5C,IAAM,aAAa,GAAG,4BAA4B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnE,IAAM,iBAAiB,GAAG,uBAAuB,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEzF,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\r\nimport { createEditorContextForEntity } from './createEditorContextForEntity';\r\nimport {\r\n contentModelToDom,\r\n createDomToModelContext,\r\n createModelToDomContext,\r\n domToContentModel,\r\n getSelectedSegmentsAndParagraphs,\r\n mergeTextSegments,\r\n} from 'roosterjs-content-model-dom';\r\nimport type {\r\n ContentModelDocument,\r\n ContentModelEntity,\r\n ContentModelSegmentFormat,\r\n FormatContentModelContext,\r\n FormattableRoot,\r\n IEditor,\r\n PluginEventData,\r\n ReadonlyContentModelDocument,\r\n ShallowMutableContentModelParagraph,\r\n ShallowMutableContentModelSegment,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Invoke a callback to format the selected segment using Content Model\r\n * @param editor The editor object\r\n * @param apiName Name of API this calling this function. This is mostly for logging.\r\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\r\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\r\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\r\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\r\n */\r\nexport function formatSegmentWithContentModel(\r\n editor: IEditor,\r\n apiName: string,\r\n toggleStyleCallback: (\r\n format: ContentModelSegmentFormat,\r\n isTuringOn: boolean,\r\n segment: ShallowMutableContentModelSegment | null,\r\n paragraph: ShallowMutableContentModelParagraph | null\r\n ) => void,\r\n segmentHasStyleCallback?: (\r\n format: ContentModelSegmentFormat,\r\n segment: ShallowMutableContentModelSegment | null,\r\n paragraph: ShallowMutableContentModelParagraph | null\r\n ) => boolean,\r\n includingFormatHolder?: boolean,\r\n afterFormatCallback?: (\r\n model: ReadonlyContentModelDocument,\r\n isTurningOff: boolean,\r\n context: FormatContentModelContext\r\n ) => void\r\n) {\r\n editor.formatContentModel(\r\n (model, context) => {\r\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\r\n model,\r\n !!includingFormatHolder,\r\n true /*includingEntity*/,\r\n true /*mutate*/\r\n );\r\n let isCollapsedSelection =\r\n segmentAndParagraphs.length >= 1 &&\r\n segmentAndParagraphs.every(x => x[0].segmentType == 'SelectionMarker');\r\n\r\n // 1. adjust selection to a word if selection is collapsed\r\n if (isCollapsedSelection) {\r\n const para = segmentAndParagraphs[0][1];\r\n const path = segmentAndParagraphs[0][2];\r\n\r\n segmentAndParagraphs = adjustWordSelection(\r\n model,\r\n segmentAndParagraphs[0][0]\r\n ).map(x => [x, para, path]);\r\n\r\n if (segmentAndParagraphs.length > 1) {\r\n isCollapsedSelection = false;\r\n }\r\n }\r\n\r\n // 2. expand selection for entities if any\r\n const formatsAndSegments: [\r\n ContentModelSegmentFormat,\r\n ShallowMutableContentModelSegment | null,\r\n ShallowMutableContentModelParagraph | null\r\n ][] = [];\r\n const modelsFromEntities: [\r\n ContentModelEntity,\r\n FormattableRoot,\r\n ContentModelDocument\r\n ][] = [];\r\n\r\n segmentAndParagraphs.forEach(item => {\r\n if (item[0].segmentType == 'Entity') {\r\n expandEntitySelections(\r\n editor,\r\n item[0],\r\n formatsAndSegments,\r\n modelsFromEntities,\r\n item[1]\r\n );\r\n } else {\r\n formatsAndSegments.push([item[0].format, item[0], item[1]]);\r\n }\r\n });\r\n\r\n // 3. check if we should turn format on (when not all selection has the required format already)\r\n // or off (all selections already have the required format)\r\n const isTurningOff = segmentHasStyleCallback\r\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\r\n segmentHasStyleCallback(format, segment, paragraph)\r\n )\r\n : false;\r\n\r\n // 4. invoke the callback function to apply the format\r\n formatsAndSegments.forEach(([format, segment, paragraph]) => {\r\n toggleStyleCallback(format, !isTurningOff, segment, paragraph);\r\n });\r\n\r\n // 5. after format is applied to all selections, invoke another callback to do some clean up before write the change back\r\n afterFormatCallback?.(model, isTurningOff, context);\r\n\r\n // 6. finally merge segments if possible, to avoid fragmentation\r\n formatsAndSegments.forEach(([_, __, paragraph]) => {\r\n if (paragraph) {\r\n mergeTextSegments(paragraph);\r\n }\r\n });\r\n\r\n // 7. Write back models that we got from entities (if any)\r\n writeBackEntities(editor, modelsFromEntities);\r\n\r\n // 8. if the selection is still collapsed, it means we didn't actually applied format, set a pending format so it can be applied when user type\r\n // otherwise, write back to editor\r\n if (isCollapsedSelection) {\r\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\r\n editor.focus();\r\n return false;\r\n } else {\r\n return formatsAndSegments.length > 0;\r\n }\r\n },\r\n {\r\n apiName,\r\n }\r\n );\r\n}\r\n\r\nfunction expandEntitySelections(\r\n editor: IEditor,\r\n entity: ContentModelEntity,\r\n formatsAndSegments: [\r\n ContentModelSegmentFormat,\r\n ShallowMutableContentModelSegment | null,\r\n ShallowMutableContentModelParagraph | null\r\n ][],\r\n modelsFromEntities: [ContentModelEntity, FormattableRoot, ContentModelDocument][],\r\n paragraph: ShallowMutableContentModelParagraph | null\r\n) {\r\n const { id, entityType: type, isReadonly } = entity.entityFormat;\r\n\r\n if (id && type) {\r\n const formattableRoots: FormattableRoot[] = [];\r\n const entityOperationEventData: PluginEventData<'entityOperation'> = {\r\n entity: { id, type, isReadonly: !!isReadonly, wrapper: entity.wrapper },\r\n operation: 'beforeFormat',\r\n formattableRoots,\r\n };\r\n\r\n editor.triggerEvent('entityOperation', entityOperationEventData);\r\n\r\n formattableRoots.forEach(root => {\r\n if (entity.wrapper.contains(root.element)) {\r\n const editorContext = createEditorContextForEntity(editor, entity);\r\n const context = createDomToModelContext(editorContext, root.domToModelOptions);\r\n\r\n // Treat everything as selected since the parent entity is selected\r\n context.isInSelection = true;\r\n\r\n const model = domToContentModel(root.element, context);\r\n const selections = getSelectedSegmentsAndParagraphs(\r\n model,\r\n false /*includingFormatHolder*/,\r\n false /*includingEntity*/,\r\n true /*mutate*/\r\n );\r\n\r\n selections.forEach(item => {\r\n formatsAndSegments.push([item[0].format, item[0], item[1]]);\r\n });\r\n\r\n modelsFromEntities.push([entity, root, model]);\r\n }\r\n });\r\n if (formattableRoots.length > 0) {\r\n formatsAndSegments.push([entity.format, entity, paragraph]);\r\n }\r\n }\r\n}\r\n\r\nfunction writeBackEntities(\r\n editor: IEditor,\r\n modelsFromEntities: [ContentModelEntity, FormattableRoot, ContentModelDocument][]\r\n) {\r\n modelsFromEntities.forEach(([entity, root, model]) => {\r\n const editorContext = createEditorContextForEntity(editor, entity);\r\n const modelToDomContext = createModelToDomContext(editorContext, root.modelToDomOptions);\r\n\r\n contentModelToDom(editor.getDocument(), root.element, model, modelToDomContext);\r\n });\r\n}\r\n"]}
1
+ {"version":3,"file":"formatSegmentWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatSegmentWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,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iBAAiB,CAAC,CAAC;QAEzF,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACpF,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { adjustWordSelection } from '../../modelApi/selection/adjustWordSelection';\nimport { createEditorContextForEntity } from './createEditorContextForEntity';\nimport {\n contentModelToDom,\n createDomToModelContext,\n createModelToDomContext,\n domToContentModel,\n getSelectedSegmentsAndParagraphs,\n mergeTextSegments,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n ContentModelEntity,\n ContentModelSegmentFormat,\n FormatContentModelContext,\n FormattableRoot,\n IEditor,\n PluginEventData,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n ShallowMutableContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected segment using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param toggleStyleCallback The callback to format the segment. It will be called with current selected table. If no table is selected, it will not be called.\n * @param segmentHasStyleCallback The callback used for checking if the given segment already has required format\n * @param includingFormatHolder True to also include format holder of list item when search selected segments\n * @param afterFormatCallback A callback to invoke after format is applied to all selected segments and before the change is applied to DOM tree\n */\nexport function formatSegmentWithContentModel(\n editor: IEditor,\n apiName: string,\n toggleStyleCallback: (\n format: ContentModelSegmentFormat,\n isTuringOn: boolean,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => void,\n segmentHasStyleCallback?: (\n format: ContentModelSegmentFormat,\n segment: ShallowMutableContentModelSegment | null,\n paragraph: ShallowMutableContentModelParagraph | null\n ) => boolean,\n includingFormatHolder?: boolean,\n afterFormatCallback?: (\n model: ReadonlyContentModelDocument,\n isTurningOff: boolean,\n context: FormatContentModelContext\n ) => void\n) {\n editor.formatContentModel(\n (model, context) => {\n let segmentAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n !!includingFormatHolder,\n true /*includingEntity*/,\n true /*mutate*/\n );\n let isCollapsedSelection =\n segmentAndParagraphs.length >= 1 &&\n segmentAndParagraphs.every(x => x[0].segmentType == 'SelectionMarker');\n\n // 1. adjust selection to a word if selection is collapsed\n if (isCollapsedSelection) {\n const para = segmentAndParagraphs[0][1];\n const path = segmentAndParagraphs[0][2];\n\n segmentAndParagraphs = adjustWordSelection(\n model,\n segmentAndParagraphs[0][0]\n ).map(x => [x, para, path]);\n\n if (segmentAndParagraphs.length > 1) {\n isCollapsedSelection = false;\n }\n }\n\n // 2. expand selection for entities if any\n const formatsAndSegments: [\n ContentModelSegmentFormat,\n ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | null\n ][] = [];\n const modelsFromEntities: [\n ContentModelEntity,\n FormattableRoot,\n ContentModelDocument\n ][] = [];\n\n segmentAndParagraphs.forEach(item => {\n if (item[0].segmentType == 'Entity') {\n expandEntitySelections(\n editor,\n item[0],\n formatsAndSegments,\n modelsFromEntities,\n item[1]\n );\n } else {\n formatsAndSegments.push([item[0].format, item[0], item[1]]);\n }\n });\n\n // 3. check if we should turn format on (when not all selection has the required format already)\n // or off (all selections already have the required format)\n const isTurningOff = segmentHasStyleCallback\n ? formatsAndSegments.every(([format, segment, paragraph]) =>\n segmentHasStyleCallback(format, segment, paragraph)\n )\n : false;\n\n // 4. invoke the callback function to apply the format\n formatsAndSegments.forEach(([format, segment, paragraph]) => {\n toggleStyleCallback(format, !isTurningOff, segment, paragraph);\n });\n\n // 5. after format is applied to all selections, invoke another callback to do some clean up before write the change back\n afterFormatCallback?.(model, isTurningOff, context);\n\n // 6. finally merge segments if possible, to avoid fragmentation\n formatsAndSegments.forEach(([_, __, paragraph]) => {\n if (paragraph) {\n mergeTextSegments(paragraph);\n }\n });\n\n // 7. Write back models that we got from entities (if any)\n writeBackEntities(editor, modelsFromEntities);\n\n // 8. if the selection is still collapsed, it means we didn't actually applied format, set a pending format so it can be applied when user type\n // otherwise, write back to editor\n if (isCollapsedSelection) {\n context.newPendingFormat = segmentAndParagraphs[0][0].format;\n editor.focus();\n return false;\n } else {\n return formatsAndSegments.length > 0;\n }\n },\n {\n apiName,\n }\n );\n}\n\nfunction expandEntitySelections(\n editor: IEditor,\n entity: ContentModelEntity,\n formatsAndSegments: [\n ContentModelSegmentFormat,\n ShallowMutableContentModelSegment | null,\n ShallowMutableContentModelParagraph | null\n ][],\n modelsFromEntities: [ContentModelEntity, FormattableRoot, ContentModelDocument][],\n paragraph: ShallowMutableContentModelParagraph | null\n) {\n const { id, entityType: type, isReadonly } = entity.entityFormat;\n\n if (id && type) {\n const formattableRoots: FormattableRoot[] = [];\n const entityOperationEventData: PluginEventData<'entityOperation'> = {\n entity: { id, type, isReadonly: !!isReadonly, wrapper: entity.wrapper },\n operation: 'beforeFormat',\n formattableRoots,\n };\n\n editor.triggerEvent('entityOperation', entityOperationEventData);\n\n formattableRoots.forEach(root => {\n if (entity.wrapper.contains(root.element)) {\n const editorContext = createEditorContextForEntity(editor, entity);\n const context = createDomToModelContext(editorContext, root.domToModelOptions);\n\n // Treat everything as selected since the parent entity is selected\n context.isInSelection = true;\n\n const model = domToContentModel(root.element, context);\n const selections = getSelectedSegmentsAndParagraphs(\n model,\n false /*includingFormatHolder*/,\n false /*includingEntity*/,\n true /*mutate*/\n );\n\n selections.forEach(item => {\n formatsAndSegments.push([item[0].format, item[0], item[1]]);\n });\n\n modelsFromEntities.push([entity, root, model]);\n }\n });\n if (formattableRoots.length > 0) {\n formatsAndSegments.push([entity.format, entity, paragraph]);\n }\n }\n}\n\nfunction writeBackEntities(\n editor: IEditor,\n modelsFromEntities: [ContentModelEntity, FormattableRoot, ContentModelDocument][]\n) {\n modelsFromEntities.forEach(([entity, root, model]) => {\n const editorContext = createEditorContextForEntity(editor, entity);\n const modelToDomContext = createModelToDomContext(editorContext, root.modelToDomOptions);\n\n contentModelToDom(editor.getDocument(), root.element, model, modelToDomContext);\n });\n}\n"]}
@@ -1,9 +1,9 @@
1
- import type { IEditor, ShallowMutableContentModelTable, TableSelection } from 'roosterjs-content-model-types';
2
- /**
3
- * Invoke a callback to format the selected table using Content Model
4
- * @param editor The editor object
5
- * @param apiName Name of API this calling this function. This is mostly for logging.
6
- * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.
7
- * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
8
- */
9
- export declare function formatTableWithContentModel(editor: IEditor, apiName: string, callback: (tableModel: ShallowMutableContentModelTable) => void, selectionOverride?: TableSelection): void;
1
+ import type { IEditor, ShallowMutableContentModelTable, TableSelection } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Invoke a callback to format the selected table using Content Model
4
+ * @param editor The editor object
5
+ * @param apiName Name of API this calling this function. This is mostly for logging.
6
+ * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.
7
+ * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
8
+ */
9
+ export declare function formatTableWithContentModel(editor: IEditor, apiName: string, callback: (tableModel: ShallowMutableContentModelTable) => void, selectionOverride?: TableSelection): void;
@@ -1,43 +1,43 @@
1
- import { __read } from "tslib";
2
- import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';
3
- import { createSelectionMarker, hasMetadata, setParagraphNotImplicit, hasSelectionInBlock, applyTableFormat, getFirstSelectedTable, normalizeTable, setSelection, mutateBlock, } from 'roosterjs-content-model-dom';
4
- /**
5
- * Invoke a callback to format the selected table using Content Model
6
- * @param editor The editor object
7
- * @param apiName Name of API this calling this function. This is mostly for logging.
8
- * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.
9
- * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
10
- */
11
- export function formatTableWithContentModel(editor, apiName, callback, selectionOverride) {
12
- editor.focus();
13
- editor.formatContentModel(function (model) {
14
- var _a = __read(getFirstSelectedTable(model), 2), readonlyTableModel = _a[0], path = _a[1];
15
- if (readonlyTableModel) {
16
- var tableModel = mutateBlock(readonlyTableModel);
17
- callback(tableModel);
18
- if (!hasSelectionInBlock(tableModel)) {
19
- var paragraph = ensureFocusableParagraphForTable(model, path, tableModel);
20
- if (paragraph) {
21
- var marker = createSelectionMarker(model.format);
22
- paragraph.segments.unshift(marker);
23
- setParagraphNotImplicit(paragraph);
24
- setSelection(model, marker);
25
- }
26
- }
27
- normalizeTable(tableModel, model.format);
28
- if (hasMetadata(tableModel)) {
29
- applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);
30
- }
31
- return true;
32
- }
33
- else {
34
- return false;
35
- }
36
- }, {
37
- apiName: apiName,
38
- selectionOverride: selectionOverride,
39
- }, {
40
- recalculateTableSize: 'selected',
41
- });
42
- }
1
+ import { __read } from "tslib";
2
+ import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';
3
+ import { createSelectionMarker, hasMetadata, setParagraphNotImplicit, hasSelectionInBlock, applyTableFormat, getFirstSelectedTable, normalizeTable, setSelection, mutateBlock, } from 'roosterjs-content-model-dom';
4
+ /**
5
+ * Invoke a callback to format the selected table using Content Model
6
+ * @param editor The editor object
7
+ * @param apiName Name of API this calling this function. This is mostly for logging.
8
+ * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.
9
+ * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection
10
+ */
11
+ export function formatTableWithContentModel(editor, apiName, callback, selectionOverride) {
12
+ editor.focus();
13
+ editor.formatContentModel(function (model) {
14
+ var _a = __read(getFirstSelectedTable(model), 2), readonlyTableModel = _a[0], path = _a[1];
15
+ if (readonlyTableModel) {
16
+ var tableModel = mutateBlock(readonlyTableModel);
17
+ callback(tableModel);
18
+ if (!hasSelectionInBlock(tableModel)) {
19
+ var paragraph = ensureFocusableParagraphForTable(model, path, tableModel);
20
+ if (paragraph) {
21
+ var marker = createSelectionMarker(model.format);
22
+ paragraph.segments.unshift(marker);
23
+ setParagraphNotImplicit(paragraph);
24
+ setSelection(model, marker);
25
+ }
26
+ }
27
+ normalizeTable(tableModel, model.format);
28
+ if (hasMetadata(tableModel)) {
29
+ applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);
30
+ }
31
+ return true;
32
+ }
33
+ else {
34
+ return false;
35
+ }
36
+ }, {
37
+ apiName: apiName,
38
+ selectionOverride: selectionOverride,
39
+ }, {
40
+ recalculateTableSize: 'selected',
41
+ });
42
+ }
43
43
  //# sourceMappingURL=formatTableWithContentModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\r\nimport {\r\n createSelectionMarker,\r\n hasMetadata,\r\n setParagraphNotImplicit,\r\n hasSelectionInBlock,\r\n applyTableFormat,\r\n getFirstSelectedTable,\r\n normalizeTable,\r\n setSelection,\r\n mutateBlock,\r\n} from 'roosterjs-content-model-dom';\r\nimport type {\r\n IEditor,\r\n ShallowMutableContentModelTable,\r\n TableSelection,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Invoke a callback to format the selected table using Content Model\r\n * @param editor The editor object\r\n * @param apiName Name of API this calling this function. This is mostly for logging.\r\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\r\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\r\n */\r\nexport function formatTableWithContentModel(\r\n editor: IEditor,\r\n apiName: string,\r\n callback: (tableModel: ShallowMutableContentModelTable) => void,\r\n selectionOverride?: TableSelection\r\n) {\r\n editor.focus();\r\n editor.formatContentModel(\r\n model => {\r\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\r\n\r\n if (readonlyTableModel) {\r\n const tableModel = mutateBlock(readonlyTableModel);\r\n\r\n callback(tableModel);\r\n\r\n if (!hasSelectionInBlock(tableModel)) {\r\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\r\n\r\n if (paragraph) {\r\n const marker = createSelectionMarker(model.format);\r\n\r\n paragraph.segments.unshift(marker);\r\n setParagraphNotImplicit(paragraph);\r\n setSelection(model, marker);\r\n }\r\n }\r\n\r\n normalizeTable(tableModel, model.format);\r\n\r\n if (hasMetadata(tableModel)) {\r\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\r\n }\r\n\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n },\r\n {\r\n apiName,\r\n selectionOverride,\r\n },\r\n {\r\n recalculateTableSize: 'selected',\r\n }\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"formatTableWithContentModel.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTableWithContentModel.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,uDAAuD,CAAC;AACzG,OAAO,EACH,qBAAqB,EACrB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,WAAW,GACd,MAAM,6BAA6B,CAAC;AAOrC;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACvC,MAAe,EACf,OAAe,EACf,QAA+D,EAC/D,iBAAkC;IAElC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,CAAC,kBAAkB,CACrB,UAAA,KAAK;QACK,IAAA,KAAA,OAA6B,qBAAqB,CAAC,KAAK,CAAC,IAAA,EAAxD,kBAAkB,QAAA,EAAE,IAAI,QAAgC,CAAC;QAEhE,IAAI,kBAAkB,EAAE;YACpB,IAAM,UAAU,GAAG,WAAW,CAAC,kBAAkB,CAAC,CAAC;YAEnD,QAAQ,CAAC,UAAU,CAAC,CAAC;YAErB,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAM,SAAS,GAAG,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAE5E,IAAI,SAAS,EAAE;oBACX,IAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;oBAEnD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;oBACnC,uBAAuB,CAAC,SAAS,CAAC,CAAC;oBACnC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;iBAC/B;aACJ;YAED,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAEzC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBACzB,gBAAgB,CAAC,UAAU,EAAE,SAAS,CAAC,aAAa,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;aACjF;YAED,OAAO,IAAI,CAAC;SACf;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC,EACD;QACI,OAAO,SAAA;QACP,iBAAiB,mBAAA;KACpB,EACD;QACI,oBAAoB,EAAE,UAAU;KACnC,CACJ,CAAC;AACN,CAAC","sourcesContent":["import { ensureFocusableParagraphForTable } from '../../modelApi/table/ensureFocusableParagraphForTable';\nimport {\n createSelectionMarker,\n hasMetadata,\n setParagraphNotImplicit,\n hasSelectionInBlock,\n applyTableFormat,\n getFirstSelectedTable,\n normalizeTable,\n setSelection,\n mutateBlock,\n} from 'roosterjs-content-model-dom';\nimport type {\n IEditor,\n ShallowMutableContentModelTable,\n TableSelection,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the selected table using Content Model\n * @param editor The editor object\n * @param apiName Name of API this calling this function. This is mostly for logging.\n * @param callback The callback to format the table. It will be called with current selected table. If no table is selected, it will not be called.\n * @param selectionOverride Override the current selection. If we want to format a table even currently it is not selected, we can use this parameter to override current selection\n */\nexport function formatTableWithContentModel(\n editor: IEditor,\n apiName: string,\n callback: (tableModel: ShallowMutableContentModelTable) => void,\n selectionOverride?: TableSelection\n) {\n editor.focus();\n editor.formatContentModel(\n model => {\n const [readonlyTableModel, path] = getFirstSelectedTable(model);\n\n if (readonlyTableModel) {\n const tableModel = mutateBlock(readonlyTableModel);\n\n callback(tableModel);\n\n if (!hasSelectionInBlock(tableModel)) {\n const paragraph = ensureFocusableParagraphForTable(model, path, tableModel);\n\n if (paragraph) {\n const marker = createSelectionMarker(model.format);\n\n paragraph.segments.unshift(marker);\n setParagraphNotImplicit(paragraph);\n setSelection(model, marker);\n }\n }\n\n normalizeTable(tableModel, model.format);\n\n if (hasMetadata(tableModel)) {\n applyTableFormat(tableModel, undefined /*newFormat*/, true /*keepCellShade*/);\n }\n\n return true;\n } else {\n return false;\n }\n },\n {\n apiName,\n selectionOverride,\n },\n {\n recalculateTableSize: 'selected',\n }\n );\n}\n"]}
@@ -1,8 +1,8 @@
1
- import type { ContentModelSegmentFormat, ContentModelText, FormatContentModelContext, FormatContentModelOptions, IEditor, ShallowMutableContentModelDocument, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
2
- /**
3
- * Invoke a callback to format the text segment before the selection marker using Content Model
4
- * @param editor The editor object
5
- * @param callback The callback to format the text segment.
6
- * @returns True if the segment before cursor is found and callback is called, otherwise false
7
- */
8
- export declare function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ShallowMutableContentModelDocument, previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean, options?: FormatContentModelOptions): boolean;
1
+ import type { ContentModelSegmentFormat, ContentModelText, FormatContentModelContext, FormatContentModelOptions, IEditor, ShallowMutableContentModelDocument, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Invoke a callback to format the text segment before the selection marker using Content Model
4
+ * @param editor The editor object
5
+ * @param callback The callback to format the text segment.
6
+ * @returns True if the segment before cursor is found and callback is called, otherwise false
7
+ */
8
+ export declare function formatTextSegmentBeforeSelectionMarker(editor: IEditor, callback: (model: ShallowMutableContentModelDocument, previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, markerFormat: ContentModelSegmentFormat, context: FormatContentModelContext) => boolean, options?: FormatContentModelOptions): boolean;
@@ -1,31 +1,31 @@
1
- import { getSelectedSegmentsAndParagraphs, mutateSegment } from 'roosterjs-content-model-dom';
2
- /**
3
- * Invoke a callback to format the text segment before the selection marker using Content Model
4
- * @param editor The editor object
5
- * @param callback The callback to format the text segment.
6
- * @returns True if the segment before cursor is found and callback is called, otherwise false
7
- */
8
- export function formatTextSegmentBeforeSelectionMarker(editor, callback, options) {
9
- var result = false;
10
- editor.formatContentModel(function (model, context) {
11
- var selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false /*includeFormatHolder*/);
12
- var rewrite = false;
13
- if (selectedSegmentsAndParagraphs.length > 0 &&
14
- selectedSegmentsAndParagraphs[0][0].segmentType == 'SelectionMarker' &&
15
- selectedSegmentsAndParagraphs[0][1]) {
16
- mutateSegment(selectedSegmentsAndParagraphs[0][1], selectedSegmentsAndParagraphs[0][0], function (marker, paragraph, markerIndex) {
17
- var previousSegment = paragraph.segments[markerIndex - 1];
18
- if (previousSegment && previousSegment.segmentType === 'Text') {
19
- result = true;
20
- // Preserve pending format if any when format text segment, so if there is pending format (e.g. from paste)
21
- // and some auto action happens after paste, the pending format will still take effect
22
- context.newPendingFormat = 'preserve';
23
- rewrite = callback(model, previousSegment, paragraph, marker.format, context);
24
- }
25
- });
26
- }
27
- return rewrite;
28
- }, options);
29
- return result;
30
- }
1
+ import { getSelectedSegmentsAndParagraphs, mutateSegment } from 'roosterjs-content-model-dom';
2
+ /**
3
+ * Invoke a callback to format the text segment before the selection marker using Content Model
4
+ * @param editor The editor object
5
+ * @param callback The callback to format the text segment.
6
+ * @returns True if the segment before cursor is found and callback is called, otherwise false
7
+ */
8
+ export function formatTextSegmentBeforeSelectionMarker(editor, callback, options) {
9
+ var result = false;
10
+ editor.formatContentModel(function (model, context) {
11
+ var selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false /*includeFormatHolder*/);
12
+ var rewrite = false;
13
+ if (selectedSegmentsAndParagraphs.length > 0 &&
14
+ selectedSegmentsAndParagraphs[0][0].segmentType == 'SelectionMarker' &&
15
+ selectedSegmentsAndParagraphs[0][1]) {
16
+ mutateSegment(selectedSegmentsAndParagraphs[0][1], selectedSegmentsAndParagraphs[0][0], function (marker, paragraph, markerIndex) {
17
+ var previousSegment = paragraph.segments[markerIndex - 1];
18
+ if (previousSegment && previousSegment.segmentType === 'Text') {
19
+ result = true;
20
+ // Preserve pending format if any when format text segment, so if there is pending format (e.g. from paste)
21
+ // and some auto action happens after paste, the pending format will still take effect
22
+ context.newPendingFormat = 'preserve';
23
+ rewrite = callback(model, previousSegment, paragraph, marker.format, context);
24
+ }
25
+ });
26
+ }
27
+ return rewrite;
28
+ }, options);
29
+ return result;
30
+ }
31
31
  //# sourceMappingURL=formatTextSegmentBeforeSelectionMarker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatTextSegmentBeforeSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW9F;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,CAClD,MAAe,EACf,QAMY,EACZ,OAAmC;IAEnC,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,uBAAuB,CAChC,CAAC;QACF,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,IACI,6BAA6B,CAAC,MAAM,GAAG,CAAC;YACxC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB;YACpE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACrC;YACE,aAAa,CACT,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnC,UAAC,MAAM,EAAE,SAAS,EAAE,WAAW;gBAC3B,IAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAE5D,IAAI,eAAe,IAAI,eAAe,CAAC,WAAW,KAAK,MAAM,EAAE;oBAC3D,MAAM,GAAG,IAAI,CAAC;oBAEd,2GAA2G;oBAC3G,sFAAsF;oBACtF,OAAO,CAAC,gBAAgB,GAAG,UAAU,CAAC;oBAEtC,OAAO,GAAG,QAAQ,CACd,KAAK,EACL,eAAe,EACf,SAAS,EACT,MAAM,CAAC,MAAM,EACb,OAAO,CACV,CAAC;iBACL;YACL,CAAC,CACJ,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs, mutateSegment } from 'roosterjs-content-model-dom';\r\nimport type {\r\n ContentModelSegmentFormat,\r\n ContentModelText,\r\n FormatContentModelContext,\r\n FormatContentModelOptions,\r\n IEditor,\r\n ShallowMutableContentModelDocument,\r\n ShallowMutableContentModelParagraph,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Invoke a callback to format the text segment before the selection marker using Content Model\r\n * @param editor The editor object\r\n * @param callback The callback to format the text segment.\r\n * @returns True if the segment before cursor is found and callback is called, otherwise false\r\n */\r\nexport function formatTextSegmentBeforeSelectionMarker(\r\n editor: IEditor,\r\n callback: (\r\n model: ShallowMutableContentModelDocument,\r\n previousSegment: ContentModelText,\r\n paragraph: ShallowMutableContentModelParagraph,\r\n markerFormat: ContentModelSegmentFormat,\r\n context: FormatContentModelContext\r\n ) => boolean,\r\n options?: FormatContentModelOptions\r\n): boolean {\r\n let result = false;\r\n\r\n editor.formatContentModel((model, context) => {\r\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\r\n model,\r\n false /*includeFormatHolder*/\r\n );\r\n let rewrite = false;\r\n\r\n if (\r\n selectedSegmentsAndParagraphs.length > 0 &&\r\n selectedSegmentsAndParagraphs[0][0].segmentType == 'SelectionMarker' &&\r\n selectedSegmentsAndParagraphs[0][1]\r\n ) {\r\n mutateSegment(\r\n selectedSegmentsAndParagraphs[0][1],\r\n selectedSegmentsAndParagraphs[0][0],\r\n (marker, paragraph, markerIndex) => {\r\n const previousSegment = paragraph.segments[markerIndex - 1];\r\n\r\n if (previousSegment && previousSegment.segmentType === 'Text') {\r\n result = true;\r\n\r\n // Preserve pending format if any when format text segment, so if there is pending format (e.g. from paste)\r\n // and some auto action happens after paste, the pending format will still take effect\r\n context.newPendingFormat = 'preserve';\r\n\r\n rewrite = callback(\r\n model,\r\n previousSegment,\r\n paragraph,\r\n marker.format,\r\n context\r\n );\r\n }\r\n }\r\n );\r\n }\r\n\r\n return rewrite;\r\n }, options);\r\n\r\n return result;\r\n}\r\n"]}
1
+ {"version":3,"file":"formatTextSegmentBeforeSelectionMarker.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-api/lib/publicApi/utils/formatTextSegmentBeforeSelectionMarker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAW9F;;;;;GAKG;AACH,MAAM,UAAU,sCAAsC,CAClD,MAAe,EACf,QAMY,EACZ,OAAmC;IAEnC,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,6BAA6B,GAAG,gCAAgC,CAClE,KAAK,EACL,KAAK,CAAC,uBAAuB,CAChC,CAAC;QACF,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,IACI,6BAA6B,CAAC,MAAM,GAAG,CAAC;YACxC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB;YACpE,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACrC;YACE,aAAa,CACT,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnC,UAAC,MAAM,EAAE,SAAS,EAAE,WAAW;gBAC3B,IAAM,eAAe,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAE5D,IAAI,eAAe,IAAI,eAAe,CAAC,WAAW,KAAK,MAAM,EAAE;oBAC3D,MAAM,GAAG,IAAI,CAAC;oBAEd,2GAA2G;oBAC3G,sFAAsF;oBACtF,OAAO,CAAC,gBAAgB,GAAG,UAAU,CAAC;oBAEtC,OAAO,GAAG,QAAQ,CACd,KAAK,EACL,eAAe,EACf,SAAS,EACT,MAAM,CAAC,MAAM,EACb,OAAO,CACV,CAAC;iBACL;YACL,CAAC,CACJ,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { getSelectedSegmentsAndParagraphs, mutateSegment } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelSegmentFormat,\n ContentModelText,\n FormatContentModelContext,\n FormatContentModelOptions,\n IEditor,\n ShallowMutableContentModelDocument,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * Invoke a callback to format the text segment before the selection marker using Content Model\n * @param editor The editor object\n * @param callback The callback to format the text segment.\n * @returns True if the segment before cursor is found and callback is called, otherwise false\n */\nexport function formatTextSegmentBeforeSelectionMarker(\n editor: IEditor,\n callback: (\n model: ShallowMutableContentModelDocument,\n previousSegment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n markerFormat: ContentModelSegmentFormat,\n context: FormatContentModelContext\n ) => boolean,\n options?: FormatContentModelOptions\n): boolean {\n let result = false;\n\n editor.formatContentModel((model, context) => {\n const selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(\n model,\n false /*includeFormatHolder*/\n );\n let rewrite = false;\n\n if (\n selectedSegmentsAndParagraphs.length > 0 &&\n selectedSegmentsAndParagraphs[0][0].segmentType == 'SelectionMarker' &&\n selectedSegmentsAndParagraphs[0][1]\n ) {\n mutateSegment(\n selectedSegmentsAndParagraphs[0][1],\n selectedSegmentsAndParagraphs[0][0],\n (marker, paragraph, markerIndex) => {\n const previousSegment = paragraph.segments[markerIndex - 1];\n\n if (previousSegment && previousSegment.segmentType === 'Text') {\n result = true;\n\n // Preserve pending format if any when format text segment, so if there is pending format (e.g. from paste)\n // and some auto action happens after paste, the pending format will still take effect\n context.newPendingFormat = 'preserve';\n\n rewrite = callback(\n model,\n previousSegment,\n paragraph,\n marker.format,\n context\n );\n }\n }\n );\n }\n\n return rewrite;\n }, options);\n\n return result;\n}\n"]}
package/package.json CHANGED
@@ -3,10 +3,10 @@
3
3
  "description": "Format API for roosterjs",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.1",
6
- "roosterjs-content-model-dom": "^9.45.0",
7
- "roosterjs-content-model-types": "^9.45.0"
6
+ "roosterjs-content-model-dom": "^9.45.2",
7
+ "roosterjs-content-model-types": "^9.45.2"
8
8
  },
9
- "version": "9.45.0",
9
+ "version": "9.45.2",
10
10
  "main": "./lib/index.js",
11
11
  "typings": "./lib/index.d.ts",
12
12
  "module": "./lib-mjs/index.js",