roosterjs-content-model-plugins 0.21.2 → 0.21.4

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 (280) hide show
  1. package/lib/edit/ContentModelEditPlugin.d.ts +35 -35
  2. package/lib/edit/ContentModelEditPlugin.js +75 -75
  3. package/lib/edit/ContentModelEditPlugin.js.map +1 -1
  4. package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  5. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +19 -19
  6. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  7. package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  8. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +90 -90
  9. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  10. package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  11. package/lib/edit/deleteSteps/deleteWordSelection.js +170 -170
  12. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  13. package/lib/edit/handleKeyboardEventCommon.d.ts +15 -15
  14. package/lib/edit/handleKeyboardEventCommon.js +54 -54
  15. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  16. package/lib/edit/keyboardDelete.d.ts +8 -8
  17. package/lib/edit/keyboardDelete.js +67 -67
  18. package/lib/edit/keyboardDelete.js.map +1 -1
  19. package/lib/edit/keyboardInput.d.ts +5 -5
  20. package/lib/edit/keyboardInput.js +50 -49
  21. package/lib/edit/keyboardInput.js.map +1 -1
  22. package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  23. package/lib/edit/utils/getLeafSiblingBlock.js +75 -75
  24. package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
  25. package/lib/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  26. package/lib/entityDelimiter/EntityDelimiterPlugin.js +256 -254
  27. package/lib/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  28. package/lib/index.d.ts +3 -3
  29. package/lib/index.js +9 -9
  30. package/lib/index.js.map +1 -1
  31. package/lib/paste/ContentModelPastePlugin.d.ts +42 -42
  32. package/lib/paste/ContentModelPastePlugin.js +148 -148
  33. package/lib/paste/ContentModelPastePlugin.js.map +1 -1
  34. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  35. package/lib/paste/Excel/processPastedContentFromExcel.js +82 -82
  36. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  37. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  38. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +19 -19
  39. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  40. package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  41. package/lib/paste/WacComponents/processPastedContentWacComponents.js +207 -207
  42. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  43. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  44. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +69 -69
  45. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  46. package/lib/paste/WordDesktop/processWordComments.d.ts +7 -7
  47. package/lib/paste/WordDesktop/processWordComments.js +21 -21
  48. package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
  49. package/lib/paste/WordDesktop/processWordLists.d.ts +10 -10
  50. package/lib/paste/WordDesktop/processWordLists.js +154 -154
  51. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  52. package/lib/paste/pasteSourceValidations/constants.d.ts +17 -17
  53. package/lib/paste/pasteSourceValidations/constants.js +21 -21
  54. package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
  55. package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  56. package/lib/paste/pasteSourceValidations/documentContainWacElements.js +24 -24
  57. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  58. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  59. package/lib/paste/pasteSourceValidations/getPasteSource.js +43 -43
  60. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  61. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  62. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +16 -16
  63. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  64. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  65. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +18 -18
  66. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  67. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  68. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +14 -14
  69. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  70. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  71. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +14 -14
  72. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  73. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  74. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +18 -18
  75. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  76. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  77. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +18 -18
  78. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  79. package/lib/paste/utils/addParser.d.ts +5 -5
  80. package/lib/paste/utils/addParser.js +16 -16
  81. package/lib/paste/utils/addParser.js.map +1 -1
  82. package/lib/paste/utils/deprecatedColorParser.d.ts +5 -5
  83. package/lib/paste/utils/deprecatedColorParser.js +19 -19
  84. package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
  85. package/lib/paste/utils/getStyles.d.ts +6 -6
  86. package/lib/paste/utils/getStyles.js +22 -22
  87. package/lib/paste/utils/getStyles.js.map +1 -1
  88. package/lib/paste/utils/linkParser.d.ts +5 -5
  89. package/lib/paste/utils/linkParser.js +27 -27
  90. package/lib/paste/utils/linkParser.js.map +1 -1
  91. package/lib/paste/utils/setProcessor.d.ts +5 -5
  92. package/lib/paste/utils/setProcessor.js +13 -13
  93. package/lib/paste/utils/setProcessor.js.map +1 -1
  94. package/lib-amd/edit/ContentModelEditPlugin.d.ts +35 -35
  95. package/lib-amd/edit/ContentModelEditPlugin.js +75 -75
  96. package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
  97. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  98. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +20 -20
  99. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  100. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  101. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +89 -89
  102. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  103. package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  104. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +169 -169
  105. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  106. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +15 -15
  107. package/lib-amd/edit/handleKeyboardEventCommon.js +55 -55
  108. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  109. package/lib-amd/edit/keyboardDelete.d.ts +8 -8
  110. package/lib-amd/edit/keyboardDelete.js +63 -63
  111. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  112. package/lib-amd/edit/keyboardInput.d.ts +5 -5
  113. package/lib-amd/edit/keyboardInput.js +50 -49
  114. package/lib-amd/edit/keyboardInput.js.map +1 -1
  115. package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  116. package/lib-amd/edit/utils/getLeafSiblingBlock.js +75 -75
  117. package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
  118. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  119. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js +255 -253
  120. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  121. package/lib-amd/index.d.ts +3 -3
  122. package/lib-amd/index.js +8 -8
  123. package/lib-amd/index.js.map +1 -1
  124. package/lib-amd/paste/ContentModelPastePlugin.d.ts +42 -42
  125. package/lib-amd/paste/ContentModelPastePlugin.js +140 -140
  126. package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
  127. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  128. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +80 -80
  129. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  130. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  131. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -20
  132. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  133. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  134. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +206 -206
  135. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  136. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  137. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
  138. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  139. package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -7
  140. package/lib-amd/paste/WordDesktop/processWordComments.js +22 -22
  141. package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
  142. package/lib-amd/paste/WordDesktop/processWordLists.d.ts +10 -10
  143. package/lib-amd/paste/WordDesktop/processWordLists.js +153 -153
  144. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  145. package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -17
  146. package/lib-amd/paste/pasteSourceValidations/constants.js +23 -23
  147. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
  148. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  149. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +26 -26
  150. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  151. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  152. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +38 -38
  153. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  154. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  155. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +18 -18
  156. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  157. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  158. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +20 -20
  159. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  160. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  161. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +16 -16
  162. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  163. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  164. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +16 -16
  165. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  166. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  167. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +20 -20
  168. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  169. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  170. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +20 -20
  171. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  172. package/lib-amd/paste/utils/addParser.d.ts +5 -5
  173. package/lib-amd/paste/utils/addParser.js +18 -18
  174. package/lib-amd/paste/utils/addParser.js.map +1 -1
  175. package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -5
  176. package/lib-amd/paste/utils/deprecatedColorParser.js +20 -20
  177. package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
  178. package/lib-amd/paste/utils/getStyles.d.ts +6 -6
  179. package/lib-amd/paste/utils/getStyles.js +24 -24
  180. package/lib-amd/paste/utils/getStyles.js.map +1 -1
  181. package/lib-amd/paste/utils/linkParser.d.ts +5 -5
  182. package/lib-amd/paste/utils/linkParser.js +28 -28
  183. package/lib-amd/paste/utils/linkParser.js.map +1 -1
  184. package/lib-amd/paste/utils/setProcessor.d.ts +5 -5
  185. package/lib-amd/paste/utils/setProcessor.js +15 -15
  186. package/lib-amd/paste/utils/setProcessor.js.map +1 -1
  187. package/lib-mjs/edit/ContentModelEditPlugin.d.ts +35 -35
  188. package/lib-mjs/edit/ContentModelEditPlugin.js +72 -72
  189. package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
  190. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  191. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +15 -15
  192. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  193. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  194. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +87 -87
  195. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  196. package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  197. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +167 -167
  198. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  199. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +15 -15
  200. package/lib-mjs/edit/handleKeyboardEventCommon.js +48 -48
  201. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  202. package/lib-mjs/edit/keyboardDelete.d.ts +8 -8
  203. package/lib-mjs/edit/keyboardDelete.js +63 -63
  204. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  205. package/lib-mjs/edit/keyboardInput.d.ts +5 -5
  206. package/lib-mjs/edit/keyboardInput.js +46 -45
  207. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  208. package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  209. package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
  210. package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
  211. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  212. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js +252 -250
  213. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  214. package/lib-mjs/index.d.ts +3 -3
  215. package/lib-mjs/index.js +3 -3
  216. package/lib-mjs/index.js.map +1 -1
  217. package/lib-mjs/paste/ContentModelPastePlugin.d.ts +42 -42
  218. package/lib-mjs/paste/ContentModelPastePlugin.js +145 -145
  219. package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
  220. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  221. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
  222. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  223. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  224. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +15 -15
  225. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  226. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  227. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +203 -203
  228. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  229. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  230. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
  231. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  232. package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -7
  233. package/lib-mjs/paste/WordDesktop/processWordComments.js +17 -17
  234. package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
  235. package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +10 -10
  236. package/lib-mjs/paste/WordDesktop/processWordLists.js +150 -150
  237. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  238. package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -17
  239. package/lib-mjs/paste/pasteSourceValidations/constants.js +18 -18
  240. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
  241. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  242. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +20 -20
  243. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  244. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  245. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +39 -39
  246. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  247. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  248. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +12 -12
  249. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  250. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  251. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +14 -14
  252. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  253. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  254. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +10 -10
  255. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  256. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  257. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +10 -10
  258. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  259. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  260. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +14 -14
  261. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  262. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  263. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +14 -14
  264. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  265. package/lib-mjs/paste/utils/addParser.d.ts +5 -5
  266. package/lib-mjs/paste/utils/addParser.js +13 -13
  267. package/lib-mjs/paste/utils/addParser.js.map +1 -1
  268. package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -5
  269. package/lib-mjs/paste/utils/deprecatedColorParser.js +15 -15
  270. package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
  271. package/lib-mjs/paste/utils/getStyles.d.ts +6 -6
  272. package/lib-mjs/paste/utils/getStyles.js +18 -18
  273. package/lib-mjs/paste/utils/getStyles.js.map +1 -1
  274. package/lib-mjs/paste/utils/linkParser.d.ts +5 -5
  275. package/lib-mjs/paste/utils/linkParser.js +23 -23
  276. package/lib-mjs/paste/utils/linkParser.js.map +1 -1
  277. package/lib-mjs/paste/utils/setProcessor.d.ts +5 -5
  278. package/lib-mjs/paste/utils/setProcessor.js +9 -9
  279. package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
  280. package/package.json +1 -1
