roosterjs-content-model-plugins 0.24.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 (469) hide show
  1. package/lib/autoFormat/AutoFormatPlugin.d.ts +53 -0
  2. package/lib/autoFormat/AutoFormatPlugin.js +81 -0
  3. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -0
  4. package/lib/autoFormat/keyboardListTrigger.d.ts +5 -0
  5. package/lib/autoFormat/keyboardListTrigger.js +46 -0
  6. package/lib/autoFormat/keyboardListTrigger.js.map +1 -0
  7. package/lib/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
  8. package/lib/autoFormat/utils/convertAlphaToDecimals.js +23 -0
  9. package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
  10. package/lib/autoFormat/utils/getIndex.d.ts +4 -0
  11. package/lib/autoFormat/utils/getIndex.js +14 -0
  12. package/lib/autoFormat/utils/getIndex.js.map +1 -0
  13. package/lib/autoFormat/utils/getListTypeStyle.d.ts +14 -0
  14. package/lib/autoFormat/utils/getListTypeStyle.js +88 -0
  15. package/lib/autoFormat/utils/getListTypeStyle.js.map +1 -0
  16. package/lib/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
  17. package/lib/autoFormat/utils/getNumberingListStyle.js +154 -0
  18. package/lib/autoFormat/utils/getNumberingListStyle.js.map +1 -0
  19. package/{lib-mjs/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-mjs/paste/ContentModelPastePlugin.d.ts → lib/paste/PastePlugin.d.ts} +43 -43
  59. package/lib/paste/{ContentModelPastePlugin.js → PastePlugin.js} +131 -132
  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/AutoFormatPlugin.d.ts +53 -0
  152. package/lib-amd/autoFormat/AutoFormatPlugin.js +82 -0
  153. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -0
  154. package/lib-amd/autoFormat/keyboardListTrigger.d.ts +5 -0
  155. package/lib-amd/autoFormat/keyboardListTrigger.js +44 -0
  156. package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -0
  157. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
  158. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js +25 -0
  159. package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
  160. package/lib-amd/autoFormat/utils/getIndex.d.ts +4 -0
  161. package/lib-amd/autoFormat/utils/getIndex.js +15 -0
  162. package/lib-amd/autoFormat/utils/getIndex.js.map +1 -0
  163. package/lib-amd/autoFormat/utils/getListTypeStyle.d.ts +14 -0
  164. package/lib-amd/autoFormat/utils/getListTypeStyle.js +87 -0
  165. package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +1 -0
  166. package/lib-amd/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
  167. package/lib-amd/autoFormat/utils/getNumberingListStyle.js +154 -0
  168. package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +1 -0
  169. package/lib-amd/edit/{ContentModelEditPlugin.d.ts → 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 -124
  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-mjs/autoFormat/AutoFormatPlugin.d.ts +53 -0
  302. package/lib-mjs/autoFormat/AutoFormatPlugin.js +78 -0
  303. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -0
  304. package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +5 -0
  305. package/lib-mjs/autoFormat/keyboardListTrigger.js +42 -0
  306. package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -0
  307. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
  308. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js +19 -0
  309. package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
  310. package/lib-mjs/autoFormat/utils/getIndex.d.ts +4 -0
  311. package/lib-mjs/autoFormat/utils/getIndex.js +10 -0
  312. package/lib-mjs/autoFormat/utils/getIndex.js.map +1 -0
  313. package/lib-mjs/autoFormat/utils/getListTypeStyle.d.ts +14 -0
  314. package/lib-mjs/autoFormat/utils/getListTypeStyle.js +84 -0
  315. package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +1 -0
  316. package/lib-mjs/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
  317. package/lib-mjs/autoFormat/utils/getNumberingListStyle.js +150 -0
  318. package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +1 -0
  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-amd/paste/ContentModelPastePlugin.d.ts → lib-mjs/paste/PastePlugin.d.ts} +43 -43
  359. package/lib-mjs/paste/{ContentModelPastePlugin.js → PastePlugin.js} +128 -129
  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 -7
  452. package/lib/edit/ContentModelEditPlugin.js +0 -75
  453. package/lib/edit/ContentModelEditPlugin.js.map +0 -1
  454. package/lib/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
  455. package/lib/entityDelimiter/EntityDelimiterPlugin.js +0 -257
  456. package/lib/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
  457. package/lib/paste/ContentModelPastePlugin.js.map +0 -1
  458. package/lib-amd/edit/ContentModelEditPlugin.js +0 -75
  459. package/lib-amd/edit/ContentModelEditPlugin.js.map +0 -1
  460. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
  461. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js +0 -256
  462. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
  463. package/lib-amd/paste/ContentModelPastePlugin.js.map +0 -1
  464. package/lib-mjs/edit/ContentModelEditPlugin.js +0 -72
  465. package/lib-mjs/edit/ContentModelEditPlugin.js.map +0 -1
  466. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
  467. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js +0 -253
  468. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
  469. package/lib-mjs/paste/ContentModelPastePlugin.js.map +0 -1
