roosterjs-content-model-plugins 0.21.2 → 0.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/lib/edit/ContentModelEditPlugin.d.ts +35 -35
  2. package/lib/edit/ContentModelEditPlugin.js +75 -75
  3. package/lib/edit/ContentModelEditPlugin.js.map +1 -1
  4. package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  5. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +19 -19
  6. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  7. package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  8. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +90 -90
  9. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  10. package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  11. package/lib/edit/deleteSteps/deleteWordSelection.js +170 -170
  12. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  13. package/lib/edit/handleKeyboardEventCommon.d.ts +15 -15
  14. package/lib/edit/handleKeyboardEventCommon.js +54 -54
  15. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  16. package/lib/edit/keyboardDelete.d.ts +8 -8
  17. package/lib/edit/keyboardDelete.js +67 -67
  18. package/lib/edit/keyboardDelete.js.map +1 -1
  19. package/lib/edit/keyboardInput.d.ts +5 -5
  20. package/lib/edit/keyboardInput.js +50 -49
  21. package/lib/edit/keyboardInput.js.map +1 -1
  22. package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  23. package/lib/edit/utils/getLeafSiblingBlock.js +75 -75
  24. package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
  25. package/lib/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  26. package/lib/entityDelimiter/EntityDelimiterPlugin.js +256 -254
  27. package/lib/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  28. package/lib/index.d.ts +3 -3
  29. package/lib/index.js +9 -9
  30. package/lib/index.js.map +1 -1
  31. package/lib/paste/ContentModelPastePlugin.d.ts +42 -42
  32. package/lib/paste/ContentModelPastePlugin.js +148 -148
  33. package/lib/paste/ContentModelPastePlugin.js.map +1 -1
  34. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  35. package/lib/paste/Excel/processPastedContentFromExcel.js +82 -82
  36. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  37. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  38. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +19 -19
  39. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  40. package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  41. package/lib/paste/WacComponents/processPastedContentWacComponents.js +207 -207
  42. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  43. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  44. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +69 -69
  45. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  46. package/lib/paste/WordDesktop/processWordComments.d.ts +7 -7
  47. package/lib/paste/WordDesktop/processWordComments.js +21 -21
  48. package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
  49. package/lib/paste/WordDesktop/processWordLists.d.ts +10 -10
  50. package/lib/paste/WordDesktop/processWordLists.js +154 -154
  51. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  52. package/lib/paste/pasteSourceValidations/constants.d.ts +17 -17
  53. package/lib/paste/pasteSourceValidations/constants.js +21 -21
  54. package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
  55. package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  56. package/lib/paste/pasteSourceValidations/documentContainWacElements.js +24 -24
  57. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  58. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  59. package/lib/paste/pasteSourceValidations/getPasteSource.js +43 -43
  60. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  61. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  62. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +16 -16
  63. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  64. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  65. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +18 -18
  66. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  67. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  68. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +14 -14
  69. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  70. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  71. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +14 -14
  72. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  73. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  74. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +18 -18
  75. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  76. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  77. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +18 -18
  78. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  79. package/lib/paste/utils/addParser.d.ts +5 -5
  80. package/lib/paste/utils/addParser.js +16 -16
  81. package/lib/paste/utils/addParser.js.map +1 -1
  82. package/lib/paste/utils/deprecatedColorParser.d.ts +5 -5
  83. package/lib/paste/utils/deprecatedColorParser.js +19 -19
  84. package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
  85. package/lib/paste/utils/getStyles.d.ts +6 -6
  86. package/lib/paste/utils/getStyles.js +22 -22
  87. package/lib/paste/utils/getStyles.js.map +1 -1
  88. package/lib/paste/utils/linkParser.d.ts +5 -5
  89. package/lib/paste/utils/linkParser.js +27 -27
  90. package/lib/paste/utils/linkParser.js.map +1 -1
  91. package/lib/paste/utils/setProcessor.d.ts +5 -5
  92. package/lib/paste/utils/setProcessor.js +13 -13
  93. package/lib/paste/utils/setProcessor.js.map +1 -1
  94. package/lib-amd/edit/ContentModelEditPlugin.d.ts +35 -35
  95. package/lib-amd/edit/ContentModelEditPlugin.js +75 -75
  96. package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
  97. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  98. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +20 -20
  99. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  100. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  101. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +89 -89
  102. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  103. package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  104. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +169 -169
  105. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  106. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +15 -15
  107. package/lib-amd/edit/handleKeyboardEventCommon.js +55 -55
  108. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  109. package/lib-amd/edit/keyboardDelete.d.ts +8 -8
  110. package/lib-amd/edit/keyboardDelete.js +63 -63
  111. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  112. package/lib-amd/edit/keyboardInput.d.ts +5 -5
  113. package/lib-amd/edit/keyboardInput.js +50 -49
  114. package/lib-amd/edit/keyboardInput.js.map +1 -1
  115. package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  116. package/lib-amd/edit/utils/getLeafSiblingBlock.js +75 -75
  117. package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
  118. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  119. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js +255 -253
  120. package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  121. package/lib-amd/index.d.ts +3 -3
  122. package/lib-amd/index.js +8 -8
  123. package/lib-amd/index.js.map +1 -1
  124. package/lib-amd/paste/ContentModelPastePlugin.d.ts +42 -42
  125. package/lib-amd/paste/ContentModelPastePlugin.js +140 -140
  126. package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
  127. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  128. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +80 -80
  129. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  130. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  131. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -20
  132. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  133. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  134. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +206 -206
  135. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  136. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  137. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
  138. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  139. package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -7
  140. package/lib-amd/paste/WordDesktop/processWordComments.js +22 -22
  141. package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
  142. package/lib-amd/paste/WordDesktop/processWordLists.d.ts +10 -10
  143. package/lib-amd/paste/WordDesktop/processWordLists.js +153 -153
  144. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  145. package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -17
  146. package/lib-amd/paste/pasteSourceValidations/constants.js +23 -23
  147. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
  148. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  149. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +26 -26
  150. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  151. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  152. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +38 -38
  153. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  154. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  155. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +18 -18
  156. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  157. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  158. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +20 -20
  159. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  160. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  161. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +16 -16
  162. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  163. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  164. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +16 -16
  165. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  166. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  167. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +20 -20
  168. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  169. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  170. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +20 -20
  171. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  172. package/lib-amd/paste/utils/addParser.d.ts +5 -5
  173. package/lib-amd/paste/utils/addParser.js +18 -18
  174. package/lib-amd/paste/utils/addParser.js.map +1 -1
  175. package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -5
  176. package/lib-amd/paste/utils/deprecatedColorParser.js +20 -20
  177. package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
  178. package/lib-amd/paste/utils/getStyles.d.ts +6 -6
  179. package/lib-amd/paste/utils/getStyles.js +24 -24
  180. package/lib-amd/paste/utils/getStyles.js.map +1 -1
  181. package/lib-amd/paste/utils/linkParser.d.ts +5 -5
  182. package/lib-amd/paste/utils/linkParser.js +28 -28
  183. package/lib-amd/paste/utils/linkParser.js.map +1 -1
  184. package/lib-amd/paste/utils/setProcessor.d.ts +5 -5
  185. package/lib-amd/paste/utils/setProcessor.js +15 -15
  186. package/lib-amd/paste/utils/setProcessor.js.map +1 -1
  187. package/lib-mjs/edit/ContentModelEditPlugin.d.ts +35 -35
  188. package/lib-mjs/edit/ContentModelEditPlugin.js +72 -72
  189. package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
  190. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
  191. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +15 -15
  192. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  193. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
  194. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +87 -87
  195. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  196. package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
  197. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +167 -167
  198. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  199. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +15 -15
  200. package/lib-mjs/edit/handleKeyboardEventCommon.js +48 -48
  201. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  202. package/lib-mjs/edit/keyboardDelete.d.ts +8 -8
  203. package/lib-mjs/edit/keyboardDelete.js +63 -63
  204. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  205. package/lib-mjs/edit/keyboardInput.d.ts +5 -5
  206. package/lib-mjs/edit/keyboardInput.js +46 -45
  207. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  208. package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
  209. package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
  210. package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
  211. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
  212. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js +252 -250
  213. package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
  214. package/lib-mjs/index.d.ts +3 -3
  215. package/lib-mjs/index.js +3 -3
  216. package/lib-mjs/index.js.map +1 -1
  217. package/lib-mjs/paste/ContentModelPastePlugin.d.ts +42 -42
  218. package/lib-mjs/paste/ContentModelPastePlugin.js +145 -145
  219. package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
  220. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
  221. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
  222. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  223. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
  224. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +15 -15
  225. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  226. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
  227. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +203 -203
  228. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  229. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
  230. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
  231. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  232. package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -7
  233. package/lib-mjs/paste/WordDesktop/processWordComments.js +17 -17
  234. package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
  235. package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +10 -10
  236. package/lib-mjs/paste/WordDesktop/processWordLists.js +150 -150
  237. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  238. package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -17
  239. package/lib-mjs/paste/pasteSourceValidations/constants.js +18 -18
  240. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
  241. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
  242. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +20 -20
  243. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  244. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
  245. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +39 -39
  246. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  247. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
  248. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +12 -12
  249. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  250. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
  251. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +14 -14
  252. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  253. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
  254. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +10 -10
  255. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  256. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
  257. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +10 -10
  258. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  259. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
  260. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +14 -14
  261. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  262. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
  263. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +14 -14
  264. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  265. package/lib-mjs/paste/utils/addParser.d.ts +5 -5
  266. package/lib-mjs/paste/utils/addParser.js +13 -13
  267. package/lib-mjs/paste/utils/addParser.js.map +1 -1
  268. package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -5
  269. package/lib-mjs/paste/utils/deprecatedColorParser.js +15 -15
  270. package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
  271. package/lib-mjs/paste/utils/getStyles.d.ts +6 -6
  272. package/lib-mjs/paste/utils/getStyles.js +18 -18
  273. package/lib-mjs/paste/utils/getStyles.js.map +1 -1
  274. package/lib-mjs/paste/utils/linkParser.d.ts +5 -5
  275. package/lib-mjs/paste/utils/linkParser.js +23 -23
  276. package/lib-mjs/paste/utils/linkParser.js.map +1 -1
  277. package/lib-mjs/paste/utils/setProcessor.d.ts +5 -5
  278. package/lib-mjs/paste/utils/setProcessor.js +9 -9
  279. package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
  280. package/package.json +1 -1
