roosterjs-content-model-plugins 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (463) hide show
  1. package/{lib-mjs/autoFormat/ContentModelAutoFormatPlugin.d.ts → lib/autoFormat/AutoFormatPlugin.d.ts} +53 -53
  2. package/lib/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +81 -81
  3. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -0
  4. package/lib/autoFormat/keyboardListTrigger.d.ts +5 -5
  5. package/lib/autoFormat/keyboardListTrigger.js +45 -45
  6. package/lib/autoFormat/keyboardListTrigger.js.map +1 -1
  7. package/lib/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
  8. package/lib/autoFormat/utils/convertAlphaToDecimals.js +22 -22
  9. package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
  10. package/lib/autoFormat/utils/getIndex.d.ts +4 -4
  11. package/lib/autoFormat/utils/getIndex.js +13 -13
  12. package/lib/autoFormat/utils/getIndex.js.map +1 -1
  13. package/lib/autoFormat/utils/getListTypeStyle.d.ts +14 -14
  14. package/lib/autoFormat/utils/getListTypeStyle.js +87 -79
  15. package/lib/autoFormat/utils/getListTypeStyle.js.map +1 -1
  16. package/lib/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
  17. package/lib/autoFormat/utils/getNumberingListStyle.js +153 -152
  18. package/lib/autoFormat/utils/getNumberingListStyle.js.map +1 -1
  19. package/{lib-amd/edit/ContentModelEditPlugin.d.ts → lib/edit/EditPlugin.d.ts} +39 -35
  20. package/lib/edit/EditPlugin.js +129 -0
  21. package/lib/edit/EditPlugin.js.map +1 -0
  22. package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  23. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +22 -22
  24. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  25. package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  26. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +93 -93
  27. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  28. package/lib/edit/deleteSteps/deleteList.d.ts +5 -5
  29. package/lib/edit/deleteSteps/deleteList.js +23 -23
  30. package/lib/edit/deleteSteps/deleteList.js.map +1 -1
  31. package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  32. package/lib/edit/deleteSteps/deleteWordSelection.js +173 -173
  33. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  34. package/lib/edit/handleKeyboardEventCommon.d.ts +14 -14
  35. package/lib/edit/handleKeyboardEventCommon.js +54 -54
  36. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  37. package/lib/edit/inputSteps/handleEnterOnList.d.ts +5 -0
  38. package/lib/edit/inputSteps/handleEnterOnList.js +68 -0
  39. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -0
  40. package/lib/edit/keyboardDelete.d.ts +9 -8
  41. package/lib/edit/keyboardDelete.js +71 -74
  42. package/lib/edit/keyboardDelete.js.map +1 -1
  43. package/lib/edit/keyboardInput.d.ts +5 -5
  44. package/lib/edit/keyboardInput.js +58 -50
  45. package/lib/edit/keyboardInput.js.map +1 -1
  46. package/lib/edit/keyboardTab.d.ts +5 -0
  47. package/lib/edit/keyboardTab.js +35 -0
  48. package/lib/edit/keyboardTab.js.map +1 -0
  49. package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  50. package/lib/edit/utils/getLeafSiblingBlock.js +75 -75
  51. package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
  52. package/lib/index.d.ts +3 -3
  53. package/lib/index.js +9 -9
  54. package/lib/index.js.map +1 -1
  55. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
  56. package/lib/paste/Excel/processPastedContentFromExcel.js +82 -82
  57. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  58. package/{lib-amd/paste/ContentModelPastePlugin.d.ts → lib/paste/PastePlugin.d.ts} +43 -43
  59. package/lib/paste/{ContentModelPastePlugin.js → PastePlugin.js} +131 -131
  60. package/lib/paste/PastePlugin.js.map +1 -0
  61. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  62. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +19 -19
  63. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  64. package/lib/paste/WacComponents/constants.d.ts +48 -48
  65. package/lib/paste/WacComponents/constants.js +62 -62
  66. package/lib/paste/WacComponents/constants.js.map +1 -1
  67. package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  68. package/lib/paste/WacComponents/processPastedContentWacComponents.js +188 -188
  69. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  70. package/lib/paste/WordDesktop/WordMetadata.d.ts +9 -9
  71. package/lib/paste/WordDesktop/WordMetadata.js +2 -2
  72. package/lib/paste/WordDesktop/WordMetadata.js.map +1 -1
  73. package/lib/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
  74. package/lib/paste/WordDesktop/getStyleMetadata.js +78 -78
  75. package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  76. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
  77. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +58 -58
  78. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  79. package/lib/paste/WordDesktop/processWordComments.d.ts +7 -7
  80. package/lib/paste/WordDesktop/processWordComments.js +21 -21
  81. package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
  82. package/lib/paste/WordDesktop/processWordLists.d.ts +11 -11
  83. package/lib/paste/WordDesktop/processWordLists.js +179 -179
  84. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  85. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
  86. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +13 -13
  87. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  88. package/lib/paste/pasteSourceValidations/constants.d.ts +17 -17
  89. package/lib/paste/pasteSourceValidations/constants.js +20 -20
  90. package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
  91. package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  92. package/lib/paste/pasteSourceValidations/documentContainWacElements.js +15 -15
  93. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  94. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  95. package/lib/paste/pasteSourceValidations/getPasteSource.js +43 -43
  96. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  97. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  98. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +17 -17
  99. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  100. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  101. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +19 -19
  102. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  103. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  104. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +15 -15
  105. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  106. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  107. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +15 -15
  108. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  109. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  110. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +19 -19
  111. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  112. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  113. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +18 -18
  114. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  115. package/lib/paste/utils/addParser.d.ts +5 -5
  116. package/lib/paste/utils/addParser.js +16 -16
  117. package/lib/paste/utils/addParser.js.map +1 -1
  118. package/lib/paste/utils/deprecatedColorParser.d.ts +5 -5
  119. package/lib/paste/utils/deprecatedColorParser.js +19 -19
  120. package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
  121. package/lib/paste/utils/getStyles.d.ts +6 -6
  122. package/lib/paste/utils/getStyles.js +22 -22
  123. package/lib/paste/utils/getStyles.js.map +1 -1
  124. package/lib/paste/utils/linkParser.d.ts +5 -5
  125. package/lib/paste/utils/linkParser.js +27 -27
  126. package/lib/paste/utils/linkParser.js.map +1 -1
  127. package/lib/paste/utils/setProcessor.d.ts +5 -5
  128. package/lib/paste/utils/setProcessor.js +13 -13
  129. package/lib/paste/utils/setProcessor.js.map +1 -1
  130. package/lib/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
  131. package/lib/pluginUtils/CreateElement/CreateElementData.js +3 -0
  132. package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
  133. package/lib/pluginUtils/CreateElement/createElement.d.ts +9 -0
  134. package/lib/pluginUtils/CreateElement/createElement.js +51 -0
  135. package/lib/pluginUtils/CreateElement/createElement.js.map +1 -0
  136. package/lib/pluginUtils/Disposable.d.ts +10 -0
  137. package/lib/pluginUtils/Disposable.js +3 -0
  138. package/lib/pluginUtils/Disposable.js.map +1 -0
  139. package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
  140. package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js +3 -0
  141. package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
  142. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
  143. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +120 -0
  144. package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
  145. package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
  146. package/lib/pluginUtils/Rect/getIntersectedRect.js +45 -0
  147. package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
  148. package/lib/pluginUtils/Rect/normalizeRect.d.ts +7 -0
  149. package/lib/pluginUtils/Rect/normalizeRect.js +20 -0
  150. package/lib/pluginUtils/Rect/normalizeRect.js.map +1 -0
  151. package/lib-amd/autoFormat/{ContentModelAutoFormatPlugin.d.ts → AutoFormatPlugin.d.ts} +53 -53
  152. package/lib-amd/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +82 -82
  153. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -0
  154. package/lib-amd/autoFormat/keyboardListTrigger.d.ts +5 -5
  155. package/lib-amd/autoFormat/keyboardListTrigger.js +43 -43
  156. package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -1
  157. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
  158. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js +24 -24
  159. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
  160. package/lib-amd/autoFormat/utils/getIndex.d.ts +4 -4
  161. package/lib-amd/autoFormat/utils/getIndex.js +14 -14
  162. package/lib-amd/autoFormat/utils/getIndex.js.map +1 -1
  163. package/lib-amd/autoFormat/utils/getListTypeStyle.d.ts +14 -14
  164. package/lib-amd/autoFormat/utils/getListTypeStyle.js +86 -78
  165. package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +1 -1
  166. package/lib-amd/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
  167. package/lib-amd/autoFormat/utils/getNumberingListStyle.js +153 -152
  168. package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +1 -1
  169. package/{lib-mjs/edit/ContentModelEditPlugin.d.ts → lib-amd/edit/EditPlugin.d.ts} +39 -35
  170. package/lib-amd/edit/EditPlugin.js +128 -0
  171. package/lib-amd/edit/EditPlugin.js.map +1 -0
  172. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  173. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +23 -23
  174. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  175. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  176. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +92 -92
  177. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  178. package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -5
  179. package/lib-amd/edit/deleteSteps/deleteList.js +24 -24
  180. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
  181. package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  182. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +172 -172
  183. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  184. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +14 -14
  185. package/lib-amd/edit/handleKeyboardEventCommon.js +55 -55
  186. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  187. package/lib-amd/edit/inputSteps/handleEnterOnList.d.ts +5 -0
  188. package/lib-amd/edit/inputSteps/handleEnterOnList.js +67 -0
  189. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -0
  190. package/lib-amd/edit/keyboardDelete.d.ts +9 -8
  191. package/lib-amd/edit/keyboardDelete.js +66 -69
  192. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  193. package/lib-amd/edit/keyboardInput.d.ts +5 -5
  194. package/lib-amd/edit/keyboardInput.js +57 -50
  195. package/lib-amd/edit/keyboardInput.js.map +1 -1
  196. package/lib-amd/edit/keyboardTab.d.ts +5 -0
  197. package/lib-amd/edit/keyboardTab.js +35 -0
  198. package/lib-amd/edit/keyboardTab.js.map +1 -0
  199. package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  200. package/lib-amd/edit/utils/getLeafSiblingBlock.js +75 -75
  201. package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
  202. package/lib-amd/index.d.ts +3 -3
  203. package/lib-amd/index.js +8 -8
  204. package/lib-amd/index.js.map +1 -1
  205. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
  206. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +80 -80
  207. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  208. package/{lib/paste/ContentModelPastePlugin.d.ts → lib-amd/paste/PastePlugin.d.ts} +43 -43
  209. package/lib-amd/paste/{ContentModelPastePlugin.js → PastePlugin.js} +123 -123
  210. package/lib-amd/paste/PastePlugin.js.map +1 -0
  211. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  212. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -20
  213. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  214. package/lib-amd/paste/WacComponents/constants.d.ts +48 -48
  215. package/lib-amd/paste/WacComponents/constants.js +63 -63
  216. package/lib-amd/paste/WacComponents/constants.js.map +1 -1
  217. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  218. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +185 -185
  219. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  220. package/lib-amd/paste/WordDesktop/WordMetadata.d.ts +9 -9
  221. package/lib-amd/paste/WordDesktop/WordMetadata.js +4 -4
  222. package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -1
  223. package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
  224. package/lib-amd/paste/WordDesktop/getStyleMetadata.js +78 -78
  225. package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  226. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
  227. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +53 -53
  228. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  229. package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -7
  230. package/lib-amd/paste/WordDesktop/processWordComments.js +22 -22
  231. package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
  232. package/lib-amd/paste/WordDesktop/processWordLists.d.ts +11 -11
  233. package/lib-amd/paste/WordDesktop/processWordLists.js +177 -177
  234. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  235. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
  236. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +15 -15
  237. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  238. package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -17
  239. package/lib-amd/paste/pasteSourceValidations/constants.js +22 -22
  240. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
  241. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  242. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +16 -16
  243. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  244. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  245. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +38 -38
  246. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  247. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  248. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +18 -18
  249. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  250. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  251. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +20 -20
  252. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  253. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  254. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +16 -16
  255. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  256. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  257. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +16 -16
  258. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  259. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  260. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +20 -20
  261. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  262. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  263. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +20 -20
  264. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  265. package/lib-amd/paste/utils/addParser.d.ts +5 -5
  266. package/lib-amd/paste/utils/addParser.js +18 -18
  267. package/lib-amd/paste/utils/addParser.js.map +1 -1
  268. package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -5
  269. package/lib-amd/paste/utils/deprecatedColorParser.js +20 -20
  270. package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
  271. package/lib-amd/paste/utils/getStyles.d.ts +6 -6
  272. package/lib-amd/paste/utils/getStyles.js +24 -24
  273. package/lib-amd/paste/utils/getStyles.js.map +1 -1
  274. package/lib-amd/paste/utils/linkParser.d.ts +5 -5
  275. package/lib-amd/paste/utils/linkParser.js +28 -28
  276. package/lib-amd/paste/utils/linkParser.js.map +1 -1
  277. package/lib-amd/paste/utils/setProcessor.d.ts +5 -5
  278. package/lib-amd/paste/utils/setProcessor.js +15 -15
  279. package/lib-amd/paste/utils/setProcessor.js.map +1 -1
  280. package/lib-amd/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
  281. package/lib-amd/pluginUtils/CreateElement/CreateElementData.js +5 -0
  282. package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
  283. package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +9 -0
  284. package/lib-amd/pluginUtils/CreateElement/createElement.js +52 -0
  285. package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -0
  286. package/lib-amd/pluginUtils/Disposable.d.ts +10 -0
  287. package/lib-amd/pluginUtils/Disposable.js +5 -0
  288. package/lib-amd/pluginUtils/Disposable.js.map +1 -0
  289. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
  290. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js +5 -0
  291. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
  292. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
  293. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +121 -0
  294. package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
  295. package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
  296. package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +45 -0
  297. package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
  298. package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +7 -0
  299. package/lib-amd/pluginUtils/Rect/normalizeRect.js +22 -0
  300. package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +1 -0
  301. package/{lib/autoFormat/ContentModelAutoFormatPlugin.d.ts → lib-mjs/autoFormat/AutoFormatPlugin.d.ts} +53 -53
  302. package/lib-mjs/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +78 -78
  303. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -0
  304. package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +5 -5
  305. package/lib-mjs/autoFormat/keyboardListTrigger.js +41 -41
  306. package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -1
  307. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
  308. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js +18 -18
  309. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
  310. package/lib-mjs/autoFormat/utils/getIndex.d.ts +4 -4
  311. package/lib-mjs/autoFormat/utils/getIndex.js +9 -9
  312. package/lib-mjs/autoFormat/utils/getIndex.js.map +1 -1
  313. package/lib-mjs/autoFormat/utils/getListTypeStyle.d.ts +14 -14
  314. package/lib-mjs/autoFormat/utils/getListTypeStyle.js +83 -75
  315. package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +1 -1
  316. package/lib-mjs/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
  317. package/lib-mjs/autoFormat/utils/getNumberingListStyle.js +149 -148
  318. package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +1 -1
  319. package/{lib/edit/ContentModelEditPlugin.d.ts → lib-mjs/edit/EditPlugin.d.ts} +39 -35
  320. package/lib-mjs/edit/EditPlugin.js +126 -0
  321. package/lib-mjs/edit/EditPlugin.js.map +1 -0
  322. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  323. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +18 -18
  324. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  325. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  326. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +90 -90
  327. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  328. package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -5
  329. package/lib-mjs/edit/deleteSteps/deleteList.js +19 -19
  330. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
  331. package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  332. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +170 -170
  333. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  334. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +14 -14
  335. package/lib-mjs/edit/handleKeyboardEventCommon.js +48 -48
  336. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  337. package/lib-mjs/edit/inputSteps/handleEnterOnList.d.ts +5 -0
  338. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +64 -0
  339. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -0
  340. package/lib-mjs/edit/keyboardDelete.d.ts +9 -8
  341. package/lib-mjs/edit/keyboardDelete.js +67 -70
  342. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  343. package/lib-mjs/edit/keyboardInput.d.ts +5 -5
  344. package/lib-mjs/edit/keyboardInput.js +54 -46
  345. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  346. package/lib-mjs/edit/keyboardTab.d.ts +5 -0
  347. package/lib-mjs/edit/keyboardTab.js +31 -0
  348. package/lib-mjs/edit/keyboardTab.js.map +1 -0
  349. package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  350. package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
  351. package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
  352. package/lib-mjs/index.d.ts +3 -3
  353. package/lib-mjs/index.js +3 -3
  354. package/lib-mjs/index.js.map +1 -1
  355. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
  356. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
  357. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  358. package/lib-mjs/paste/{ContentModelPastePlugin.d.ts → PastePlugin.d.ts} +43 -43
  359. package/lib-mjs/paste/{ContentModelPastePlugin.js → PastePlugin.js} +128 -128
  360. package/lib-mjs/paste/PastePlugin.js.map +1 -0
  361. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  362. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +15 -15
  363. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  364. package/lib-mjs/paste/WacComponents/constants.d.ts +48 -48
  365. package/lib-mjs/paste/WacComponents/constants.js +59 -59
  366. package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
  367. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  368. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +184 -184
  369. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  370. package/lib-mjs/paste/WordDesktop/WordMetadata.d.ts +9 -9
  371. package/lib-mjs/paste/WordDesktop/WordMetadata.js +1 -1
  372. package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -1
  373. package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
  374. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +75 -75
  375. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  376. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
  377. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +54 -54
  378. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  379. package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -7
  380. package/lib-mjs/paste/WordDesktop/processWordComments.js +17 -17
  381. package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
  382. package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +11 -11
  383. package/lib-mjs/paste/WordDesktop/processWordLists.js +175 -175
  384. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  385. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
  386. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +9 -9
  387. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
  388. package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -17
  389. package/lib-mjs/paste/pasteSourceValidations/constants.js +17 -17
  390. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
  391. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  392. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +11 -11
  393. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  394. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  395. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +39 -39
  396. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  397. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  398. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +13 -13
  399. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  400. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  401. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +15 -15
  402. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  403. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  404. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +11 -11
  405. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  406. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  407. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +11 -11
  408. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  409. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  410. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +15 -15
  411. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  412. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  413. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +14 -14
  414. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  415. package/lib-mjs/paste/utils/addParser.d.ts +5 -5
  416. package/lib-mjs/paste/utils/addParser.js +13 -13
  417. package/lib-mjs/paste/utils/addParser.js.map +1 -1
  418. package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -5
  419. package/lib-mjs/paste/utils/deprecatedColorParser.js +15 -15
  420. package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
  421. package/lib-mjs/paste/utils/getStyles.d.ts +6 -6
  422. package/lib-mjs/paste/utils/getStyles.js +18 -18
  423. package/lib-mjs/paste/utils/getStyles.js.map +1 -1
  424. package/lib-mjs/paste/utils/linkParser.d.ts +5 -5
  425. package/lib-mjs/paste/utils/linkParser.js +23 -23
  426. package/lib-mjs/paste/utils/linkParser.js.map +1 -1
  427. package/lib-mjs/paste/utils/setProcessor.d.ts +5 -5
  428. package/lib-mjs/paste/utils/setProcessor.js +9 -9
  429. package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
  430. package/lib-mjs/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
  431. package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js +2 -0
  432. package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
  433. package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +9 -0
  434. package/lib-mjs/pluginUtils/CreateElement/createElement.js +48 -0
  435. package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -0
  436. package/lib-mjs/pluginUtils/Disposable.d.ts +10 -0
  437. package/lib-mjs/pluginUtils/Disposable.js +2 -0
  438. package/lib-mjs/pluginUtils/Disposable.js.map +1 -0
  439. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
  440. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js +2 -0
  441. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
  442. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
  443. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +118 -0
  444. package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
  445. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
  446. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +42 -0
  447. package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
  448. package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +7 -0
  449. package/lib-mjs/pluginUtils/Rect/normalizeRect.js +17 -0
  450. package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +1 -0
  451. package/package.json +5 -5
  452. package/lib/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
  453. package/lib/edit/ContentModelEditPlugin.js +0 -74
  454. package/lib/edit/ContentModelEditPlugin.js.map +0 -1
  455. package/lib/paste/ContentModelPastePlugin.js.map +0 -1
  456. package/lib-amd/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
  457. package/lib-amd/edit/ContentModelEditPlugin.js +0 -74
  458. package/lib-amd/edit/ContentModelEditPlugin.js.map +0 -1
  459. package/lib-amd/paste/ContentModelPastePlugin.js.map +0 -1
  460. package/lib-mjs/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
  461. package/lib-mjs/edit/ContentModelEditPlugin.js +0 -71
  462. package/lib-mjs/edit/ContentModelEditPlugin.js.map +0 -1
  463. package/lib-mjs/paste/ContentModelPastePlugin.js.map +0 -1