@@ -0,0 +1,121 @@
1
+ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /**
5
+ * Generate event names and getXY function based on different platforms to be compatible with desktop and mobile browsers
6
+ */
7
+ var MOUSE_EVENT_INFO_DESKTOP = (function () {
8
+ return {
9
+ MOUSEDOWN: 'mousedown',
10
+ MOUSEMOVE: 'mousemove',
11
+ MOUSEUP: 'mouseup',
12
+ getPageXY: getMouseEventPageXY,
13
+ };
14
+ })();
15
+ var MOUSE_EVENT_INFO_MOBILE = (function () {
16
+ return {
17
+ MOUSEDOWN: 'touchstart',
18
+ MOUSEMOVE: 'touchmove',
19
+ MOUSEUP: 'touchend',
20
+ getPageXY: getTouchEventPageXY,
21
+ };
22
+ })();
23
+ function getMouseEventPageXY(e) {
24
+ return [e.pageX, e.pageY];
25
+ }
26
+ function getTouchEventPageXY(e) {
27
+ var pageX = 0;
28
+ var pageY = 0;
29
+ if (e.targetTouches && e.targetTouches.length > 0) {
30
+ var touch = e.targetTouches[0];
31
+ pageX = touch.pageX;
32
+ pageY = touch.pageY;
33
+ }
34
+ return [pageX, pageY];
35
+ }
36
+ /**
37
+ * @internal
38
+ * A helper class to help manage drag and drop to an HTML element
39
+ */
40
+ var DragAndDropHelper = /** @class */ (function () {
41
+ /**
42
+ * Create a new instance of DragAndDropHelper class
43
+ * @param trigger The trigger element. When user start drag on this element,
44
+ * events will be fired to the handler object
45
+ * @param context Context object that will be passed to handler function when event is fired,
46
+ * so that the handler object knows which element it is triggered from.
47
+ * @param onSubmit A callback that will be invoked when event handler in handler object returns true
48
+ * @param handler The event handler object, see DragAndDropHandler interface for more information
49
+ * @param zoomScale The zoom scale of the editor
50
+ * @param forceMobile A boolean to force the use of touch controls for the helper
51
+ */
52
+ function DragAndDropHelper(trigger, context, onSubmit, handler, zoomScale, forceMobile) {
53
+ var _this = this;
54
+ this.trigger = trigger;
55
+ this.context = context;
56
+ this.onSubmit = onSubmit;
57
+ this.handler = handler;
58
+ this.zoomScale = zoomScale;
59
+ this.initX = 0;
60
+ this.initY = 0;
61
+ this.initValue = undefined;
62
+ this.onMouseDown = function (e) {
63
+ var _a;
64
+ var _b, _c;
65
+ e.preventDefault();
66
+ e.stopPropagation();
67
+ _this.addDocumentEvents();
68
+ _a = (0, tslib_1.__read)(_this.dndMouse.getPageXY(e), 2), _this.initX = _a[0], _this.initY = _a[1];
69
+ _this.initValue = (_c = (_b = _this.handler).onDragStart) === null || _c === void 0 ? void 0 : _c.call(_b, _this.context, e);
70
+ };
71
+ this.onMouseMove = function (e) {
72
+ var _a, _b, _c;
73
+ e.preventDefault();
74
+ var _d = (0, tslib_1.__read)(_this.dndMouse.getPageXY(e), 2), pageX = _d[0], pageY = _d[1];
75
+ var deltaX = (pageX - _this.initX) / _this.zoomScale;
76
+ var deltaY = (pageY - _this.initY) / _this.zoomScale;
77
+ if (_this.initValue &&
78
+ ((_b = (_a = _this.handler).onDragging) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, e, _this.initValue, deltaX, deltaY))) {
79
+ (_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
80
+ }
81
+ };
82
+ this.onMouseUp = function (e) {
83
+ var _a, _b, _c;
84
+ e.preventDefault();
85
+ _this.removeDocumentEvents();
86
+ if ((_b = (_a = _this.handler).onDragEnd) === null || _b === void 0 ? void 0 : _b.call(_a, _this.context, e, _this.initValue)) {
87
+ (_c = _this.onSubmit) === null || _c === void 0 ? void 0 : _c.call(_this, _this.context, _this.trigger);
88
+ }
89
+ };
90
+ this.dndMouse = forceMobile ? MOUSE_EVENT_INFO_MOBILE : MOUSE_EVENT_INFO_DESKTOP;
91
+ trigger.addEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);
92
+ }
93
+ /**
94
+ * Dispose this object, remove all event listeners that has been attached
95
+ */
96
+ DragAndDropHelper.prototype.dispose = function () {
97
+ this.trigger.removeEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);
98
+ this.removeDocumentEvents();
99
+ };
100
+ Object.defineProperty(DragAndDropHelper.prototype, "mouseType", {
101
+ get: function () {
102
+ return this.dndMouse == MOUSE_EVENT_INFO_MOBILE ? 'touch' : 'mouse';
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ DragAndDropHelper.prototype.addDocumentEvents = function () {
108
+ var doc = this.trigger.ownerDocument;
109
+ doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);
110
+ doc.addEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, true /*useCapture*/);
111
+ };
112
+ DragAndDropHelper.prototype.removeDocumentEvents = function () {
113
+ var doc = this.trigger.ownerDocument;
114
+ doc.removeEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);
115
+ doc.removeEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, true /*useCapture*/);
116
+ };
117
+ return DragAndDropHelper;
118
+ }());
119
+ exports.default = DragAndDropHelper;
120
+ });
121
+ //# sourceMappingURL=DragAndDropHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragAndDropHelper.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/pluginUtils/DragAndDrop/DragAndDropHelper.ts"],"names":[],"mappings":"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","sourcesContent":["import type Disposable from '../Disposable';\r\nimport type DragAndDropHandler from './DragAndDropHandler';\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface MouseEventMoves {\r\n MOUSEDOWN: string;\r\n MOUSEMOVE: string;\r\n MOUSEUP: string;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\ninterface MouseEventInfo extends MouseEventMoves {\r\n getPageXY: (e: MouseEvent) => number[];\r\n}\r\n\r\n/**\r\n * @internal\r\n * Compatible mouse event names for different platform\r\n */\r\ninterface TouchEventInfo extends MouseEventMoves {\r\n getPageXY: (e: TouchEvent) => number[];\r\n}\r\n\r\n/**\r\n * Generate event names and getXY function based on different platforms to be compatible with desktop and mobile browsers\r\n */\r\nconst MOUSE_EVENT_INFO_DESKTOP: MouseEventInfo = (() => {\r\n return {\r\n MOUSEDOWN: 'mousedown',\r\n MOUSEMOVE: 'mousemove',\r\n MOUSEUP: 'mouseup',\r\n getPageXY: getMouseEventPageXY,\r\n };\r\n})();\r\n\r\nconst MOUSE_EVENT_INFO_MOBILE: TouchEventInfo = (() => {\r\n return {\r\n MOUSEDOWN: 'touchstart',\r\n MOUSEMOVE: 'touchmove',\r\n MOUSEUP: 'touchend',\r\n getPageXY: getTouchEventPageXY,\r\n };\r\n})();\r\n\r\nfunction getMouseEventPageXY(e: MouseEvent): [number, number] {\r\n return [e.pageX, e.pageY];\r\n}\r\n\r\nfunction getTouchEventPageXY(e: TouchEvent): [number, number] {\r\n let pageX = 0;\r\n let pageY = 0;\r\n if (e.targetTouches && e.targetTouches.length > 0) {\r\n const touch = e.targetTouches[0];\r\n pageX = touch.pageX;\r\n pageY = touch.pageY;\r\n }\r\n return [pageX, pageY];\r\n}\r\n\r\n/**\r\n * @internal\r\n * A helper class to help manage drag and drop to an HTML element\r\n */\r\nexport default class DragAndDropHelper<TContext, TInitValue> implements Disposable {\r\n private initX: number = 0;\r\n private initY: number = 0;\r\n private initValue: TInitValue | undefined = undefined;\r\n private dndMouse: MouseEventInfo | TouchEventInfo;\r\n\r\n /**\r\n * Create a new instance of DragAndDropHelper class\r\n * @param trigger The trigger element. When user start drag on this element,\r\n * events will be fired to the handler object\r\n * @param context Context object that will be passed to handler function when event is fired,\r\n * so that the handler object knows which element it is triggered from.\r\n * @param onSubmit A callback that will be invoked when event handler in handler object returns true\r\n * @param handler The event handler object, see DragAndDropHandler interface for more information\r\n * @param zoomScale The zoom scale of the editor\r\n * @param forceMobile A boolean to force the use of touch controls for the helper\r\n */\r\n constructor(\r\n private trigger: HTMLElement,\r\n private context: TContext,\r\n private onSubmit: (context: TContext, trigger: HTMLElement) => void,\r\n private handler: DragAndDropHandler<TContext, TInitValue>,\r\n private zoomScale: number,\r\n forceMobile?: boolean\r\n ) {\r\n this.dndMouse = forceMobile ? MOUSE_EVENT_INFO_MOBILE : MOUSE_EVENT_INFO_DESKTOP;\r\n trigger.addEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);\r\n }\r\n\r\n /**\r\n * Dispose this object, remove all event listeners that has been attached\r\n */\r\n dispose() {\r\n this.trigger.removeEventListener(this.dndMouse.MOUSEDOWN, this.onMouseDown);\r\n this.removeDocumentEvents();\r\n }\r\n\r\n public get mouseType(): string {\r\n return this.dndMouse == MOUSE_EVENT_INFO_MOBILE ? 'touch' : 'mouse';\r\n }\r\n\r\n private addDocumentEvents() {\r\n const doc = this.trigger.ownerDocument;\r\n doc.addEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);\r\n doc.addEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, true /*useCapture*/);\r\n }\r\n\r\n private removeDocumentEvents() {\r\n const doc = this.trigger.ownerDocument;\r\n doc.removeEventListener(this.dndMouse.MOUSEMOVE, this.onMouseMove, true /*useCapture*/);\r\n doc.removeEventListener(this.dndMouse.MOUSEUP, this.onMouseUp, true /*useCapture*/);\r\n }\r\n\r\n private onMouseDown = (e: Event) => {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n this.addDocumentEvents();\r\n [this.initX, this.initY] = this.dndMouse.getPageXY(e as MouseEvent & TouchEvent);\r\n this.initValue = this.handler.onDragStart?.(this.context, e as MouseEvent);\r\n };\r\n\r\n private onMouseMove = (e: Event) => {\r\n e.preventDefault();\r\n const [pageX, pageY] = this.dndMouse.getPageXY(e as MouseEvent & TouchEvent);\r\n const deltaX = (pageX - this.initX) / this.zoomScale;\r\n const deltaY = (pageY - this.initY) / this.zoomScale;\r\n if (\r\n this.initValue &&\r\n this.handler.onDragging?.(this.context, e as MouseEvent, this.initValue, deltaX, deltaY)\r\n ) {\r\n this.onSubmit?.(this.context, this.trigger);\r\n }\r\n };\r\n\r\n private onMouseUp = (e: Event) => {\r\n e.preventDefault();\r\n this.removeDocumentEvents();\r\n if (this.handler.onDragEnd?.(this.context, e as MouseEvent, this.initValue)) {\r\n this.onSubmit?.(this.context, this.trigger);\r\n }\r\n };\r\n}\r\n"]}
@@ -0,0 +1,27 @@
1
+ import type { Rect } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Get the intersected Rect of elements provided
4
+ *
5
+ * @example
6
+ * The result of the following Elements Rects would be:
7
+ {
8
+ top: Element2.top,
9
+ bottom: Element1.bottom,
10
+ left: Element2.left,
11
+ right: Element2.right
12
+ }
13
+ +-------------------------+
14
+ | Element 1 |
15
+ | +-----------------+ |
16
+ | | Element2 | |
17
+ | | | |
18
+ | | | |
19
+ +-------------------------+
20
+ | |
21
+ +-----------------+
22
+ * @internal
23
+ * @param elements Elements to use.
24
+ * @param additionalRects additional rects to use
25
+ * @returns If the Rect is valid return the rect, if not, return null.
26
+ */
27
+ export default function getIntersectedRect(elements: HTMLElement[], additionalRects?: Rect[]): Rect | null;
@@ -0,0 +1,45 @@
1
+ define(["require", "exports", "tslib", "./normalizeRect"], function (require, exports, tslib_1, normalizeRect_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /**
5
+ * Get the intersected Rect of elements provided
6
+ *
7
+ * @example
8
+ * The result of the following Elements Rects would be:
9
+ {
10
+ top: Element2.top,
11
+ bottom: Element1.bottom,
12
+ left: Element2.left,
13
+ right: Element2.right
14
+ }
15
+ +-------------------------+
16
+ | Element 1 |
17
+ | +-----------------+ |
18
+ | | Element2 | |
19
+ | | | |
20
+ | | | |
21
+ +-------------------------+
22
+ | |
23
+ +-----------------+
24
+ * @internal
25
+ * @param elements Elements to use.
26
+ * @param additionalRects additional rects to use
27
+ * @returns If the Rect is valid return the rect, if not, return null.
28
+ */
29
+ function getIntersectedRect(elements, additionalRects) {
30
+ if (additionalRects === void 0) { additionalRects = []; }
31
+ var rects = elements
32
+ .map(function (element) { return (0, normalizeRect_1.default)(element.getBoundingClientRect()); })
33
+ .concat(additionalRects)
34
+ .filter(function (element) { return !!element; });
35
+ var result = {
36
+ top: Math.max.apply(Math, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(rects.map(function (r) { return r.top; })), false)),
37
+ bottom: Math.min.apply(Math, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(rects.map(function (r) { return r.bottom; })), false)),
38
+ left: Math.max.apply(Math, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(rects.map(function (r) { return r.left; })), false)),
39
+ right: Math.min.apply(Math, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(rects.map(function (r) { return r.right; })), false)),
40
+ };
41
+ return result.top < result.bottom && result.left < result.right ? result : null;
42
+ }
43
+ exports.default = getIntersectedRect;
44
+ });
45
+ //# sourceMappingURL=getIntersectedRect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIntersectedRect.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/pluginUtils/Rect/getIntersectedRect.ts"],"names":[],"mappings":";;;IAGA;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAwB,kBAAkB,CACtC,QAAuB,EACvB,eAA4B;QAA5B,gCAAA,EAAA,oBAA4B;QAE5B,IAAM,KAAK,GAAG,QAAQ;aACjB,GAAG,CAAC,UAAA,OAAO,IAAI,OAAA,IAAA,uBAAa,EAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,EAA9C,CAA8C,CAAC;aAC9D,MAAM,CAAC,eAAe,CAAC;aACvB,MAAM,CAAC,UAAA,OAAO,IAAI,OAAA,CAAC,CAAC,OAAO,EAAT,CAAS,CAAW,CAAC;QAE5C,IAAM,MAAM,GAAS;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG,OAAR,IAAI,qDAAQ,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,GAAG,EAAL,CAAK,CAAC,UAAC;YACvC,MAAM,EAAE,IAAI,CAAC,GAAG,OAAR,IAAI,qDAAQ,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,MAAM,EAAR,CAAQ,CAAC,UAAC;YAC7C,IAAI,EAAE,IAAI,CAAC,GAAG,OAAR,IAAI,qDAAQ,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,EAAN,CAAM,CAAC,UAAC;YACzC,KAAK,EAAE,IAAI,CAAC,GAAG,OAAR,IAAI,qDAAQ,KAAK,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,EAAP,CAAO,CAAC,UAAC;SAC9C,CAAC;QAEF,OAAO,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACpF,CAAC;IAjBD,qCAiBC","sourcesContent":["import normalizeRect from './normalizeRect';\r\nimport type { Rect } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Get the intersected Rect of elements provided\r\n *\r\n * @example\r\n * The result of the following Elements Rects would be:\r\n {\r\n top: Element2.top,\r\n bottom: Element1.bottom,\r\n left: Element2.left,\r\n right: Element2.right\r\n }\r\n +-------------------------+\r\n | Element 1 |\r\n | +-----------------+ |\r\n | | Element2 | |\r\n | | | |\r\n | | | |\r\n +-------------------------+\r\n | |\r\n +-----------------+\r\n * @internal\r\n * @param elements Elements to use.\r\n * @param additionalRects additional rects to use\r\n * @returns If the Rect is valid return the rect, if not, return null.\r\n */\r\nexport default function getIntersectedRect(\r\n elements: HTMLElement[],\r\n additionalRects: Rect[] = []\r\n): Rect | null {\r\n const rects = elements\r\n .map(element => normalizeRect(element.getBoundingClientRect()))\r\n .concat(additionalRects)\r\n .filter(element => !!element) as Rect[];\r\n\r\n const result: Rect = {\r\n top: Math.max(...rects.map(r => r.top)),\r\n bottom: Math.min(...rects.map(r => r.bottom)),\r\n left: Math.max(...rects.map(r => r.left)),\r\n right: Math.min(...rects.map(r => r.right)),\r\n };\r\n\r\n return result.top < result.bottom && result.left < result.right ? result : null;\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ import type { Rect } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p
5
+ * We validate that and only return a rect when the passed in ClientRect is valid
6
+ */
7
+ export default function normalizeRect(clientRect: DOMRect): Rect | null;
@@ -0,0 +1,22 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /**
5
+ * @internal
6
+ * A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p
7
+ * We validate that and only return a rect when the passed in ClientRect is valid
8
+ */
9
+ function normalizeRect(clientRect) {
10
+ var _a = clientRect || { left: 0, right: 0, top: 0, bottom: 0 }, left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
11
+ return left === 0 && right === 0 && top === 0 && bottom === 0
12
+ ? null
13
+ : {
14
+ left: Math.round(left),
15
+ right: Math.round(right),
16
+ top: Math.round(top),
17
+ bottom: Math.round(bottom),
18
+ };
19
+ }
20
+ exports.default = normalizeRect;
21
+ });
22
+ //# sourceMappingURL=normalizeRect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeRect.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/pluginUtils/Rect/normalizeRect.ts"],"names":[],"mappings":";;;IAEA;;;;OAIG;IACH,SAAwB,aAAa,CAAC,UAAmB;QAC/C,IAAA,KACF,UAAU,IAAa,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAD3D,IAAI,UAAA,EAAE,KAAK,WAAA,EAAE,GAAG,SAAA,EAAE,MAAM,YACmC,CAAC;QACpE,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC;YACzD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC;gBACI,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;gBACtB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;gBACxB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;gBACpB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;aAC7B,CAAC;IACZ,CAAC;IAXD,gCAWC","sourcesContent":["import type { Rect } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n * A ClientRect of all 0 is possible. i.e. chrome returns a ClientRect of 0 when the cursor is on an empty p\r\n * We validate that and only return a rect when the passed in ClientRect is valid\r\n */\r\nexport default function normalizeRect(clientRect: DOMRect): Rect | null {\r\n const { left, right, top, bottom } =\r\n clientRect || <DOMRect>{ left: 0, right: 0, top: 0, bottom: 0 };\r\n return left === 0 && right === 0 && top === 0 && bottom === 0\r\n ? null\r\n : {\r\n left: Math.round(left),\r\n right: Math.round(right),\r\n top: Math.round(top),\r\n bottom: Math.round(bottom),\r\n };\r\n}\r\n"]}
@@ -0,0 +1,53 @@
1
+ import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Options to customize the Content Model Auto Format Plugin
4
+ */
5
+ export declare type AutoFormatOptions = {
6
+ /**
7
+ * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true
8
+ */
9
+ autoBullet: boolean;
10
+ /**
11
+ * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true
12
+ */
13
+ autoNumbering: boolean;
14
+ };
15
+ /**
16
+ * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
17
+ * It can be customized with options to enable or disable auto list features.
18
+ */
19
+ export declare class AutoFormatPlugin implements EditorPlugin {
20
+ private options;
21
+ private editor;
22
+ /**
23
+ * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
24
+ * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to true.
25
+ * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to true.
26
+ */
27
+ constructor(options?: AutoFormatOptions);
28
+ /**
29
+ * Get name of this plugin
30
+ */
31
+ getName(): string;
32
+ /**
33
+ * The first method that editor will call to a plugin when editor is initializing.
34
+ * It will pass in the editor instance, plugin should take this chance to save the
35
+ * editor reference so that it can call to any editor method or format API later.
36
+ * @param editor The editor object
37
+ */
38
+ initialize(editor: IStandaloneEditor): void;
39
+ /**
40
+ * The last method that editor will call to a plugin before it is disposed.
41
+ * Plugin can take this chance to clear the reference to editor. After this method is
42
+ * called, plugin should not call to any editor method since it will result in error.
43
+ */
44
+ dispose(): void;
45
+ /**
46
+ * Core method for a plugin. Once an event happens in editor, editor will call this
47
+ * method of each plugin to handle the event as long as the event is not handled
48
+ * exclusively by another plugin.
49
+ * @param event The event to handle:
50
+ */
51
+ onPluginEvent(event: PluginEvent): void;
52
+ private handleKeyDownEvent;
53
+ }
@@ -0,0 +1,78 @@
1
+ import { keyboardListTrigger } from './keyboardListTrigger';
2
+ /**
3
+ * @internal
4
+ */
5
+ var DefaultOptions = {
6
+ autoBullet: true,
7
+ autoNumbering: true,
8
+ };
9
+ /**
10
+ * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.
11
+ * It can be customized with options to enable or disable auto list features.
12
+ */
13
+ var AutoFormatPlugin = /** @class */ (function () {
14
+ /**
15
+ * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:
16
+ * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to true.
17
+ * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to true.
18
+ */
19
+ function AutoFormatPlugin(options) {
20
+ if (options === void 0) { options = DefaultOptions; }
21
+ this.options = options;
22
+ this.editor = null;
23
+ }
24
+ /**
25
+ * Get name of this plugin
26
+ */
27
+ AutoFormatPlugin.prototype.getName = function () {
28
+ return 'AutoFormat';
29
+ };
30
+ /**
31
+ * The first method that editor will call to a plugin when editor is initializing.
32
+ * It will pass in the editor instance, plugin should take this chance to save the
33
+ * editor reference so that it can call to any editor method or format API later.
34
+ * @param editor The editor object
35
+ */
36
+ AutoFormatPlugin.prototype.initialize = function (editor) {
37
+ this.editor = editor;
38
+ };
39
+ /**
40
+ * The last method that editor will call to a plugin before it is disposed.
41
+ * Plugin can take this chance to clear the reference to editor. After this method is
42
+ * called, plugin should not call to any editor method since it will result in error.
43
+ */
44
+ AutoFormatPlugin.prototype.dispose = function () {
45
+ this.editor = null;
46
+ };
47
+ /**
48
+ * Core method for a plugin. Once an event happens in editor, editor will call this
49
+ * method of each plugin to handle the event as long as the event is not handled
50
+ * exclusively by another plugin.
51
+ * @param event The event to handle:
52
+ */
53
+ AutoFormatPlugin.prototype.onPluginEvent = function (event) {
54
+ if (this.editor) {
55
+ switch (event.eventType) {
56
+ case 'keyDown':
57
+ this.handleKeyDownEvent(this.editor, event);
58
+ break;
59
+ }
60
+ }
61
+ };
62
+ AutoFormatPlugin.prototype.handleKeyDownEvent = function (editor, event) {
63
+ var rawEvent = event.rawEvent;
64
+ if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
65
+ switch (rawEvent.key) {
66
+ case ' ':
67
+ var _a = this.options, autoBullet = _a.autoBullet, autoNumbering = _a.autoNumbering;
68
+ if (autoBullet || autoNumbering) {
69
+ keyboardListTrigger(editor, rawEvent, autoBullet, autoNumbering);
70
+ }
71
+ break;
72
+ }
73
+ }
74
+ };
75
+ return AutoFormatPlugin;
76
+ }());
77
+ export { AutoFormatPlugin };
78
+ //# sourceMappingURL=AutoFormatPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoFormatPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/autoFormat/AutoFormatPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAuB5D;;GAEG;AACH,IAAM,cAAc,GAAgC;IAChD,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAI;CACtB,CAAC;AAEF;;;GAGG;AACH;IAGI;;;;OAIG;IACH,0BAAoB,OAA2C;QAA3C,wBAAA,EAAA,wBAA2C;QAA3C,YAAO,GAAP,OAAO,CAAoC;QAPvD,WAAM,GAA6B,IAAI,CAAC;IAOkB,CAAC;IAEnE;;OAEG;IACH,kCAAO,GAAP;QACI,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,qCAAU,GAAV,UAAW,MAAyB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,kCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,wCAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,SAAS;oBACV,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,6CAAkB,GAA1B,UAA2B,MAAyB,EAAE,KAAmB;QACrE,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,GAAG;oBACE,IAAA,KAAgC,IAAI,CAAC,OAAO,EAA1C,UAAU,gBAAA,EAAE,aAAa,mBAAiB,CAAC;oBACnD,IAAI,UAAU,IAAI,aAAa,EAAE;wBAC7B,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;qBACpE;oBACD,MAAM;aACb;SACJ;IACL,CAAC;IACL,uBAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { keyboardListTrigger } from './keyboardListTrigger';\r\nimport type {\r\n EditorPlugin,\r\n IStandaloneEditor,\r\n KeyDownEvent,\r\n PluginEvent,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Options to customize the Content Model Auto Format Plugin\r\n */\r\nexport type AutoFormatOptions = {\r\n /**\r\n * When true, after type *, ->, -, --, => , —, > and space key a type of bullet list will be triggered. @default true\r\n */\r\n autoBullet: boolean;\r\n\r\n /**\r\n * When true, after type 1, A, a, i, I followed by ., ), - or between () and space key a type of numbering list will be triggered. @default true\r\n */\r\n autoNumbering: boolean;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nconst DefaultOptions: Required<AutoFormatOptions> = {\r\n autoBullet: true,\r\n autoNumbering: true,\r\n};\r\n\r\n/**\r\n * Auto Format plugin handles auto formatting, such as transforming * characters into a bullet list.\r\n * It can be customized with options to enable or disable auto list features.\r\n */\r\nexport class AutoFormatPlugin implements EditorPlugin {\r\n private editor: IStandaloneEditor | null = null;\r\n\r\n /**\r\n * @param options An optional parameter that takes in an object of type AutoFormatOptions, which includes the following properties:\r\n * - autoBullet: A boolean that enables or disables automatic bullet list formatting. Defaults to true.\r\n * - autoNumbering: A boolean that enables or disables automatic numbering formatting. Defaults to true.\r\n */\r\n constructor(private options: AutoFormatOptions = DefaultOptions) {}\r\n\r\n /**\r\n * Get name of this plugin\r\n */\r\n getName() {\r\n return 'AutoFormat';\r\n }\r\n\r\n /**\r\n * The first method that editor will call to a plugin when editor is initializing.\r\n * It will pass in the editor instance, plugin should take this chance to save the\r\n * editor reference so that it can call to any editor method or format API later.\r\n * @param editor The editor object\r\n */\r\n initialize(editor: IStandaloneEditor) {\r\n this.editor = editor;\r\n }\r\n\r\n /**\r\n * The last method that editor will call to a plugin before it is disposed.\r\n * Plugin can take this chance to clear the reference to editor. After this method is\r\n * called, plugin should not call to any editor method since it will result in error.\r\n */\r\n dispose() {\r\n this.editor = null;\r\n }\r\n\r\n /**\r\n * Core method for a plugin. Once an event happens in editor, editor will call this\r\n * method of each plugin to handle the event as long as the event is not handled\r\n * exclusively by another plugin.\r\n * @param event The event to handle:\r\n */\r\n onPluginEvent(event: PluginEvent) {\r\n if (this.editor) {\r\n switch (event.eventType) {\r\n case 'keyDown':\r\n this.handleKeyDownEvent(this.editor, event);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private handleKeyDownEvent(editor: IStandaloneEditor, event: KeyDownEvent) {\r\n const rawEvent = event.rawEvent;\r\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\r\n switch (rawEvent.key) {\r\n case ' ':\r\n const { autoBullet, autoNumbering } = this.options;\r\n if (autoBullet || autoNumbering) {\r\n keyboardListTrigger(editor, rawEvent, autoBullet, autoNumbering);\r\n }\r\n break;\r\n }\r\n }\r\n }\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 keyboardListTrigger(editor: IStandaloneEditor, rawEvent: KeyboardEvent, shouldSearchForBullet?: boolean, shouldSearchForNumbering?: boolean): void;
@@ -0,0 +1,42 @@
1
+ import { getListTypeStyle } from './utils/getListTypeStyle';
2
+ import { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';
3
+ import { normalizeContentModel } from 'roosterjs-content-model-dom';
4
+ import { setListStartNumber, setListStyle, setListType } from 'roosterjs-content-model-api';
5
+ /**
6
+ * @internal
7
+ */
8
+ export function keyboardListTrigger(editor, rawEvent, shouldSearchForBullet, shouldSearchForNumbering) {
9
+ if (shouldSearchForBullet === void 0) { shouldSearchForBullet = true; }
10
+ if (shouldSearchForNumbering === void 0) { shouldSearchForNumbering = true; }
11
+ editor.formatContentModel(function (model, _context) {
12
+ var listStyleType = getListTypeStyle(model, shouldSearchForBullet, shouldSearchForNumbering);
13
+ if (listStyleType) {
14
+ var segmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false);
15
+ if (segmentsAndParagraphs[0] && segmentsAndParagraphs[0][1]) {
16
+ segmentsAndParagraphs[0][1].segments.splice(0, 1);
17
+ }
18
+ var listType = listStyleType.listType, styleType = listStyleType.styleType, index = listStyleType.index;
19
+ triggerList(editor, model, listType, styleType, index);
20
+ rawEvent.preventDefault();
21
+ normalizeContentModel(model);
22
+ return true;
23
+ }
24
+ return false;
25
+ });
26
+ }
27
+ var triggerList = function (editor, model, listType, styleType, index) {
28
+ setListType(model, listType);
29
+ var isOrderedList = listType == 'OL';
30
+ // If the index < 1, it is a new list, so it will be starting by 1, then no need to set startNumber
31
+ if (index && index > 1 && isOrderedList) {
32
+ setListStartNumber(editor, index);
33
+ }
34
+ setListStyle(editor, isOrderedList
35
+ ? {
36
+ orderedStyleType: styleType,
37
+ }
38
+ : {
39
+ unorderedStyleType: styleType,
40
+ });
41
+ };
42
+ //# sourceMappingURL=keyboardListTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardListTrigger.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/autoFormat/keyboardListTrigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAI5F;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAC/B,MAAyB,EACzB,QAAuB,EACvB,qBAAqC,EACrC,wBAAwC;IADxC,sCAAA,EAAA,4BAAqC;IACrC,yCAAA,EAAA,+BAAwC;IAExC,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,QAAQ;QACtC,IAAM,aAAa,GAAG,gBAAgB,CAClC,KAAK,EACL,qBAAqB,EACrB,wBAAwB,CAC3B,CAAC;QACF,IAAI,aAAa,EAAE;YACf,IAAM,qBAAqB,GAAG,gCAAgC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC7E,IAAI,qBAAqB,CAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;gBACzD,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;aACrD;YACO,IAAA,QAAQ,GAAuB,aAAa,SAApC,EAAE,SAAS,GAAY,aAAa,UAAzB,EAAE,KAAK,GAAK,aAAa,MAAlB,CAAmB;YACrD,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YACvD,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAE7B,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC;AAED,IAAM,WAAW,GAAG,UAChB,MAAyB,EACzB,KAA2B,EAC3B,QAAqB,EACrB,SAAiB,EACjB,KAAc;IAEd,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7B,IAAM,aAAa,GAAG,QAAQ,IAAI,IAAI,CAAC;IACvC,mGAAmG;IACnG,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,IAAI,aAAa,EAAE;QACrC,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KACrC;IACD,YAAY,CACR,MAAM,EACN,aAAa;QACT,CAAC,CAAC;YACI,gBAAgB,EAAE,SAAS;SAC9B;QACH,CAAC,CAAC;YACI,kBAAkB,EAAE,SAAS;SAChC,CACV,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { getListTypeStyle } from './utils/getListTypeStyle';\r\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';\r\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\r\nimport { setListStartNumber, setListStyle, setListType } from 'roosterjs-content-model-api';\r\n\r\nimport type { ContentModelDocument, IStandaloneEditor } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function keyboardListTrigger(\r\n editor: IStandaloneEditor,\r\n rawEvent: KeyboardEvent,\r\n shouldSearchForBullet: boolean = true,\r\n shouldSearchForNumbering: boolean = true\r\n) {\r\n editor.formatContentModel((model, _context) => {\r\n const listStyleType = getListTypeStyle(\r\n model,\r\n shouldSearchForBullet,\r\n shouldSearchForNumbering\r\n );\r\n if (listStyleType) {\r\n const segmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false);\r\n if (segmentsAndParagraphs[0] && segmentsAndParagraphs[0][1]) {\r\n segmentsAndParagraphs[0][1].segments.splice(0, 1);\r\n }\r\n const { listType, styleType, index } = listStyleType;\r\n triggerList(editor, model, listType, styleType, index);\r\n rawEvent.preventDefault();\r\n normalizeContentModel(model);\r\n\r\n return true;\r\n }\r\n return false;\r\n });\r\n}\r\n\r\nconst triggerList = (\r\n editor: IStandaloneEditor,\r\n model: ContentModelDocument,\r\n listType: 'OL' | 'UL',\r\n styleType: number,\r\n index?: number\r\n) => {\r\n setListType(model, listType);\r\n const isOrderedList = listType == 'OL';\r\n // If the index < 1, it is a new list, so it will be starting by 1, then no need to set startNumber\r\n if (index && index > 1 && isOrderedList) {\r\n setListStartNumber(editor, index);\r\n }\r\n setListStyle(\r\n editor,\r\n isOrderedList\r\n ? {\r\n orderedStyleType: styleType,\r\n }\r\n : {\r\n unorderedStyleType: styleType,\r\n }\r\n );\r\n};\r\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ * Convert english alphabet numbers into decimal numbers
4
+ * @param letter The letter that needs to be converted
5
+ * @returns
6
+ */
7
+ export declare function convertAlphaToDecimals(letter: string): number | undefined;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @internal
3
+ * Convert english alphabet numbers into decimal numbers
4
+ * @param letter The letter that needs to be converted
5
+ * @returns
6
+ */
7
+ export function convertAlphaToDecimals(letter) {
8
+ var alpha = letter.toUpperCase();
9
+ if (alpha) {
10
+ var result = 0;
11
+ for (var i = 0; i < alpha.length; i++) {
12
+ var charCode = alpha.charCodeAt(i) - 65 + 1;
13
+ result = result * 26 + charCode;
14
+ }
15
+ return result;
16
+ }
17
+ return undefined;
18
+ }
19
+ //# sourceMappingURL=convertAlphaToDecimals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertAlphaToDecimals.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/autoFormat/utils/convertAlphaToDecimals.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACjD,IAAM,KAAK,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IACnC,IAAI,KAAK,EAAE;QACP,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACnC,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC9C,MAAM,GAAG,MAAM,GAAG,EAAE,GAAG,QAAQ,CAAC;SACnC;QAED,OAAO,MAAM,CAAC;KACjB;IACD,OAAO,SAAS,CAAC;AACrB,CAAC","sourcesContent":["/**\r\n * @internal\r\n * Convert english alphabet numbers into decimal numbers\r\n * @param letter The letter that needs to be converted\r\n * @returns\r\n */\r\nexport function convertAlphaToDecimals(letter: string): number | undefined {\r\n const alpha = letter.toUpperCase();\r\n if (alpha) {\r\n let result = 0;\r\n for (let i = 0; i < alpha.length; i++) {\r\n const charCode = alpha.charCodeAt(i) - 65 + 1;\r\n result = result * 26 + charCode;\r\n }\r\n\r\n return result;\r\n }\r\n return undefined;\r\n}\r\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare function getIndex(listIndex: string): number | undefined;
@@ -0,0 +1,10 @@
1
+ import { convertAlphaToDecimals } from './convertAlphaToDecimals';
2
+ /**
3
+ * @internal
4
+ */
5
+ export function getIndex(listIndex) {
6
+ var index = listIndex.replace(/[^a-zA-Z0-9 ]/g, '');
7
+ var indexNumber = parseInt(index);
8
+ return !isNaN(indexNumber) ? indexNumber : convertAlphaToDecimals(index);
9
+ }
10
+ //# sourceMappingURL=getIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIndex.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/autoFormat/utils/getIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAiB;IACtC,IAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,IAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import { convertAlphaToDecimals } from './convertAlphaToDecimals';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getIndex(listIndex: string) {\r\n const index = listIndex.replace(/[^a-zA-Z0-9 ]/g, '');\r\n const indexNumber = parseInt(index);\r\n return !isNaN(indexNumber) ? indexNumber : convertAlphaToDecimals(index);\r\n}\r\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ContentModelDocument } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ interface ListTypeStyle {
6
+ listType: 'UL' | 'OL';
7
+ styleType: number;
8
+ index?: number;
9
+ }
10
+ /**
11
+ * @internal
12
+ */
13
+ export declare function getListTypeStyle(model: ContentModelDocument, shouldSearchForBullet?: boolean, shouldSearchForNumbering?: boolean): ListTypeStyle | undefined;
14
+ export {};
@@ -0,0 +1,84 @@
1
+ import { findListItemsInSameThread } from 'roosterjs-content-model-api';
2
+ import { getNumberingListStyle } from './getNumberingListStyle';
3
+ import { BulletListType, isBlockGroupOfType, updateListMetadata, getOperationalBlocks, getSelectedSegmentsAndParagraphs, } from 'roosterjs-content-model-core';
4
+ /**
5
+ * @internal
6
+ */
7
+ export function getListTypeStyle(model, shouldSearchForBullet, shouldSearchForNumbering) {
8
+ if (shouldSearchForBullet === void 0) { shouldSearchForBullet = true; }
9
+ if (shouldSearchForNumbering === void 0) { shouldSearchForNumbering = true; }
10
+ var selectedSegmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, true);
11
+ var marker = selectedSegmentsAndParagraphs[0][0];
12
+ var paragraph = selectedSegmentsAndParagraphs[0][1];
13
+ var listMarkerSegment = paragraph === null || paragraph === void 0 ? void 0 : paragraph.segments[0];
14
+ if (marker &&
15
+ marker.segmentType == 'SelectionMarker' &&
16
+ listMarkerSegment &&
17
+ listMarkerSegment.segmentType == 'Text') {
18
+ var listMarker = listMarkerSegment.text;
19
+ var bulletType = bulletListType[listMarker];
20
+ if (bulletType && shouldSearchForBullet) {
21
+ return { listType: 'UL', styleType: bulletType };
22
+ }
23
+ else if (shouldSearchForNumbering) {
24
+ var previousList = getPreviousListLevel(model, paragraph);
25
+ var previousIndex = getPreviousListIndex(model, previousList);
26
+ var previousListStyle = getPreviousListStyle(previousList);
27
+ var numberingType = getNumberingListStyle(listMarker, previousIndex, previousListStyle);
28
+ if (numberingType) {
29
+ return {
30
+ listType: 'OL',
31
+ styleType: numberingType,
32
+ index: !isNewList(listMarker) &&
33
+ previousListStyle === numberingType &&
34
+ previousIndex
35
+ ? previousIndex + 1
36
+ : undefined,
37
+ };
38
+ }
39
+ }
40
+ }
41
+ return undefined;
42
+ }
43
+ var getPreviousListIndex = function (model, previousListItem) {
44
+ return previousListItem ? findListItemsInSameThread(model, previousListItem).length : undefined;
45
+ };
46
+ var getPreviousListLevel = function (model, paragraph) {
47
+ var blocks = getOperationalBlocks(model, ['ListItem'], ['TableCell'])[0];
48
+ var listItem = undefined;
49
+ if (blocks) {
50
+ var listBlockIndex = blocks.parent.blocks.indexOf(paragraph);
51
+ if (listBlockIndex > -1) {
52
+ for (var i = listBlockIndex - 1; i > -1; i--) {
53
+ var item = blocks.parent.blocks[i];
54
+ if (isBlockGroupOfType(item, 'ListItem')) {
55
+ listItem = item;
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ return listItem;
62
+ };
63
+ var getPreviousListStyle = function (list) {
64
+ var _a;
65
+ if (list === null || list === void 0 ? void 0 : list.levels[0].dataset) {
66
+ return (_a = updateListMetadata(list.levels[0])) === null || _a === void 0 ? void 0 : _a.orderedStyleType;
67
+ }
68
+ };
69
+ var bulletListType = {
70
+ '*': BulletListType.Disc,
71
+ '-': BulletListType.Dash,
72
+ '--': BulletListType.Square,
73
+ '->': BulletListType.LongArrow,
74
+ '-->': BulletListType.DoubleLongArrow,
75
+ '=>': BulletListType.UnfilledArrow,
76
+ '>': BulletListType.ShortArrow,
77
+ '—': BulletListType.Hyphen,
78
+ };
79
+ var isNewList = function (listMarker) {
80
+ var marker = listMarker.replace(/[^\w\s]/g, '');
81
+ var pattern = /^[1aAiI]$/;
82
+ return pattern.test(marker);
83
+ };
84
+ //# sourceMappingURL=getListTypeStyle.js.map