roosterjs-content-model-plugins 0.20.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 (264) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +262 -0
  3. package/lib/edit/ContentModelEditPlugin.d.ts +35 -0
  4. package/lib/edit/ContentModelEditPlugin.js +71 -0
  5. package/lib/edit/ContentModelEditPlugin.js.map +1 -0
  6. package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
  7. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +20 -0
  8. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
  9. package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
  10. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +91 -0
  11. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
  12. package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
  13. package/lib/edit/deleteSteps/deleteWordSelection.js +171 -0
  14. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -0
  15. package/lib/edit/handleKeyboardEventCommon.d.ts +15 -0
  16. package/lib/edit/handleKeyboardEventCommon.js +55 -0
  17. package/lib/edit/handleKeyboardEventCommon.js.map +1 -0
  18. package/lib/edit/keyboardDelete.d.ts +9 -0
  19. package/lib/edit/keyboardDelete.js +64 -0
  20. package/lib/edit/keyboardDelete.js.map +1 -0
  21. package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -0
  22. package/lib/edit/utils/getLeafSiblingBlock.js +76 -0
  23. package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -0
  24. package/lib/index.d.ts +2 -0
  25. package/lib/index.js +8 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/paste/ContentModelPastePlugin.d.ts +42 -0
  28. package/lib/paste/ContentModelPastePlugin.js +149 -0
  29. package/lib/paste/ContentModelPastePlugin.js.map +1 -0
  30. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
  31. package/lib/paste/Excel/processPastedContentFromExcel.js +83 -0
  32. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -0
  33. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
  34. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -0
  35. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
  36. package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
  37. package/lib/paste/WacComponents/processPastedContentWacComponents.js +208 -0
  38. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
  39. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
  40. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +70 -0
  41. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
  42. package/lib/paste/WordDesktop/processWordComments.d.ts +7 -0
  43. package/lib/paste/WordDesktop/processWordComments.js +22 -0
  44. package/lib/paste/WordDesktop/processWordComments.js.map +1 -0
  45. package/lib/paste/WordDesktop/processWordLists.d.ts +10 -0
  46. package/lib/paste/WordDesktop/processWordLists.js +155 -0
  47. package/lib/paste/WordDesktop/processWordLists.js.map +1 -0
  48. package/lib/paste/pasteSourceValidations/constants.d.ts +17 -0
  49. package/lib/paste/pasteSourceValidations/constants.js +22 -0
  50. package/lib/paste/pasteSourceValidations/constants.js.map +1 -0
  51. package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
  52. package/lib/paste/pasteSourceValidations/documentContainWacElements.js +25 -0
  53. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
  54. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
  55. package/lib/paste/pasteSourceValidations/getPasteSource.js +44 -0
  56. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
  57. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
  58. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +17 -0
  59. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
  60. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
  61. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +19 -0
  62. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
  63. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
  64. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +15 -0
  65. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
  66. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
  67. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +15 -0
  68. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
  69. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
  70. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +19 -0
  71. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
  72. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
  73. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +19 -0
  74. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
  75. package/lib/paste/utils/addParser.d.ts +5 -0
  76. package/lib/paste/utils/addParser.js +17 -0
  77. package/lib/paste/utils/addParser.js.map +1 -0
  78. package/lib/paste/utils/deprecatedColorParser.d.ts +5 -0
  79. package/lib/paste/utils/deprecatedColorParser.js +20 -0
  80. package/lib/paste/utils/deprecatedColorParser.js.map +1 -0
  81. package/lib/paste/utils/getStyles.d.ts +6 -0
  82. package/lib/paste/utils/getStyles.js +23 -0
  83. package/lib/paste/utils/getStyles.js.map +1 -0
  84. package/lib/paste/utils/linkParser.d.ts +5 -0
  85. package/lib/paste/utils/linkParser.js +28 -0
  86. package/lib/paste/utils/linkParser.js.map +1 -0
  87. package/lib/paste/utils/setProcessor.d.ts +5 -0
  88. package/lib/paste/utils/setProcessor.js +14 -0
  89. package/lib/paste/utils/setProcessor.js.map +1 -0
  90. package/lib-amd/edit/ContentModelEditPlugin.d.ts +35 -0
  91. package/lib-amd/edit/ContentModelEditPlugin.js +72 -0
  92. package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -0
  93. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
  94. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +21 -0
  95. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
  96. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
  97. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +90 -0
  98. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
  99. package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
  100. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +170 -0
  101. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -0
  102. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +15 -0
  103. package/lib-amd/edit/handleKeyboardEventCommon.js +56 -0
  104. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -0
  105. package/lib-amd/edit/keyboardDelete.d.ts +9 -0
  106. package/lib-amd/edit/keyboardDelete.js +60 -0
  107. package/lib-amd/edit/keyboardDelete.js.map +1 -0
  108. package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -0
  109. package/lib-amd/edit/utils/getLeafSiblingBlock.js +76 -0
  110. package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -0
  111. package/lib-amd/index.d.ts +2 -0
  112. package/lib-amd/index.js +8 -0
  113. package/lib-amd/index.js.map +1 -0
  114. package/lib-amd/paste/ContentModelPastePlugin.d.ts +42 -0
  115. package/lib-amd/paste/ContentModelPastePlugin.js +141 -0
  116. package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -0
  117. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
  118. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +81 -0
  119. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -0
  120. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
  121. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +21 -0
  122. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
  123. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
  124. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +207 -0
  125. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
  126. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
  127. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +65 -0
  128. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
  129. package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -0
  130. package/lib-amd/paste/WordDesktop/processWordComments.js +23 -0
  131. package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -0
  132. package/lib-amd/paste/WordDesktop/processWordLists.d.ts +10 -0
  133. package/lib-amd/paste/WordDesktop/processWordLists.js +154 -0
  134. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -0
  135. package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -0
  136. package/lib-amd/paste/pasteSourceValidations/constants.js +24 -0
  137. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -0
  138. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
  139. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +27 -0
  140. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
  141. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
  142. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +39 -0
  143. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
  144. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
  145. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +19 -0
  146. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
  147. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
  148. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +21 -0
  149. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
  150. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
  151. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +17 -0
  152. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
  153. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
  154. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +17 -0
  155. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
  156. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
  157. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +21 -0
  158. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
  159. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
  160. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +21 -0
  161. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
  162. package/lib-amd/paste/utils/addParser.d.ts +5 -0
  163. package/lib-amd/paste/utils/addParser.js +19 -0
  164. package/lib-amd/paste/utils/addParser.js.map +1 -0
  165. package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -0
  166. package/lib-amd/paste/utils/deprecatedColorParser.js +21 -0
  167. package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -0
  168. package/lib-amd/paste/utils/getStyles.d.ts +6 -0
  169. package/lib-amd/paste/utils/getStyles.js +25 -0
  170. package/lib-amd/paste/utils/getStyles.js.map +1 -0
  171. package/lib-amd/paste/utils/linkParser.d.ts +5 -0
  172. package/lib-amd/paste/utils/linkParser.js +29 -0
  173. package/lib-amd/paste/utils/linkParser.js.map +1 -0
  174. package/lib-amd/paste/utils/setProcessor.d.ts +5 -0
  175. package/lib-amd/paste/utils/setProcessor.js +16 -0
  176. package/lib-amd/paste/utils/setProcessor.js.map +1 -0
  177. package/lib-mjs/edit/ContentModelEditPlugin.d.ts +35 -0
  178. package/lib-mjs/edit/ContentModelEditPlugin.js +68 -0
  179. package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -0
  180. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
  181. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +16 -0
  182. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
  183. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
  184. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +88 -0
  185. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
  186. package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
  187. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +168 -0
  188. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -0
  189. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +15 -0
  190. package/lib-mjs/edit/handleKeyboardEventCommon.js +49 -0
  191. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -0
  192. package/lib-mjs/edit/keyboardDelete.d.ts +9 -0
  193. package/lib-mjs/edit/keyboardDelete.js +60 -0
  194. package/lib-mjs/edit/keyboardDelete.js.map +1 -0
  195. package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -0
  196. package/lib-mjs/edit/utils/getLeafSiblingBlock.js +72 -0
  197. package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -0
  198. package/lib-mjs/index.d.ts +2 -0
  199. package/lib-mjs/index.js +3 -0
  200. package/lib-mjs/index.js.map +1 -0
  201. package/lib-mjs/paste/ContentModelPastePlugin.d.ts +42 -0
  202. package/lib-mjs/paste/ContentModelPastePlugin.js +146 -0
  203. package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -0
  204. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
  205. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +78 -0
  206. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -0
  207. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
  208. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +16 -0
  209. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
  210. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
  211. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +204 -0
  212. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
  213. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
  214. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +65 -0
  215. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
  216. package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -0
  217. package/lib-mjs/paste/WordDesktop/processWordComments.js +18 -0
  218. package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -0
  219. package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +10 -0
  220. package/lib-mjs/paste/WordDesktop/processWordLists.js +151 -0
  221. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -0
  222. package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -0
  223. package/lib-mjs/paste/pasteSourceValidations/constants.js +19 -0
  224. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -0
  225. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
  226. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +21 -0
  227. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
  228. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
  229. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +40 -0
  230. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
  231. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
  232. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +13 -0
  233. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
  234. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
  235. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +15 -0
  236. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
  237. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
  238. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +11 -0
  239. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
  240. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
  241. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +11 -0
  242. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
  243. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
  244. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +15 -0
  245. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
  246. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
  247. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +15 -0
  248. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
  249. package/lib-mjs/paste/utils/addParser.d.ts +5 -0
  250. package/lib-mjs/paste/utils/addParser.js +14 -0
  251. package/lib-mjs/paste/utils/addParser.js.map +1 -0
  252. package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -0
  253. package/lib-mjs/paste/utils/deprecatedColorParser.js +16 -0
  254. package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -0
  255. package/lib-mjs/paste/utils/getStyles.d.ts +6 -0
  256. package/lib-mjs/paste/utils/getStyles.js +19 -0
  257. package/lib-mjs/paste/utils/getStyles.js.map +1 -0
  258. package/lib-mjs/paste/utils/linkParser.d.ts +5 -0
  259. package/lib-mjs/paste/utils/linkParser.js +24 -0
  260. package/lib-mjs/paste/utils/linkParser.js.map +1 -0
  261. package/lib-mjs/paste/utils/setProcessor.d.ts +5 -0
  262. package/lib-mjs/paste/utils/setProcessor.js +10 -0
  263. package/lib-mjs/paste/utils/setProcessor.js.map +1 -0
  264. package/package.json +22 -0
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ RoosterJS
2
+ Copyright (c) Microsoft Corporation
3
+ All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Copyright (c) Microsoft Corporation. All rights reserved.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ [![Build Status](https://github.com/microsoft/roosterjs/actions/workflows/build-and-deploy.yml/badge.svg)](https://github.com/microsoft/roosterjs/actions/workflows/build-and-deploy.yml)
2
+
3
+ # Rooster
4
+
5
+ Rooster is a framework-independent JavaScript rich-text editor neatly nested
6
+ inside one HTML `<div>` element. Editing operations performed by end users are
7
+ handled in simple ways to generate the final HTML.
8
+
9
+ To view the sample site, please click the link below:
10
+
11
+ [RoosterJs Sample Site](https://microsoft.github.io/roosterjs/index.html).
12
+
13
+ ## Upgrade from RoosterJs 7.\*
14
+
15
+ Please see [here](https://github.com/microsoft/roosterjs/wiki/RoosterJs-8).
16
+
17
+ ## Features
18
+
19
+ ### Packages
20
+
21
+ Rooster contains 6 basic packages.
22
+
23
+ 1. [roosterjs](https://microsoft.github.io/roosterjs/docs/modules/roosterjs.html):
24
+ A facade of all Rooster code for those who want a quick start. Use the
25
+ `createEditor()` function in roosterjs to create an editor with default
26
+ configurations.
27
+
28
+ 2. [roosterjs-editor-core](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_core.html):
29
+ Defines the core editor and plugin infrastructure. Use `roosterjs-editor-core`
30
+ instead of `roosterjs` to build and customize your own editor.
31
+
32
+ 3. [roosterjs-editor-api](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_api.html):
33
+ Defines APIs for editor operations. Use these APIs to modify content and
34
+ formatting in the editor you built using `roosterjs-editor-core`.
35
+
36
+ 4. [roosterjs-editor-dom](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_dom.html):
37
+ Defines APIs for DOM operations. Use `roosterjs-editor-api` instead unless
38
+ you want to access DOM API directly.
39
+
40
+ 5. [roosterjs-editor-plugins](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_plugins.html):
41
+ Defines basic plugins for common features. Examples: making hyperlinks,
42
+ pasting HTML content, inserting inline images.
43
+
44
+ 6. [roosterjs-editor-types](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types.html):
45
+ Defines public interfaces and enumerations.
46
+
47
+ There are also some extension packages to provide additional functionalities.
48
+
49
+ 1. [roosterjs-color-utils](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_color_utils.html):
50
+ Provide color transformation utility to make editor work under dark mode.
51
+
52
+ 2. [roosterjs-react](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_react.html):
53
+ Provide a React wrapper of roosterjs so it can be easily used with React.
54
+
55
+ 3. [roosterjs-editor-types-compatible](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types_compatible.html):
56
+ Provide types that are compatible with isolatedModules mode. When using isolatedModules mode,
57
+ "const enum" will not work correctly, this package provides enums with prefix "Compatible" in
58
+ their names and they have the same value with const enums in roosterjs-editor-types package
59
+
60
+ ### APIs
61
+
62
+ Rooster provides DOM level APIs (in `roosterjs-editor-dom`), core APIs (in `roosterjs-editor-core`), and formatting APIs
63
+ (in `roosterjs-editor-api`) to perform editing operations.
64
+
65
+ `roosterjs-editor-dom` provides several levels of DOM operations:
66
+
67
+ - Perform basic DOM operations such as `wrap()`, `unwrap()`, ...
68
+ - Wrap a given DOM node with `InlineElement` or `BlockElement` and perform
69
+ operations with DOM Walker API.
70
+ - Perform DOM operations on a given scope using scopers.
71
+ - Travel among `InlineElements` and `BlockElements` with scope using
72
+ ContentTraverser API.
73
+
74
+ `roosterjs-editor-core` provides APIs for editor core. Editor class will call such
75
+ APIs to perform basic editor operations. These APIs are overridable by specifying
76
+ API overrides in Editor options when creating the editor.
77
+
78
+ `roosterjs-editor-api` provides APIs for scenario-based operations triggered by
79
+ user interaction.
80
+
81
+ ## Plugins
82
+
83
+ Rooster supports plugins. You can use built-in plugins or build your own.
84
+ Plugins call APIs to communicate with the editor. When an operation is
85
+ performed by the user or when content is changed by code, the editor will
86
+ trigger events for the plugins to handle.
87
+
88
+ Here's a sample plugin which will show a dialog containing "Hello Rooster" when
89
+ an "a" is typed in the editor:
90
+
91
+ ```typescript
92
+ class HelloRooster implements EditorPlugin {
93
+ getName() {
94
+ return 'HelloRooster';
95
+ }
96
+
97
+ initialize(editor: IEditor) {}
98
+
99
+ dispose() {}
100
+
101
+ onPluginEvent(e: PluginEvent) {
102
+ if (e.eventType == PluginEventType.KeyPress && e.rawEvent.which == 65) {
103
+ alert('Hello Rooster');
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ ## Installation
110
+
111
+ Install via NPM or Yarn:
112
+
113
+ `yarn add roosterjs`
114
+
115
+ You can also install sub packages separately:
116
+
117
+ `yarn add roosterjs-editor-core`
118
+
119
+ `yarn add roosterjs-editor-api`
120
+
121
+ `...`
122
+
123
+ In order to run the code below, you may also need to install [webpack](https://webpack.js.org/):
124
+
125
+ `yarn add webpack -g`
126
+
127
+ ## Usage
128
+
129
+ ### A quick start
130
+
131
+ 1. Create `editor.htm` which contains a DIV with some styles, buttons to handle some click events and a reference to rooster.js (update with the path to your rooster.js file):
132
+
133
+ ```html
134
+ <html>
135
+ <body>
136
+ <div style="width: 500px; height: 400px; border: solid 1px black" id="contentDiv"></div>
137
+ <button id="buttonB">B</button> <button id="buttonI">I</button>
138
+ <button id="buttonU">U</button>
139
+ <script src="rooster.js"></script>
140
+ <script>
141
+ var contentDiv = document.getElementById('contentDiv');
142
+ var editor = roosterjs.createEditor(contentDiv);
143
+
144
+ editor.setContent('Welcome to <b>RoosterJs</b>!');
145
+ document.getElementById('buttonB').addEventListener('click', function () {
146
+ roosterjs.toggleBold(editor);
147
+ });
148
+ document.getElementById('buttonI').addEventListener('click', function () {
149
+ roosterjs.toggleItalic(editor);
150
+ });
151
+ document.getElementById('buttonU').addEventListener('click', function () {
152
+ roosterjs.toggleUnderline(editor);
153
+ });
154
+ </script>
155
+ </body>
156
+ </html>
157
+ ```
158
+
159
+ 2. Navigate to editor.htm, you will see a editor shown in the page which includes buttons with bold, italic, underline
160
+ actions.
161
+
162
+ ## Sample code
163
+
164
+ To view the sample site, please click [here](https://microsoft.github.io/roosterjs/index.html).
165
+
166
+ To build the sample site code yourself, follow these instructions:
167
+
168
+ 1. Get dependencies using [yarn](https://yarnpkg.com) or [npm](https://www.npmjs.com/):
169
+
170
+ ```cmd
171
+ yarn
172
+ ```
173
+
174
+ 2. Build the source code, and start the sample editor:
175
+
176
+ ```
177
+ yarn start
178
+ ```
179
+
180
+ or
181
+
182
+ ```
183
+ npm start
184
+ ```
185
+
186
+ ## Debugging
187
+
188
+ There are two options for debugging:
189
+
190
+ 1. Debugging from VSCode
191
+
192
+ - Ensure the sample editor is running
193
+ - Set the breakpoints within VSCode
194
+ - Select "Debug app in Chrome" from the VSCode debugging configuration dropdown
195
+ <img src="/assets/readme-images/debug-in-VSCode.png" width="411" height="278"><br>
196
+ - Run the scenario that needs to be debugged
197
+
198
+ 2. Debugging directly from the development tools within the web browser
199
+ - The directions for how to do this are specific to each web browser. By opening the developer
200
+ tools for the web browser that Rooster is running on, you will be able to set breakpoints in
201
+ the code and debug accordingly.
202
+
203
+ ## Running tests
204
+
205
+ There are two ways that tests can be run:
206
+
207
+ 1. Run all tests or a single test from VSCode<br>
208
+ - (Skip if running all tests) Ensure the file that you want to test is selected (ie: toggleBold.ts
209
+ or toggleBoldTest.ts)
210
+ - Select "Test all files" or "Test current file" from the VSCode debugging configuration dropdown
211
+ <img src="/assets/readme-images/test-in-VSCode.png" width="402" height="268">
212
+ 2. Run all tests from command line
213
+ ```
214
+ yarn test
215
+ ```
216
+
217
+ ## Dependencies
218
+
219
+ As a NodeJs package, RoosterJs has dependencies for runtime (specified in package.json under each sub
220
+ packages in "dependencies" section) and dependencies for build time (specified in package.json under
221
+ root path in "devDependencies" section).
222
+
223
+ For runtime dependencies, there are two parts:
224
+
225
+ - Internal dependencies (a RoosterJs package depends on other RoosterJs packages)
226
+ - External dependencies (RoosterJs depends on other NPM packages)
227
+
228
+ Currently we have very few external dependencies. Before adding any new dependency, we need to check:
229
+
230
+ 1. What's the value of the new dependency and the code using the dependency bring into roosterjs?
231
+ If we add a new dependency and create our new API to just call into the dependency, that new API
232
+ doesn't actually bring too much value, and people who uses roosterjs in their project can do this
233
+ themselves in their code, and we should not add such dependency to people who don't really need it.
234
+
235
+ 2. What's the dependency tree of the dependency?
236
+ If we introduce a new dependency which has a deep dependency tree, we need to be careful since it
237
+ means we are actually adding a lot of new dependencies and our code size may be increased a lot.
238
+
239
+ 3. How much functionalities do we need from the dependency?
240
+ If the dependency provides a lot of functionalities but we actually only need a small piece of them,
241
+ we may need to consider other solutions, such as find another smaller one, or do it ourselves.
242
+
243
+ 4. What's the license of the dependency?
244
+ A dependency package under MIT license is good to be used for RoosterJs. For other licenses, we need
245
+ to review and see if we can take it as a dependency.
246
+
247
+ If you still feel a new dependency is required after checking these questions, we can review it and
248
+ finally decide whether we should add the new dependency.
249
+
250
+ For build time dependencies, it is more flexible to add new dependencies since it won't increase runtime
251
+ code size or dependencies.
252
+
253
+ ## More documentation
254
+
255
+ We are still working on more documentation in [roosterjs wiki](https://github.com/Microsoft/roosterjs/wiki) and [API reference](https://microsoft.github.io/roosterjs/docs/index.html).
256
+
257
+ ## License - MIT
258
+
259
+ License
260
+ Copyright (c) Microsoft Corporation. All rights reserved.
261
+
262
+ Licensed under the [MIT](LICENSE) License.
@@ -0,0 +1,35 @@
1
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
2
+ /**
3
+ * ContentModel edit plugins helps editor to do editing operation on top of content model.
4
+ * This includes:
5
+ * 1. Delete Key
6
+ * 2. Backspace Key
7
+ */
8
+ export declare class ContentModelEditPlugin implements EditorPlugin {
9
+ private editor;
10
+ /**
11
+ * Get name of this plugin
12
+ */
13
+ getName(): string;
14
+ /**
15
+ * The first method that editor will call to a plugin when editor is initializing.
16
+ * It will pass in the editor instance, plugin should take this chance to save the
17
+ * editor reference so that it can call to any editor method or format API later.
18
+ * @param editor The editor object
19
+ */
20
+ initialize(editor: IEditor): void;
21
+ /**
22
+ * The last method that editor will call to a plugin before it is disposed.
23
+ * Plugin can take this chance to clear the reference to editor. After this method is
24
+ * called, plugin should not call to any editor method since it will result in error.
25
+ */
26
+ dispose(): void;
27
+ /**
28
+ * Core method for a plugin. Once an event happens in editor, editor will call this
29
+ * method of each plugin to handle the event as long as the event is not handled
30
+ * exclusively by another plugin.
31
+ * @param event The event to handle:
32
+ */
33
+ onPluginEvent(event: PluginEvent): void;
34
+ private handleKeyDownEvent;
35
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContentModelEditPlugin = void 0;
4
+ var keyboardDelete_1 = require("./keyboardDelete");
5
+ /**
6
+ * ContentModel edit plugins helps editor to do editing operation on top of content model.
7
+ * This includes:
8
+ * 1. Delete Key
9
+ * 2. Backspace Key
10
+ */
11
+ var ContentModelEditPlugin = /** @class */ (function () {
12
+ function ContentModelEditPlugin() {
13
+ this.editor = null;
14
+ }
15
+ /**
16
+ * Get name of this plugin
17
+ */
18
+ ContentModelEditPlugin.prototype.getName = function () {
19
+ return 'ContentModelEdit';
20
+ };
21
+ /**
22
+ * The first method that editor will call to a plugin when editor is initializing.
23
+ * It will pass in the editor instance, plugin should take this chance to save the
24
+ * editor reference so that it can call to any editor method or format API later.
25
+ * @param editor The editor object
26
+ */
27
+ ContentModelEditPlugin.prototype.initialize = function (editor) {
28
+ // TODO: Later we may need a different interface for Content Model editor plugin
29
+ this.editor = editor;
30
+ };
31
+ /**
32
+ * The last method that editor will call to a plugin before it is disposed.
33
+ * Plugin can take this chance to clear the reference to editor. After this method is
34
+ * called, plugin should not call to any editor method since it will result in error.
35
+ */
36
+ ContentModelEditPlugin.prototype.dispose = function () {
37
+ this.editor = null;
38
+ };
39
+ /**
40
+ * Core method for a plugin. Once an event happens in editor, editor will call this
41
+ * method of each plugin to handle the event as long as the event is not handled
42
+ * exclusively by another plugin.
43
+ * @param event The event to handle:
44
+ */
45
+ ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
46
+ if (this.editor) {
47
+ switch (event.eventType) {
48
+ case 0 /* KeyDown */:
49
+ this.handleKeyDownEvent(this.editor, event);
50
+ break;
51
+ }
52
+ }
53
+ };
54
+ ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
55
+ var rawEvent = event.rawEvent;
56
+ if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
57
+ // TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model
58
+ switch (rawEvent.key) {
59
+ case 'Backspace':
60
+ case 'Delete':
61
+ // Use our API to handle BACKSPACE/DELETE key.
62
+ // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache
63
+ (0, keyboardDelete_1.keyboardDelete)(editor, rawEvent);
64
+ break;
65
+ }
66
+ }
67
+ };
68
+ return ContentModelEditPlugin;
69
+ }());
70
+ exports.ContentModelEditPlugin = ContentModelEditPlugin;
71
+ //# sourceMappingURL=ContentModelEditPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAUlD;;;;;GAKG;AACH;IAAA;QACY,WAAM,GAA+B,IAAI,CAAC;IA4DtD,CAAC;IA1DG;;OAEG;IACH,wCAAO,GAAP;QACI,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,2CAAU,GAAV,UAAW,MAAe;QACtB,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,wCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,8CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB;oBACI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,mDAAkB,GAA1B,UAA2B,MAA2B,EAAE,KAAyB;QAC7E,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,qHAAqH;YACrH,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,QAAQ;oBACT,8CAA8C;oBAC9C,qIAAqI;oBACrI,IAAA,+BAAc,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBACjC,MAAM;aACb;SACJ;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,wDAAsB","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n EditorPlugin,\n IEditor,\n PluginEvent,\n PluginKeyDownEvent,\n} from 'roosterjs-editor-types';\n\n/**\n * ContentModel edit plugins helps editor to do editing operation on top of content model.\n * This includes:\n * 1. Delete Key\n * 2. Backspace Key\n */\nexport class ContentModelEditPlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelEdit';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor as IContentModelEditor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case PluginEventType.KeyDown:\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IContentModelEditor, event: PluginKeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n // TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model\n switch (rawEvent.key) {\n case 'Backspace':\n case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n }\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const deleteAllSegmentBefore: DeleteSelectionStep;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteAllSegmentBefore = void 0;
4
+ var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
5
+ /**
6
+ * @internal
7
+ */
8
+ var deleteAllSegmentBefore = function (context) {
9
+ var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker;
10
+ var index = paragraph.segments.indexOf(marker);
11
+ for (var i = index - 1; i >= 0; i--) {
12
+ var segment = paragraph.segments[i];
13
+ segment.isSelected = true;
14
+ if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segment, context.formatContext)) {
15
+ context.deleteResult = 'range';
16
+ }
17
+ }
18
+ };
19
+ exports.deleteAllSegmentBefore = deleteAllSegmentBefore;
20
+ //# sourceMappingURL=deleteAllSegmentBefore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;AAAA,6EAA6D;AAG7D;;GAEG;AACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;IACxD,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,SAAS,eAAA,EAAE,MAAM,YAAwB,CAAC;IAClD,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;YAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;SAClC;KACJ;AACL,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC","sourcesContent":["import { deleteSegment } from 'roosterjs-content-model-core';\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteAllSegmentBefore: DeleteSelectionStep = context => {\n const { paragraph, marker } = context.insertPoint;\n const index = paragraph.segments.indexOf(marker);\n\n for (let i = index - 1; i >= 0; i--) {\n const segment = paragraph.segments[i];\n\n segment.isSelected = true;\n\n if (deleteSegment(paragraph, segment, context.formatContext)) {\n context.deleteResult = 'range';\n }\n }\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal if we didn't delete anything, and we want to delete forward, now perform it
4
+ */
5
+ export declare const forwardDeleteCollapsedSelection: DeleteSelectionStep;
6
+ /**
7
+ * @internal if we didn't delete anything, and we want to delete backward, now perform it
8
+ */
9
+ export declare const backwardDeleteCollapsedSelection: DeleteSelectionStep;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.backwardDeleteCollapsedSelection = exports.forwardDeleteCollapsedSelection = void 0;
4
+ var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
5
+ var getLeafSiblingBlock_1 = require("../utils/getLeafSiblingBlock");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ function getDeleteCollapsedSelection(direction) {
8
+ return function (context) {
9
+ var _a;
10
+ var isForward = direction == 'forward';
11
+ var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
12
+ var segments = paragraph.segments;
13
+ fixupBr(segments);
14
+ var index = segments.indexOf(marker) + (isForward ? 1 : -1);
15
+ var segmentToDelete = segments[index];
16
+ var blockToDelete;
17
+ if (segmentToDelete) {
18
+ if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segmentToDelete, context.formatContext, direction)) {
19
+ context.deleteResult = 'singleChar';
20
+ // It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit
21
+ // to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953
22
+ (0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
23
+ }
24
+ }
25
+ else if ((blockToDelete = (0, getLeafSiblingBlock_1.getLeafSiblingBlock)(path, paragraph, isForward))) {
26
+ var block = blockToDelete.block, path_1 = blockToDelete.path, siblingSegment = blockToDelete.siblingSegment;
27
+ if (block.blockType == 'Paragraph') {
28
+ if (siblingSegment) {
29
+ // When selection is under general segment, need to check if it has a sibling sibling, and delete from it
30
+ if ((0, roosterjs_content_model_core_1.deleteSegment)(block, siblingSegment, context.formatContext, direction)) {
31
+ context.deleteResult = 'range';
32
+ }
33
+ }
34
+ else {
35
+ if (isForward) {
36
+ context.lastParagraph = block;
37
+ }
38
+ else {
39
+ if (((_a = block.segments[block.segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
40
+ block.segments.pop();
41
+ }
42
+ context.insertPoint = {
43
+ marker: marker,
44
+ paragraph: block,
45
+ path: path_1,
46
+ tableContext: tableContext,
47
+ };
48
+ context.lastParagraph = paragraph;
49
+ delete block.cachedElement;
50
+ }
51
+ context.deleteResult = 'range';
52
+ }
53
+ // When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context
54
+ context.lastTableContext = tableContext;
55
+ }
56
+ else {
57
+ if ((0, roosterjs_content_model_core_1.deleteBlock)(path_1[0].blocks, block, undefined /*replacement*/, context.formatContext, direction)) {
58
+ context.deleteResult = 'range';
59
+ }
60
+ }
61
+ }
62
+ else {
63
+ // We have nothing to delete, in this case we don't want browser handle it as well.
64
+ // Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes
65
+ // editor is really empty. We don't want that happen. So the handling should stop here.
66
+ context.deleteResult = 'nothingToDelete';
67
+ }
68
+ };
69
+ }
70
+ /**
71
+ * If the last segment is BR, remove it for now. We may add it back later when normalize model.
72
+ * So that if this is an empty paragraph, it will start to delete next block
73
+ */
74
+ function fixupBr(segments) {
75
+ var _a, _b;
76
+ if (((_a = segments[segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
77
+ var segmentsWithoutBr = segments.filter(function (x) { return x.segmentType != 'SelectionMarker'; });
78
+ if (((_b = segmentsWithoutBr[segmentsWithoutBr.length - 2]) === null || _b === void 0 ? void 0 : _b.segmentType) != 'Br') {
79
+ segments.pop();
80
+ }
81
+ }
82
+ }
83
+ /**
84
+ * @internal if we didn't delete anything, and we want to delete forward, now perform it
85
+ */
86
+ exports.forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');
87
+ /**
88
+ * @internal if we didn't delete anything, and we want to delete backward, now perform it
89
+ */
90
+ exports.backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');
91
+ //# sourceMappingURL=deleteCollapsedSelection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":"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","sourcesContent":["import { deleteBlock, deleteSegment } from 'roosterjs-content-model-core';\nimport { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type { ContentModelSegment, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n const isForward = direction == 'forward';\n const { paragraph, marker, path, tableContext } = context.insertPoint;\n const segments = paragraph.segments;\n\n fixupBr(segments);\n\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\n const segmentToDelete = segments[index];\n let blockToDelete: BlockAndPath | null;\n\n if (segmentToDelete) {\n if (deleteSegment(paragraph, segmentToDelete, context.formatContext, direction)) {\n context.deleteResult = 'singleChar';\n\n // It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit\n // to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953\n setParagraphNotImplicit(paragraph);\n }\n } else if ((blockToDelete = getLeafSiblingBlock(path, paragraph, isForward))) {\n const { block, path, siblingSegment } = blockToDelete;\n\n if (block.blockType == 'Paragraph') {\n if (siblingSegment) {\n // When selection is under general segment, need to check if it has a sibling sibling, and delete from it\n if (deleteSegment(block, siblingSegment, context.formatContext, direction)) {\n context.deleteResult = 'range';\n }\n } else {\n if (isForward) {\n context.lastParagraph = block;\n } else {\n if (block.segments[block.segments.length - 1]?.segmentType == 'Br') {\n block.segments.pop();\n }\n\n context.insertPoint = {\n marker,\n paragraph: block,\n path,\n tableContext,\n };\n context.lastParagraph = paragraph;\n delete block.cachedElement;\n }\n\n context.deleteResult = 'range';\n }\n\n // When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context\n context.lastTableContext = tableContext;\n } else {\n if (\n deleteBlock(\n path[0].blocks,\n block,\n undefined /*replacement*/,\n context.formatContext,\n direction\n )\n ) {\n context.deleteResult = 'range';\n }\n }\n } else {\n // We have nothing to delete, in this case we don't want browser handle it as well.\n // Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes\n // editor is really empty. We don't want that happen. So the handling should stop here.\n context.deleteResult = 'nothingToDelete';\n }\n };\n}\n\n/**\n * If the last segment is BR, remove it for now. We may add it back later when normalize model.\n * So that if this is an empty paragraph, it will start to delete next block\n */\nfunction fixupBr(segments: ContentModelSegment[]) {\n if (segments[segments.length - 1]?.segmentType == 'Br') {\n const segmentsWithoutBr = segments.filter(x => x.segmentType != 'SelectionMarker');\n\n if (segmentsWithoutBr[segmentsWithoutBr.length - 2]?.segmentType != 'Br') {\n segments.pop();\n }\n }\n}\n\n/**\n * @internal if we didn't delete anything, and we want to delete forward, now perform it\n */\nexport const forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');\n\n/**\n * @internal if we didn't delete anything, and we want to delete backward, now perform it\n */\nexport const backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');\n"]}
@@ -0,0 +1,9 @@
1
+ import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const forwardDeleteWordSelection: DeleteSelectionStep;
6
+ /**
7
+ * @internal
8
+ */
9
+ export declare const backwardDeleteWordSelection: DeleteSelectionStep;