@@ -1,8 +1,9 @@
1
- import type { IStandaloneEditor } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- * Do keyboard event handling for DELETE/BACKSPACE key
5
- * @param editor The Content Model Editor
6
- * @param rawEvent DOM keyboard event
7
- */
8
- export declare function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
1
+ import type { IStandaloneEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * Do keyboard event handling for DELETE/BACKSPACE key
5
+ * @param editor The Content Model Editor
6
+ * @param rawEvent DOM keyboard event
7
+ * @returns True if the event is handled by content model, otherwise false
8
+ */
9
+ export declare function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent): boolean;
@@ -1,71 +1,68 @@
1
- import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
2
- import { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';
3
- import { deleteList } from './deleteSteps/deleteList';
4
- import { isNodeOfType } from 'roosterjs-content-model-dom';
5
- import { handleKeyboardEventResult, shouldDeleteAllSegmentsBefore, shouldDeleteWord, } from './handleKeyboardEventCommon';
6
- import { backwardDeleteWordSelection, forwardDeleteWordSelection, } from './deleteSteps/deleteWordSelection';
7
- import { backwardDeleteCollapsedSelection, forwardDeleteCollapsedSelection, } from './deleteSteps/deleteCollapsedSelection';
8
- /**
9
- * @internal
10
- * Do keyboard event handling for DELETE/BACKSPACE key
11
- * @param editor The Content Model Editor
12
- * @param rawEvent DOM keyboard event
13
- */
14
- export function keyboardDelete(editor, rawEvent) {
15
- var selection = editor.getDOMSelection();
16
- if (shouldDeleteWithContentModel(selection, rawEvent)) {
17
- editor.formatContentModel(function (model, context) {
18
- var result = deleteSelection(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
19
- return handleKeyboardEventResult(editor, model, rawEvent, result, context);
20
- }, {
21
- rawEvent: rawEvent,
22
- changeSource: ChangeSource.Keyboard,
23
- getChangeData: function () { return rawEvent.which; },
24
- apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
25
- });
26
- return true;
27
- }
28
- }
29
- function getDeleteSteps(rawEvent, isMac) {
30
- var isForward = rawEvent.key == 'Delete';
31
- var deleteAllSegmentBeforeStep = shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;
32
- var deleteWordSelection = shouldDeleteWord(rawEvent, isMac)
33
- ? isForward
34
- ? forwardDeleteWordSelection
35
- : backwardDeleteWordSelection
36
- : null;
37
- var deleteCollapsedSelection = isForward
38
- ? forwardDeleteCollapsedSelection
39
- : backwardDeleteCollapsedSelection;
40
- var deleteListStep = !isForward ? deleteList : null;
41
- return [
42
- deleteAllSegmentBeforeStep,
43
- deleteWordSelection,
44
- deleteCollapsedSelection,
45
- deleteListStep,
46
- ];
47
- }
48
- function shouldDeleteWithContentModel(selection, rawEvent) {
49
- if (!selection) {
50
- return false; // Nothing to delete
51
- }
52
- else if (selection.type != 'range' || !selection.range.collapsed) {
53
- return true; // Selection is not collapsed, need to delete all selections
54
- }
55
- else {
56
- var range = selection.range;
57
- // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
58
- return !(isNodeOfType(range.startContainer, 'TEXT_NODE') &&
59
- !isModifierKey(rawEvent) &&
60
- (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
61
- }
62
- }
63
- function canDeleteBefore(rawEvent, range) {
64
- return rawEvent.key == 'Backspace' && range.startOffset > 1;
65
- }
66
- function canDeleteAfter(rawEvent, range) {
67
- var _a, _b;
68
- return (rawEvent.key == 'Delete' &&
69
- range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
70
- }
1
+ import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
2
+ import { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';
3
+ import { deleteList } from './deleteSteps/deleteList';
4
+ import { isNodeOfType } from 'roosterjs-content-model-dom';
5
+ import { handleKeyboardEventResult, shouldDeleteAllSegmentsBefore, shouldDeleteWord, } from './handleKeyboardEventCommon';
6
+ import { backwardDeleteWordSelection, forwardDeleteWordSelection, } from './deleteSteps/deleteWordSelection';
7
+ import { backwardDeleteCollapsedSelection, forwardDeleteCollapsedSelection, } from './deleteSteps/deleteCollapsedSelection';
8
+ /**
9
+ * @internal
10
+ * Do keyboard event handling for DELETE/BACKSPACE key
11
+ * @param editor The Content Model Editor
12
+ * @param rawEvent DOM keyboard event
13
+ * @returns True if the event is handled by content model, otherwise false
14
+ */
15
+ export function keyboardDelete(editor, rawEvent) {
16
+ var handled = false;
17
+ var selection = editor.getDOMSelection();
18
+ if (shouldDeleteWithContentModel(selection, rawEvent)) {
19
+ editor.formatContentModel(function (model, context) {
20
+ var result = deleteSelection(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
21
+ handled = handleKeyboardEventResult(editor, model, rawEvent, result, context);
22
+ return handled;
23
+ }, {
24
+ rawEvent: rawEvent,
25
+ changeSource: ChangeSource.Keyboard,
26
+ getChangeData: function () { return rawEvent.which; },
27
+ apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
28
+ });
29
+ }
30
+ return handled;
31
+ }
32
+ function getDeleteSteps(rawEvent, isMac) {
33
+ var isForward = rawEvent.key == 'Delete';
34
+ var deleteAllSegmentBeforeStep = shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;
35
+ var deleteWordSelection = shouldDeleteWord(rawEvent, isMac)
36
+ ? isForward
37
+ ? forwardDeleteWordSelection
38
+ : backwardDeleteWordSelection
39
+ : null;
40
+ var deleteCollapsedSelection = isForward
41
+ ? forwardDeleteCollapsedSelection
42
+ : backwardDeleteCollapsedSelection;
43
+ return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection, deleteList];
44
+ }
45
+ function shouldDeleteWithContentModel(selection, rawEvent) {
46
+ if (!selection) {
47
+ return false; // Nothing to delete
48
+ }
49
+ else if (selection.type != 'range' || !selection.range.collapsed) {
50
+ return true; // Selection is not collapsed, need to delete all selections
51
+ }
52
+ else {
53
+ var range = selection.range;
54
+ // When selection is collapsed and is in middle of text node, no need to use Content Model to delete
55
+ return !(isNodeOfType(range.startContainer, 'TEXT_NODE') &&
56
+ !isModifierKey(rawEvent) &&
57
+ (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
58
+ }
59
+ }
60
+ function canDeleteBefore(rawEvent, range) {
61
+ return rawEvent.key == 'Backspace' && range.startOffset > 1;
62
+ }
63
+ function canDeleteAfter(rawEvent, range) {
64
+ var _a, _b;
65
+ return (rawEvent.key == 'Delete' &&
66
+ range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
67
+ }
71
68
  //# 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":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACH,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gCAAgC,EAChC,+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ource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { deleteList } from './deleteSteps/deleteList';\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 {\n DOMSelection,\n DeleteSelectionStep,\n IStandaloneEditor,\n} 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: IStandaloneEditor, 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 const deleteListStep = !isForward ? deleteList : null;\n return [\n deleteAllSegmentBeforeStep,\n deleteWordSelection,\n deleteCollapsedSelection,\n deleteListStep,\n ];\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":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACH,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gCAAgC,EAChC,+BAA+B,GAClC,MAAM,wCAAwC,CAAC;AAOhD;;;;;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CAAC,CAAC,IAAI,CAAC;IACX,IAAM,wBAAwB,GAAG,SAAS;QACtC,CAAC,CAAC,+BAA+B;QACjC,CAAC,CAAC,gCAAgC,CAAC;IACvC,OAAO,CAAC,0BAA0B,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,UAAU,CAAC,CAAC;AACnG,CAAC;AAED,SAAS,4BAA4B,CAAC,SAA8B,EAAE,QAAuB;IACzF,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;QAChE,OAAO,IAAI,CAAC,CAAC,4DAA4D;KAC5E;SAAM;QACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAE9B,oGAAoG;QACpG,OAAO,CAAC,CACJ,YAAY,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;YAC/C,CAAC,aAAa,CAAC,QAAQ,CAAC;YACxB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CACxE,CAAC;KACL;AACL,CAAC;AAED,SAAS,eAAe,CAAC,QAAuB,EAAE,KAAY;IAC1D,OAAO,QAAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;IACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;QACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;AACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\r\nimport { deleteList } from './deleteSteps/deleteList';\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 {\r\n DOMSelection,\r\n DeleteSelectionStep,\r\n IStandaloneEditor,\r\n} 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 * @returns True if the event is handled by content model, otherwise false\r\n */\r\nexport function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\r\n let handled = false;\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 handled = handleKeyboardEventResult(editor, model, rawEvent, result, context);\r\n return handled;\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\r\n return handled;\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, deleteList];\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 { IStandaloneEditor } from 'roosterjs-content-model-types';
2
- /**
3
- * @internal
4
- */
5
- export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
1
+ import type { IStandaloneEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
@@ -1,47 +1,55 @@
1
- import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
2
- import { normalizeContentModel } from 'roosterjs-content-model-dom';
3
- /**
4
- * @internal
5
- */
6
- export function keyboardInput(editor, rawEvent) {
7
- var selection = editor.getDOMSelection();
8
- if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {
9
- editor.takeSnapshot();
10
- editor.formatContentModel(function (model, context) {
11
- var _a;
12
- var result = deleteSelection(model, [], context);
13
- // We have deleted selection then we will let browser to handle the input.
14
- // With this combined operation, we don't wan to mass up the cached model so clear it
15
- context.clearModelCache = true;
16
- // 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
17
- context.skipUndoSnapshot = true;
18
- if (result.deleteResult == 'range') {
19
- // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
20
- context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
21
- normalizeContentModel(model);
22
- // Do not preventDefault since we still want browser to handle the final input for now
23
- return true;
24
- }
25
- else {
26
- return false;
27
- }
28
- }, {
29
- rawEvent: rawEvent,
30
- });
31
- return true;
32
- }
33
- }
34
- function shouldInputWithContentModel(selection, rawEvent, isInIME) {
35
- if (!selection) {
36
- return false; // Nothing to delete
37
- }
38
- else if (!isModifierKey(rawEvent) &&
39
- (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
40
- return (selection.type != 'range' ||
41
- (!selection.range.collapsed && !rawEvent.isComposing && !isInIME));
42
- }
43
- else {
44
- return false;
45
- }
46
- }
1
+ import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
2
+ import { handleEnterOnList } from './inputSteps/handleEnterOnList';
3
+ import { normalizeContentModel } from 'roosterjs-content-model-dom';
4
+ /**
5
+ * @internal
6
+ */
7
+ export function keyboardInput(editor, rawEvent) {
8
+ var selection = editor.getDOMSelection();
9
+ if (shouldInputWithContentModel(selection, rawEvent)) {
10
+ editor.takeSnapshot();
11
+ editor.formatContentModel(function (model, context) {
12
+ var _a;
13
+ var result = deleteSelection(model, getInputSteps(selection, rawEvent), context);
14
+ // We have deleted selection then we will let browser to handle the input.
15
+ // With this combined operation, we don't wan to mass up the cached model so clear it
16
+ context.clearModelCache = true;
17
+ // 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
18
+ context.skipUndoSnapshot = true;
19
+ if (result.deleteResult == 'range') {
20
+ // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
21
+ context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
22
+ normalizeContentModel(model);
23
+ // Do not preventDefault since we still want browser to handle the final input for now
24
+ return true;
25
+ }
26
+ else {
27
+ return false;
28
+ }
29
+ }, {
30
+ rawEvent: rawEvent,
31
+ });
32
+ return true;
33
+ }
34
+ }
35
+ function getInputSteps(selection, rawEvent) {
36
+ return shouldHandleEnterKey(selection, rawEvent) ? [handleEnterOnList] : [];
37
+ }
38
+ function shouldInputWithContentModel(selection, rawEvent) {
39
+ if (!selection) {
40
+ return false; // Nothing to delete
41
+ }
42
+ else if (!isModifierKey(rawEvent) &&
43
+ (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
44
+ return (selection.type != 'range' ||
45
+ !selection.range.collapsed ||
46
+ shouldHandleEnterKey(selection, rawEvent));
47
+ }
48
+ else {
49
+ return false;
50
+ }
51
+ }
52
+ var shouldHandleEnterKey = function (selection, rawEvent) {
53
+ return selection && selection.type == 'range' && rawEvent.key == 'Enter' && !rawEvent.shiftKey;
54
+ };
47
55
  //# 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":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGpE;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,QAAuB;IAC5E,IAAM,SAAS,GAAG,MA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C,WAAW,IAAI,CAAC,OAAO,CAAC,CACpE,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { DOMSelection, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {\n editor.takeSnapshot();\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(\n selection: DOMSelection | null,\n rawEvent: KeyboardEvent,\n isInIME: boolean\n) {\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 (\n selection.type != 'range' ||\n (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)\n );\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":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC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AAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IACH,CAAC,aAAa,CAAC,QAAQ,CAAC;QACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;QACE,OAAO,CACH,SAAS,CAAC,IAAI,IAAI,OAAO;YACzB,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS;YAC1B,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC5C,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AAED,IAAM,oBAAoB,GAAG,UAAC,SAA8B,EAAE,QAAuB;IACjF,OAAO,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACnG,CAAC,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\r\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\r\nimport type { DOMSelection, IStandaloneEditor } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (shouldInputWithContentModel(selection, rawEvent)) {\r\n editor.takeSnapshot();\r\n\r\n editor.formatContentModel(\r\n (model, context) => {\r\n const result = deleteSelection(model, getInputSteps(selection, rawEvent), 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 getInputSteps(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\r\n return shouldHandleEnterKey(selection, rawEvent) ? [handleEnterOnList] : [];\r\n}\r\n\r\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\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 ||\r\n shouldHandleEnterKey(selection, rawEvent)\r\n );\r\n } else {\r\n return false;\r\n }\r\n}\r\n\r\nconst shouldHandleEnterKey = (selection: DOMSelection | null, rawEvent: KeyboardEvent) => {\r\n return selection && selection.type == 'range' && rawEvent.key == 'Enter' && !rawEvent.shiftKey;\r\n};\r\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IStandaloneEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function keyboardTab(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
@@ -0,0 +1,31 @@
1
+ import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';
2
+ import { setModelIndentation } from 'roosterjs-content-model-api';
3
+ /**
4
+ * @internal
5
+ */
6
+ export function keyboardTab(editor, rawEvent) {
7
+ var selection = editor.getDOMSelection();
8
+ if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
9
+ editor.takeSnapshot();
10
+ editor.formatContentModel(function (model, _context) {
11
+ return handleTabOnList(model, rawEvent);
12
+ });
13
+ return true;
14
+ }
15
+ }
16
+ function isMarkerAtStartOfBlock(listItem) {
17
+ return (listItem.blocks[0].blockType == 'Paragraph' &&
18
+ listItem.blocks[0].segments[0].segmentType == 'SelectionMarker');
19
+ }
20
+ function handleTabOnList(model, rawEvent) {
21
+ var blocks = getOperationalBlocks(model, ['ListItem'], ['TableCell']);
22
+ var listItem = blocks[0].block;
23
+ if (isBlockGroupOfType(listItem, 'ListItem') &&
24
+ isMarkerAtStartOfBlock(listItem)) {
25
+ setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');
26
+ rawEvent.preventDefault();
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ //# sourceMappingURL=keyboardTab.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardTab.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardTab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAOlE;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAAyB,EAAE,QAAuB;IAC1E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,OAAO,EAAE;QAC5B,MAAM,CAAC,YAAY,EAAE,CAAC;QAEtB,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,QAAQ;YACtC,OAAO,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,QAA8B;IAC1D,OAAO,CACH,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;QAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAClE,CAAC;AACN,CAAC;AAED,SAAS,eAAe,CAAC,KAA2B,EAAE,QAAuB;IACzE,IAAM,MAAM,GAAG,oBAAoB,CAAuB,KAAK,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9F,IAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAEjC,IACI,kBAAkB,CAAuB,QAAQ,EAAE,UAAU,CAAC;QAC9D,sBAAsB,CAAC,QAAQ,CAAC,EAClC;QACE,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACrE,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["import { getOperationalBlocks, isBlockGroupOfType } from 'roosterjs-content-model-core';\r\nimport { setModelIndentation } from 'roosterjs-content-model-api';\r\nimport type {\r\n ContentModelDocument,\r\n ContentModelListItem,\r\n IStandaloneEditor,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function keyboardTab(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (selection?.type == 'range') {\r\n editor.takeSnapshot();\r\n\r\n editor.formatContentModel((model, _context) => {\r\n return handleTabOnList(model, rawEvent);\r\n });\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction isMarkerAtStartOfBlock(listItem: ContentModelListItem) {\r\n return (\r\n listItem.blocks[0].blockType == 'Paragraph' &&\r\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\r\n );\r\n}\r\n\r\nfunction handleTabOnList(model: ContentModelDocument, rawEvent: KeyboardEvent) {\r\n const blocks = getOperationalBlocks<ContentModelListItem>(model, ['ListItem'], ['TableCell']);\r\n const listItem = blocks[0].block;\r\n\r\n if (\r\n isBlockGroupOfType<ContentModelListItem>(listItem, 'ListItem') &&\r\n isMarkerAtStartOfBlock(listItem)\r\n ) {\r\n setModelIndentation(model, rawEvent.shiftKey ? 'outdent' : 'indent');\r\n rawEvent.preventDefault();\r\n return true;\r\n }\r\n return false;\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,72 +1,72 @@
1
- import { __read, __spreadArray } from "tslib";
2
- import { isGeneralSegment } from 'roosterjs-content-model-dom';
3
- /**
4
- * @internal
5
- */
6
- export function getLeafSiblingBlock(path, block, isNext) {
7
- var _a;
8
- var newPath = __spreadArray([], __read(path), false);
9
- var _loop_1 = function () {
10
- var group = newPath[0];
11
- var index = group.blocks.indexOf(block);
12
- if (index < 0) {
13
- return "break";
14
- }
15
- var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
16
- if (nextBlock) {
17
- while (nextBlock.blockType == 'BlockGroup') {
18
- var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
19
- if (!child) {
20
- return { value: { block: nextBlock, path: newPath } };
21
- }
22
- else if (child.blockType != 'BlockGroup') {
23
- newPath.unshift(nextBlock);
24
- return { value: { block: child, path: newPath } };
25
- }
26
- else {
27
- newPath.unshift(nextBlock);
28
- nextBlock = child;
29
- }
30
- }
31
- return { value: { block: nextBlock, path: newPath } };
32
- }
33
- else if (isGeneralSegment(group)) {
34
- // For general segment, we need to check if there is sibling segment under the same paragraph
35
- // First let's find the parent paragraph of this segment
36
- newPath.shift();
37
- var segmentIndex_1 = -1;
38
- var segment_1 = group;
39
- 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; });
40
- if (para) {
41
- // Now we have found the parent paragraph, so let's check if it has a sibling segment
42
- var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
43
- if (siblingSegment) {
44
- return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
45
- }
46
- else {
47
- // No sibling segment, let's keep go upper level
48
- block = para;
49
- }
50
- }
51
- else {
52
- return "break";
53
- }
54
- }
55
- else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
56
- newPath.shift();
57
- block = group;
58
- }
59
- else {
60
- return "break";
61
- }
62
- };
63
- while (newPath.length > 0) {
64
- var state_1 = _loop_1();
65
- if (typeof state_1 === "object")
66
- return state_1.value;
67
- if (state_1 === "break")
68
- break;
69
- }
70
- return null;
71
- }
1
+ import { __read, __spreadArray } from "tslib";
2
+ import { isGeneralSegment } from 'roosterjs-content-model-dom';
3
+ /**
4
+ * @internal
5
+ */
6
+ export function getLeafSiblingBlock(path, block, isNext) {
7
+ var _a;
8
+ var newPath = __spreadArray([], __read(path), false);
9
+ var _loop_1 = function () {
10
+ var group = newPath[0];
11
+ var index = group.blocks.indexOf(block);
12
+ if (index < 0) {
13
+ return "break";
14
+ }
15
+ var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
16
+ if (nextBlock) {
17
+ while (nextBlock.blockType == 'BlockGroup') {
18
+ var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
19
+ if (!child) {
20
+ return { value: { block: nextBlock, path: newPath } };
21
+ }
22
+ else if (child.blockType != 'BlockGroup') {
23
+ newPath.unshift(nextBlock);
24
+ return { value: { block: child, path: newPath } };
25
+ }
26
+ else {
27
+ newPath.unshift(nextBlock);
28
+ nextBlock = child;
29
+ }
30
+ }
31
+ return { value: { block: nextBlock, path: newPath } };
32
+ }
33
+ else if (isGeneralSegment(group)) {
34
+ // For general segment, we need to check if there is sibling segment under the same paragraph
35
+ // First let's find the parent paragraph of this segment
36
+ newPath.shift();
37
+ var segmentIndex_1 = -1;
38
+ var segment_1 = group;
39
+ 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; });
40
+ if (para) {
41
+ // Now we have found the parent paragraph, so let's check if it has a sibling segment
42
+ var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
43
+ if (siblingSegment) {
44
+ return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
45
+ }
46
+ else {
47
+ // No sibling segment, let's keep go upper level
48
+ block = para;
49
+ }
50
+ }
51
+ else {
52
+ return "break";
53
+ }
54
+ }
55
+ else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
56
+ newPath.shift();
57
+ block = group;
58
+ }
59
+ else {
60
+ return "break";
61
+ }
62
+ };
63
+ while (newPath.length > 0) {
64
+ var state_1 = _loop_1();
65
+ if (typeof state_1 === "object")
66
+ return state_1.value;
67
+ if (state_1 === "break")
68
+ break;
69
+ }
70
+ return null;
71
+ }
72
72
  //# 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":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AA6B/D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;IAEf,IAAM,OAAO,4BAAO,IAAI,SAAC,CAAC;;QAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;SAEd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,SAAS,IAAI,YAAY,EAAE;gBACxC,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzE,IAAI,CAAC,KAAK,EAAE;oCACD,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;iBAC7C;qBAAM,IAAI,K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AW,EAAE;YAClF,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,GAAG,KAAK,CAAC;SACjB;aAAM;;SAEN;;IAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;KA0DxB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","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":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AA6B/D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;IAEf,IAAM,OAAO,4BAAO,IAAI,SAAC,CAAC;;QAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;SAEd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,SAAS,IAAI,YAAY,EAAE;gBACxC,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzE,IAAI,CAAC,KAAK,EAAE;oCACD,EAAE,KA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IAAI,KAAK,CAAC,cAAc,IAAI,UAAU,IAAI,KAAK,CAAC,cAAc,IAAI,WAAW,EAAE;YAClF,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,GAAG,KAAK,CAAC;SACjB;aAAM;;SAEN;;IAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;KA0DxB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","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,3 +1,3 @@
1
- export { ContentModelPastePlugin } from './paste/ContentModelPastePlugin';
2
- export { ContentModelEditPlugin } from './edit/ContentModelEditPlugin';
3
- export { ContentModelAutoFormatPlugin, AutoFormatOptions, } from './autoFormat/ContentModelAutoFormatPlugin';
1
+ export { PastePlugin } from './paste/PastePlugin';
2
+ export { EditPlugin } from './edit/EditPlugin';
3
+ export { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';