@@ -1,171 +1,171 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.backwardDeleteWordSelection = exports.forwardDeleteWordSelection = void 0;
4
- var tslib_1 = require("tslib");
5
- var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
6
- var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
- var DeleteWordState;
8
- (function (DeleteWordState) {
9
- DeleteWordState[DeleteWordState["Start"] = 0] = "Start";
10
- DeleteWordState[DeleteWordState["Punctuation"] = 1] = "Punctuation";
11
- DeleteWordState[DeleteWordState["Text"] = 2] = "Text";
12
- DeleteWordState[DeleteWordState["NonText"] = 3] = "NonText";
13
- DeleteWordState[DeleteWordState["Space"] = 4] = "Space";
14
- DeleteWordState[DeleteWordState["End"] = 5] = "End";
15
- })(DeleteWordState || (DeleteWordState = {}));
16
- function getDeleteWordSelection(direction) {
17
- return function (context) {
18
- var _a = context.insertPoint, marker = _a.marker, paragraph = _a.paragraph;
19
- var startIndex = paragraph.segments.indexOf(marker);
20
- var deleteNext = direction == 'forward';
21
- var iterator = iterateSegments(paragraph, startIndex, deleteNext, context);
22
- var curr = iterator.next();
23
- for (var state = 0 /* Start */; state != 5 /* End */ && !curr.done;) {
24
- var _b = curr.value, punctuation = _b.punctuation, space = _b.space, text = _b.text;
25
- // This is a state machine of how to delete a whole word together with space and punctuations.
26
- // For a full state machine chart, see
27
- // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png
28
- // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png
29
- switch (state) {
30
- case 0 /* Start */:
31
- state = space
32
- ? 4 /* Space */
33
- : punctuation
34
- ? 1 /* Punctuation */
35
- : 2 /* Text */;
36
- curr = iterator.next(true /*delete*/);
37
- break;
38
- case 1 /* Punctuation */:
39
- if (deleteNext && space) {
40
- state = 3 /* NonText */;
41
- curr = iterator.next(true /*delete*/);
42
- }
43
- else if (punctuation) {
44
- curr = iterator.next(true /*delete*/);
45
- }
46
- else {
47
- state = 5 /* End */;
48
- }
49
- break;
50
- case 2 /* Text */:
51
- if (deleteNext && space) {
52
- state = 3 /* NonText */;
53
- curr = iterator.next(true /*delete*/);
54
- }
55
- else if (text) {
56
- curr = iterator.next(true /*delete*/);
57
- }
58
- else {
59
- state = 5 /* End */;
60
- }
61
- break;
62
- case 3 /* NonText */:
63
- if (punctuation || !space) {
64
- state = 5 /* End */;
65
- }
66
- else {
67
- curr = iterator.next(true /*delete*/);
68
- }
69
- break;
70
- case 4 /* Space */:
71
- if (space) {
72
- curr = iterator.next(true /*delete*/);
73
- }
74
- else if (punctuation) {
75
- state = deleteNext ? 3 /* NonText */ : 1 /* Punctuation */;
76
- curr = iterator.next(true /*delete*/);
77
- }
78
- else {
79
- state = deleteNext ? 5 /* End */ : 2 /* Text */;
80
- }
81
- break;
82
- }
83
- }
84
- };
85
- }
86
- function iterateSegments(paragraph, markerIndex, forward, context) {
87
- var step, segments, preserveWhiteSpace, i, segment, _a, j, c, punctuation, space, text, newText;
88
- return (0, tslib_1.__generator)(this, function (_b) {
89
- switch (_b.label) {
90
- case 0:
91
- step = forward ? 1 : -1;
92
- segments = paragraph.segments;
93
- preserveWhiteSpace = (0, roosterjs_content_model_dom_1.isWhiteSpacePreserved)(paragraph);
94
- i = markerIndex + step;
95
- _b.label = 1;
96
- case 1:
97
- if (!(i >= 0 && i < segments.length)) return [3 /*break*/, 12];
98
- segment = segments[i];
99
- _a = segment.segmentType;
100
- switch (_a) {
101
- case 'Text': return [3 /*break*/, 2];
102
- case 'Image': return [3 /*break*/, 7];
103
- case 'SelectionMarker': return [3 /*break*/, 9];
104
- }
105
- return [3 /*break*/, 10];
106
- case 2:
107
- j = forward ? 0 : segment.text.length - 1;
108
- _b.label = 3;
109
- case 3:
110
- if (!(j >= 0 && j < segment.text.length)) return [3 /*break*/, 6];
111
- c = segment.text[j];
112
- punctuation = (0, roosterjs_content_model_core_1.isPunctuation)(c);
113
- space = (0, roosterjs_content_model_core_1.isSpace)(c);
114
- text = !punctuation && !space;
115
- return [4 /*yield*/, { punctuation: punctuation, space: space, text: text }];
116
- case 4:
117
- if (_b.sent()) {
118
- newText = segment.text;
119
- newText = newText.substring(0, j) + newText.substring(j + 1);
120
- if (!preserveWhiteSpace) {
121
- newText = (0, roosterjs_content_model_core_1.normalizeText)(newText, forward);
122
- }
123
- context.deleteResult = 'range';
124
- if (newText) {
125
- segment.text = newText;
126
- if (step > 0) {
127
- j -= step;
128
- }
129
- }
130
- else {
131
- segments.splice(i, 1);
132
- if (step > 0) {
133
- i -= step;
134
- }
135
- return [3 /*break*/, 6];
136
- }
137
- }
138
- _b.label = 5;
139
- case 5:
140
- j += step;
141
- return [3 /*break*/, 3];
142
- case 6: return [3 /*break*/, 11];
143
- case 7: return [4 /*yield*/, { punctuation: true, space: false, text: false }]; // Treat image as punctuation since they have the same behavior.
144
- case 8:
145
- if (_b.sent() // Treat image as punctuation since they have the same behavior.
146
- ) {
147
- segments.splice(i, 1);
148
- if (step > 0) {
149
- i -= step;
150
- }
151
- context.deleteResult = 'range';
152
- }
153
- return [3 /*break*/, 11];
154
- case 9: return [3 /*break*/, 11];
155
- case 10: return [2 /*return*/, null];
156
- case 11:
157
- i += step;
158
- return [3 /*break*/, 1];
159
- case 12: return [2 /*return*/, null];
160
- }
161
- });
162
- }
163
- /**
164
- * @internal
165
- */
166
- exports.forwardDeleteWordSelection = getDeleteWordSelection('forward');
167
- /**
168
- * @internal
169
- */
170
- exports.backwardDeleteWordSelection = getDeleteWordSelection('backward');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.backwardDeleteWordSelection = exports.forwardDeleteWordSelection = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ var DeleteWordState;
8
+ (function (DeleteWordState) {
9
+ DeleteWordState[DeleteWordState["Start"] = 0] = "Start";
10
+ DeleteWordState[DeleteWordState["Punctuation"] = 1] = "Punctuation";
11
+ DeleteWordState[DeleteWordState["Text"] = 2] = "Text";
12
+ DeleteWordState[DeleteWordState["NonText"] = 3] = "NonText";
13
+ DeleteWordState[DeleteWordState["Space"] = 4] = "Space";
14
+ DeleteWordState[DeleteWordState["End"] = 5] = "End";
15
+ })(DeleteWordState || (DeleteWordState = {}));
16
+ function getDeleteWordSelection(direction) {
17
+ return function (context) {
18
+ var _a = context.insertPoint, marker = _a.marker, paragraph = _a.paragraph;
19
+ var startIndex = paragraph.segments.indexOf(marker);
20
+ var deleteNext = direction == 'forward';
21
+ var iterator = iterateSegments(paragraph, startIndex, deleteNext, context);
22
+ var curr = iterator.next();
23
+ for (var state = 0 /* Start */; state != 5 /* End */ && !curr.done;) {
24
+ var _b = curr.value, punctuation = _b.punctuation, space = _b.space, text = _b.text;
25
+ // This is a state machine of how to delete a whole word together with space and punctuations.
26
+ // For a full state machine chart, see
27
+ // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png
28
+ // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png
29
+ switch (state) {
30
+ case 0 /* Start */:
31
+ state = space
32
+ ? 4 /* Space */
33
+ : punctuation
34
+ ? 1 /* Punctuation */
35
+ : 2 /* Text */;
36
+ curr = iterator.next(true /*delete*/);
37
+ break;
38
+ case 1 /* Punctuation */:
39
+ if (deleteNext && space) {
40
+ state = 3 /* NonText */;
41
+ curr = iterator.next(true /*delete*/);
42
+ }
43
+ else if (punctuation) {
44
+ curr = iterator.next(true /*delete*/);
45
+ }
46
+ else {
47
+ state = 5 /* End */;
48
+ }
49
+ break;
50
+ case 2 /* Text */:
51
+ if (deleteNext && space) {
52
+ state = 3 /* NonText */;
53
+ curr = iterator.next(true /*delete*/);
54
+ }
55
+ else if (text) {
56
+ curr = iterator.next(true /*delete*/);
57
+ }
58
+ else {
59
+ state = 5 /* End */;
60
+ }
61
+ break;
62
+ case 3 /* NonText */:
63
+ if (punctuation || !space) {
64
+ state = 5 /* End */;
65
+ }
66
+ else {
67
+ curr = iterator.next(true /*delete*/);
68
+ }
69
+ break;
70
+ case 4 /* Space */:
71
+ if (space) {
72
+ curr = iterator.next(true /*delete*/);
73
+ }
74
+ else if (punctuation) {
75
+ state = deleteNext ? 3 /* NonText */ : 1 /* Punctuation */;
76
+ curr = iterator.next(true /*delete*/);
77
+ }
78
+ else {
79
+ state = deleteNext ? 5 /* End */ : 2 /* Text */;
80
+ }
81
+ break;
82
+ }
83
+ }
84
+ };
85
+ }
86
+ function iterateSegments(paragraph, markerIndex, forward, context) {
87
+ var step, segments, preserveWhiteSpace, i, segment, _a, j, c, punctuation, space, text, newText;
88
+ return (0, tslib_1.__generator)(this, function (_b) {
89
+ switch (_b.label) {
90
+ case 0:
91
+ step = forward ? 1 : -1;
92
+ segments = paragraph.segments;
93
+ preserveWhiteSpace = (0, roosterjs_content_model_dom_1.isWhiteSpacePreserved)(paragraph);
94
+ i = markerIndex + step;
95
+ _b.label = 1;
96
+ case 1:
97
+ if (!(i >= 0 && i < segments.length)) return [3 /*break*/, 12];
98
+ segment = segments[i];
99
+ _a = segment.segmentType;
100
+ switch (_a) {
101
+ case 'Text': return [3 /*break*/, 2];
102
+ case 'Image': return [3 /*break*/, 7];
103
+ case 'SelectionMarker': return [3 /*break*/, 9];
104
+ }
105
+ return [3 /*break*/, 10];
106
+ case 2:
107
+ j = forward ? 0 : segment.text.length - 1;
108
+ _b.label = 3;
109
+ case 3:
110
+ if (!(j >= 0 && j < segment.text.length)) return [3 /*break*/, 6];
111
+ c = segment.text[j];
112
+ punctuation = (0, roosterjs_content_model_core_1.isPunctuation)(c);
113
+ space = (0, roosterjs_content_model_core_1.isSpace)(c);
114
+ text = !punctuation && !space;
115
+ return [4 /*yield*/, { punctuation: punctuation, space: space, text: text }];
116
+ case 4:
117
+ if (_b.sent()) {
118
+ newText = segment.text;
119
+ newText = newText.substring(0, j) + newText.substring(j + 1);
120
+ if (!preserveWhiteSpace) {
121
+ newText = (0, roosterjs_content_model_core_1.normalizeText)(newText, forward);
122
+ }
123
+ context.deleteResult = 'range';
124
+ if (newText) {
125
+ segment.text = newText;
126
+ if (step > 0) {
127
+ j -= step;
128
+ }
129
+ }
130
+ else {
131
+ segments.splice(i, 1);
132
+ if (step > 0) {
133
+ i -= step;
134
+ }
135
+ return [3 /*break*/, 6];
136
+ }
137
+ }
138
+ _b.label = 5;
139
+ case 5:
140
+ j += step;
141
+ return [3 /*break*/, 3];
142
+ case 6: return [3 /*break*/, 11];
143
+ case 7: return [4 /*yield*/, { punctuation: true, space: false, text: false }]; // Treat image as punctuation since they have the same behavior.
144
+ case 8:
145
+ if (_b.sent() // Treat image as punctuation since they have the same behavior.
146
+ ) {
147
+ segments.splice(i, 1);
148
+ if (step > 0) {
149
+ i -= step;
150
+ }
151
+ context.deleteResult = 'range';
152
+ }
153
+ return [3 /*break*/, 11];
154
+ case 9: return [3 /*break*/, 11];
155
+ case 10: return [2 /*return*/, null];
156
+ case 11:
157
+ i += step;
158
+ return [3 /*break*/, 1];
159
+ case 12: return [2 /*return*/, null];
160
+ }
161
+ });
162
+ }
163
+ /**
164
+ * @internal
165
+ */
166
+ exports.forwardDeleteWordSelection = getDeleteWordSelection('forward');
167
+ /**
168
+ * @internal
169
+ */
170
+ exports.backwardDeleteWordSelection = getDeleteWordSelection('backward');
171
171
  //# sourceMappingURL=deleteWordSelection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";;;;AAAA,6EAAqF;AACrF,2EAAoE;AAOpE,IAAW,eAOV;AAPD,WAAW,eAAe;IACtB,uDAAK,CAAA;IACL,mEAAW,CAAA;IACX,qDAAI,CAAA;IACJ,2DAAO,CAAA;IACP,uDAAK,CAAA;IACL,mDAAG,CAAA;AACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;AAQD,SAAS,sBAAsB,CAAC,SAAiC;IAC7D,OAAO,UAAA,OAAO;QACJ,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;QAClD,IAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACtD,IAAM,UAAU,GAAG,SAAS,IAAI,SAAS,CAAC;QAE1C,IAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC7E,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAE3B,KAAK,IAAI,KAAK,gBAAwB,EAAE,KAAK,eAAuB,IAAI,CAAC,IAAI,CAAC,IAAI,GAAI;YAC5E,IAAA,KAA+B,IAAI,CAAC,KAAK,EAAvC,WAAW,iBAAA,EAAE,KAAK,WAAA,EAAE,IAAI,UAAe,CAAC;YAEhD,8FAA8F;YAC9F,sCAAsC;YACtC,gHAAgH;YAChH,kHAAkH;YAClH,QAAQ,KAAK,EAAE;gBACX;oBACI,KAAK,GAAG,KAAK;wBACT,CAAC;wBACD,CAAC,CAAC,WAAW;4BACb,CAAC;4BACD,CAAC,aAAqB,CAAC;oBAC3B,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,U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Punctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n DeleteSelectionContext,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\nconst enum DeleteWordState {\n Start,\n Punctuation,\n Text,\n NonText,\n Space,\n End,\n}\n\ninterface CharInfo {\n text: boolean;\n space: boolean;\n punctuation: boolean;\n}\n\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n const { marker, paragraph } = context.insertPoint;\n const startIndex = paragraph.segments.indexOf(marker);\n const deleteNext = direction == 'forward';\n\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\n let curr = iterator.next();\n\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\n const { punctuation, space, text } = curr.value;\n\n // This is a state machine of how to delete a whole word together with space and punctuations.\n // For a full state machine chart, see\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\n switch (state) {\n case DeleteWordState.Start:\n state = space\n ? DeleteWordState.Space\n : punctuation\n ? DeleteWordState.Punctuation\n : DeleteWordState.Text;\n curr = iterator.next(true /*delete*/);\n break;\n\n case DeleteWordState.Punctuation:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.Text:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (text) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.NonText:\n if (punctuation || !space) {\n state = DeleteWordState.End;\n } else {\n curr = iterator.next(true /*delete*/);\n }\n break;\n\n case DeleteWordState.Space:\n if (space) {\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\n curr = iterator.next(true /*delete*/);\n } else {\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\n }\n break;\n }\n }\n };\n}\n\nfunction* iterateSegments(\n paragraph: ContentModelParagraph,\n markerIndex: number,\n forward: boolean,\n context: DeleteSelectionContext\n): Generator<CharInfo, null, boolean> {\n const step = forward ? 1 : -1;\n const segments = paragraph.segments;\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph);\n\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\n const segment = segments[i];\n\n switch (segment.segmentType) {\n case 'Text':\n for (\n let j = forward ? 0 : segment.text.length - 1;\n j >= 0 && j < segment.text.length;\n j += step\n ) {\n const c = segment.text[j];\n const punctuation = isPunctuation(c);\n const space = isSpace(c);\n const text = !punctuation && !space;\n\n if (yield { punctuation, space, text }) {\n let newText = segment.text;\n\n newText = newText.substring(0, j) + newText.substring(j + 1);\n\n if (!preserveWhiteSpace) {\n newText = normalizeText(newText, forward);\n }\n\n context.deleteResult = 'range';\n\n if (newText) {\n segment.text = newText;\n\n if (step > 0) {\n j -= step;\n }\n } else {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n break;\n }\n }\n }\n break;\n\n case 'Image':\n if (\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\n ) {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n context.deleteResult = 'range';\n }\n break;\n\n case 'SelectionMarker':\n break;\n\n default:\n return null;\n }\n }\n\n return null;\n}\n\n/**\n * @internal\n */\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\n\n/**\n * @internal\n */\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\n"]}