@@ -1,64 +1,64 @@
1
- define(["require", "exports", "roosterjs-content-model-core", "./deleteSteps/deleteAllSegmentBefore", "roosterjs-content-model-dom", "./handleKeyboardEventCommon", "./deleteSteps/deleteWordSelection", "./deleteSteps/deleteCollapsedSelection"], function (require, exports, roosterjs_content_model_core_1, deleteAllSegmentBefore_1, roosterjs_content_model_dom_1, handleKeyboardEventCommon_1, deleteWordSelection_1, deleteCollapsedSelection_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.keyboardDelete = void 0;
5
- /**
6
- * @internal
7
- * Do keyboard event handling for DELETE/BACKSPACE key
8
- * @param editor The Content Model Editor
9
- * @param rawEvent DOM keyboard event
10
- */
11
- function keyboardDelete(editor, rawEvent) {
12
- var selection = editor.getDOMSelection();
13
- if (shouldDeleteWithContentModel(selection, rawEvent)) {
14
- editor.formatContentModel(function (model, context) {
15
- var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
16
- return (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
17
- }, {
18
- rawEvent: rawEvent,
19
- changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
20
- getChangeData: function () { return rawEvent.which; },
21
- apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
22
- });
23
- return true;
24
- }
25
- }
26
- exports.keyboardDelete = keyboardDelete;
27
- function getDeleteSteps(rawEvent, isMac) {
28
- var isForward = rawEvent.key == 'Delete';
29
- var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
30
- var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
31
- ? isForward
32
- ? deleteWordSelection_1.forwardDeleteWordSelection
33
- : deleteWordSelection_1.backwardDeleteWordSelection
34
- : null;
35
- var deleteCollapsedSelection = isForward
36
- ? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
37
- : deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
38
- return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];
39
- }
40
- function shouldDeleteWithContentModel(selection, rawEvent) {
41
- if (!selection) {
42
- return false; // Nothing to delete
43
- }
44
- else if (selection.type != 'range' || !selection.range.collapsed) {
45
- return true; // Selection is not collapsed, need to delete all selections
46
- }
47
- else {
48
- var range = selection.range;
49
- // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
50
- return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
51
- !(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
52
- (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
53
- }
54
- }
55
- function canDeleteBefore(rawEvent, range) {
56
- return rawEvent.key == 'Backspace' && range.startOffset > 1;
57
- }
58
- function canDeleteAfter(rawEvent, range) {
59
- var _a, _b;
60
- return (rawEvent.key == 'Delete' &&
61
- range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
62
- }
63
- });
1
+ define(["require", "exports", "roosterjs-content-model-core", "./deleteSteps/deleteAllSegmentBefore", "roosterjs-content-model-dom", "./handleKeyboardEventCommon", "./deleteSteps/deleteWordSelection", "./deleteSteps/deleteCollapsedSelection"], function (require, exports, roosterjs_content_model_core_1, deleteAllSegmentBefore_1, roosterjs_content_model_dom_1, handleKeyboardEventCommon_1, deleteWordSelection_1, deleteCollapsedSelection_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.keyboardDelete = void 0;
5
+ /**
6
+ * @internal
7
+ * Do keyboard event handling for DELETE/BACKSPACE key
8
+ * @param editor The Content Model Editor
9
+ * @param rawEvent DOM keyboard event
10
+ */
11
+ function keyboardDelete(editor, rawEvent) {
12
+ var selection = editor.getDOMSelection();
13
+ if (shouldDeleteWithContentModel(selection, rawEvent)) {
14
+ editor.formatContentModel(function (model, context) {
15
+ var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
16
+ return (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
17
+ }, {
18
+ rawEvent: rawEvent,
19
+ changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
20
+ getChangeData: function () { return rawEvent.which; },
21
+ apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
22
+ });
23
+ return true;
24
+ }
25
+ }
26
+ exports.keyboardDelete = keyboardDelete;
27
+ function getDeleteSteps(rawEvent, isMac) {
28
+ var isForward = rawEvent.key == 'Delete';
29
+ var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
30
+ var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
31
+ ? isForward
32
+ ? deleteWordSelection_1.forwardDeleteWordSelection
33
+ : deleteWordSelection_1.backwardDeleteWordSelection
34
+ : null;
35
+ var deleteCollapsedSelection = isForward
36
+ ? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
37
+ : deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
38
+ return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];
39
+ }
40
+ function shouldDeleteWithContentModel(selection, rawEvent) {
41
+ if (!selection) {
42
+ return false; // Nothing to delete
43
+ }
44
+ else if (selection.type != 'range' || !selection.range.collapsed) {
45
+ return true; // Selection is not collapsed, need to delete all selections
46
+ }
47
+ else {
48
+ var range = selection.range;
49
+ // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
50
+ return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
51
+ !(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
52
+ (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
53
+ }
54
+ }
55
+ function canDeleteBefore(rawEvent, range) {
56
+ return rawEvent.key == 'Backspace' && range.startOffset > 1;
57
+ }
58
+ function canDeleteAfter(rawEvent, range) {
59
+ var _a, _b;
60
+ return (rawEvent.key == 'Delete' &&
61
+ range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
62
+ }
63
+ });
64
64
  //# sourceMappingURL=keyboardDelete.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;;IAmBA;;;;;OAKG;IACH,SAAgB,cAAc,CAAC,MAA2B,EAAE,QAAuB;QAC/E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc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AAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;YAChE,OAAO,IAAI,CAAC,CAAC,4DAA4D;SAC5E;aAAM;YACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;YAE9B,oGAAoG;YACpG,OAAO,CAAC,CACJ,IAAA,0CAAY,EAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;gBAC/C,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;gBACxB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CACxE,CAAC;SACL;IACL,CAAC;IAED,SAAS,eAAe,CAAC,QAAuB,EAAE,KAAY;QAC1D,OAAO,QAAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;IAChE,CAAC;IAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;QACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;YACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;IACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\nimport {\n handleKeyboardEventResult,\n shouldDeleteAllSegmentsBefore,\n shouldDeleteWord,\n} from './handleKeyboardEventCommon';\nimport {\n backwardDeleteWordSelection,\n forwardDeleteWordSelection,\n} from './deleteSteps/deleteWordSelection';\nimport {\n backwardDeleteCollapsedSelection,\n forwardDeleteCollapsedSelection,\n} from './deleteSteps/deleteCollapsedSelection';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Do keyboard event handling for DELETE/BACKSPACE key\n * @param editor The Content Model Editor\n * @param rawEvent DOM keyboard event\n */\nexport function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(\n model,\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\n context\n ).deleteResult;\n\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\n },\n {\n rawEvent,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\n }\n );\n\n return true;\n }\n}\n\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\n const isForward = rawEvent.key == 'Delete';\n const deleteAllSegmentBeforeStep =\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\n ? isForward\n ? forwardDeleteWordSelection\n : backwardDeleteWordSelection\n : null;\n const deleteCollapsedSelection = isForward\n ? forwardDeleteCollapsedSelection\n : backwardDeleteCollapsedSelection;\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];\n}\n\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (selection.type != 'range' || !selection.range.collapsed) {\n return true; // Selection is not collapsed, need to delete all selections\n } else {\n const range = selection.range;\n\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\n return !(\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\n !isModifierKey(rawEvent) &&\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\n );\n }\n}\n\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\n}\n\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\n return (\n rawEvent.key == 'Delete' &&\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\n );\n}\n"]}
1
+ {"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;;IAmBA;;;;;OAKG;IACH,SAAgB,cAAc,CAAC,MAA2B,EAAE,QAAuB;QAC/E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,EACzD,OAAO,CACV,CAAC,YAAY,CAAC;gBAEf,OAAO,IAAA,qDAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YAC/E,CAAC,EACD;gBACI,QAAQ,UAAA;gBACR,YAAY,EAAE,2CAAY,CAAC,QAAQ;gBACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;gBACnC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,oBAAoB;aAC/E,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAxBD,wCAwBC;IAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAc;QAC3D,IAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,IAAI,QAAQ,CAAC;QAC3C,IAA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E,KAAY;;QACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;YACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;IACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\r\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\r\nimport {\r\n handleKeyboardEventResult,\r\n shouldDeleteAllSegmentsBefore,\r\n shouldDeleteWord,\r\n} from './handleKeyboardEventCommon';\r\nimport {\r\n backwardDeleteWordSelection,\r\n forwardDeleteWordSelection,\r\n} from './deleteSteps/deleteWordSelection';\r\nimport {\r\n backwardDeleteCollapsedSelection,\r\n forwardDeleteCollapsedSelection,\r\n} from './deleteSteps/deleteCollapsedSelection';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type { DOMSelection, DeleteSelectionStep } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n * Do keyboard event handling for DELETE/BACKSPACE key\r\n * @param editor The Content Model Editor\r\n * @param rawEvent DOM keyboard event\r\n */\r\nexport function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\r\n editor.formatContentModel(\r\n (model, context) => {\r\n const result = deleteSelection(\r\n model,\r\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\r\n context\r\n ).deleteResult;\r\n\r\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\r\n },\r\n {\r\n rawEvent,\r\n changeSource: ChangeSource.Keyboard,\r\n getChangeData: () => rawEvent.which,\r\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\r\n }\r\n );\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\r\n const isForward = rawEvent.key == 'Delete';\r\n const deleteAllSegmentBeforeStep =\r\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\r\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\r\n ? isForward\r\n ? forwardDeleteWordSelection\r\n : backwardDeleteWordSelection\r\n : null;\r\n const deleteCollapsedSelection = isForward\r\n ? forwardDeleteCollapsedSelection\r\n : backwardDeleteCollapsedSelection;\r\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];\r\n}\r\n\r\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\r\n if (!selection) {\r\n return false; // Nothing to delete\r\n } else if (selection.type != 'range' || !selection.range.collapsed) {\r\n return true; // Selection is not collapsed, need to delete all selections\r\n } else {\r\n const range = selection.range;\r\n\r\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\r\n return !(\r\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\r\n !isModifierKey(rawEvent) &&\r\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\r\n );\r\n }\r\n}\r\n\r\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\r\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\r\n}\r\n\r\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\r\n return (\r\n rawEvent.key == 'Delete' &&\r\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\r\n );\r\n}\r\n"]}
@@ -1,5 +1,5 @@
1
- import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
- /**
3
- * @internal
4
- */
5
- export declare function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
1
+ import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
@@ -1,50 +1,51 @@
1
- define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_core_1, roosterjs_content_model_dom_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.keyboardInput = void 0;
5
- /**
6
- * @internal
7
- */
8
- function keyboardInput(editor, rawEvent) {
9
- var selection = editor.getDOMSelection();
10
- if (shouldInputWithContentModel(selection, rawEvent)) {
11
- editor.addUndoSnapshot();
12
- editor.formatContentModel(function (model, context) {
13
- var _a;
14
- var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context);
15
- // We have deleted selection then we will let browser to handle the input.
16
- // With this combined operation, we don't wan to mass up the cached model so clear it
17
- context.clearModelCache = true;
18
- // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
19
- context.skipUndoSnapshot = true;
20
- if (result.deleteResult == 'range') {
21
- // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
22
- context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
23
- (0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
24
- // Do not preventDefault since we still want browser to handle the final input for now
25
- return true;
26
- }
27
- else {
28
- return false;
29
- }
30
- }, {
31
- rawEvent: rawEvent,
32
- });
33
- return true;
34
- }
35
- }
36
- exports.keyboardInput = keyboardInput;
37
- function shouldInputWithContentModel(selection, rawEvent) {
38
- if (!selection) {
39
- return false; // Nothing to delete
40
- }
41
- else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
42
- (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
43
- return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed
44
- }
45
- else {
46
- return false;
47
- }
48
- }
49
- });
1
+ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_core_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.keyboardInput = void 0;
5
+ /**
6
+ * @internal
7
+ */
8
+ function keyboardInput(editor, rawEvent) {
9
+ var selection = editor.getDOMSelection();
10
+ if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {
11
+ editor.addUndoSnapshot();
12
+ editor.formatContentModel(function (model, context) {
13
+ var _a;
14
+ var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context);
15
+ // We have deleted selection then we will let browser to handle the input.
16
+ // With this combined operation, we don't wan to mass up the cached model so clear it
17
+ context.clearModelCache = true;
18
+ // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
19
+ context.skipUndoSnapshot = true;
20
+ if (result.deleteResult == 'range') {
21
+ // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
22
+ context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
23
+ (0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
24
+ // Do not preventDefault since we still want browser to handle the final input for now
25
+ return true;
26
+ }
27
+ else {
28
+ return false;
29
+ }
30
+ }, {
31
+ rawEvent: rawEvent,
32
+ });
33
+ return true;
34
+ }
35
+ }
36
+ exports.keyboardInput = keyboardInput;
37
+ function shouldInputWithContentModel(selection, rawEvent, isInIME) {
38
+ if (!selection) {
39
+ return false; // Nothing to delete
40
+ }
41
+ else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
42
+ (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
43
+ return (selection.type != 'range' ||
44
+ (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)); // TODO: Also handle Enter key even selection is collapsed
45
+ }
46
+ else {
47
+ return false;
48
+ }
49
+ }
50
+ });
50
51
  //# sourceMappingURL=keyboardInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;QAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAClD,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;QACxF,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0DAA0D;SAC7H;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.addUndoSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;QAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;YACpE,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAChC,SAA8B,EAC9B,QAAuB,EACvB,OAAgB;QAEhB,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,CACH,SAAS,CAAC,IAAI,IAAI,OAAO;gBACzB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,CACpE,CAAC,CAAC,0DAA0D;SAChE;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type { DOMSelection } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {\r\n editor.addUndoSnapshot();\r\n\r\n editor.formatContentModel(\r\n (model, context) => {\r\n const result = deleteSelection(model, [], context);\r\n\r\n // We have deleted selection then we will let browser to handle the input.\r\n // With this combined operation, we don't wan to mass up the cached model so clear it\r\n context.clearModelCache = true;\r\n\r\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\r\n context.skipUndoSnapshot = true;\r\n\r\n if (result.deleteResult == 'range') {\r\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\r\n context.newPendingFormat = result.insertPoint?.marker.format;\r\n\r\n normalizeContentModel(model);\r\n\r\n // Do not preventDefault since we still want browser to handle the final input for now\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n },\r\n {\r\n rawEvent,\r\n }\r\n );\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction shouldInputWithContentModel(\r\n selection: DOMSelection | null,\r\n rawEvent: KeyboardEvent,\r\n isInIME: boolean\r\n) {\r\n if (!selection) {\r\n return false; // Nothing to delete\r\n } else if (\r\n !isModifierKey(rawEvent) &&\r\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\r\n ) {\r\n return (\r\n selection.type != 'range' ||\r\n (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)\r\n ); // TODO: Also handle Enter key even selection is collapsed\r\n } else {\r\n return false;\r\n }\r\n}\r\n"]}
@@ -1,23 +1,23 @@
1
- import type { ContentModelBlock, ContentModelBlockGroup, ContentModelSegment } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare type BlockAndPath = {
6
- /**
7
- * The sibling block
8
- */
9
- block: ContentModelBlock;
10
- /**
11
- * Path of this sibling block
12
- */
13
- path: ContentModelBlockGroup[];
14
- /**
15
- * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.
16
- * Use this property to return the sibling sibling under the same paragraph
17
- */
18
- siblingSegment?: ContentModelSegment;
19
- };
20
- /**
21
- * @internal
22
- */
23
- export declare function getLeafSiblingBlock(path: ContentModelBlockGroup[], block: ContentModelBlock, isNext: boolean): BlockAndPath | null;
1
+ import type { ContentModelBlock, ContentModelBlockGroup, ContentModelSegment } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare type BlockAndPath = {
6
+ /**
7
+ * The sibling block
8
+ */
9
+ block: ContentModelBlock;
10
+ /**
11
+ * Path of this sibling block
12
+ */
13
+ path: ContentModelBlockGroup[];
14
+ /**
15
+ * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.
16
+ * Use this property to return the sibling sibling under the same paragraph
17
+ */
18
+ siblingSegment?: ContentModelSegment;
19
+ };
20
+ /**
21
+ * @internal
22
+ */
23
+ export declare function getLeafSiblingBlock(path: ContentModelBlockGroup[], block: ContentModelBlock, isNext: boolean): BlockAndPath | null;
@@ -1,76 +1,76 @@
1
- define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getLeafSiblingBlock = void 0;
5
- /**
6
- * @internal
7
- */
8
- function getLeafSiblingBlock(path, block, isNext) {
9
- var _a;
10
- var newPath = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(path), false);
11
- var _loop_1 = function () {
12
- var group = newPath[0];
13
- var index = group.blocks.indexOf(block);
14
- if (index < 0) {
15
- return "break";
16
- }
17
- var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
18
- if (nextBlock) {
19
- while (nextBlock.blockType == 'BlockGroup') {
20
- var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
21
- if (!child) {
22
- return { value: { block: nextBlock, path: newPath } };
23
- }
24
- else if (child.blockType != 'BlockGroup') {
25
- newPath.unshift(nextBlock);
26
- return { value: { block: child, path: newPath } };
27
- }
28
- else {
29
- newPath.unshift(nextBlock);
30
- nextBlock = child;
31
- }
32
- }
33
- return { value: { block: nextBlock, path: newPath } };
34
- }
35
- else if ((0, roosterjs_content_model_dom_1.isGeneralSegment)(group)) {
36
- // For general segment, we need to check if there is sibling segment under the same paragraph
37
- // First let's find the parent paragraph of this segment
38
- newPath.shift();
39
- var segmentIndex_1 = -1;
40
- var segment_1 = group;
41
- var para = (_a = newPath[0]) === null || _a === void 0 ? void 0 : _a.blocks.find(function (x) { return x.blockType == 'Paragraph' && (segmentIndex_1 = x.segments.indexOf(segment_1)) >= 0; });
42
- if (para) {
43
- // Now we have found the parent paragraph, so let's check if it has a sibling segment
44
- var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
45
- if (siblingSegment) {
46
- return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
47
- }
48
- else {
49
- // No sibling segment, let's keep go upper level
50
- block = para;
51
- }
52
- }
53
- else {
54
- return "break";
55
- }
56
- }
57
- else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
58
- newPath.shift();
59
- block = group;
60
- }
61
- else {
62
- return "break";
63
- }
64
- };
65
- while (newPath.length > 0) {
66
- var state_1 = _loop_1();
67
- if (typeof state_1 === "object")
68
- return state_1.value;
69
- if (state_1 === "break")
70
- break;
71
- }
72
- return null;
73
- }
74
- exports.getLeafSiblingBlock = getLeafSiblingBlock;
75
- });
1
+ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function (require, exports, tslib_1, roosterjs_content_model_dom_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getLeafSiblingBlock = void 0;
5
+ /**
6
+ * @internal
7
+ */
8
+ function getLeafSiblingBlock(path, block, isNext) {
9
+ var _a;
10
+ var newPath = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(path), false);
11
+ var _loop_1 = function () {
12
+ var group = newPath[0];
13
+ var index = group.blocks.indexOf(block);
14
+ if (index < 0) {
15
+ return "break";
16
+ }
17
+ var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
18
+ if (nextBlock) {
19
+ while (nextBlock.blockType == 'BlockGroup') {
20
+ var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
21
+ if (!child) {
22
+ return { value: { block: nextBlock, path: newPath } };
23
+ }
24
+ else if (child.blockType != 'BlockGroup') {
25
+ newPath.unshift(nextBlock);
26
+ return { value: { block: child, path: newPath } };
27
+ }
28
+ else {
29
+ newPath.unshift(nextBlock);
30
+ nextBlock = child;
31
+ }
32
+ }
33
+ return { value: { block: nextBlock, path: newPath } };
34
+ }
35
+ else if ((0, roosterjs_content_model_dom_1.isGeneralSegment)(group)) {
36
+ // For general segment, we need to check if there is sibling segment under the same paragraph
37
+ // First let's find the parent paragraph of this segment
38
+ newPath.shift();
39
+ var segmentIndex_1 = -1;
40
+ var segment_1 = group;
41
+ var para = (_a = newPath[0]) === null || _a === void 0 ? void 0 : _a.blocks.find(function (x) { return x.blockType == 'Paragraph' && (segmentIndex_1 = x.segments.indexOf(segment_1)) >= 0; });
42
+ if (para) {
43
+ // Now we have found the parent paragraph, so let's check if it has a sibling segment
44
+ var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
45
+ if (siblingSegment) {
46
+ return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
47
+ }
48
+ else {
49
+ // No sibling segment, let's keep go upper level
50
+ block = para;
51
+ }
52
+ }
53
+ else {
54
+ return "break";
55
+ }
56
+ }
57
+ else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
58
+ newPath.shift();
59
+ block = group;
60
+ }
61
+ else {
62
+ return "break";
63
+ }
64
+ };
65
+ while (newPath.length > 0) {
66
+ var state_1 = _loop_1();
67
+ if (typeof state_1 === "object")
68
+ return state_1.value;
69
+ if (state_1 === "break")
70
+ break;
71
+ }
72
+ return null;
73
+ }
74
+ exports.getLeafSiblingBlock = getLeafSiblingBlock;
75
+ });
76
76
  //# sourceMappingURL=getLeafSiblingBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/utils/getLeafSiblingBlock.ts"],"names":[],"mappings":";;;;IA6BA;;OAEG;IACH,SAAgB,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;QAEf,IAAM,OAAO,sDAAO,IAAI,SAAC,CAAC;;YAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;aAEd;YAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExD,IAAI,SAAS,EAAE;gBACX,OAAO,SAAS,CAAC,SAAS,IAAI,YAAY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AAC,CAAC,CAAC;oBAEvE,IAAI,cAAc,EAAE;wCAET,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,gBAAA,EAAE;qBACxD;yBAAM;wBACH,gDAAgD;wBAChD,KAAK,GAAG,IAAI,CAAC;qBAChB;iBACJ;qBAAM;;iBAGN;aACJ;iBAAM,IAAI,KAAK,CAAC,cAAc,IAAI,UAAU,IAAI,KAAK,CAAC,cAAc,IAAI,WAAW,EAAE;gBAClF,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,KAAK,GAAG,KAAK,CAAC;aACjB;iBAAM;;aAEN;;QAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;SA0DxB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IApED,kDAoEC","sourcesContent":["import { isGeneralSegment } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelParagraph,\n ContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport type BlockAndPath = {\n /**\n * The sibling block\n */\n block: ContentModelBlock;\n\n /**\n * Path of this sibling block\n */\n path: ContentModelBlockGroup[];\n\n /**\n * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.\n * Use this property to return the sibling sibling under the same paragraph\n */\n siblingSegment?: ContentModelSegment;\n};\n\n/**\n * @internal\n */\nexport function getLeafSiblingBlock(\n path: ContentModelBlockGroup[],\n block: ContentModelBlock,\n isNext: boolean\n): BlockAndPath | null {\n const newPath = [...path];\n\n while (newPath.length > 0) {\n const group = newPath[0];\n const index = group.blocks.indexOf(block);\n\n if (index < 0) {\n break;\n }\n\n let nextBlock = group.blocks[index + (isNext ? 1 : -1)];\n\n if (nextBlock) {\n while (nextBlock.blockType == 'BlockGroup') {\n const child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];\n\n if (!child) {\n return { block: nextBlock, path: newPath };\n } else if (child.blockType != 'BlockGroup') {\n newPath.unshift(nextBlock);\n return { block: child, path: newPath };\n } else {\n newPath.unshift(nextBlock);\n nextBlock = child;\n }\n }\n\n return { block: nextBlock, path: newPath };\n } else if (isGeneralSegment(group)) {\n // For general segment, we need to check if there is sibling segment under the same paragraph\n // First let's find the parent paragraph of this segment\n newPath.shift();\n\n let segmentIndex = -1;\n const segment = group;\n const para = newPath[0]?.blocks.find(\n x => x.blockType == 'Paragraph' && (segmentIndex = x.segments.indexOf(segment)) >= 0\n ) as ContentModelParagraph;\n\n if (para) {\n // Now we have found the parent paragraph, so let's check if it has a sibling segment\n const siblingSegment = para.segments[segmentIndex + (isNext ? 1 : -1)];\n\n if (siblingSegment) {\n // Return this block, path and segment since we have found it\n return { block: para, path: newPath, siblingSegment };\n } else {\n // No sibling segment, let's keep go upper level\n block = para;\n }\n } else {\n // Parent sibling is not found (in theory this should never happen), just return null\n break;\n }\n } else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {\n newPath.shift();\n block = group;\n } else {\n break;\n }\n }\n\n return null;\n}\n"]}
