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
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ContentModelPastePlugin = void 0;
5
+ var addParser_1 = require("./utils/addParser");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ var roosterjs_editor_dom_1 = require("roosterjs-editor-dom");
8
+ var deprecatedColorParser_1 = require("./utils/deprecatedColorParser");
9
+ var getPasteSource_1 = require("./pasteSourceValidations/getPasteSource");
10
+ var linkParser_1 = require("./utils/linkParser");
11
+ var processPastedContentFromExcel_1 = require("./Excel/processPastedContentFromExcel");
12
+ var processPastedContentFromPowerPoint_1 = require("./PowerPoint/processPastedContentFromPowerPoint");
13
+ var processPastedContentFromWordDesktop_1 = require("./WordDesktop/processPastedContentFromWordDesktop");
14
+ var processPastedContentWacComponents_1 = require("./WacComponents/processPastedContentWacComponents");
15
+ // Map old PasteType to new PasteType
16
+ // TODO: We can remove this once we have standalone editor
17
+ var PasteTypeMap = (_a = {},
18
+ _a[3 /* AsImage */] = 'asImage',
19
+ _a[1 /* AsPlainText */] = 'asPlainText',
20
+ _a[2 /* MergeFormat */] = 'mergeFormat',
21
+ _a[0 /* Normal */] = 'normal',
22
+ _a);
23
+ /**
24
+ * Paste plugin, handles BeforePaste event and reformat some special content, including:
25
+ * 1. Content copied from Word
26
+ * 2. Content copied from Excel
27
+ * 3. Content copied from Word Online or OneNote Online
28
+ * 4. Content copied from Power Point
29
+ * (This class is still under development, and may still be changed in the future with some breaking changes)
30
+ */
31
+ var ContentModelPastePlugin = /** @class */ (function () {
32
+ /**
33
+ * Construct a new instance of Paste class
34
+ * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
35
+ */
36
+ function ContentModelPastePlugin(unknownTagReplacement) {
37
+ if (unknownTagReplacement === void 0) { unknownTagReplacement = 'SPAN'; }
38
+ this.unknownTagReplacement = unknownTagReplacement;
39
+ this.editor = null;
40
+ }
41
+ /**
42
+ * Get name of this plugin
43
+ */
44
+ ContentModelPastePlugin.prototype.getName = function () {
45
+ return 'ContentModelPaste';
46
+ };
47
+ /**
48
+ * The first method that editor will call to a plugin when editor is initializing.
49
+ * It will pass in the editor instance, plugin should take this chance to save the
50
+ * editor reference so that it can call to any editor method or format API later.
51
+ * @param editor The editor object
52
+ */
53
+ ContentModelPastePlugin.prototype.initialize = function (editor) {
54
+ // TODO: Later we may need a different interface for Content Model editor plugin
55
+ this.editor = editor;
56
+ };
57
+ /**
58
+ * The last method that editor will call to a plugin before it is disposed.
59
+ * Plugin can take this chance to clear the reference to editor. After this method is
60
+ * called, plugin should not call to any editor method since it will result in error.
61
+ */
62
+ ContentModelPastePlugin.prototype.dispose = function () {
63
+ this.editor = null;
64
+ };
65
+ /**
66
+ * Core method for a plugin. Once an event happens in editor, editor will call this
67
+ * method of each plugin to handle the event as long as the event is not handled
68
+ * exclusively by another plugin.
69
+ * @param event The event to handle:
70
+ */
71
+ ContentModelPastePlugin.prototype.onPluginEvent = function (event) {
72
+ if (!this.editor || event.eventType != 10 /* BeforePaste */) {
73
+ return;
74
+ }
75
+ var ev = event;
76
+ if (!ev.domToModelOption) {
77
+ return;
78
+ }
79
+ var pasteSource = (0, getPasteSource_1.getPasteSource)(ev, false);
80
+ var pasteType = PasteTypeMap[ev.pasteType];
81
+ switch (pasteSource) {
82
+ case 'wordDesktop':
83
+ (0, processPastedContentFromWordDesktop_1.processPastedContentFromWordDesktop)(ev);
84
+ break;
85
+ case 'wacComponents':
86
+ (0, processPastedContentWacComponents_1.processPastedContentWacComponents)(ev);
87
+ break;
88
+ case 'excelOnline':
89
+ case 'excelDesktop':
90
+ if (pasteType === 'normal' || pasteType === 'mergeFormat') {
91
+ // Handle HTML copied from Excel
92
+ (0, processPastedContentFromExcel_1.processPastedContentFromExcel)(ev, this.editor.getTrustedHTMLHandler());
93
+ }
94
+ break;
95
+ case 'googleSheets':
96
+ ev.sanitizingOption.additionalTagReplacements["google-sheets-html-origin" /* GOOGLE_SHEET_NODE_NAME */] = '*';
97
+ break;
98
+ case 'powerPointDesktop':
99
+ (0, processPastedContentFromPowerPoint_1.processPastedContentFromPowerPoint)(ev, this.editor.getTrustedHTMLHandler());
100
+ break;
101
+ }
102
+ (0, addParser_1.default)(ev.domToModelOption, 'link', linkParser_1.parseLink);
103
+ (0, addParser_1.default)(ev.domToModelOption, 'tableCell', deprecatedColorParser_1.deprecatedBorderColorParser);
104
+ (0, addParser_1.default)(ev.domToModelOption, 'tableCell', tableBorderParser);
105
+ (0, addParser_1.default)(ev.domToModelOption, 'table', deprecatedColorParser_1.deprecatedBorderColorParser);
106
+ sanitizeBlockStyles(ev.sanitizingOption);
107
+ if (pasteType === 'mergeFormat') {
108
+ (0, addParser_1.default)(ev.domToModelOption, 'block', blockElementParser);
109
+ (0, addParser_1.default)(ev.domToModelOption, 'listLevel', blockElementParser);
110
+ }
111
+ ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;
112
+ };
113
+ return ContentModelPastePlugin;
114
+ }());
115
+ exports.ContentModelPastePlugin = ContentModelPastePlugin;
116
+ /**
117
+ * For block elements that have background color style, remove the background color when user selects the merge current format
118
+ * paste option
119
+ */
120
+ var blockElementParser = function (format, element) {
121
+ if (element.style.backgroundColor) {
122
+ delete format.backgroundColor;
123
+ }
124
+ };
125
+ function sanitizeBlockStyles(sanitizingOption) {
126
+ (0, roosterjs_editor_dom_1.chainSanitizerCallback)(sanitizingOption.cssStyleCallbacks, 'display', function (value) {
127
+ return value != 'flex'; // return whether we keep the style
128
+ });
129
+ }
130
+ var ElementBorderKeys = new Map([
131
+ ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],
132
+ ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],
133
+ ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],
134
+ ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],
135
+ ]);
136
+ function tableBorderParser(format, element) {
137
+ roosterjs_content_model_dom_1.BorderKeys.forEach(function (key) {
138
+ if (!format[key]) {
139
+ var styleSet = ElementBorderKeys.get(key);
140
+ if (styleSet &&
141
+ element.style[styleSet.w] &&
142
+ element.style[styleSet.s] &&
143
+ !element.style[styleSet.c]) {
144
+ format[key] = element.style[styleSet.w] + " " + element.style[styleSet.s];
145
+ }
146
+ }
147
+ });
148
+ }
149
+ //# sourceMappingURL=ContentModelPastePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/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,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;gBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;aAC7E;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { chainSanitizerCallback } from 'roosterjs-editor-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { PasteType as OldPasteType, PluginEventType } from 'roosterjs-editor-types';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n BorderFormat,\n ContentModelBeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n FormatParser,\n PasteType,\n} from 'roosterjs-content-model-types';\nimport type {\n EditorPlugin,\n HtmlSanitizerOptions,\n IEditor,\n PluginEvent,\n} from 'roosterjs-editor-types';\n\n// Map old PasteType to new PasteType\n// TODO: We can remove this once we have standalone editor\nconst PasteTypeMap: Record<OldPasteType, PasteType> = {\n [OldPasteType.AsImage]: 'asImage',\n [OldPasteType.AsPlainText]: 'asPlainText',\n [OldPasteType.MergeFormat]: 'mergeFormat',\n [OldPasteType.Normal]: 'normal',\n};\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n */\n constructor(private unknownTagReplacement: string = 'SPAN') {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\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 || event.eventType != PluginEventType.BeforePaste) {\n return;\n }\n\n const ev = event as ContentModelBeforePasteEvent;\n\n if (!ev.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(ev, false);\n const pasteType = PasteTypeMap[ev.pasteType];\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(ev);\n break;\n case 'wacComponents':\n processPastedContentWacComponents(ev);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(ev, this.editor.getTrustedHTMLHandler());\n }\n break;\n case 'googleSheets':\n ev.sanitizingOption.additionalTagReplacements[\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME\n ] = '*';\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(ev, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(ev.domToModelOption, 'link', parseLink);\n addParser(ev.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(ev.domToModelOption, 'tableCell', tableBorderParser);\n addParser(ev.domToModelOption, 'table', deprecatedBorderColorParser);\n sanitizeBlockStyles(ev.sanitizingOption);\n\n if (pasteType === 'mergeFormat') {\n addParser(ev.domToModelOption, 'block', blockElementParser);\n addParser(ev.domToModelOption, 'listLevel', blockElementParser);\n }\n\n ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nfunction sanitizeBlockStyles(sanitizingOption: Required<HtmlSanitizerOptions>) {\n chainSanitizerCallback(sanitizingOption.cssStyleCallbacks, 'display', (value: string) => {\n return value != 'flex'; // return whether we keep the style\n });\n}\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { TrustedHTMLHandler } from 'roosterjs-editor-types';
2
+ import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types';
3
+ /**
4
+ * @internal
5
+ * Convert pasted content from Excel, add borders when source doc doesn't have a border
6
+ * @param event The BeforePaste event
7
+ */
8
+ export declare function processPastedContentFromExcel(event: ContentModelBeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler): void;
9
+ /**
10
+ * @internal Export for test only
11
+ * @param html Source html
12
+ */
13
+ export declare function excelHandler(html: string, htmlBefore: string): string;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.excelHandler = exports.processPastedContentFromExcel = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var addParser_1 = require("../utils/addParser");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ var setProcessor_1 = require("../utils/setProcessor");
8
+ var LAST_TD_END_REGEX = /<\/\s*td\s*>((?!<\/\s*tr\s*>)[\s\S])*$/i;
9
+ var LAST_TR_END_REGEX = /<\/\s*tr\s*>((?!<\/\s*table\s*>)[\s\S])*$/i;
10
+ var LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;
11
+ var LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;
12
+ var DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';
13
+ /**
14
+ * @internal
15
+ * Convert pasted content from Excel, add borders when source doc doesn't have a border
16
+ * @param event The BeforePaste event
17
+ */
18
+ function processPastedContentFromExcel(event, trustedHTMLHandler) {
19
+ var fragment = event.fragment, htmlBefore = event.htmlBefore, clipboardData = event.clipboardData;
20
+ var html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;
21
+ if (html && clipboardData.html != html) {
22
+ var doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');
23
+ (0, roosterjs_content_model_dom_1.moveChildNodes)(fragment, doc === null || doc === void 0 ? void 0 : doc.body);
24
+ }
25
+ // For Excel Online
26
+ var firstChild = fragment.firstChild;
27
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(firstChild, 'ELEMENT_NODE') &&
28
+ firstChild.tagName == 'div' &&
29
+ firstChild.firstChild) {
30
+ var tableFound = Array.from(firstChild.childNodes).every(function (child) {
31
+ // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag
32
+ var tagName = (0, roosterjs_content_model_dom_1.isNodeOfType)(child, 'ELEMENT_NODE') && child.tagName;
33
+ return tagName == 'META'
34
+ ? true
35
+ : tagName == 'TABLE'
36
+ ? child == firstChild.lastChild
37
+ : false;
38
+ });
39
+ // Extract Table from Div
40
+ if (tableFound && firstChild.lastChild) {
41
+ event.fragment.replaceChildren(firstChild.lastChild);
42
+ }
43
+ }
44
+ (0, addParser_1.default)(event.domToModelOption, 'tableCell', function (format, element) {
45
+ if (element.style.borderStyle === 'none') {
46
+ format.borderBottom = DEFAULT_BORDER_STYLE;
47
+ format.borderLeft = DEFAULT_BORDER_STYLE;
48
+ format.borderRight = DEFAULT_BORDER_STYLE;
49
+ format.borderTop = DEFAULT_BORDER_STYLE;
50
+ }
51
+ });
52
+ (0, setProcessor_1.setProcessor)(event.domToModelOption, 'child', function (group, element, context) {
53
+ var segmentFormat = (0, tslib_1.__assign)({}, context.segmentFormat);
54
+ if (group.blockGroupType === 'TableCell' && group.format.textColor) {
55
+ context.segmentFormat.textColor = group.format.textColor;
56
+ }
57
+ context.defaultElementProcessors.child(group, element, context);
58
+ if (group.blockGroupType === 'TableCell' && group.format.textColor) {
59
+ context.segmentFormat = segmentFormat;
60
+ delete group.format.textColor;
61
+ }
62
+ });
63
+ }
64
+ exports.processPastedContentFromExcel = processPastedContentFromExcel;
65
+ /**
66
+ * @internal Export for test only
67
+ * @param html Source html
68
+ */
69
+ function excelHandler(html, htmlBefore) {
70
+ if (html.match(LAST_TD_END_REGEX)) {
71
+ var trMatch = htmlBefore.match(LAST_TR_REGEX);
72
+ var tr = trMatch ? trMatch[0] : '<TR>';
73
+ html = tr + html + '</TR>';
74
+ }
75
+ if (html.match(LAST_TR_END_REGEX)) {
76
+ var tableMatch = htmlBefore.match(LAST_TABLE_REGEX);
77
+ var table = tableMatch ? tableMatch[0] : '<TABLE>';
78
+ html = table + html + '</TABLE>';
79
+ }
80
+ return html;
81
+ }
82
+ exports.excelHandler = excelHandler;
83
+ //# sourceMappingURL=processPastedContentFromExcel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;AAAA,gDAA2C;AAC3C,2EAA2E;AAC3E,sDAAqD;AAIrD,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;AACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;AACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;;;GAIG;AAEH,SAAgB,6BAA6B,CACzC,KAAmC,EACnC,kBAAsC;IAE9B,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3F,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,IAAI,EAAE;QACpC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,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AC,CAAC,SAAS,CAAC;QACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAbD,oCAaC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { TrustedHTMLHandler } from 'roosterjs-editor-types';\nimport type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types';\n\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\n\n/**\n * @internal\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromExcel(\n event: ContentModelBeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\n) {\n const { fragment, htmlBefore, clipboardData } = event;\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\n\n if (html && clipboardData.html != html) {\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\n moveChildNodes(fragment, doc?.body);\n }\n\n // For Excel Online\n const firstChild = fragment.firstChild;\n if (\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\n firstChild.tagName == 'div' &&\n firstChild.firstChild\n ) {\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\n\n return tagName == 'META'\n ? true\n : tagName == 'TABLE'\n ? child == firstChild.lastChild\n : false;\n });\n\n // Extract Table from Div\n if (tableFound && firstChild.lastChild) {\n event.fragment.replaceChildren(firstChild.lastChild);\n }\n }\n\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\n if (element.style.borderStyle === 'none') {\n format.borderBottom = DEFAULT_BORDER_STYLE;\n format.borderLeft = DEFAULT_BORDER_STYLE;\n format.borderRight = DEFAULT_BORDER_STYLE;\n format.borderTop = DEFAULT_BORDER_STYLE;\n }\n });\n\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\n const segmentFormat = { ...context.segmentFormat };\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat.textColor = group.format.textColor;\n }\n\n context.defaultElementProcessors.child(group, element, context);\n\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat = segmentFormat;\n delete group.format.textColor;\n }\n });\n}\n\n/**\n * @internal Export for test only\n * @param html Source html\n */\n\nexport function excelHandler(html: string, htmlBefore: string): string {\n if (html.match(LAST_TD_END_REGEX)) {\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\n const tr = trMatch ? trMatch[0] : '<TR>';\n html = tr + html + '</TR>';\n }\n if (html.match(LAST_TR_END_REGEX)) {\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\n html = table + html + '</TABLE>';\n }\n\n return html;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-editor-types';
2
+ /**
3
+ * @internal
4
+ * Convert pasted content from PowerPoint
5
+ * @param event The BeforePaste event
6
+ */
7
+ export declare function processPastedContentFromPowerPoint(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processPastedContentFromPowerPoint = void 0;
4
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
+ /**
6
+ * @internal
7
+ * Convert pasted content from PowerPoint
8
+ * @param event The BeforePaste event
9
+ */
10
+ function processPastedContentFromPowerPoint(event, trustedHTMLHandler) {
11
+ var fragment = event.fragment, clipboardData = event.clipboardData;
12
+ if (clipboardData.html && !clipboardData.text && clipboardData.image) {
13
+ // It is possible that PowerPoint copied both image and HTML but not plain text.
14
+ // We always prefer HTML if any.
15
+ var doc = new DOMParser().parseFromString(trustedHTMLHandler(clipboardData.html), 'text/html');
16
+ (0, roosterjs_content_model_dom_1.moveChildNodes)(fragment, doc === null || doc === void 0 ? void 0 : doc.body);
17
+ }
18
+ }
19
+ exports.processPastedContentFromPowerPoint = processPastedContentFromPowerPoint;
20
+ //# sourceMappingURL=processPastedContentFromPowerPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":";;;AAAA,2EAA6D;AAG7D;;;;GAIG;AAEH,SAAgB,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;IAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;QAClE,gFAAgF;QAChF,gCAAgC;QAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;QAEF,IAAA,4CAAc,EAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;KACvC;AACL,CAAC;AAhBD,gFAgBC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-editor-types';\n\n/**\n * @internal\n * Convert pasted content from PowerPoint\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromPowerPoint(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\n) {\n const { fragment, clipboardData } = event;\n\n if (clipboardData.html && !clipboardData.text && clipboardData.image) {\n // It is possible that PowerPoint copied both image and HTML but not plain text.\n // We always prefer HTML if any.\n const doc = new DOMParser().parseFromString(\n trustedHTMLHandler(clipboardData.html),\n 'text/html'\n );\n\n moveChildNodes(fragment, doc?.body);\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * Convert pasted content from Office Online
5
+ * Once it is known that the document is from WAC
6
+ * We need to remove the display property and margin from all the list item
7
+ * @param ev ContentModelBeforePasteEvent
8
+ */
9
+ export declare function processPastedContentWacComponents(ev: ContentModelBeforePasteEvent): void;
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processPastedContentWacComponents = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var addParser_1 = require("../utils/addParser");
6
+ var setProcessor_1 = require("../utils/setProcessor");
7
+ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer,span.WACImageBorder';
8
+ var LIST_CONTAINER_ELEMENT_CLASS_NAME = 'ListContainerWrapper';
9
+ var PARAGRAPH = 'Paragraph';
10
+ var TABLE_CONTAINER = 'TableContainer';
11
+ var TEMP_ELEMENTS_CLASSES = [
12
+ 'TableInsertRowGapBlank',
13
+ 'TableColumnResizeHandle',
14
+ 'TableCellTopBorderHandle',
15
+ 'TableCellLeftBorderHandle',
16
+ 'TableHoverColumnHandle',
17
+ 'TableHoverRowHandle',
18
+ 'ListMarkerWrappingSpan',
19
+ ];
20
+ var CLASSES_TO_KEEP = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([
21
+ 'OutlineElement',
22
+ 'NumberListStyle',
23
+ 'WACImageContainer',
24
+ 'ListContainerWrapper',
25
+ 'BulletListStyle'
26
+ ], (0, tslib_1.__read)(TEMP_ELEMENTS_CLASSES), false), [
27
+ 'TableCellContent',
28
+ PARAGRAPH,
29
+ 'WACImageContainer',
30
+ 'WACImageBorder',
31
+ TABLE_CONTAINER,
32
+ 'LineBreakBlob',
33
+ ], false);
34
+ var LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];
35
+ var LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');
36
+ /**
37
+ * Wac components do not use sub and super tags, instead only add vertical align to a span.
38
+ * This parser normalize the content for content model
39
+ */
40
+ var wacSubSuperParser = function (format, element) {
41
+ var verticalAlign = element.style.verticalAlign;
42
+ if (verticalAlign === 'super') {
43
+ format.superOrSubScriptSequence = 'super';
44
+ }
45
+ if (verticalAlign === 'sub') {
46
+ format.superOrSubScriptSequence = 'sub';
47
+ }
48
+ };
49
+ /**
50
+ * This processor does:
51
+ * 1) Remove the display and margin of the element.
52
+ * 2) When an element should be ignored but should handle the child elements call the default child processor.
53
+ * 3) Removes the End of Paragraph element to avoid empty lines, we should only remove this if the previous element of the EOP is an EmptyTextRun
54
+ * 4) Finally call the default processor.
55
+ * @returns
56
+ */
57
+ var wacElementProcessor = function (group, element, context) {
58
+ var elementTag = element.tagName;
59
+ if (element.matches(WAC_IDENTIFY_SELECTOR)) {
60
+ element.style.removeProperty('display');
61
+ element.style.removeProperty('margin');
62
+ }
63
+ if (element.classList.contains(LIST_CONTAINER_ELEMENT_CLASS_NAME)) {
64
+ context.elementProcessors.child(group, element, context);
65
+ return;
66
+ }
67
+ if (TEMP_ELEMENTS_CLASSES.some(function (className) { return element.classList.contains(className); })) {
68
+ return;
69
+ }
70
+ else if (shouldClearListContext(elementTag, element, context)) {
71
+ var listFormat = context.listFormat;
72
+ listFormat.levels = [];
73
+ listFormat.listParent = undefined;
74
+ }
75
+ context.defaultElementProcessors.element(group, element, context);
76
+ };
77
+ /**
78
+ * This processor calls the default list processor and then sets the correct list level and list bullet.
79
+ */
80
+ var wacLiElementProcessor = function (group, element, context) {
81
+ var _a, _b, _c;
82
+ (_b = (_a = context.defaultElementProcessors).li) === null || _b === void 0 ? void 0 : _b.call(_a, group, element, context);
83
+ var listFormat = context.listFormat;
84
+ var listParent = listFormat.listParent;
85
+ if (listParent) {
86
+ var lastblock = listParent.blocks[listParent.blocks.length - 1];
87
+ if (lastblock.blockType == 'BlockGroup' &&
88
+ lastblock.blockGroupType == 'ListItem' &&
89
+ context.listFormat.listParent !== lastblock) {
90
+ var currentLevel = lastblock.levels[lastblock.levels.length - 1];
91
+ // Get item level from 'data-aria-level' attribute
92
+ var level = parseInt((_c = element.getAttribute('data-aria-level')) !== null && _c !== void 0 ? _c : '');
93
+ if (level > 0) {
94
+ if (level > lastblock.levels.length) {
95
+ while (level != lastblock.levels.length) {
96
+ lastblock.levels.push(currentLevel);
97
+ }
98
+ }
99
+ else {
100
+ lastblock.levels.splice(level, lastblock.levels.length - 1);
101
+ lastblock.levels[level - 1] = currentLevel;
102
+ }
103
+ }
104
+ }
105
+ }
106
+ };
107
+ /**
108
+ * This parsers does:
109
+ * 1) Sets the display for dummy item to undefined when the current style is block.
110
+ * 2) Removes the Margin Left
111
+ */
112
+ var wacListItemParser = function (format, element) {
113
+ if (element.style.display === 'block') {
114
+ format.displayForDummyItem = undefined;
115
+ }
116
+ format.marginLeft = undefined;
117
+ };
118
+ /**
119
+ * Wac usually adds padding to lists which is unwanted so remove it.
120
+ */
121
+ var wacListLevelParser = function (format) {
122
+ format.marginLeft = undefined;
123
+ format.paddingLeft = undefined;
124
+ };
125
+ /**
126
+ * This function returns whether we need to clear the list format.
127
+ * Word Online wraps lists inside divs to have this structure:
128
+ *
129
+ * <div class='ListContainerWrapper'>
130
+ * <ol>...</ol>
131
+ * </div>
132
+ * <div>
133
+ * <p>...</p>
134
+ * <div>
135
+ * <div class='ListContainerWrapper'>
136
+ * <ol>...</ol>
137
+ * </div>
138
+ *
139
+ * So if a elements is not contained inside of a list we should clear the list context to prevent normal text to be
140
+ * transformed into list
141
+ * For the above scenario, if we do not clear the format, the content inside of the second div would be transformed to a list too.
142
+ */
143
+ function shouldClearListContext(elementTag, element, context) {
144
+ return (context.listFormat.levels.length > 0 &&
145
+ LIST_ELEMENT_TAGS.every(function (tag) { return tag != elementTag; }) &&
146
+ !element.closest(LIST_ELEMENT_SELECTOR));
147
+ }
148
+ /**
149
+ * @internal
150
+ * Convert pasted content from Office Online
151
+ * Once it is known that the document is from WAC
152
+ * We need to remove the display property and margin from all the list item
153
+ * @param ev ContentModelBeforePasteEvent
154
+ */
155
+ function processPastedContentWacComponents(ev) {
156
+ var _a;
157
+ (0, addParser_1.default)(ev.domToModelOption, 'segment', wacSubSuperParser);
158
+ (0, addParser_1.default)(ev.domToModelOption, 'listItemThread', wacListItemParser);
159
+ (0, addParser_1.default)(ev.domToModelOption, 'listLevel', wacListLevelParser);
160
+ (0, addParser_1.default)(ev.domToModelOption, 'container', wacBlockParser);
161
+ (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wacElementProcessor);
162
+ (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'li', wacLiElementProcessor);
163
+ (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'ol', wacListProcessor);
164
+ (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'ul', wacListProcessor);
165
+ (_a = ev.sanitizingOption.additionalAllowedCssClasses).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(CLASSES_TO_KEEP), false));
166
+ }
167
+ exports.processPastedContentWacComponents = processPastedContentWacComponents;
168
+ /**
169
+ * List items from word have this format when using List items:
170
+ * @example
171
+ <div>
172
+ <ol></ol>
173
+ </div>
174
+ <div>
175
+ <ol></ol>
176
+ </div>
177
+ <div>
178
+ <ol></ol>
179
+ </div>
180
+ * Due to this the div between each of the lists we need to restore the list context to use the previous list,
181
+ * otherwise it could create a new list instead under the same list element
182
+ */
183
+ var wacListProcessor = function (group, element, context) {
184
+ var _a, _b, _c, _d, _e;
185
+ var lastBlock = group.blocks[group.blocks.length - 1];
186
+ var isWrappedInContainer = element.closest("." + LIST_CONTAINER_ELEMENT_CLASS_NAME);
187
+ if ((_a = isWrappedInContainer === null || isWrappedInContainer === void 0 ? void 0 : isWrappedInContainer.previousElementSibling) === null || _a === void 0 ? void 0 : _a.classList.contains(LIST_CONTAINER_ELEMENT_CLASS_NAME)) {
188
+ if ((lastBlock === null || lastBlock === void 0 ? void 0 : lastBlock.blockType) === 'BlockGroup' && lastBlock.blockGroupType == 'ListItem') {
189
+ context.listFormat = {
190
+ threadItemCounts: [],
191
+ levels: lastBlock.levels,
192
+ listParent: group,
193
+ };
194
+ }
195
+ }
196
+ if (element.tagName.toUpperCase() === 'OL') {
197
+ (_c = (_b = context.defaultElementProcessors).ol) === null || _c === void 0 ? void 0 : _c.call(_b, group, element, context);
198
+ }
199
+ else {
200
+ (_e = (_d = context.defaultElementProcessors).ul) === null || _e === void 0 ? void 0 : _e.call(_d, group, element, context);
201
+ }
202
+ };
203
+ var wacBlockParser = function (format, element) {
204
+ if (element.classList.contains(TABLE_CONTAINER) && element.style.marginLeft.startsWith('-')) {
205
+ delete format.marginLeft;
206
+ }
207
+ };
208
+ //# sourceMappingURL=processPastedContentWacComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processPastedContentWacComponents.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WacComponents/processPastedContentWacComponents.ts"],"names":[],"mappings":";;;;AAAA,gDAA2C;AAC3C,sDAAqD;AAYrD,IAAM,qBAAqB,GACvB,sIAAsI,CAAC;AAC3I,IAAM,iCAAiC,GAAG,sBAAsB,CAAC;AAEjE,IAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,IAAM,eAAe,GAAG,gBAAgB,CAAC;AAEzC,IAAM,qBAAqB,GAAG;I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AAiC,CACpC,EACH;QACE,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,MAAK,YAAY,IAAI,SAAS,CAAC,cAAc,IAAI,UAAU,EAAE;YACjF,OAAO,CAAC,UAAU,GAAG;gBACjB,gBAAgB,EAAE,EAAE;gBACpB,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,UAAU,EAAE,KAAK;aACpB,CAAC;SACL;KACJ;IACD,IAAI,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;QACxC,MAAA,MAAA,OAAO,CAAC,wBAAwB,EAAC,EAAE,mDAAG,KAAK,EAAE,OAA2B,EAAE,OAAO,CAAC,CAAC;KACtF;SAAM;QACH,MAAA,MAAA,OAAO,CAAC,wBAAwB,EAAC,EAAE,mDAAG,KAAK,EAAE,OAA2B,EAAE,OAAO,CAAC,CAAC;KACtF;AACL,CAAC,CAAC;AAEF,IAAM,cAAc,GAA0C,UAC1D,MAA+B,EAC/B,OAAoB;IAEpB,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACzF,OAAO,MAAM,CAAC,UAAU,CAAC;KAC5B;AACL,CAAC,CAAC","sourcesContent":["import addParser from '../utils/addParser';\nimport { setProcessor } from '../utils/setProcessor';\nimport type {\n ContentModelBeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelBlockGroup,\n ContentModelListItemLevelFormat,\n ContentModelSegmentFormat,\n DomToModelContext,\n ElementProcessor,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\nconst WAC_IDENTIFY_SELECTOR =\n 'ul[class^=\"BulletListStyle\"]>.OutlineElement,ol[class^=\"NumberListStyle\"]>.OutlineElement,span.WACImageContainer,span.WACImageBorder';\nconst LIST_CONTAINER_ELEMENT_CLASS_NAME = 'ListContainerWrapper';\n\nconst PARAGRAPH = 'Paragraph';\nconst TABLE_CONTAINER = 'TableContainer';\n\nconst TEMP_ELEMENTS_CLASSES = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n 'ListMarkerWrappingSpan',\n];\n\nconst CLASSES_TO_KEEP = [\n 'OutlineElement',\n 'NumberListStyle',\n 'WACImageContainer',\n 'ListContainerWrapper',\n 'BulletListStyle',\n ...TEMP_ELEMENTS_CLASSES,\n 'TableCellContent',\n PARAGRAPH,\n 'WACImageContainer',\n 'WACImageBorder',\n TABLE_CONTAINER,\n 'LineBreakBlob',\n];\n\nconst LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];\nconst LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');\n\n/**\n * Wac components do not use sub and super tags, instead only add vertical align to a span.\n * This parser normalize the content for content model\n */\nconst wacSubSuperParser: FormatParser<ContentModelSegmentFormat> = (\n format: ContentModelSegmentFormat,\n element: HTMLElement\n): void => {\n const verticalAlign = element.style.verticalAlign;\n if (verticalAlign === 'super') {\n format.superOrSubScriptSequence = 'super';\n }\n if (verticalAlign === 'sub') {\n format.superOrSubScriptSequence = 'sub';\n }\n};\n\n/**\n * This processor does:\n * 1) Remove the display and margin of the element.\n * 2) When an element should be ignored but should handle the child elements call the default child processor.\n * 3) Removes the End of Paragraph element to avoid empty lines, we should only remove this if the previous element of the EOP is an EmptyTextRun\n * 4) Finally call the default processor.\n * @returns\n */\nconst wacElementProcessor: ElementProcessor<HTMLElement> = (\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext\n): void => {\n const elementTag = element.tagName;\n\n if (element.matches(WAC_IDENTIFY_SELECTOR)) {\n element.style.removeProperty('display');\n element.style.removeProperty('margin');\n }\n\n if (element.classList.contains(LIST_CONTAINER_ELEMENT_CLASS_NAME)) {\n context.elementProcessors.child(group, element, context);\n return;\n }\n\n if (TEMP_ELEMENTS_CLASSES.some(className => element.classList.contains(className))) {\n return;\n } else if (shouldClearListContext(elementTag, element, context)) {\n const { listFormat } = context;\n listFormat.levels = [];\n listFormat.listParent = undefined;\n }\n\n context.defaultElementProcessors.element(group, element, context);\n};\n\n/**\n * This processor calls the default list processor and then sets the correct list level and list bullet.\n */\nconst wacLiElementProcessor: ElementProcessor<HTMLLIElement> = (\n group: ContentModelBlockGroup,\n element: HTMLLIElement,\n context: DomToModelContext\n): void => {\n context.defaultElementProcessors.li?.(group, element, context);\n const { listFormat } = context;\n const listParent = listFormat.listParent;\n if (listParent) {\n const lastblock = listParent.blocks[listParent.blocks.length - 1];\n if (\n lastblock.blockType == 'BlockGroup' &&\n lastblock.blockGroupType == 'ListItem' &&\n context.listFormat.listParent !== lastblock\n ) {\n const currentLevel = lastblock.levels[lastblock.levels.length - 1];\n\n // Get item level from 'data-aria-level' attribute\n const level = parseInt(element.getAttribute('data-aria-level') ?? '');\n if (level > 0) {\n if (level > lastblock.levels.length) {\n while (level != lastblock.levels.length) {\n lastblock.levels.push(currentLevel);\n }\n } else {\n lastblock.levels.splice(level, lastblock.levels.length - 1);\n lastblock.levels[level - 1] = currentLevel;\n }\n }\n }\n }\n};\n\n/**\n * This parsers does:\n * 1) Sets the display for dummy item to undefined when the current style is block.\n * 2) Removes the Margin Left\n */\nconst wacListItemParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat,\n element: HTMLElement\n): void => {\n if (element.style.display === 'block') {\n format.displayForDummyItem = undefined;\n }\n\n format.marginLeft = undefined;\n};\n\n/**\n * Wac usually adds padding to lists which is unwanted so remove it.\n */\nconst wacListLevelParser: FormatParser<ContentModelListItemLevelFormat> = (\n format: ContentModelListItemLevelFormat\n): void => {\n format.marginLeft = undefined;\n format.paddingLeft = undefined;\n};\n\n/**\n * This function returns whether we need to clear the list format.\n * Word Online wraps lists inside divs to have this structure:\n *\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n * <div>\n * <p>...</p>\n * <div>\n * <div class='ListContainerWrapper'>\n * <ol>...</ol>\n * </div>\n *\n * So if a elements is not contained inside of a list we should clear the list context to prevent normal text to be\n * transformed into list\n * For the above scenario, if we do not clear the format, the content inside of the second div would be transformed to a list too.\n */\nfunction shouldClearListContext(\n elementTag: string,\n element: HTMLElement,\n context: DomToModelContext\n) {\n return (\n context.listFormat.levels.length > 0 &&\n LIST_ELEMENT_TAGS.every(tag => tag != elementTag) &&\n !element.closest(LIST_ELEMENT_SELECTOR)\n );\n}\n\n/**\n * @internal\n * Convert pasted content from Office Online\n * Once it is known that the document is from WAC\n * We need to remove the display property and margin from all the list item\n * @param ev ContentModelBeforePasteEvent\n */\nexport function processPastedContentWacComponents(ev: ContentModelBeforePasteEvent) {\n addParser(ev.domToModelOption, 'segment', wacSubSuperParser);\n addParser(ev.domToModelOption, 'listItemThread', wacListItemParser);\n addParser(ev.domToModelOption, 'listLevel', wacListLevelParser);\n addParser(ev.domToModelOption, 'container', wacBlockParser);\n\n setProcessor(ev.domToModelOption, 'element', wacElementProcessor);\n setProcessor(ev.domToModelOption, 'li', wacLiElementProcessor);\n setProcessor(ev.domToModelOption, 'ol', wacListProcessor);\n setProcessor(ev.domToModelOption, 'ul', wacListProcessor);\n ev.sanitizingOption.additionalAllowedCssClasses.push(...CLASSES_TO_KEEP);\n}\n\n/**\n * List items from word have this format when using List items:\n * @example\n <div>\n <ol></ol>\n </div>\n <div>\n <ol></ol>\n </div>\n <div>\n <ol></ol>\n </div>\n * Due to this the div between each of the lists we need to restore the list context to use the previous list,\n * otherwise it could create a new list instead under the same list element\n */\nconst wacListProcessor: ElementProcessor<HTMLOListElement | HTMLUListElement> = (\n group: ContentModelBlockGroup,\n element: HTMLOListElement | HTMLUListElement,\n context: DomToModelContext\n): void => {\n const lastBlock = group.blocks[group.blocks.length - 1];\n const isWrappedInContainer = element.closest(`.${LIST_CONTAINER_ELEMENT_CLASS_NAME}`);\n if (\n isWrappedInContainer?.previousElementSibling?.classList.contains(\n LIST_CONTAINER_ELEMENT_CLASS_NAME\n )\n ) {\n if (lastBlock?.blockType === 'BlockGroup' && lastBlock.blockGroupType == 'ListItem') {\n context.listFormat = {\n threadItemCounts: [],\n levels: lastBlock.levels,\n listParent: group,\n };\n }\n }\n if (element.tagName.toUpperCase() === 'OL') {\n context.defaultElementProcessors.ol?.(group, element as HTMLOListElement, context);\n } else {\n context.defaultElementProcessors.ul?.(group, element as HTMLUListElement, context);\n }\n};\n\nconst wacBlockParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.classList.contains(TABLE_CONTAINER) && element.style.marginLeft.startsWith('-')) {\n delete format.marginLeft;\n }\n};\n"]}
@@ -0,0 +1,12 @@
1
+ import type { ContentModelBeforePasteEvent, ElementProcessor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * Handles Pasted content when source is Word Desktop
5
+ * @param ev ContentModelBeforePasteEvent
6
+ */
7
+ export declare function processPastedContentFromWordDesktop(ev: ContentModelBeforePasteEvent): void;
8
+ /**
9
+ * @internal
10
+ * Exported only for unit test
11
+ */
12
+ export declare const wordDesktopElementProcessor: ElementProcessor<HTMLElement>;