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,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wordDesktopElementProcessor = exports.processPastedContentFromWordDesktop = void 0;
4
+ var addParser_1 = require("../utils/addParser");
5
+ var roosterjs_editor_dom_1 = require("roosterjs-editor-dom");
6
+ var getStyles_1 = require("../utils/getStyles");
7
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
8
+ var processWordComments_1 = require("./processWordComments");
9
+ var processWordLists_1 = require("./processWordLists");
10
+ var setProcessor_1 = require("../utils/setProcessor");
11
+ var PERCENTAGE_REGEX = /%/;
12
+ var DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE = 120;
13
+ /**
14
+ * @internal
15
+ * Handles Pasted content when source is Word Desktop
16
+ * @param ev ContentModelBeforePasteEvent
17
+ */
18
+ function processPastedContentFromWordDesktop(ev) {
19
+ (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', exports.wordDesktopElementProcessor);
20
+ (0, addParser_1.default)(ev.domToModelOption, 'block', removeNonValidLineHeight);
21
+ (0, addParser_1.default)(ev.domToModelOption, 'listLevel', listLevelParser);
22
+ (0, addParser_1.default)(ev.domToModelOption, 'listItemElement', listItemElementParser);
23
+ // Remove "border:none" for image to fix image resize behavior
24
+ // We found a problem that when paste an image with "border:none" then the resize border will be
25
+ // displayed incorrectly when resize it. So we need to drop this style
26
+ (0, roosterjs_editor_dom_1.chainSanitizerCallback)(ev.sanitizingOption.cssStyleCallbacks, 'border', function (value, element) { return element.tagName != 'IMG' || value != 'none'; });
27
+ // Preserve <o:p> when its innerHTML is "&nbsp;" to avoid dropping an empty line
28
+ (0, roosterjs_editor_dom_1.chainSanitizerCallback)(ev.sanitizingOption.elementCallbacks, 'O:P', function (element) {
29
+ (0, roosterjs_content_model_dom_1.moveChildNodes)(element);
30
+ element.appendChild(element.ownerDocument.createTextNode('\u00A0')); // &nbsp;
31
+ return true;
32
+ });
33
+ }
34
+ exports.processPastedContentFromWordDesktop = processPastedContentFromWordDesktop;
35
+ /**
36
+ * @internal
37
+ * Exported only for unit test
38
+ */
39
+ var wordDesktopElementProcessor = function (group, element, context) {
40
+ var styles = (0, getStyles_1.getStyles)(element);
41
+ // Process Word Lists or Word Commands, otherwise use the default processor on this element.
42
+ if (!((0, processWordLists_1.processWordList)(styles, group, element, context) || (0, processWordComments_1.processWordComments)(styles, element))) {
43
+ context.defaultElementProcessors.element(group, element, context);
44
+ }
45
+ };
46
+ exports.wordDesktopElementProcessor = wordDesktopElementProcessor;
47
+ function removeNonValidLineHeight(format, element, context, defaultStyle) {
48
+ //If the line height is less than the browser default line height, line between the text is going to be too narrow
49
+ var parsedLineHeight;
50
+ if (PERCENTAGE_REGEX.test(element.style.lineHeight) &&
51
+ !isNaN((parsedLineHeight = parseInt(element.style.lineHeight))) &&
52
+ parsedLineHeight < DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE) {
53
+ format.lineHeight = defaultStyle.lineHeight;
54
+ }
55
+ }
56
+ function listLevelParser(format, element, context, defaultStyle) {
57
+ if (element.style.marginLeft != '') {
58
+ format.marginLeft = defaultStyle.marginLeft;
59
+ }
60
+ format.marginBottom = undefined;
61
+ }
62
+ var listItemElementParser = function (format, element) {
63
+ if (element.style.marginLeft) {
64
+ format.marginLeft = undefined;
65
+ }
66
+ if (element.style.marginRight) {
67
+ format.marginRight = undefined;
68
+ }
69
+ };
70
+ //# sourceMappingURL=processPastedContentFromWordDesktop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processPastedContentFromWordDesktop.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/processPastedContentFromWordDesktop.ts"],"names":[],"mappings":";;;AAAA,gDAA2C;AAC3C,6DAA8D;AAC9D,gDAA+C;AAC/C,2EAA6D;AAC7D,6DAA4D;AAC5D,uDAAqD;AACrD,sDAAqD;AAWrD,IAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,IAAM,sCAAsC,GAAG,GAAG,CAAC;AAEnD;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,EAAgC;IAChF,IAAA,2BAAY,EAAC,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,mCAA2B,CAAC,CAAC;IAC1E,IAAA,mBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,wBAAwB,CAAC,CAAC;IAClE,IAAA,mBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;IAC7D,IAAA,mBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;IA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,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;QAC/D,gBAAgB,GAAG,sCAAsC,EAC3D;QACE,MAAM,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;KAC/C;AACL,CAAC;AAED,SAAS,eAAe,CACpB,MAAuC,EACvC,OAAoB,EACpB,OAA0B,EAC1B,YAAoD;IAEpD,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,EAAE;QAChC,MAAM,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;KAC/C;IAED,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC;AACpC,CAAC;AAED,IAAM,qBAAqB,GAA6C,UACpE,MAAkC,EAClC,OAAoB;IAEpB,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE;QAC1B,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;KACjC;IACD,IAAI,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE;QAC3B,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;KAClC;AACL,CAAC,CAAC","sourcesContent":["import addParser from '../utils/addParser';\nimport { chainSanitizerCallback } from 'roosterjs-editor-dom';\nimport { getStyles } from '../utils/getStyles';\nimport { moveChildNodes } from 'roosterjs-content-model-dom';\nimport { processWordComments } from './processWordComments';\nimport { processWordList } from './processWordLists';\nimport { setProcessor } from '../utils/setProcessor';\nimport type {\n ContentModelBeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelListItemFormat,\n ContentModelListItemLevelFormat,\n DomToModelContext,\n ElementProcessor,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\nconst PERCENTAGE_REGEX = /%/;\nconst DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE = 120;\n\n/**\n * @internal\n * Handles Pasted content when source is Word Desktop\n * @param ev ContentModelBeforePasteEvent\n */\nexport function processPastedContentFromWordDesktop(ev: ContentModelBeforePasteEvent) {\n setProcessor(ev.domToModelOption, 'element', wordDesktopElementProcessor);\n addParser(ev.domToModelOption, 'block', removeNonValidLineHeight);\n addParser(ev.domToModelOption, 'listLevel', listLevelParser);\n addParser(ev.domToModelOption, 'listItemElement', listItemElementParser);\n\n // Remove \"border:none\" for image to fix image resize behavior\n // We found a problem that when paste an image with \"border:none\" then the resize border will be\n // displayed incorrectly when resize it. So we need to drop this style\n chainSanitizerCallback(\n ev.sanitizingOption.cssStyleCallbacks,\n 'border',\n (value, element) => element.tagName != 'IMG' || value != 'none'\n );\n\n // Preserve <o:p> when its innerHTML is \"&nbsp;\" to avoid dropping an empty line\n chainSanitizerCallback(ev.sanitizingOption.elementCallbacks, 'O:P', element => {\n moveChildNodes(element);\n element.appendChild(element.ownerDocument.createTextNode('\\u00A0')); // &nbsp;\n return true;\n });\n}\n\n/**\n * @internal\n * Exported only for unit test\n */\nexport const wordDesktopElementProcessor: ElementProcessor<HTMLElement> = (\n group,\n element,\n context\n) => {\n const styles = getStyles(element);\n // Process Word Lists or Word Commands, otherwise use the default processor on this element.\n if (\n !(processWordList(styles, group, element, context) || processWordComments(styles, element))\n ) {\n context.defaultElementProcessors.element(group, element, context);\n }\n};\n\nfunction removeNonValidLineHeight(\n format: ContentModelBlockFormat,\n element: HTMLElement,\n context: DomToModelContext,\n defaultStyle: Readonly<Partial<CSSStyleDeclaration>>\n): void {\n //If the line height is less than the browser default line height, line between the text is going to be too narrow\n let parsedLineHeight: number;\n if (\n PERCENTAGE_REGEX.test(element.style.lineHeight) &&\n !isNaN((parsedLineHeight = parseInt(element.style.lineHeight))) &&\n parsedLineHeight < DEFAULT_BROWSER_LINE_HEIGHT_PERCENTAGE\n ) {\n format.lineHeight = defaultStyle.lineHeight;\n }\n}\n\nfunction listLevelParser(\n format: ContentModelListItemLevelFormat,\n element: HTMLElement,\n context: DomToModelContext,\n defaultStyle: Readonly<Partial<CSSStyleDeclaration>>\n): void {\n if (element.style.marginLeft != '') {\n format.marginLeft = defaultStyle.marginLeft;\n }\n\n format.marginBottom = undefined;\n}\n\nconst listItemElementParser: FormatParser<ContentModelListItemFormat> = (\n format: ContentModelListItemFormat,\n element: HTMLElement\n): void => {\n if (element.style.marginLeft) {\n format.marginLeft = undefined;\n }\n if (element.style.marginRight) {\n format.marginRight = undefined;\n }\n};\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @internal
3
+ * Check whether the element contain Word attributes related to comments and if it does we should no process
4
+ * this element.
5
+ * @returns
6
+ */
7
+ export declare function processWordComments(styles: Record<string, string>, element: HTMLElement): boolean;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processWordComments = void 0;
4
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
5
+ var MSO_COMMENT_ANCHOR_HREF_REGEX = /#_msocom_/;
6
+ var MSO_SPECIAL_CHARACTER = 'mso-special-character';
7
+ var MSO_SPECIAL_CHARACTER_COMMENT = 'comment';
8
+ var MSO_ELEMENT = 'mso-element';
9
+ var MSO_ELEMENT_COMMENT_LIST = 'comment-list';
10
+ /**
11
+ * @internal
12
+ * Check whether the element contain Word attributes related to comments and if it does we should no process
13
+ * this element.
14
+ * @returns
15
+ */
16
+ function processWordComments(styles, element) {
17
+ return (styles[MSO_SPECIAL_CHARACTER] == MSO_SPECIAL_CHARACTER_COMMENT ||
18
+ ((0, roosterjs_content_model_dom_1.isElementOfType)(element, 'a') && MSO_COMMENT_ANCHOR_HREF_REGEX.test(element.href)) ||
19
+ styles[MSO_ELEMENT] == MSO_ELEMENT_COMMENT_LIST);
20
+ }
21
+ exports.processWordComments = processWordComments;
22
+ //# sourceMappingURL=processWordComments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processWordComments.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/processWordComments.ts"],"names":[],"mappings":";;;AAAA,2EAA8D;AAE9D,IAAM,6BAA6B,GAAG,WAAW,CAAC;AAClD,IAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD,IAAM,6BAA6B,GAAG,SAAS,CAAC;AAChD,IAAM,WAAW,GAAG,aAAa,CAAC;AAClC,IAAM,wBAAwB,GAAG,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,MAA8B,EAAE,OAAoB;IACpF,OAAO,CACH,MAAM,CAAC,qBAAqB,CAAC,IAAI,6BAA6B;QAC9D,CAAC,IAAA,6CAAe,EAAC,OAAO,EAAE,GAAG,CAAC,IAAI,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnF,MAAM,CAAC,WAAW,CAAC,IAAI,wBAAwB,CAClD,CAAC;AACN,CAAC;AAND,kDAMC","sourcesContent":["import { isElementOfType } from 'roosterjs-content-model-dom';\n\nconst MSO_COMMENT_ANCHOR_HREF_REGEX = /#_msocom_/;\nconst MSO_SPECIAL_CHARACTER = 'mso-special-character';\nconst MSO_SPECIAL_CHARACTER_COMMENT = 'comment';\nconst MSO_ELEMENT = 'mso-element';\nconst MSO_ELEMENT_COMMENT_LIST = 'comment-list';\n\n/**\n * @internal\n * Check whether the element contain Word attributes related to comments and if it does we should no process\n * this element.\n * @returns\n */\nexport function processWordComments(styles: Record<string, string>, element: HTMLElement) {\n return (\n styles[MSO_SPECIAL_CHARACTER] == MSO_SPECIAL_CHARACTER_COMMENT ||\n (isElementOfType(element, 'a') && MSO_COMMENT_ANCHOR_HREF_REGEX.test(element.href)) ||\n styles[MSO_ELEMENT] == MSO_ELEMENT_COMMENT_LIST\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ContentModelBlockGroup, DomToModelContext } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * @param styles
5
+ * @param group
6
+ * @param element
7
+ * @param context
8
+ * @returns
9
+ */
10
+ export declare function processWordList(styles: Record<string, string>, group: ContentModelBlockGroup, element: HTMLElement, context: DomToModelContext): boolean;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processWordList = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var getStyles_1 = require("../utils/getStyles");
6
+ var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
7
+ /** Word list metadata style name */
8
+ var MSO_LIST = 'mso-list';
9
+ var MSO_LIST_IGNORE = 'ignore';
10
+ var LOOKUP_DEPTH = 5;
11
+ var WORD_FIRST_LIST = 'l0';
12
+ /**
13
+ * @internal
14
+ * @param styles
15
+ * @param group
16
+ * @param element
17
+ * @param context
18
+ * @returns
19
+ */
20
+ function processWordList(styles, group, element, context) {
21
+ var listFormat = context.listFormat;
22
+ if (!listFormat.wordKnownLevels) {
23
+ listFormat.wordKnownLevels = new Map();
24
+ }
25
+ var wordListStyle = styles[MSO_LIST] || '';
26
+ // If the element contains Ignore style, do not process it,
27
+ // Usually this element contains the fake bullet used in Word Desktop.
28
+ if (wordListStyle.toLowerCase() === MSO_LIST_IGNORE) {
29
+ return true;
30
+ }
31
+ var listProps = wordListStyle.split(' ');
32
+ // Try get the list metadata from word, which follows this format: l1 level1 lfo2
33
+ // If we are able to get the level property means we can process this element to be a list
34
+ listFormat.wordLevel = listProps[1] && parseInt(listProps[1].substr('level'.length));
35
+ listFormat.wordList = listProps[0] || WORD_FIRST_LIST;
36
+ if (listFormat.levels.length == 0) {
37
+ listFormat.levels = listFormat.wordKnownLevels.get(listFormat.wordList) || [];
38
+ }
39
+ if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {
40
+ var wordLevel = listFormat.wordLevel;
41
+ // Retrieve the Fake bullet on the element and also the list type
42
+ var fakeBullet = getFakeBulletText(element);
43
+ var listType = getFakeBulletTagName(fakeBullet);
44
+ // Create the new level of the list item and parse the format
45
+ var newLevel = (0, roosterjs_content_model_dom_1.createListLevel)(listType);
46
+ (0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listLevel, newLevel.format, context);
47
+ // If the list format is in a different level, update the array so we get the new item
48
+ // To be in the same level as the provided level metadata.
49
+ if (wordLevel > listFormat.levels.length) {
50
+ while (wordLevel != listFormat.levels.length) {
51
+ listFormat.levels.push(newLevel);
52
+ }
53
+ }
54
+ else {
55
+ listFormat.levels.splice(wordLevel, listFormat.levels.length - 1);
56
+ listFormat.levels[wordLevel - 1] = newLevel;
57
+ }
58
+ listFormat.listParent = group;
59
+ processAsListItem(listFormat, context, element, group, fakeBullet);
60
+ if (listFormat.levels.length > 0 &&
61
+ listFormat.wordKnownLevels.get(listFormat.wordList) != listFormat.levels) {
62
+ listFormat.wordKnownLevels.set(listFormat.wordList, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(listFormat.levels), false));
63
+ }
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+ exports.processWordList = processWordList;
69
+ function processAsListItem(listFormat, context, element, group, fakeBullet) {
70
+ var listItem = (0, roosterjs_content_model_dom_1.createListItem)(listFormat.levels, context.segmentFormat);
71
+ var lastLevel = listItem.levels[listItem.levels.length - 1];
72
+ (0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);
73
+ (0, roosterjs_content_model_dom_1.parseFormat)(element, context.formatParsers.listItemElement, listItem.format, context);
74
+ if ((lastLevel === null || lastLevel === void 0 ? void 0 : lastLevel.listType) == 'OL') {
75
+ (0, roosterjs_content_model_dom_1.parseFormat)(element, [startNumberOverrideParser(fakeBullet)], listItem.levels[listItem.levels.length - 1].format, context);
76
+ }
77
+ context.elementProcessors.child(listItem, element, context);
78
+ (0, roosterjs_content_model_dom_1.addBlock)(group, listItem);
79
+ }
80
+ function startNumberOverrideParser(fakeBullet) {
81
+ return function (format, _, context) {
82
+ var _a = context.listFormat, wordKnownLevels = _a.wordKnownLevels, wordLevel = _a.wordLevel, wordList = _a.wordList;
83
+ if (typeof wordLevel === 'number' && wordList) {
84
+ var start = parseInt(fakeBullet);
85
+ if (start != undefined && !isNaN(start) && !(wordKnownLevels === null || wordKnownLevels === void 0 ? void 0 : wordKnownLevels.has(wordList))) {
86
+ format.startNumberOverride = start;
87
+ }
88
+ }
89
+ };
90
+ }
91
+ /**
92
+ * Check whether the string is a fake bullet from word Desktop
93
+ */
94
+ function isFakeBullet(fakeBullet) {
95
+ return ['o', '·', '§', '-'].indexOf(fakeBullet) >= 0;
96
+ }
97
+ /** Given a fake bullet text, returns the type of list that should be used for it */
98
+ function getFakeBulletTagName(fakeBullet) {
99
+ return isFakeBullet(fakeBullet) ? 'UL' : 'OL';
100
+ }
101
+ /**
102
+ * Finds the fake bullet text out of the specified node and returns it. For images, it will return
103
+ * a bullet string. If not found, it returns null...
104
+ */
105
+ function getFakeBulletText(node, levels) {
106
+ var _a, _b;
107
+ // Word uses the following format for their bullets:
108
+ // &lt;p style="mso-list:l1 level1 lfo2"&gt;
109
+ // &lt;span style="..."&gt;
110
+ // &lt;span style="mso-list:Ignore"&gt;1.&lt;span style="..."&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;&lt;/span&gt;
111
+ // &lt;/span&gt;
112
+ // Content here...
113
+ // &lt;/p&gt;
114
+ //
115
+ // Basically, we need to locate the mso-list:Ignore SPAN, which holds either one text or image node. That
116
+ // text or image node will be the fake bullet we are looking for
117
+ var result = '';
118
+ levels = levels || LOOKUP_DEPTH;
119
+ var child = node.firstChild;
120
+ while (!result && child) {
121
+ // Check if this is the node that holds the fake bullets (mso-list: Ignore)
122
+ if (isIgnoreNode(child)) {
123
+ // Yes... this is the node that holds either the text or image data
124
+ result = (_b = (_a = child.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
125
+ // This is the case for image case
126
+ if (result.length == 0) {
127
+ result = 'o';
128
+ }
129
+ }
130
+ else if ((0, roosterjs_content_model_dom_1.isNodeOfType)(child, 'ELEMENT_NODE') && levels > 1) {
131
+ // If this is an element and we are not in the last level, try to get the fake bullet
132
+ // out of the child
133
+ result = getFakeBulletText(child, levels - 1);
134
+ }
135
+ child = child.nextSibling;
136
+ }
137
+ return result;
138
+ }
139
+ /**
140
+ * Checks if the specified node is marked as a mso-list: Ignore. These
141
+ * nodes need to be ignored when a list item is converted into standard
142
+ * HTML lists
143
+ */
144
+ function isIgnoreNode(node) {
145
+ if ((0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE')) {
146
+ var listAttribute = (0, getStyles_1.getStyles)(node)[MSO_LIST];
147
+ if (listAttribute &&
148
+ listAttribute.length > 0 &&
149
+ listAttribute.trim().toLowerCase() == MSO_LIST_IGNORE) {
150
+ return true;
151
+ }
152
+ }
153
+ return false;
154
+ }
155
+ //# sourceMappingURL=processWordLists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processWordLists.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WordDesktop/processWordLists.ts"],"names":[],"mappings":";;;;AAAA,gDAA+C;AAC/C,2EAMqC;AAUrC,oCAAoC;AACpC,IAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,IAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,IAAM,YAAY,GAAG,CAAC,CAAC;AACvB,IAAM,eAAe,GAAG,IAAI,CAAC;AAQ7B;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC3B,MAA8B,EAC9B,KAA6B,EAC7B,OAAoB,EACpB,OAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,UAAmC,CAAC;IAC/D,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE;QAC7B,UAAU,CAAC,eAAe,GAAG,IAAI,GAAG,EAAmC,CAAC;KAC3E;IACD,IAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAE7C,2DAA2D;IAC3D,sEAAsE;IACtE,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,eAAe,EAAE;QACjD,OAAO,IAAI,CAAC;KACf;IAED,IAAM,SAAS,GAAG,aAAa,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yles } from '../utils/getStyles';\nimport {\n addBlock,\n createListItem,\n createListLevel,\n isNodeOfType,\n parseFormat,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockGroup,\n ContentModelListItemLevelFormat,\n ContentModelListLevel,\n DomToModelContext,\n DomToModelListFormat,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\n/** Word list metadata style name */\nconst MSO_LIST = 'mso-list';\nconst MSO_LIST_IGNORE = 'ignore';\nconst LOOKUP_DEPTH = 5;\nconst WORD_FIRST_LIST = 'l0';\n\ninterface WordDesktopListFormat extends DomToModelListFormat {\n wordLevel?: number | '';\n wordList?: string;\n wordKnownLevels?: Map<string, ContentModelListLevel[]>;\n}\n\n/**\n * @internal\n * @param styles\n * @param group\n * @param element\n * @param context\n * @returns\n */\nexport function processWordList(\n styles: Record<string, string>,\n group: ContentModelBlockGroup,\n element: HTMLElement,\n context: DomToModelContext\n) {\n const listFormat = context.listFormat as WordDesktopListFormat;\n if (!listFormat.wordKnownLevels) {\n listFormat.wordKnownLevels = new Map<string, ContentModelListLevel[]>();\n }\n const wordListStyle = styles[MSO_LIST] || '';\n\n // If the element contains Ignore style, do not process it,\n // Usually this element contains the fake bullet used in Word Desktop.\n if (wordListStyle.toLowerCase() === MSO_LIST_IGNORE) {\n return true;\n }\n\n const listProps = wordListStyle.split(' ');\n // Try get the list metadata from word, which follows this format: l1 level1 lfo2\n // If we are able to get the level property means we can process this element to be a list\n listFormat.wordLevel = listProps[1] && parseInt(listProps[1].substr('level'.length));\n\n listFormat.wordList = listProps[0] || WORD_FIRST_LIST;\n if (listFormat.levels.length == 0) {\n listFormat.levels = listFormat.wordKnownLevels.get(listFormat.wordList) || [];\n }\n\n if (wordListStyle && group && typeof listFormat.wordLevel === 'number') {\n const { wordLevel } = listFormat;\n // Retrieve the Fake bullet on the element and also the list type\n const fakeBullet = getFakeBulletText(element);\n const listType = getFakeBulletTagName(fakeBullet);\n\n // Create the new level of the list item and parse the format\n const newLevel: ContentModelListLevel = createListLevel(listType);\n parseFormat(element, context.formatParsers.listLevel, newLevel.format, context);\n\n // If the list format is in a different level, update the array so we get the new item\n // To be in the same level as the provided level metadata.\n if (wordLevel > listFormat.levels.length) {\n while (wordLevel != listFormat.levels.length) {\n listFormat.levels.push(newLevel);\n }\n } else {\n listFormat.levels.splice(wordLevel, listFormat.levels.length - 1);\n listFormat.levels[wordLevel - 1] = newLevel;\n }\n\n listFormat.listParent = group;\n\n processAsListItem(listFormat, context, element, group, fakeBullet);\n\n if (\n listFormat.levels.length > 0 &&\n listFormat.wordKnownLevels.get(listFormat.wordList) != listFormat.levels\n ) {\n listFormat.wordKnownLevels.set(listFormat.wordList, [...listFormat.levels]);\n }\n return true;\n }\n\n return false;\n}\n\nfunction processAsListItem(\n listFormat: WordDesktopListFormat,\n context: DomToModelContext,\n element: HTMLElement,\n group: ContentModelBlockGroup,\n fakeBullet: string\n) {\n const listItem = createListItem(listFormat.levels, context.segmentFormat);\n const lastLevel = listItem.levels[listItem.levels.length - 1];\n\n parseFormat(element, context.formatParsers.segmentOnBlock, context.segmentFormat, context);\n parseFormat(element, context.formatParsers.listItemElement, listItem.format, context);\n\n if (lastLevel?.listType == 'OL') {\n parseFormat(\n element,\n [startNumberOverrideParser(fakeBullet)],\n listItem.levels[listItem.levels.length - 1].format,\n context\n );\n }\n\n context.elementProcessors.child(listItem, element, context);\n addBlock(group, listItem);\n}\n\nfunction startNumberOverrideParser(\n fakeBullet: string\n): FormatParser<ContentModelListItemLevelFormat> | null {\n return (format, _, context) => {\n const {\n wordKnownLevels,\n wordLevel,\n wordList,\n } = context.listFormat as WordDesktopListFormat;\n if (typeof wordLevel === 'number' && wordList) {\n const start = parseInt(fakeBullet);\n if (start != undefined && !isNaN(start) && !wordKnownLevels?.has(wordList)) {\n format.startNumberOverride = start;\n }\n }\n };\n}\n\n/**\n * Check whether the string is a fake bullet from word Desktop\n */\nfunction isFakeBullet(fakeBullet: string): boolean {\n return ['o', '·', '§', '-'].indexOf(fakeBullet) >= 0;\n}\n\n/** Given a fake bullet text, returns the type of list that should be used for it */\nfunction getFakeBulletTagName(fakeBullet: string): 'UL' | 'OL' {\n return isFakeBullet(fakeBullet) ? 'UL' : 'OL';\n}\n\n/**\n * Finds the fake bullet text out of the specified node and returns it. For images, it will return\n * a bullet string. If not found, it returns null...\n */\nfunction getFakeBulletText(node: Node, levels?: number): string {\n // Word uses the following format for their bullets:\n // &lt;p style=\"mso-list:l1 level1 lfo2\"&gt;\n // &lt;span style=\"...\"&gt;\n // &lt;span style=\"mso-list:Ignore\"&gt;1.&lt;span style=\"...\"&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/span&gt;&lt;/span&gt;\n // &lt;/span&gt;\n // Content here...\n // &lt;/p&gt;\n //\n // Basically, we need to locate the mso-list:Ignore SPAN, which holds either one text or image node. That\n // text or image node will be the fake bullet we are looking for\n let result: string = '';\n levels = levels || LOOKUP_DEPTH;\n let child: Node | null = node.firstChild;\n while (!result && child) {\n // Check if this is the node that holds the fake bullets (mso-list: Ignore)\n if (isIgnoreNode(child)) {\n // Yes... this is the node that holds either the text or image data\n result = child.textContent?.trim() ?? '';\n\n // This is the case for image case\n if (result.length == 0) {\n result = 'o';\n }\n } else if (isNodeOfType(child, 'ELEMENT_NODE') && levels > 1) {\n // If this is an element and we are not in the last level, try to get the fake bullet\n // out of the child\n result = getFakeBulletText(child, levels - 1);\n }\n\n child = child.nextSibling;\n }\n\n return result;\n}\n/**\n * Checks if the specified node is marked as a mso-list: Ignore. These\n * nodes need to be ignored when a list item is converted into standard\n * HTML lists\n */\nfunction isIgnoreNode(node: Node): boolean {\n if (isNodeOfType(node, 'ELEMENT_NODE')) {\n const listAttribute = getStyles(node as HTMLElement)[MSO_LIST];\n if (\n listAttribute &&\n listAttribute.length > 0 &&\n listAttribute.trim().toLowerCase() == MSO_LIST_IGNORE\n ) {\n return true;\n }\n }\n\n return false;\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @internal
3
+ */
4
+ export declare const enum PastePropertyNames {
5
+ /**
6
+ * Node attribute used to identify if the content is from Google Sheets.
7
+ */
8
+ GOOGLE_SHEET_NODE_NAME = "google-sheets-html-origin",
9
+ /**
10
+ * Name of the HTMLMeta Property that provides the Office App Source of the pasted content
11
+ */
12
+ PROG_ID_NAME = "ProgId",
13
+ /**
14
+ * Name of the HTMLMeta Property that identifies pated content as from Excel Desktop
15
+ */
16
+ EXCEL_DESKTOP_ATTRIBUTE_NAME = "xmlns:x"
17
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PastePropertyNames = void 0;
4
+ /**
5
+ * @internal
6
+ */
7
+ var PastePropertyNames;
8
+ (function (PastePropertyNames) {
9
+ /**
10
+ * Node attribute used to identify if the content is from Google Sheets.
11
+ */
12
+ PastePropertyNames["GOOGLE_SHEET_NODE_NAME"] = "google-sheets-html-origin";
13
+ /**
14
+ * Name of the HTMLMeta Property that provides the Office App Source of the pasted content
15
+ */
16
+ PastePropertyNames["PROG_ID_NAME"] = "ProgId";
17
+ /**
18
+ * Name of the HTMLMeta Property that identifies pated content as from Excel Desktop
19
+ */
20
+ PastePropertyNames["EXCEL_DESKTOP_ATTRIBUTE_NAME"] = "xmlns:x";
21
+ })(PastePropertyNames = exports.PastePropertyNames || (exports.PastePropertyNames = {}));
22
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAkB,kBAejB;AAfD,WAAkB,kBAAkB;IAChC;;OAEG;IACH,0EAAoD,CAAA;IAEpD;;OAEG;IACH,6CAAuB,CAAA;IAEvB;;OAEG;IACH,8DAAwC,CAAA;AAC5C,CAAC,EAfiB,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAenC","sourcesContent":["/**\n * @internal\n */\nexport const enum PastePropertyNames {\n /**\n * Node attribute used to identify if the content is from Google Sheets.\n */\n GOOGLE_SHEET_NODE_NAME = 'google-sheets-html-origin',\n\n /**\n * Name of the HTMLMeta Property that provides the Office App Source of the pasted content\n */\n PROG_ID_NAME = 'ProgId',\n\n /**\n * Name of the HTMLMeta Property that identifies pated content as from Excel Desktop\n */\n EXCEL_DESKTOP_ATTRIBUTE_NAME = 'xmlns:x',\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { GetSourceFunction } from './getPasteSource';
2
+ /**
3
+ * @internal
4
+ * Check whether the fragment provided contain Wac Elements
5
+ * @param props Properties related to the PasteEvent
6
+ * @returns
7
+ */
8
+ export declare const documentContainWacElements: GetSourceFunction;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.documentContainWacElements = void 0;
4
+ var WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = [
5
+ 'TableInsertRowGapBlank',
6
+ 'TableColumnResizeHandle',
7
+ 'TableCellTopBorderHandle',
8
+ 'TableCellLeftBorderHandle',
9
+ 'TableHoverColumnHandle',
10
+ 'TableHoverRowHandle',
11
+ ];
12
+ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer,' +
13
+ WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(function (c) { return "table div[class^=\"" + c + "\"]"; }).join(',');
14
+ /**
15
+ * @internal
16
+ * Check whether the fragment provided contain Wac Elements
17
+ * @param props Properties related to the PasteEvent
18
+ * @returns
19
+ */
20
+ var documentContainWacElements = function (props) {
21
+ var fragment = props.fragment;
22
+ return !!fragment.querySelector(WAC_IDENTIFY_SELECTOR);
23
+ };
24
+ exports.documentContainWacElements = documentContainWacElements;
25
+ //# sourceMappingURL=documentContainWacElements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documentContainWacElements.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/documentContainWacElements.ts"],"names":[],"mappings":";;;AAEA,IAAM,sCAAsC,GAAG;IAC3C,wBAAwB;IACxB,yBAAyB;IACzB,0BAA0B;IAC1B,2BAA2B;IAC3B,wBAAwB;IACxB,qBAAqB;CACxB,CAAC;AAEF,IAAM,qBAAqB,GACvB,mHAAmH;IACnH,sCAAsC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,wBAAqB,CAAC,QAAI,EAA1B,CAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1F;;;;;GAKG;AACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;IACtD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC,CAAC;AAHW,QAAA,0BAA0B,8BAGrC","sourcesContent":["import type { GetSourceFunction } from './getPasteSource';\n\nconst WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n];\n\nconst WAC_IDENTIFY_SELECTOR =\n 'ul[class^=\"BulletListStyle\"]>.OutlineElement,ol[class^=\"NumberListStyle\"]>.OutlineElement,span.WACImageContainer,' +\n WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(c => `table div[class^=\"${c}\"]`).join(',');\n\n/**\n * @internal\n * Check whether the fragment provided contain Wac Elements\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const documentContainWacElements: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(WAC_IDENTIFY_SELECTOR);\n};\n"]}
@@ -0,0 +1,27 @@
1
+ import type { BeforePasteEvent, ClipboardData } from 'roosterjs-editor-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare type GetSourceInputParams = {
6
+ htmlAttributes: Record<string, string>;
7
+ fragment: DocumentFragment;
8
+ shouldConvertSingleImage: boolean;
9
+ clipboardData: ClipboardData;
10
+ };
11
+ /**
12
+ * @internal
13
+ * Represent the types of sources to handle in the Paste Plugin
14
+ */
15
+ export declare type KnownPasteSourceType = 'wordDesktop' | 'excelDesktop' | 'excelOnline' | 'powerPointDesktop' | 'googleSheets' | 'wacComponents' | 'default' | 'singleImage';
16
+ /**
17
+ * @internal
18
+ */
19
+ export declare type GetSourceFunction = (props: GetSourceInputParams) => boolean;
20
+ /**
21
+ * @internal
22
+ * This function tries to get the source of the Pasted content
23
+ * @param event the before paste event
24
+ * @param shouldConvertSingleImage Whether convert single image is enabled.
25
+ * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
26
+ */
27
+ export declare function getPasteSource(event: BeforePasteEvent, shouldConvertSingleImage: boolean): KnownPasteSourceType;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPasteSource = void 0;
4
+ var documentContainWacElements_1 = require("./documentContainWacElements");
5
+ var isExcelDesktopDocument_1 = require("./isExcelDesktopDocument");
6
+ var isExcelOnlineDocument_1 = require("./isExcelOnlineDocument");
7
+ var isGoogleSheetDocument_1 = require("./isGoogleSheetDocument");
8
+ var isPowerPointDesktopDocument_1 = require("./isPowerPointDesktopDocument");
9
+ var isWordDesktopDocument_1 = require("./isWordDesktopDocument");
10
+ var shouldConvertToSingleImage_1 = require("./shouldConvertToSingleImage");
11
+ var getSourceFunctions = new Map([
12
+ ['wordDesktop', isWordDesktopDocument_1.isWordDesktopDocument],
13
+ ['excelDesktop', isExcelDesktopDocument_1.isExcelDesktopDocument],
14
+ ['excelOnline', isExcelOnlineDocument_1.isExcelOnlineDocument],
15
+ ['powerPointDesktop', isPowerPointDesktopDocument_1.isPowerPointDesktopDocument],
16
+ ['wacComponents', documentContainWacElements_1.documentContainWacElements],
17
+ ['googleSheets', isGoogleSheetDocument_1.isGoogleSheetDocument],
18
+ ['singleImage', shouldConvertToSingleImage_1.shouldConvertToSingleImage],
19
+ ]);
20
+ /**
21
+ * @internal
22
+ * This function tries to get the source of the Pasted content
23
+ * @param event the before paste event
24
+ * @param shouldConvertSingleImage Whether convert single image is enabled.
25
+ * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
26
+ */
27
+ function getPasteSource(event, shouldConvertSingleImage) {
28
+ var htmlAttributes = event.htmlAttributes, clipboardData = event.clipboardData, fragment = event.fragment;
29
+ var result = null;
30
+ var param = {
31
+ htmlAttributes: htmlAttributes,
32
+ fragment: fragment,
33
+ shouldConvertSingleImage: shouldConvertSingleImage,
34
+ clipboardData: clipboardData,
35
+ };
36
+ getSourceFunctions.forEach(function (func, key) {
37
+ if (!result && func(param)) {
38
+ result = key;
39
+ }
40
+ });
41
+ return result !== null && result !== void 0 ? result : 'default';
42
+ }
43
+ exports.getPasteSource = getPasteSource;
44
+ //# sourceMappingURL=getPasteSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPasteSource.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getPasteSource.ts"],"names":[],"mappings":";;;AAAA,2EAA0E;AAC1E,mEAAkE;AAClE,iEAAgE;AAChE,iEAAgE;AAChE,6EAA4E;AAC5E,iEAAgE;AAChE,2EAA0E;AAgC1E,IAAM,kBAAkB,GAAG,IAAI,GAAG,CAA0C;IACxE,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,cAAc,EAAE,+CAAsB,CAAC;IACxC,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,mBAAmB,EAAE,yDAA2B,CAAC;IAClD,CAAC,eAAe,EAAE,uDAA0B,CAAC;IAC7C,CAAC,cAAc,EAAE,6CAAqB,CAAC;IACvC,CAAC,aAAa,EAAE,uDAA0B,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAAuB,EACvB,wBAAiC;IAEzB,IAAA,cAAc,GAA8B,KAAK,eAAnC,EAAE,aAAa,GAAe,KAAK,cAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IAE1D,IAAI,MAAM,GAAgC,IAAI,CAAC;IAC/C,IAAM,KAAK,GAAyB;QAChC,cAAc,gBAAA;QACd,QAAQ,UAAA;QACR,wBAAwB,0BAAA;QACxB,aAAa,eAAA;KAChB,CAAC;IAEF,kBAAkB,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,GAAG;QACjC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,GAAG,GAAG,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;AAC/B,CAAC;AArBD,wCAqBC","sourcesContent":["import { documentContainWacElements } from './documentContainWacElements';\nimport { isExcelDesktopDocument } from './isExcelDesktopDocument';\nimport { isExcelOnlineDocument } from './isExcelOnlineDocument';\nimport { isGoogleSheetDocument } from './isGoogleSheetDocument';\nimport { isPowerPointDesktopDocument } from './isPowerPointDesktopDocument';\nimport { isWordDesktopDocument } from './isWordDesktopDocument';\nimport { shouldConvertToSingleImage } from './shouldConvertToSingleImage';\nimport type { BeforePasteEvent, ClipboardData } from 'roosterjs-editor-types';\n\n/**\n * @internal\n */\nexport type GetSourceInputParams = {\n htmlAttributes: Record<string, string>;\n fragment: DocumentFragment;\n shouldConvertSingleImage: boolean;\n clipboardData: ClipboardData;\n};\n\n/**\n * @internal\n * Represent the types of sources to handle in the Paste Plugin\n */\nexport type KnownPasteSourceType =\n | 'wordDesktop'\n | 'excelDesktop'\n | 'excelOnline'\n | 'powerPointDesktop'\n | 'googleSheets'\n | 'wacComponents'\n | 'default'\n | 'singleImage';\n\n/**\n * @internal\n */\nexport type GetSourceFunction = (props: GetSourceInputParams) => boolean;\n\nconst getSourceFunctions = new Map<KnownPasteSourceType, GetSourceFunction>([\n ['wordDesktop', isWordDesktopDocument],\n ['excelDesktop', isExcelDesktopDocument],\n ['excelOnline', isExcelOnlineDocument],\n ['powerPointDesktop', isPowerPointDesktopDocument],\n ['wacComponents', documentContainWacElements],\n ['googleSheets', isGoogleSheetDocument],\n ['singleImage', shouldConvertToSingleImage],\n]);\n\n/**\n * @internal\n * This function tries to get the source of the Pasted content\n * @param event the before paste event\n * @param shouldConvertSingleImage Whether convert single image is enabled.\n * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}\n */\nexport function getPasteSource(\n event: BeforePasteEvent,\n shouldConvertSingleImage: boolean\n): KnownPasteSourceType {\n const { htmlAttributes, clipboardData, fragment } = event;\n\n let result: KnownPasteSourceType | null = null;\n const param: GetSourceInputParams = {\n htmlAttributes,\n fragment,\n shouldConvertSingleImage,\n clipboardData,\n };\n\n getSourceFunctions.forEach((func, key) => {\n if (!result && func(param)) {\n result = key;\n }\n });\n\n return result ?? 'default';\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { GetSourceFunction } from './getPasteSource';
2
+ /**
3
+ * @internal
4
+ * Checks whether the Array provided contains strings that identify Excel Desktop documents
5
+ * @param props Properties related to the PasteEvent
6
+ * @returns
7
+ */
8
+ export declare const isExcelDesktopDocument: GetSourceFunction;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExcelDesktopDocument = void 0;
4
+ var EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';
5
+ /**
6
+ * @internal
7
+ * Checks whether the Array provided contains strings that identify Excel Desktop documents
8
+ * @param props Properties related to the PasteEvent
9
+ * @returns
10
+ */
11
+ var isExcelDesktopDocument = function (props) {
12
+ var htmlAttributes = props.htmlAttributes;
13
+ // The presence of this attribute confirms its origin from Excel Desktop
14
+ return htmlAttributes["xmlns:x" /* EXCEL_DESKTOP_ATTRIBUTE_NAME */] == EXCEL_ATTRIBUTE_VALUE;
15
+ };
16
+ exports.isExcelDesktopDocument = isExcelDesktopDocument;
17
+ //# sourceMappingURL=isExcelDesktopDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExcelDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelDesktopDocument.ts"],"names":[],"mappings":";;;AAGA,IAAM,qBAAqB,GAAG,wCAAwC,CAAC;AAEvE;;;;;GAKG;AACI,IAAM,sBAAsB,GAAsB,UAAA,KAAK;IAClD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,wEAAwE;IACxE,OAAO,cAAc,8CAAiD,IAAI,qBAAqB,CAAC;AACpG,CAAC,CAAC;AAJW,QAAA,sBAAsB,0BAIjC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst EXCEL_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:excel';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Excel Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isExcelDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of this attribute confirms its origin from Excel Desktop\n return htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == EXCEL_ATTRIBUTE_VALUE;\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { GetSourceFunction } from './getPasteSource';
2
+ /**
3
+ * @internal
4
+ * Checks whether the Array provided contains strings that identify Excel Online documents
5
+ * @param props Properties related to the PasteEvent
6
+ * @returns
7
+ */
8
+ export declare const isExcelOnlineDocument: GetSourceFunction;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExcelOnlineDocument = void 0;
4
+ // Excel Desktop also has this attribute
5
+ var EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';
6
+ /**
7
+ * @internal
8
+ * Checks whether the Array provided contains strings that identify Excel Online documents
9
+ * @param props Properties related to the PasteEvent
10
+ * @returns
11
+ */
12
+ var isExcelOnlineDocument = function (props) {
13
+ var htmlAttributes = props.htmlAttributes;
14
+ // The presence of Excel.Sheet confirms its origin from Excel, the absence of EXCEL_DESKTOP_ATTRIBUTE_NAME confirms it is from the Online version
15
+ return (htmlAttributes["ProgId" /* PROG_ID_NAME */] == EXCEL_ONLINE_ATTRIBUTE_VALUE &&
16
+ htmlAttributes["xmlns:x" /* EXCEL_DESKTOP_ATTRIBUTE_NAME */] == undefined);
17
+ };
18
+ exports.isExcelOnlineDocument = isExcelOnlineDocument;
19
+ //# sourceMappingURL=isExcelOnlineDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":";;;AAGA,wCAAwC;AACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;AAEnD;;;;;GAKG;AACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,iJAAiJ;IACjJ,OAAO,CACH,cAAc,6BAAiC,IAAI,4BAA4B;QAC/E,cAAc,8CAAiD,IAAI,SAAS,CAC/E,CAAC;AACN,CAAC,CAAC;AAPW,QAAA,qBAAqB,yBAOhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n// Excel Desktop also has this attribute\nconst EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Excel Online documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isExcelOnlineDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of Excel.Sheet confirms its origin from Excel, the absence of EXCEL_DESKTOP_ATTRIBUTE_NAME confirms it is from the Online version\n return (\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE &&\n htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == undefined\n );\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { GetSourceFunction } from './getPasteSource';
2
+ /**
3
+ * @internal
4
+ * Checks whether the fragment provided contain elements from Google sheets
5
+ * @param props Properties related to the PasteEvent
6
+ * @returns
7
+ */
8
+ export declare const isGoogleSheetDocument: GetSourceFunction;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isGoogleSheetDocument = void 0;
4
+ /**
5
+ * @internal
6
+ * Checks whether the fragment provided contain elements from Google sheets
7
+ * @param props Properties related to the PasteEvent
8
+ * @returns
9
+ */
10
+ var isGoogleSheetDocument = function (props) {
11
+ var fragment = props.fragment;
12
+ return !!fragment.querySelector("google-sheets-html-origin" /* GOOGLE_SHEET_NODE_NAME */);
13
+ };
14
+ exports.isGoogleSheetDocument = isGoogleSheetDocument;
15
+ //# sourceMappingURL=isGoogleSheetDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,0DAA2C,CAAC;AAC/E,CAAC,CAAC;AAHW,QAAA,qBAAqB,yBAGhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Checks whether the fragment provided contain elements from Google sheets\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isGoogleSheetDocument: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { GetSourceFunction } from './getPasteSource';
2
+ /**
3
+ * @internal
4
+ * Checks whether the Array provided contains strings that identify Power Point Desktop documents
5
+ * @param props Properties related to the PasteEvent
6
+ * @returns
7
+ */
8
+ export declare const isPowerPointDesktopDocument: GetSourceFunction;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPowerPointDesktopDocument = void 0;
4
+ var POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';
5
+ /**
6
+ * @internal
7
+ * Checks whether the Array provided contains strings that identify Power Point Desktop documents
8
+ * @param props Properties related to the PasteEvent
9
+ * @returns
10
+ */
11
+ var isPowerPointDesktopDocument = function (props) {
12
+ return props.htmlAttributes["ProgId" /* PROG_ID_NAME */] == POWERPOINT_ATTRIBUTE_VALUE;
13
+ };
14
+ exports.isPowerPointDesktopDocument = isPowerPointDesktopDocument;
15
+ //# sourceMappingURL=isPowerPointDesktopDocument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":";;;AAGA,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;AAEtD;;;;;GAKG;AACI,IAAM,2BAA2B,GAAsB,UAAA,KAAK;IAC/D,OAAO,KAAK,CAAC,cAAc,6BAAiC,IAAI,0BAA0B,CAAC;AAC/F,CAAC,CAAC;AAFW,QAAA,2BAA2B,+BAEtC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Power Point Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isPowerPointDesktopDocument: GetSourceFunction = props => {\n return props.htmlAttributes[PastePropertyNames.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;\n};\n"]}