1
+ {"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/utils/getLeafSiblingBlock.ts"],"names":[],"mappings":";;;;IA6BA;;OAEG;IACH,SAAgB,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;QAEf,IAAM,OAAO,sDAAO,IAAI,SAAC,CAAC;;YAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;aAEd;YAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExD,IAAI,S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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAEvE,IAAI,cAAc,EAAE;wCAET,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,gBAAA,EAAE;qBACxD;yBAAM;wBACH,gDAAgD;wBAChD,KAAK,GAAG,IAAI,CAAC;qBAChB;iBACJ;qBAAM;;iBAGN;aACJ;iBAAM,IAAI,KAAK,CAAC,cAAc,IAAI,UAAU,IAAI,KAAK,CAAC,cAAc,IAAI,WAAW,EAAE;gBAClF,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,KAAK,GAAG,KAAK,CAAC;aACjB;iBAAM;;aAEN;;QAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;SA0DxB;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IApED,kDAoEC","sourcesContent":["import { isGeneralSegment } from 'roosterjs-content-model-dom';\r\nimport type {\r\n ContentModelBlock,\r\n ContentModelBlockGroup,\r\n ContentModelParagraph,\r\n ContentModelSegment,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type BlockAndPath = {\r\n /**\r\n * The sibling block\r\n */\r\n block: ContentModelBlock;\r\n\r\n /**\r\n * Path of this sibling block\r\n */\r\n path: ContentModelBlockGroup[];\r\n\r\n /**\r\n * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.\r\n * Use this property to return the sibling sibling under the same paragraph\r\n */\r\n siblingSegment?: ContentModelSegment;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getLeafSiblingBlock(\r\n path: ContentModelBlockGroup[],\r\n block: ContentModelBlock,\r\n isNext: boolean\r\n): BlockAndPath | null {\r\n const newPath = [...path];\r\n\r\n while (newPath.length > 0) {\r\n const group = newPath[0];\r\n const index = group.blocks.indexOf(block);\r\n\r\n if (index < 0) {\r\n break;\r\n }\r\n\r\n let nextBlock = group.blocks[index + (isNext ? 1 : -1)];\r\n\r\n if (nextBlock) {\r\n while (nextBlock.blockType == 'BlockGroup') {\r\n const child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];\r\n\r\n if (!child) {\r\n return { block: nextBlock, path: newPath };\r\n } else if (child.blockType != 'BlockGroup') {\r\n newPath.unshift(nextBlock);\r\n return { block: child, path: newPath };\r\n } else {\r\n newPath.unshift(nextBlock);\r\n nextBlock = child;\r\n }\r\n }\r\n\r\n return { block: nextBlock, path: newPath };\r\n } else if (isGeneralSegment(group)) {\r\n // For general segment, we need to check if there is sibling segment under the same paragraph\r\n // First let's find the parent paragraph of this segment\r\n newPath.shift();\r\n\r\n let segmentIndex = -1;\r\n const segment = group;\r\n const para = newPath[0]?.blocks.find(\r\n x => x.blockType == 'Paragraph' && (segmentIndex = x.segments.indexOf(segment)) >= 0\r\n ) as ContentModelParagraph;\r\n\r\n if (para) {\r\n // Now we have found the parent paragraph, so let's check if it has a sibling segment\r\n const siblingSegment = para.segments[segmentIndex + (isNext ? 1 : -1)];\r\n\r\n if (siblingSegment) {\r\n // Return this block, path and segment since we have found it\r\n return { block: para, path: newPath, siblingSegment };\r\n } else {\r\n // No sibling segment, let's keep go upper level\r\n block = para;\r\n }\r\n } else {\r\n // Parent sibling is not found (in theory this should never happen), just return null\r\n break;\r\n }\r\n } else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {\r\n newPath.shift();\r\n block = group;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n"]}
@@ -1,35 +1,35 @@
1
- import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
2
- /**
3
- * Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
4
- */
5
- export declare class EntityDelimiterPlugin implements EditorPlugin {
6
- private editor;
7
- /**
8
- * Get a friendly name of this plugin
9
- */
10
- getName(): string;
11
- /**
12
- * The first method that editor will call to a plugin when editor is initializing.
13
- * It will pass in the editor instance, plugin should take this chance to save the
14
- * editor reference so that it can call to any editor method or format API later.
15
- * @param editor The editor object
16
- */
17
- initialize(editor: IEditor): void;
18
- /**
19
- * The last method that editor will call to a plugin before it is disposed.
20
- * Plugin can take this chance to clear the reference to editor. After this method is
21
- * called, plugin should not call to any editor method since it will result in error.
22
- */
23
- dispose(): void;
24
- /**
25
- * Core method for a plugin. Once an event happens in editor, editor will call this
26
- * method of each plugin to handle the event as long as the event is not handled
27
- * exclusively by another plugin.
28
- * @param event The event to handle:
29
- */
30
- onPluginEvent(event: PluginEvent): void;
31
- }
32
- /**
33
- * @internal
34
- */
35
- export declare function normalizeDelimitersInEditor(editor: IEditor): void;
1
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
2
+ /**
3
+ * Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
4
+ */
5
+ export declare class EntityDelimiterPlugin implements EditorPlugin {
6
+ private editor;
7
+ /**
8
+ * Get a friendly name of this plugin
9
+ */
10
+ getName(): string;
11
+ /**
12
+ * The first method that editor will call to a plugin when editor is initializing.
13
+ * It will pass in the editor instance, plugin should take this chance to save the
14
+ * editor reference so that it can call to any editor method or format API later.
15
+ * @param editor The editor object
16
+ */
17
+ initialize(editor: IEditor): void;
18
+ /**
19
+ * The last method that editor will call to a plugin before it is disposed.
20
+ * Plugin can take this chance to clear the reference to editor. After this method is
21
+ * called, plugin should not call to any editor method since it will result in error.
22
+ */
23
+ dispose(): void;
24
+ /**
25
+ * Core method for a plugin. Once an event happens in editor, editor will call this
26
+ * method of each plugin to handle the event as long as the event is not handled
27
+ * exclusively by another plugin.
28
+ * @param event The event to handle:
29
+ */
30
+ onPluginEvent(event: PluginEvent): void;
31
+ }
32
+ /**
33
+ * @internal
34
+ */
35
+ export declare function normalizeDelimitersInEditor(editor: IEditor): void;