1
+ {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/dele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BACrB,OAAO,GAAG,IAAA,4CAAa,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBAC7C;oBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;oBAE/B,IAAI,OAAO,EAAE;wBACT,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;wBAEvB,IAAI,IAAI,GAAG,CAAC,EAAE;4BACV,CAAC,IAAI,IAAI,CAAC;yBACb;qBACJ;yBAAM;wBACH,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;wBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;4BACV,CAAC,IAAI,IAAI,CAAC;yBACb;wBAED,wBAAM;qBACT;iBACJ;;;gBAjCD,CAAC,IAAI,IAAI,CAAA;;oBAmCb,yBAAM;oBAIF,qBAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CAAC,gEAAgE;;gBAD3H,IACI,SAAsD,CAAC,gEAAgE;kBACzH;oBACE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;wBACV,CAAC,IAAI,IAAI,CAAC;qBACb;oBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;iBAClC;gBACD,yBAAM;oBAGN,yBAAM;qBAGN,sBAAO,IAAI,EAAC;;gBA/DwC,CAAC,IAAI,IAAI,CAAA;;qBAmEzE,sBAAO,IAAI,EAAC;;;CACf;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;AAE5E;;GAEG;AACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { isPunctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\r\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\r\nimport type {\r\n ContentModelParagraph,\r\n DeleteSelectionContext,\r\n DeleteSelectionStep,\r\n} from 'roosterjs-content-model-types';\r\n\r\nconst enum DeleteWordState {\r\n Start,\r\n Punctuation,\r\n Text,\r\n NonText,\r\n Space,\r\n End,\r\n}\r\n\r\ninterface CharInfo {\r\n text: boolean;\r\n space: boolean;\r\n punctuation: boolean;\r\n}\r\n\r\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\r\n return context => {\r\n const { marker, paragraph } = context.insertPoint;\r\n const startIndex = paragraph.segments.indexOf(marker);\r\n const deleteNext = direction == 'forward';\r\n\r\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\r\n let curr = iterator.next();\r\n\r\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\r\n const { punctuation, space, text } = curr.value;\r\n\r\n // This is a state machine of how to delete a whole word together with space and punctuations.\r\n // For a full state machine chart, see\r\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\r\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\r\n switch (state) {\r\n case DeleteWordState.Start:\r\n state = space\r\n ? DeleteWordState.Space\r\n : punctuation\r\n ? DeleteWordState.Punctuation\r\n : DeleteWordState.Text;\r\n curr = iterator.next(true /*delete*/);\r\n break;\r\n\r\n case DeleteWordState.Punctuation:\r\n if (deleteNext && space) {\r\n state = DeleteWordState.NonText;\r\n curr = iterator.next(true /*delete*/);\r\n } else if (punctuation) {\r\n curr = iterator.next(true /*delete*/);\r\n } else {\r\n state = DeleteWordState.End;\r\n }\r\n break;\r\n\r\n case DeleteWordState.Text:\r\n if (deleteNext && space) {\r\n state = DeleteWordState.NonText;\r\n curr = iterator.next(true /*delete*/);\r\n } else if (text) {\r\n curr = iterator.next(true /*delete*/);\r\n } else {\r\n state = DeleteWordState.End;\r\n }\r\n break;\r\n\r\n case DeleteWordState.NonText:\r\n if (punctuation || !space) {\r\n state = DeleteWordState.End;\r\n } else {\r\n curr = iterator.next(true /*delete*/);\r\n }\r\n break;\r\n\r\n case DeleteWordState.Space:\r\n if (space) {\r\n curr = iterator.next(true /*delete*/);\r\n } else if (punctuation) {\r\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\r\n curr = iterator.next(true /*delete*/);\r\n } else {\r\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\r\n }\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\nfunction* iterateSegments(\r\n paragraph: ContentModelParagraph,\r\n markerIndex: number,\r\n forward: boolean,\r\n context: DeleteSelectionContext\r\n): Generator<CharInfo, null, boolean> {\r\n const step = forward ? 1 : -1;\r\n const segments = paragraph.segments;\r\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph);\r\n\r\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\r\n const segment = segments[i];\r\n\r\n switch (segment.segmentType) {\r\n case 'Text':\r\n for (\r\n let j = forward ? 0 : segment.text.length - 1;\r\n j >= 0 && j < segment.text.length;\r\n j += step\r\n ) {\r\n const c = segment.text[j];\r\n const punctuation = isPunctuation(c);\r\n const space = isSpace(c);\r\n const text = !punctuation && !space;\r\n\r\n if (yield { punctuation, space, text }) {\r\n let newText = segment.text;\r\n\r\n newText = newText.substring(0, j) + newText.substring(j + 1);\r\n\r\n if (!preserveWhiteSpace) {\r\n newText = normalizeText(newText, forward);\r\n }\r\n\r\n context.deleteResult = 'range';\r\n\r\n if (newText) {\r\n segment.text = newText;\r\n\r\n if (step > 0) {\r\n j -= step;\r\n }\r\n } else {\r\n segments.splice(i, 1);\r\n\r\n if (step > 0) {\r\n i -= step;\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n\r\n case 'Image':\r\n if (\r\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\r\n ) {\r\n segments.splice(i, 1);\r\n\r\n if (step > 0) {\r\n i -= step;\r\n }\r\n\r\n context.deleteResult = 'range';\r\n }\r\n break;\r\n\r\n case 'SelectionMarker':\r\n break;\r\n\r\n default:\r\n return null;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\r\n"]}
@@ -1,15 +1,15 @@
1
- import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
- import type { ContentModelDocument, DeleteResult, FormatWithContentModelContext } from 'roosterjs-content-model-types';
3
- /**
4
- * @internal
5
- * @return True means content is changed, so need to rewrite content model to editor. Otherwise false
6
- */
7
- export declare function handleKeyboardEventResult(editor: IContentModelEditor, model: ContentModelDocument, rawEvent: KeyboardEvent, result: DeleteResult, context: FormatWithContentModelContext): boolean;
8
- /**
9
- * @internal
10
- */
11
- export declare function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean): boolean;
12
- /**
13
- * @internal
14
- */
15
- export declare function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent): boolean;
1
+ import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
+ import type { ContentModelDocument, DeleteResult, FormatWithContentModelContext } from 'roosterjs-content-model-types';
3
+ /**
4
+ * @internal
5
+ * @return True means content is changed, so need to rewrite content model to editor. Otherwise false
6
+ */
7
+ export declare function handleKeyboardEventResult(editor: IContentModelEditor, model: ContentModelDocument, rawEvent: KeyboardEvent, result: DeleteResult, context: FormatWithContentModelContext): boolean;
8
+ /**
9
+ * @internal
10
+ */
11
+ export declare function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean): boolean;
12
+ /**
13
+ * @internal
14
+ */
15
+ export declare function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent): boolean;
@@ -1,55 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldDeleteAllSegmentsBefore = exports.shouldDeleteWord = exports.handleKeyboardEventResult = void 0;
4
- var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
- /**
6
- * @internal
7
- * @return True means content is changed, so need to rewrite content model to editor. Otherwise false
8
- */
9
- function handleKeyboardEventResult(editor, model, rawEvent, result, context) {
10
- context.skipUndoSnapshot = true;
11
- context.clearModelCache = false;
12
- switch (result) {
13
- case 'notDeleted':
14
- // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid
15
- context.clearModelCache = true;
16
- // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model
17
- return false;
18
- case 'nothingToDelete':
19
- // We known there is nothing to delete, no need to let browser keep handling the event
20
- rawEvent.preventDefault();
21
- return false;
22
- case 'range':
23
- case 'singleChar':
24
- // We have deleted what we need from content model, no need to let browser keep handling the event
25
- rawEvent.preventDefault();
26
- (0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
27
- if (result == 'range') {
28
- // A range is about to be deleted, so add an undo snapshot immediately
29
- context.skipUndoSnapshot = false;
30
- }
31
- // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.
32
- // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.
33
- editor.triggerPluginEvent(23 /* BeforeKeyboardEditing */, {
34
- rawEvent: rawEvent,
35
- });
36
- return true;
37
- }
38
- }
39
- exports.handleKeyboardEventResult = handleKeyboardEventResult;
40
- /**
41
- * @internal
42
- */
43
- function shouldDeleteWord(rawEvent, isMac) {
44
- return ((isMac && rawEvent.altKey && !rawEvent.metaKey) ||
45
- (!isMac && rawEvent.ctrlKey && !rawEvent.altKey));
46
- }
47
- exports.shouldDeleteWord = shouldDeleteWord;
48
- /**
49
- * @internal
50
- */
51
- function shouldDeleteAllSegmentsBefore(rawEvent) {
52
- return rawEvent.metaKey && !rawEvent.altKey;
53
- }
54
- exports.shouldDeleteAllSegmentsBefore = shouldDeleteAllSegmentsBefore;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldDeleteAllSegmentsBefore = exports.shouldDeleteWord = exports.handleKeyboardEventResult = void 0;
4
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
+ /**
6
+ * @internal
7
+ * @return True means content is changed, so need to rewrite content model to editor. Otherwise false
8
+ */
9
+ function handleKeyboardEventResult(editor, model, rawEvent, result, context) {
10
+ context.skipUndoSnapshot = true;
11
+ context.clearModelCache = false;
12
+ switch (result) {
13
+ case 'notDeleted':
14
+ // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid
15
+ context.clearModelCache = true;
16
+ // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model
17
+ return false;
18
+ case 'nothingToDelete':
19
+ // We known there is nothing to delete, no need to let browser keep handling the event
20
+ rawEvent.preventDefault();
21
+ return false;
22
+ case 'range':
23
+ case 'singleChar':
24
+ // We have deleted what we need from content model, no need to let browser keep handling the event
25
+ rawEvent.preventDefault();
26
+ (0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
27
+ if (result == 'range') {
28
+ // A range is about to be deleted, so add an undo snapshot immediately
29
+ context.skipUndoSnapshot = false;
30
+ }
31
+ // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.
32
+ // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.
33
+ editor.triggerPluginEvent(23 /* BeforeKeyboardEditing */, {
34
+ rawEvent: rawEvent,
35
+ });
36
+ return true;
37
+ }
38
+ }
39
+ exports.handleKeyboardEventResult = handleKeyboardEventResult;
40
+ /**
41
+ * @internal
42
+ */
43
+ function shouldDeleteWord(rawEvent, isMac) {
44
+ return ((isMac && rawEvent.altKey && !rawEvent.metaKey) ||
45
+ (!isMac && rawEvent.ctrlKey && !rawEvent.altKey));
46
+ }
47
+ exports.shouldDeleteWord = shouldDeleteWord;
48
+ /**
49
+ * @internal
50
+ */
51
+ function shouldDeleteAllSegmentsBefore(rawEvent) {
52
+ return rawEvent.metaKey && !rawEvent.altKey;
53
+ }
54
+ exports.shouldDeleteAllSegmentsBefore = shouldDeleteAllSegmentsBefore;
55
55
  //# sourceMappingURL=handleKeyboardEventCommon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/handleKeyboardEventCommon.ts"],"names":[],"mappings":";;;AAAA,2EAAoE;AASpE;;;GAGG;AACH,SAAgB,yBAAyB,CACrC,MAA2B,EAC3B,KAA2B,EAC3B,QAAuB,EACvB,MAAoB,EACpB,OAAsC;IAEtC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;IAEhC,QAAQ,MAAM,EAAE;QACZ,KAAK,YAAY;YACb,kHAAkH;YAClH,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,6GAA6G;YAC7G,OAAO,KAAK,CAAC;QAEjB,KAAK,iBAAiB;YAClB,sFAAsF;YACtF,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QAEjB,KAAK,OAAO,CAAC;QACb,KAAK,YAAY;YACb,kGAAkG;YAClG,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;YAE7B,IAAI,MAAM,IAAI,OAAO,EAAE;gBACnB,sEAAsE;gBACtE,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC;aACpC;YAED,6GAA6G;YAC7G,oHAAoH;YACpH,MAAM,CAAC,kBAAkB,iCAAwC;gBAC7D,QAAQ,UAAA;aACX,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;KACnB;AACL,CAAC;AA1CD,8DA0CC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,QAAuB,EAAE,KAAc;IACpE,OAAO,CACH,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACnD,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;GAEG;AACH,SAAgB,6BAA6B,CAAC,QAAuB;IACjE,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC;AAFD,sEAEC","sourcesContent":["import { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n ContentModelDocument,\n DeleteResult,\n FormatWithContentModelContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @return True means content is changed, so need to rewrite content model to editor. Otherwise false\n */\nexport function handleKeyboardEventResult(\n editor: IContentModelEditor,\n model: ContentModelDocument,\n rawEvent: KeyboardEvent,\n result: DeleteResult,\n context: FormatWithContentModelContext\n): boolean {\n context.skipUndoSnapshot = true;\n context.clearModelCache = false;\n\n switch (result) {\n case 'notDeleted':\n // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid\n context.clearModelCache = true;\n\n // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model\n return false;\n\n case 'nothingToDelete':\n // We known there is nothing to delete, no need to let browser keep handling the event\n rawEvent.preventDefault();\n return false;\n\n case 'range':\n case 'singleChar':\n // We have deleted what we need from content model, no need to let browser keep handling the event\n rawEvent.preventDefault();\n normalizeContentModel(model);\n\n if (result == 'range') {\n // A range is about to be deleted, so add an undo snapshot immediately\n context.skipUndoSnapshot = false;\n }\n\n // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.\n // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.\n editor.triggerPluginEvent(PluginEventType.BeforeKeyboardEditing, {\n rawEvent,\n });\n\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean) {\n return (\n (isMac && rawEvent.altKey && !rawEvent.metaKey) ||\n (!isMac && rawEvent.ctrlKey && !rawEvent.altKey)\n );\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent) {\n return rawEvent.metaKey && !rawEvent.altKey;\n}\n"]}
1
+ {"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/handleKeyboardEventCommon.ts"],"names":[],"mappings":";;;AAAA,2EAAoE;AASpE;;;GAGG;AACH,SAAgB,yBAAyB,CACrC,MAA2B,EAC3B,KAA2B,EAC3B,QAAuB,EACvB,MAAoB,EACpB,OAAsC;IAEtC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;IAEhC,QAAQ,MAAM,EAAE;QACZ,KAAK,YAAY;YACb,kHAAkH;YAClH,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,6GAA6G;YAC7G,OAAO,KAAK,CAAC;QAEjB,KAAK,iBAAiB;YAClB,sFAAsF;YACtF,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QAEjB,KAAK,OAAO,CAAC;QACb,KAAK,YAAY;YACb,kGAAkG;YAClG,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;YAE7B,IAAI,MAAM,IAAI,OAAO,EAAE;gBACnB,sEAAsE;gBACtE,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC;aACpC;YAED,6GAA6G;YAC7G,oHAAoH;YACpH,MAAM,CAAC,kBAAkB,iCAAwC;gBAC7D,QAAQ,UAAA;aACX,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;KACnB;AACL,CAAC;AA1CD,8DA0CC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,QAAuB,EAAE,KAAc;IACpE,OAAO,CACH,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACnD,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;GAEG;AACH,SAAgB,6BAA6B,CAAC,QAAuB;IACjE,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC;AAFD,sEAEC","sourcesContent":["import { normalizeContentModel } from 'roosterjs-content-model-dom';\r\nimport { PluginEventType } from 'roosterjs-editor-types';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type {\r\n ContentModelDocument,\r\n DeleteResult,\r\n FormatWithContentModelContext,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n * @return True means content is changed, so need to rewrite content model to editor. Otherwise false\r\n */\r\nexport function handleKeyboardEventResult(\r\n editor: IContentModelEditor,\r\n model: ContentModelDocument,\r\n rawEvent: KeyboardEvent,\r\n result: DeleteResult,\r\n context: FormatWithContentModelContext\r\n): boolean {\r\n context.skipUndoSnapshot = true;\r\n context.clearModelCache = false;\r\n\r\n switch (result) {\r\n case 'notDeleted':\r\n // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid\r\n context.clearModelCache = true;\r\n\r\n // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model\r\n return false;\r\n\r\n case 'nothingToDelete':\r\n // We known there is nothing to delete, no need to let browser keep handling the event\r\n rawEvent.preventDefault();\r\n return false;\r\n\r\n case 'range':\r\n case 'singleChar':\r\n // We have deleted what we need from content model, no need to let browser keep handling the event\r\n rawEvent.preventDefault();\r\n normalizeContentModel(model);\r\n\r\n if (result == 'range') {\r\n // A range is about to be deleted, so add an undo snapshot immediately\r\n context.skipUndoSnapshot = false;\r\n }\r\n\r\n // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.\r\n // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.\r\n editor.triggerPluginEvent(PluginEventType.BeforeKeyboardEditing, {\r\n rawEvent,\r\n });\r\n\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean) {\r\n return (\r\n (isMac && rawEvent.altKey && !rawEvent.metaKey) ||\r\n (!isMac && rawEvent.ctrlKey && !rawEvent.altKey)\r\n );\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent) {\r\n return rawEvent.metaKey && !rawEvent.altKey;\r\n}\r\n"]}
@@ -1,8 +1,8 @@
1
- import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
- /**
3
- * @internal
4
- * Do keyboard event handling for DELETE/BACKSPACE key
5
- * @param editor The Content Model Editor
6
- * @param rawEvent DOM keyboard event
7
- */
8
- export declare function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
1
+ import type { IContentModelEditor } from 'roosterjs-content-model-editor';
2
+ /**
3
+ * @internal
4
+ * Do keyboard event handling for DELETE/BACKSPACE key
5
+ * @param editor The Content Model Editor
6
+ * @param rawEvent DOM keyboard event
7
+ */
8
+ export declare function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;