roosterjs-content-model-plugins 9.43.0 → 9.44.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 (163) hide show
  1. package/lib/edit/EditOptions.d.ts +35 -2
  2. package/lib/edit/EditOptions.js.map +1 -1
  3. package/lib/edit/EditPlugin.d.ts +2 -2
  4. package/lib/edit/EditPlugin.js +25 -7
  5. package/lib/edit/EditPlugin.js.map +1 -1
  6. package/lib/edit/keyboardTab.d.ts +2 -1
  7. package/lib/edit/keyboardTab.js +29 -19
  8. package/lib/edit/keyboardTab.js.map +1 -1
  9. package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
  10. package/lib/imageEdit/ImageEditPlugin.js +4 -5
  11. package/lib/imageEdit/ImageEditPlugin.js.map +1 -1
  12. package/lib/imageEdit/utils/generateDataURL.js +12 -7
  13. package/lib/imageEdit/utils/generateDataURL.js.map +1 -1
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js.map +1 -1
  16. package/lib/paste/PastePlugin.js +11 -3
  17. package/lib/paste/PastePlugin.js.map +1 -1
  18. package/lib/paste/WordDesktop/getStyleMetadata.d.ts +1 -2
  19. package/lib/paste/WordDesktop/getStyleMetadata.js +5 -2
  20. package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  21. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +5 -4
  22. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -10
  23. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  24. package/lib/paste/parsers/removeNegativeTextIndentParser.js +1 -1
  25. package/lib/paste/parsers/removeNegativeTextIndentParser.js.map +1 -1
  26. package/lib/paste/parsers/wordContainerParser.d.ts +8 -0
  27. package/lib/paste/parsers/wordContainerParser.js +17 -0
  28. package/lib/paste/parsers/wordContainerParser.js.map +1 -0
  29. package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +1 -1
  30. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  31. package/lib/paste/pasteSourceValidations/getDocumentSource.d.ts +52 -0
  32. package/lib/paste/pasteSourceValidations/{getPasteSource.js → getDocumentSource.js} +4 -12
  33. package/lib/paste/pasteSourceValidations/getDocumentSource.js.map +1 -0
  34. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +1 -1
  35. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  36. package/lib/paste/pasteSourceValidations/isExcelNonNativeEvent.d.ts +1 -1
  37. package/lib/paste/pasteSourceValidations/isExcelNonNativeEvent.js +5 -5
  38. package/lib/paste/pasteSourceValidations/isExcelNonNativeEvent.js.map +1 -1
  39. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +1 -1
  40. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  41. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +1 -1
  42. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  43. package/lib/paste/pasteSourceValidations/isOneNoteDocument.d.ts +1 -1
  44. package/lib/paste/pasteSourceValidations/isOneNoteDocument.js.map +1 -1
  45. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +1 -1
  46. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  47. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +1 -1
  48. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +4 -4
  49. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  50. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +1 -1
  51. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +4 -5
  52. package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  53. package/lib-amd/edit/EditOptions.d.ts +35 -2
  54. package/lib-amd/edit/EditOptions.js.map +1 -1
  55. package/lib-amd/edit/EditPlugin.d.ts +2 -2
  56. package/lib-amd/edit/EditPlugin.js +25 -7
  57. package/lib-amd/edit/EditPlugin.js.map +1 -1
  58. package/lib-amd/edit/keyboardTab.d.ts +2 -1
  59. package/lib-amd/edit/keyboardTab.js +29 -19
  60. package/lib-amd/edit/keyboardTab.js.map +1 -1
  61. package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
  62. package/lib-amd/imageEdit/ImageEditPlugin.js +4 -5
  63. package/lib-amd/imageEdit/ImageEditPlugin.js.map +1 -1
  64. package/lib-amd/imageEdit/utils/generateDataURL.js +12 -7
  65. package/lib-amd/imageEdit/utils/generateDataURL.js.map +1 -1
  66. package/lib-amd/index.d.ts +1 -1
  67. package/lib-amd/index.js.map +1 -1
  68. package/lib-amd/paste/PastePlugin.js +11 -3
  69. package/lib-amd/paste/PastePlugin.js.map +1 -1
  70. package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +1 -2
  71. package/lib-amd/paste/WordDesktop/getStyleMetadata.js +5 -2
  72. package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  73. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +5 -4
  74. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -11
  75. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  76. package/lib-amd/paste/parsers/removeNegativeTextIndentParser.js +1 -1
  77. package/lib-amd/paste/parsers/removeNegativeTextIndentParser.js.map +1 -1
  78. package/lib-amd/paste/parsers/wordContainerParser.d.ts +8 -0
  79. package/lib-amd/paste/parsers/wordContainerParser.js +19 -0
  80. package/lib-amd/paste/parsers/wordContainerParser.js.map +1 -0
  81. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +1 -1
  82. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  83. package/lib-amd/paste/pasteSourceValidations/getDocumentSource.d.ts +52 -0
  84. package/lib-amd/paste/pasteSourceValidations/{getPasteSource.js → getDocumentSource.js} +4 -12
  85. package/lib-amd/paste/pasteSourceValidations/getDocumentSource.js.map +1 -0
  86. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +1 -1
  87. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  88. package/lib-amd/paste/pasteSourceValidations/isExcelNonNativeEvent.d.ts +1 -1
  89. package/lib-amd/paste/pasteSourceValidations/isExcelNonNativeEvent.js +5 -5
  90. package/lib-amd/paste/pasteSourceValidations/isExcelNonNativeEvent.js.map +1 -1
  91. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +1 -1
  92. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  93. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +1 -1
  94. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  95. package/lib-amd/paste/pasteSourceValidations/isOneNoteDocument.d.ts +1 -1
  96. package/lib-amd/paste/pasteSourceValidations/isOneNoteDocument.js.map +1 -1
  97. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +1 -1
  98. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  99. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +1 -1
  100. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +4 -4
  101. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  102. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +1 -1
  103. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +4 -5
  104. package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  105. package/lib-mjs/edit/EditOptions.d.ts +35 -2
  106. package/lib-mjs/edit/EditOptions.js.map +1 -1
  107. package/lib-mjs/edit/EditPlugin.d.ts +2 -2
  108. package/lib-mjs/edit/EditPlugin.js +25 -7
  109. package/lib-mjs/edit/EditPlugin.js.map +1 -1
  110. package/lib-mjs/edit/keyboardTab.d.ts +2 -1
  111. package/lib-mjs/edit/keyboardTab.js +29 -19
  112. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  113. package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
  114. package/lib-mjs/imageEdit/ImageEditPlugin.js +4 -5
  115. package/lib-mjs/imageEdit/ImageEditPlugin.js.map +1 -1
  116. package/lib-mjs/imageEdit/utils/generateDataURL.js +12 -7
  117. package/lib-mjs/imageEdit/utils/generateDataURL.js.map +1 -1
  118. package/lib-mjs/index.d.ts +1 -1
  119. package/lib-mjs/index.js.map +1 -1
  120. package/lib-mjs/paste/PastePlugin.js +11 -3
  121. package/lib-mjs/paste/PastePlugin.js.map +1 -1
  122. package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +1 -2
  123. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +5 -2
  124. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  125. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +5 -4
  126. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -10
  127. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  128. package/lib-mjs/paste/parsers/removeNegativeTextIndentParser.js +1 -1
  129. package/lib-mjs/paste/parsers/removeNegativeTextIndentParser.js.map +1 -1
  130. package/lib-mjs/paste/parsers/wordContainerParser.d.ts +8 -0
  131. package/lib-mjs/paste/parsers/wordContainerParser.js +13 -0
  132. package/lib-mjs/paste/parsers/wordContainerParser.js.map +1 -0
  133. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +1 -1
  134. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  135. package/lib-mjs/paste/pasteSourceValidations/getDocumentSource.d.ts +52 -0
  136. package/lib-mjs/paste/pasteSourceValidations/{getPasteSource.js → getDocumentSource.js} +2 -10
  137. package/lib-mjs/paste/pasteSourceValidations/getDocumentSource.js.map +1 -0
  138. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +1 -1
  139. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  140. package/lib-mjs/paste/pasteSourceValidations/isExcelNonNativeEvent.d.ts +1 -1
  141. package/lib-mjs/paste/pasteSourceValidations/isExcelNonNativeEvent.js +5 -5
  142. package/lib-mjs/paste/pasteSourceValidations/isExcelNonNativeEvent.js.map +1 -1
  143. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +1 -1
  144. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  145. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +1 -1
  146. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  147. package/lib-mjs/paste/pasteSourceValidations/isOneNoteDocument.d.ts +1 -1
  148. package/lib-mjs/paste/pasteSourceValidations/isOneNoteDocument.js.map +1 -1
  149. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +1 -1
  150. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  151. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +1 -1
  152. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +4 -4
  153. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  154. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +1 -1
  155. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +4 -5
  156. package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
  157. package/package.json +5 -5
  158. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +0 -28
  159. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +0 -1
  160. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +0 -28
  161. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +0 -1
  162. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +0 -28
  163. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":";;;;IA0BA;;;;;;OAMG;IACH;QAGI;;;;WAIG;QACH,qBACY,uBAAiC,EACjC,uBAWP;YAXO,wCAAA,EAAA;gBAOJ,eAAe,EAAE,qCAAiB;gBAClC,qBAAqB,EAAE,EAAE;gBACzB,wBAAwB,EAAE,EAAE;gBAC5B,mBAAmB,EAAE,EAAE;aAC1B;YAZO,4BAAuB,GAAvB,uBAAuB,CAAU;YACjC,4BAAuB,GAAvB,uBAAuB,CAW9B;YApBG,WAAM,GAAmB,IAAI,CAAC;QAqBnC,CAAC;QAEJ;;WAEG;QACH,6BAAO,GAAP;YACI,OAAO,OAAO,CAAC;QACnB,CAAC;QAED;;;;;WAKG;QACH,gCAAU,GAAV,UAAW,MAAe;YACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,6BAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;WAKG;QACH,mCAAa,GAAb,UAAc,KAAkB;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,aAAa,EAAE;gBAClD,OAAO;aACV;YAED,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;gBACzB,OAAO;aACV;YAED,IAAM,WAAW,GAAG,IAAA,+BAAc,EAC9B,KAAK,EACL,KAAK,CAAC,8BAA8B,EACpC,IA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A,KAAA,KAAK,CAAC,gBAAgB,CAAC,wBAAwB,CAAA,CAAC,IAAI,8DAAI,wBAAwB,WAAE;aACrF;QACL,CAAC;QACL,kBAAC;IAAD,CAAC,AAnJD,IAmJC;IAnJY,kCAAW","sourcesContent":["import { addParser } from './utils/addParser';\nimport { blockElementParser } from './parsers/blockElementParser';\nimport { chainSanitizerCallback } from './utils/chainSanitizerCallback';\nimport { DefaultSanitizers } from './DefaultSanitizers';\nimport { deprecatedBorderColorParser } from './parsers/deprecatedColorParser';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { imageSizeParser } from './parsers/imageSizeParser';\nimport { parseLink } from './parsers/linkParser';\nimport { pasteButtonProcessor } from './processors/pasteButtonProcessor';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromOneNote } from './oneNote/processPastedContentFromOneNote';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport { setProcessor } from './utils/setProcessor';\nimport { tableBorderParser } from './parsers/tableBorderParser';\nimport type {\n BeforePasteEvent,\n DomToModelOptionForSanitizing,\n EditorPlugin,\n IEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\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 */\nexport class PastePlugin implements EditorPlugin {\n private editor: IEditor | 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 * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(\n private allowExcelNoBorderTable?: boolean,\n private domToModelForSanitizing: Pick<\n DomToModelOptionForSanitizing,\n | 'additionalAllowedTags'\n | 'additionalDisallowedTags'\n | 'styleSanitizers'\n | 'attributeSanitizers'\n > = {\n styleSanitizers: DefaultSanitizers,\n additionalAllowedTags: [],\n additionalDisallowedTags: [],\n attributeSanitizers: {},\n }\n ) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Paste';\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 this.editor = editor;\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 != 'beforePaste') {\n return;\n }\n\n if (!event.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(\n event,\n false /* shouldConvertSingleImage */,\n this.editor.getEnvironment()\n );\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(event);\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n case 'excelNonNativeEvent':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getDOMCreator(),\n !!this.allowExcelNoBorderTable,\n pasteSource != 'excelNonNativeEvent' /* isNativeEvent */\n );\n }\n break;\n case 'googleSheets':\n event.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(event, this.editor.getDOMCreator());\n break;\n\n case 'oneNoteDesktop':\n processPastedContentFromOneNote(event);\n break;\n }\n\n addParser(event.domToModelOption, 'link', parseLink);\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'image', imageSizeParser);\n setProcessor(event.domToModelOption, 'button', pasteButtonProcessor);\n\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n\n this.setEventSanitizers(event);\n }\n\n private setEventSanitizers(event: BeforePasteEvent) {\n if (this.domToModelForSanitizing) {\n const {\n styleSanitizers,\n attributeSanitizers,\n additionalAllowedTags,\n additionalDisallowedTags,\n } = this.domToModelForSanitizing;\n getObjectKeys(styleSanitizers).forEach(key =>\n chainSanitizerCallback(\n event.domToModelOption.styleSanitizers,\n key,\n styleSanitizers[key]\n )\n );\n getObjectKeys(attributeSanitizers).forEach(key =>\n chainSanitizerCallback(\n event.domToModelOption.attributeSanitizers,\n key,\n attributeSanitizers[key]\n )\n );\n event.domToModelOption.additionalAllowedTags.push(...additionalAllowedTags);\n event.domToModelOption.additionalDisallowedTags.push(...additionalDisallowedTags);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":";;;;IA0BA;;;;;;OAMG;IACH;QAGI;;;;WAIG;QACH,qBACY,uBAAiC,EACjC,uBAWP;YAXO,wCAAA,EAAA;gBAOJ,eAAe,EAAE,qCAAiB;gBAClC,qBAAqB,EAAE,EAAE;gBACzB,wBAAwB,EAAE,EAAE;gBAC5B,mBAAmB,EAAE,EAAE;aAC1B;YAZO,4BAAuB,GAAvB,uBAAuB,CAAU;YACjC,4BAAuB,GAAvB,uBAAuB,CAW9B;Y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OAAO,EAAE,uCAAkB,CAAC,CAAC;gBAC/D,IAAA,qBAAS,EAAC,KAAK,CAAC,gBAAgB,EAAE,WAAW,EAAE,uCAAkB,CAAC,CAAC;aACtE;YAED,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAEO,wCAAkB,GAA1B,UAA2B,KAAuB;;YAC9C,IAAI,IAAI,CAAC,uBAAuB,EAAE;gBACxB,IAAA,KAKF,IAAI,CAAC,uBAAuB,EAJ5B,iBAAe,qBAAA,EACf,qBAAmB,yBAAA,EACnB,qBAAqB,2BAAA,EACrB,wBAAwB,8BACI,CAAC;gBACjC,IAAA,2CAAa,EAAC,iBAAe,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;oBACtC,OAAA,IAAA,+CAAsB,EAClB,KAAK,CAAC,gBAAgB,CAAC,eAAe,EACtC,GAAG,EACH,iBAAe,CAAC,GAAG,CAAC,CACvB;gBAJD,CAIC,CACJ,CAAC;gBACF,IAAA,2CAAa,EAAC,qBAAmB,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;oBAC1C,OAAA,IAAA,+CAAsB,EAClB,KAAK,CAAC,gBAAgB,CAAC,mBAAmB,EAC1C,GAAG,EACH,qBAAmB,CAAC,GAAG,CAAC,CAC3B;gBAJD,CAIC,CACJ,CAAC;gBACF,CAAA,KAAA,KAAK,CAAC,gBAAgB,CAAC,qBAAqB,CAAA,CAAC,IAAI,8DAAI,qBAAqB,WAAE;gBAC5E,CAAA,KAAA,KAAK,CAAC,gBAAgB,CAAC,wBAAwB,CAAA,CAAC,IAAI,8DAAI,wBAAwB,WAAE;aACrF;QACL,CAAC;QACL,kBAAC;IAAD,CAAC,AA3JD,IA2JC;IA3JY,kCAAW","sourcesContent":["import { addParser } from './utils/addParser';\nimport { blockElementParser } from './parsers/blockElementParser';\nimport { chainSanitizerCallback } from './utils/chainSanitizerCallback';\nimport { DefaultSanitizers } from './DefaultSanitizers';\nimport { deprecatedBorderColorParser } from './parsers/deprecatedColorParser';\nimport { getDocumentSource } from './pasteSourceValidations/getDocumentSource';\nimport { getObjectKeys } from 'roosterjs-content-model-dom';\nimport { imageSizeParser } from './parsers/imageSizeParser';\nimport { parseLink } from './parsers/linkParser';\nimport { pasteButtonProcessor } from './processors/pasteButtonProcessor';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromOneNote } from './oneNote/processPastedContentFromOneNote';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport { setProcessor } from './utils/setProcessor';\nimport { tableBorderParser } from './parsers/tableBorderParser';\nimport type {\n BeforePasteEvent,\n DomToModelOptionForSanitizing,\n EditorPlugin,\n IEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\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 */\nexport class PastePlugin implements EditorPlugin {\n private editor: IEditor | 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 * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(\n private allowExcelNoBorderTable?: boolean,\n private domToModelForSanitizing: Pick<\n DomToModelOptionForSanitizing,\n | 'additionalAllowedTags'\n | 'additionalDisallowedTags'\n | 'styleSanitizers'\n | 'attributeSanitizers'\n > = {\n styleSanitizers: DefaultSanitizers,\n additionalAllowedTags: [],\n additionalDisallowedTags: [],\n attributeSanitizers: {},\n }\n ) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Paste';\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 this.editor = editor;\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 != 'beforePaste') {\n return;\n }\n\n if (!event.domToModelOption) {\n return;\n }\n\n const { htmlAttributes, clipboardData, fragment } = event;\n\n const pasteSource = getDocumentSource({\n htmlAttributes,\n fragment,\n clipboardItemTypes: clipboardData.types,\n htmlFirstLevelChildTags: clipboardData.htmlFirstLevelChildTags,\n environment: this.editor.getEnvironment(),\n rawHtml: clipboardData.rawHtml,\n });\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(\n event.domToModelOption,\n event.htmlBefore || event.clipboardData.rawHtml || ''\n );\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n case 'excelNonNativeEvent':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getDOMCreator(),\n !!this.allowExcelNoBorderTable,\n pasteSource != 'excelNonNativeEvent' /* isNativeEvent */\n );\n }\n break;\n case 'googleSheets':\n event.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(event, this.editor.getDOMCreator());\n break;\n\n case 'oneNoteDesktop':\n processPastedContentFromOneNote(event);\n break;\n }\n\n addParser(event.domToModelOption, 'link', parseLink);\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'image', imageSizeParser);\n setProcessor(event.domToModelOption, 'button', pasteButtonProcessor);\n\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n\n this.setEventSanitizers(event);\n }\n\n private setEventSanitizers(event: BeforePasteEvent) {\n if (this.domToModelForSanitizing) {\n const {\n styleSanitizers,\n attributeSanitizers,\n additionalAllowedTags,\n additionalDisallowedTags,\n } = this.domToModelForSanitizing;\n getObjectKeys(styleSanitizers).forEach(key =>\n chainSanitizerCallback(\n event.domToModelOption.styleSanitizers,\n key,\n styleSanitizers[key]\n )\n );\n getObjectKeys(attributeSanitizers).forEach(key =>\n chainSanitizerCallback(\n event.domToModelOption.attributeSanitizers,\n key,\n attributeSanitizers[key]\n )\n );\n event.domToModelOption.additionalAllowedTags.push(...additionalAllowedTags);\n event.domToModelOption.additionalDisallowedTags.push(...additionalDisallowedTags);\n }\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  import type { WordMetadata } from './WordMetadata';
2
- import type { BeforePasteEvent } from 'roosterjs-content-model-types';
3
2
  /**
4
3
  * @internal
5
4
  * Word Desktop content has a style tag that contains data for the lists.
@@ -20,4 +19,4 @@ import type { BeforePasteEvent } from 'roosterjs-content-model-types';
20
19
  * 5. Save data in record and only use the required information.
21
20
  *
22
21
  */
23
- export declare function getStyleMetadata(ev: BeforePasteEvent): Map<string, WordMetadata>;
22
+ export declare function getStyleMetadata(htmlString: string): Map<string, WordMetadata>;
@@ -53,9 +53,12 @@ define(["require", "exports", "tslib", "roosterjs-content-model-dom"], function
53
53
  * 5. Save data in record and only use the required information.
54
54
  *
55
55
  */
56
- function getStyleMetadata(ev) {
56
+ function getStyleMetadata(htmlString) {
57
57
  var metadataMap = new Map();
58
- var headStyles = extractStyleTagsFromHtml(ev.htmlBefore || ev.clipboardData.rawHtml || '');
58
+ if (!htmlString) {
59
+ return metadataMap;
60
+ }
61
+ var headStyles = extractStyleTagsFromHtml(htmlString);
59
62
  headStyles.forEach(function (text) {
60
63
  var index = 0;
61
64
  var _loop_1 = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"getStyleMetadata.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/getStyleMetadata.ts"],"names":[],"mappings":";;;;IAIA,IAAM,eAAe,GAAG,cAAc,CAAC;IACvC,IAAM,SAAS,GAAG,QAAQ,CAAC;IAC3B,IAAM,aAAa,GAAG,UAAU,CAAC;IACjC,IAAM,qBAAqB,GAAG,IAAI,CAAC;IAEnC,SAAS,wBAAwB,CAAC,WAAmB;;QACjD,IAAM,MAAM,GAAa,EAAE,CAAC;QAExB,IAAA,KAAgC,kBAAkB,CAAC,WAAW,CAAC,EAA7D,UAAU,gBAAA,EAAE,aAAa,mBAAoC,CAAC;QACpE,OAAO,UAAU,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,EAAE;YAC1C,IAAM,YAAY,GAAG,WAAW;iBAC3B,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;iBACvD,IAAI,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC1B,CAAC,KAAgC,kBAAkB,CAAC,WAAW,EAAE,aAAa,GAAG,CAAC,CAAC,EAAhF,UAAU,gBAAA,EAAE,aAAa,mBAAA,CAAwD,CAAC;SACxF;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,UAAsB;QAAtB,2BAAA,EAAA,cAAsB;QAC5D,IAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC9D,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AAA,2CAAa,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAX,CAAW,CAAC,EAAE;oBAC9C,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;iBACvC;;YAzCL,OAAO,KAAK,IAAI,CAAC;;aA0ChB;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACvB,CAAC;IApDD,4CAoDC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { WordMetadata } from './WordMetadata';\nimport type { BeforePasteEvent } from 'roosterjs-content-model-types';\n\nconst FORMATING_REGEX = /[\\n\\t'{}\"]+/g;\nconst STYLE_TAG = '<style';\nconst STYLE_TAG_END = '</style>';\nconst nonWordCharacterRegex = /\\W/;\n\nfunction extractStyleTagsFromHtml(htmlContent: string): string[] {\n const styles: string[] = [];\n\n let { styleIndex, styleEndIndex } = extractHtmlIndexes(htmlContent);\n while (styleIndex >= 0 && styleEndIndex >= 0) {\n const styleContent = htmlContent\n .substring(styleIndex + STYLE_TAG.length, styleEndIndex)\n .trim();\n styles.push(styleContent);\n ({ styleIndex, styleEndIndex } = extractHtmlIndexes(htmlContent, styleEndIndex + 1));\n }\n return styles;\n}\n\nfunction extractHtmlIndexes(html: string, startIndex: number = 0) {\n const htmlLowercase = html.toLowerCase();\n let styleIndex = htmlLowercase.indexOf(STYLE_TAG, startIndex);\n let currentIndex = styleIndex + STYLE_TAG.length;\n let nextChar = html.substring(currentIndex, currentIndex + 1);\n\n while (!nonWordCharacterRegex.test(nextChar) && styleIndex > -1) {\n styleIndex = htmlLowercase.indexOf(STYLE_TAG, styleIndex + 1);\n currentIndex = styleIndex + STYLE_TAG.length;\n nextChar = html.substring(currentIndex, currentIndex + 1);\n }\n\n const styleEndIndex = htmlLowercase.indexOf(STYLE_TAG_END, startIndex);\n return { styleIndex, styleEndIndex };\n}\n\n/**\n * @internal\n * Word Desktop content has a style tag that contains data for the lists.\n * So this function query that style tag and extract the data from the innerHTML, since it is not available from the HTMLStyleElement.sheet.\n *\n * The format is like:\n * example of style element content\n * @list l0:level1 {\n * styleTag: styleValue;\n * ...\n * }\n *\n * To extract the data:\n * 1. Substring the value of the style selector, using @ index and { index\n * 2. Substring the value of the style rules by Substring the content between { and }\n * 3. Split the value of the rules using ; as separator { styleTag: styleValue; styleTag1: StyleValue1 } = ['styleTag: styleValue', 'styleTag1: StyleValue1']\n * 4. Split the value of the rule using : as separator: styleTag: styleValue = [styleTag, styleValue]\n * 5. Save data in record and only use the required information.\n *\n */\nexport function getStyleMetadata(ev: BeforePasteEvent) {\n const metadataMap: Map<string, WordMetadata> = new Map();\n const headStyles = extractStyleTagsFromHtml(ev.htmlBefore || ev.clipboardData.rawHtml || '');\n\n headStyles.forEach(text => {\n let index = 0;\n while (index >= 0) {\n const indexAt = text.indexOf('@', index + 1);\n const indexCurlyEnd = text.indexOf('}', indexAt);\n const indexCurlyStart = text.indexOf('{', indexAt);\n index = indexAt;\n\n // 1.\n const metadataName = text\n .substring(indexAt + 1, indexCurlyStart)\n .replace(FORMATING_REGEX, '')\n .replace('list', '')\n .trimRight()\n .trimLeft();\n\n // 2.\n const dataName = text\n .substring(indexCurlyStart, indexCurlyEnd + 1)\n .trimLeft()\n .trimRight();\n const record: Record<string, string> = {};\n\n // 3.\n const entries = dataName.split(';');\n entries.forEach(entry => {\n // 4.\n const [key, value] = entry.split(':');\n if (key && value) {\n const formatedKey = key.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n const formatedValue = value.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n // 5.\n record[formatedKey] = formatedValue;\n }\n });\n\n const data: WordMetadata = {\n 'mso-level-number-format': record['mso-level-number-format'],\n 'mso-level-start-at': record['mso-level-start-at'] || '1',\n 'mso-level-text': record['mso-level-text'],\n };\n if (getObjectKeys(data).some(key => !!data[key])) {\n metadataMap.set(metadataName, data);\n }\n }\n });\n\n return metadataMap;\n}\n"]}
1
+ {"version":3,"file":"getStyleMetadata.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/getStyleMetadata.ts"],"names":[],"mappings":";;;;IAGA,IAAM,eAAe,GAAG,cAAc,CAAC;IACvC,IAAM,SAAS,GAAG,QAAQ,CAAC;IAC3B,IAAM,aAAa,GAAG,UAAU,CAAC;IACjC,IAAM,qBAAqB,GAAG,IAAI,CAAC;IAEnC,SAAS,wBAAwB,CAAC,WAAmB;;QACjD,IAAM,MAAM,GAAa,EAAE,CAAC;QAExB,IAAA,KAAgC,kBAAkB,CAAC,WAAW,CAAC,EAA7D,UAAU,gBAAA,EAAE,aAAa,mBAAoC,CAAC;QACpE,OAAO,UAAU,IAAI,CAAC,IAAI,aAAa,IAAI,CAAC,EAAE;YAC1C,IAAM,YAAY,GAAG,WAAW;iBAC3B,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;iBACvD,IAAI,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC1B,CAAC,KAAgC,kBAAkB,CAAC,WAAW,EAAE,aAAa,GAAG,CAAC,CAAC,EAAhF,UAAU,gBAAA,EAAE,aAAa,mBAAA,CAAwD,CAAC;SACxF;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,SAAS,kBAAkB,CAAC,IAAY,EAAE,UAAsB;QAAtB,2BAAA,EAAA,cAAsB;QAC5D,IAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC;QACjD,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;QAE9D,OAAO,CA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,YAAY,EAAE,IAAI,CAAC,CAAC;iBACvC;;YAzCL,OAAO,KAAK,IAAI,CAAC;;aA0ChB;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACvB,CAAC;IAvDD,4CAuDC","sourcesContent":["import { getObjectKeys } from 'roosterjs-content-model-dom';\nimport type { WordMetadata } from './WordMetadata';\n\nconst FORMATING_REGEX = /[\\n\\t'{}\"]+/g;\nconst STYLE_TAG = '<style';\nconst STYLE_TAG_END = '</style>';\nconst nonWordCharacterRegex = /\\W/;\n\nfunction extractStyleTagsFromHtml(htmlContent: string): string[] {\n const styles: string[] = [];\n\n let { styleIndex, styleEndIndex } = extractHtmlIndexes(htmlContent);\n while (styleIndex >= 0 && styleEndIndex >= 0) {\n const styleContent = htmlContent\n .substring(styleIndex + STYLE_TAG.length, styleEndIndex)\n .trim();\n styles.push(styleContent);\n ({ styleIndex, styleEndIndex } = extractHtmlIndexes(htmlContent, styleEndIndex + 1));\n }\n return styles;\n}\n\nfunction extractHtmlIndexes(html: string, startIndex: number = 0) {\n const htmlLowercase = html.toLowerCase();\n let styleIndex = htmlLowercase.indexOf(STYLE_TAG, startIndex);\n let currentIndex = styleIndex + STYLE_TAG.length;\n let nextChar = html.substring(currentIndex, currentIndex + 1);\n\n while (!nonWordCharacterRegex.test(nextChar) && styleIndex > -1) {\n styleIndex = htmlLowercase.indexOf(STYLE_TAG, styleIndex + 1);\n currentIndex = styleIndex + STYLE_TAG.length;\n nextChar = html.substring(currentIndex, currentIndex + 1);\n }\n\n const styleEndIndex = htmlLowercase.indexOf(STYLE_TAG_END, startIndex);\n return { styleIndex, styleEndIndex };\n}\n\n/**\n * @internal\n * Word Desktop content has a style tag that contains data for the lists.\n * So this function query that style tag and extract the data from the innerHTML, since it is not available from the HTMLStyleElement.sheet.\n *\n * The format is like:\n * example of style element content\n * @list l0:level1 {\n * styleTag: styleValue;\n * ...\n * }\n *\n * To extract the data:\n * 1. Substring the value of the style selector, using @ index and { index\n * 2. Substring the value of the style rules by Substring the content between { and }\n * 3. Split the value of the rules using ; as separator { styleTag: styleValue; styleTag1: StyleValue1 } = ['styleTag: styleValue', 'styleTag1: StyleValue1']\n * 4. Split the value of the rule using : as separator: styleTag: styleValue = [styleTag, styleValue]\n * 5. Save data in record and only use the required information.\n *\n */\nexport function getStyleMetadata(htmlString: string) {\n const metadataMap: Map<string, WordMetadata> = new Map();\n if (!htmlString) {\n return metadataMap;\n }\n const headStyles = extractStyleTagsFromHtml(htmlString);\n\n headStyles.forEach(text => {\n let index = 0;\n while (index >= 0) {\n const indexAt = text.indexOf('@', index + 1);\n const indexCurlyEnd = text.indexOf('}', indexAt);\n const indexCurlyStart = text.indexOf('{', indexAt);\n index = indexAt;\n\n // 1.\n const metadataName = text\n .substring(indexAt + 1, indexCurlyStart)\n .replace(FORMATING_REGEX, '')\n .replace('list', '')\n .trimRight()\n .trimLeft();\n\n // 2.\n const dataName = text\n .substring(indexCurlyStart, indexCurlyEnd + 1)\n .trimLeft()\n .trimRight();\n const record: Record<string, string> = {};\n\n // 3.\n const entries = dataName.split(';');\n entries.forEach(entry => {\n // 4.\n const [key, value] = entry.split(':');\n if (key && value) {\n const formatedKey = key.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n const formatedValue = value.replace(FORMATING_REGEX, '').trimRight().trimLeft();\n // 5.\n record[formatedKey] = formatedValue;\n }\n });\n\n const data: WordMetadata = {\n 'mso-level-number-format': record['mso-level-number-format'],\n 'mso-level-start-at': record['mso-level-start-at'] || '1',\n 'mso-level-text': record['mso-level-text'],\n };\n if (getObjectKeys(data).some(key => !!data[key])) {\n metadataMap.set(metadataName, data);\n }\n }\n });\n\n return metadataMap;\n}\n"]}
@@ -1,7 +1,8 @@
1
- import type { BeforePasteEvent } from 'roosterjs-content-model-types';
1
+ import type { DomToModelOption } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
- * Handles Pasted content when source is Word Desktop
5
- * @param ev BeforePasteEvent
4
+ * Handles pasted content when the source is Word Desktop.
5
+ * @param domToModelOption Options for DOM to Content Model conversion
6
+ * @param htmlString The HTML string to process
6
7
  */
7
- export declare function processPastedContentFromWordDesktop(ev: BeforePasteEvent): void;
8
+ export declare function processPastedContentFromWordDesktop(domToModelOption: DomToModelOption, htmlString: string): void;
@@ -1,20 +1,22 @@
1
- define(["require", "exports", "../utils/addParser", "../parsers/adjustPercentileLineHeightParser", "./getStyleMetadata", "../utils/getStyles", "../parsers/listLevelParser", "./processWordComments", "./processWordLists", "../parsers/removeNegativeTextIndentParser", "../utils/setProcessor", "../parsers/wordTableParser"], function (require, exports, addParser_1, adjustPercentileLineHeightParser_1, getStyleMetadata_1, getStyles_1, listLevelParser_1, processWordComments_1, processWordLists_1, removeNegativeTextIndentParser_1, setProcessor_1, wordTableParser_1) {
1
+ define(["require", "exports", "../utils/addParser", "../parsers/adjustPercentileLineHeightParser", "./getStyleMetadata", "../utils/getStyles", "../parsers/listLevelParser", "./processWordComments", "./processWordLists", "../parsers/removeNegativeTextIndentParser", "../utils/setProcessor", "../parsers/wordContainerParser", "../parsers/wordTableParser"], function (require, exports, addParser_1, adjustPercentileLineHeightParser_1, getStyleMetadata_1, getStyles_1, listLevelParser_1, processWordComments_1, processWordLists_1, removeNegativeTextIndentParser_1, setProcessor_1, wordContainerParser_1, wordTableParser_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.processPastedContentFromWordDesktop = void 0;
5
5
  /**
6
6
  * @internal
7
- * Handles Pasted content when source is Word Desktop
8
- * @param ev BeforePasteEvent
7
+ * Handles pasted content when the source is Word Desktop.
8
+ * @param domToModelOption Options for DOM to Content Model conversion
9
+ * @param htmlString The HTML string to process
9
10
  */
10
- function processPastedContentFromWordDesktop(ev) {
11
- var metadataMap = (0, getStyleMetadata_1.getStyleMetadata)(ev);
12
- (0, setProcessor_1.setProcessor)(ev.domToModelOption, 'element', wordDesktopElementProcessor(metadataMap));
13
- (0, addParser_1.addParser)(ev.domToModelOption, 'block', adjustPercentileLineHeightParser_1.adjustPercentileLineHeight);
14
- (0, addParser_1.addParser)(ev.domToModelOption, 'block', removeNegativeTextIndentParser_1.removeNegativeTextIndentParser);
15
- (0, addParser_1.addParser)(ev.domToModelOption, 'listLevel', listLevelParser_1.listLevelParser);
16
- (0, addParser_1.addParser)(ev.domToModelOption, 'container', wordTableParser_1.wordTableParser);
17
- (0, addParser_1.addParser)(ev.domToModelOption, 'table', wordTableParser_1.wordTableParser);
11
+ function processPastedContentFromWordDesktop(domToModelOption, htmlString) {
12
+ var metadataMap = (0, getStyleMetadata_1.getStyleMetadata)(htmlString);
13
+ (0, setProcessor_1.setProcessor)(domToModelOption, 'element', wordDesktopElementProcessor(metadataMap));
14
+ (0, addParser_1.addParser)(domToModelOption, 'block', adjustPercentileLineHeightParser_1.adjustPercentileLineHeight);
15
+ (0, addParser_1.addParser)(domToModelOption, 'block', removeNegativeTextIndentParser_1.removeNegativeTextIndentParser);
16
+ (0, addParser_1.addParser)(domToModelOption, 'listItemElement', removeNegativeTextIndentParser_1.removeNegativeTextIndentParser);
17
+ (0, addParser_1.addParser)(domToModelOption, 'listLevel', listLevelParser_1.listLevelParser);
18
+ (0, addParser_1.addParser)(domToModelOption, 'container', wordContainerParser_1.wordContainerParser);
19
+ (0, addParser_1.addParser)(domToModelOption, 'table', wordTableParser_1.wordTableParser);
18
20
  }
19
21
  exports.processPastedContentFromWordDesktop = processPastedContentFromWordDesktop;
20
22
  var wordDesktopElementProcessor = function (metadataKey) {
@@ -1 +1 @@
1
- {"version":3,"file":"processPastedContentFromWordDesktop.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/processPastedContentFromWordDesktop.ts"],"names":[],"mappings":";;;;IAaA;;;;OAIG;IACH,SAAgB,mCAAmC,CAAC,EAAoB;QACpE,IAAM,WAAW,GAA8B,IAAA,mCAAgB,EAAC,EAAE,CAAC,CAAC;QAEpE,IAAA,2BAAY,EAAC,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;QACvF,IAAA,qBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,6DAA0B,CAAC,CAAC;QACpE,IAAA,qBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,+DAA8B,CAAC,CAAC;QACxE,IAAA,qBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,EAAE,iCAAe,CAAC,CAAC;QAC7D,IAAA,qBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,EAAE,iCAAe,CAAC,CAAC;QAC7D,IAAA,qBAAS,EAAC,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,iCAAe,CAAC,CAAC;IAC7D,CAAC;IATD,kFASC;IAED,IAAM,2BAA2B,GAAG,UAChC,WAAsC;QAEtC,OAAO,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;YAC3B,IAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;YAClC,4FAA4F;YAC5F,IACI,CAAC,CACG,IAAA,kCAAe,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC;gBAC7D,IAAA,yCAAmB,EAAC,MAAM,EAAE,OAAO,CAAC,CACvC,EACH;gBACE,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;aACrE;QACL,CAAC,CAAC;IACN,CAAC,CAAC","sourcesContent":["import { addParser } from '../utils/addParser';\nimport { adjustPercentileLineHeight } from '../parsers/adjustPercentileLineHeightParser';\nimport { getStyleMetadata } from './getStyleMetadata';\nimport { getStyles } from '../utils/getStyles';\nimport { listLevelParser } from '../parsers/listLevelParser';\nimport { processWordComments } from './processWordComments';\nimport { processWordList } from './processWordLists';\nimport { removeNegativeTextIndentParser } from '../parsers/removeNegativeTextIndentParser';\nimport { setProcessor } from '../utils/setProcessor';\nimport { wordTableParser } from '../parsers/wordTableParser';\nimport type { WordMetadata } from './WordMetadata';\nimport type { BeforePasteEvent, ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Handles Pasted content when source is Word Desktop\n * @param ev BeforePasteEvent\n */\nexport function processPastedContentFromWordDesktop(ev: BeforePasteEvent) {\n const metadataMap: Map<string, WordMetadata> = getStyleMetadata(ev);\n\n setProcessor(ev.domToModelOption, 'element', wordDesktopElementProcessor(metadataMap));\n addParser(ev.domToModelOption, 'block', adjustPercentileLineHeight);\n addParser(ev.domToModelOption, 'block', removeNegativeTextIndentParser);\n addParser(ev.domToModelOption, 'listLevel', listLevelParser);\n addParser(ev.domToModelOption, 'container', wordTableParser);\n addParser(ev.domToModelOption, 'table', wordTableParser);\n}\n\nconst wordDesktopElementProcessor = (\n metadataKey: Map<string, WordMetadata>\n): ElementProcessor<HTMLElement> => {\n return (group, element, context) => {\n const styles = getStyles(element);\n // Process Word Lists or Word Commands, otherwise use the default processor on this element.\n if (\n !(\n processWordList(styles, group, element, context, metadataKey) ||\n processWordComments(styles, element)\n )\n ) {\n context.defaultElementProcessors.element(group, element, context);\n }\n };\n};\n"]}
1
+ {"version":3,"file":"processPastedContentFromWordDesktop.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/WordDesktop/processPastedContentFromWordDesktop.ts"],"names":[],"mappings":";;;;IAcA;;;;;OAKG;IACH,SAAgB,mCAAmC,CAC/C,gBAAkC,EAClC,UAAkB;QAElB,IAAM,WAAW,GAA8B,IAAA,mCAAgB,EAAC,UAAU,CAAC,CAAC;QAE5E,IAAA,2BAAY,EAAC,gBAAgB,EAAE,SAAS,EAAE,2BAA2B,CAAC,WAAW,CAAC,CAAC,CAAC;QACpF,IAAA,qBAAS,EAAC,gBAAgB,EAAE,OAAO,EAAE,6DAA0B,CAAC,CAAC;QACjE,IAAA,qBAAS,EAAC,gBAAgB,EAAE,OAAO,EAAE,+DAA8B,CAAC,CAAC;QACrE,IAAA,qBAAS,EAAC,gBAAgB,EAAE,iBAAiB,EAAE,+DAA8B,CAAC,CAAC;QAC/E,IAAA,qBAAS,EAAC,gBAAgB,EAAE,WAAW,EAAE,iCAAe,CAAC,CAAC;QAC1D,IAAA,qBAAS,EAAC,gBAAgB,EAAE,WAAW,EAAE,yCAAmB,CAAC,CAAC;QAC9D,IAAA,qBAAS,EAAC,gBAAgB,EAAE,OAAO,EAAE,iCAAe,CAAC,CAAC;IAC1D,CAAC;IAbD,kFAaC;IAED,IAAM,2BAA2B,GAAG,UAChC,WAAsC;QAEtC,OAAO,UAAC,KAAK,EAAE,OAAO,EAAE,OAAO;YAC3B,IAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;YAClC,4FAA4F;YAC5F,IACI,CAAC,CACG,IAAA,kCAAe,EAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC;gBAC7D,IAAA,yCAAmB,EAAC,MAAM,EAAE,OAAO,CAAC,CACvC,EACH;gBACE,OAAO,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;aACrE;QACL,CAAC,CAAC;IACN,CAAC,CAAC","sourcesContent":["import { addParser } from '../utils/addParser';\nimport { adjustPercentileLineHeight } from '../parsers/adjustPercentileLineHeightParser';\nimport { getStyleMetadata } from './getStyleMetadata';\nimport { getStyles } from '../utils/getStyles';\nimport { listLevelParser } from '../parsers/listLevelParser';\nimport { processWordComments } from './processWordComments';\nimport { processWordList } from './processWordLists';\nimport { removeNegativeTextIndentParser } from '../parsers/removeNegativeTextIndentParser';\nimport { setProcessor } from '../utils/setProcessor';\nimport { wordContainerParser } from '../parsers/wordContainerParser';\nimport { wordTableParser } from '../parsers/wordTableParser';\nimport type { WordMetadata } from './WordMetadata';\nimport type { DomToModelOption, ElementProcessor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Handles pasted content when the source is Word Desktop.\n * @param domToModelOption Options for DOM to Content Model conversion\n * @param htmlString The HTML string to process\n */\nexport function processPastedContentFromWordDesktop(\n domToModelOption: DomToModelOption,\n htmlString: string\n) {\n const metadataMap: Map<string, WordMetadata> = getStyleMetadata(htmlString);\n\n setProcessor(domToModelOption, 'element', wordDesktopElementProcessor(metadataMap));\n addParser(domToModelOption, 'block', adjustPercentileLineHeight);\n addParser(domToModelOption, 'block', removeNegativeTextIndentParser);\n addParser(domToModelOption, 'listItemElement', removeNegativeTextIndentParser);\n addParser(domToModelOption, 'listLevel', listLevelParser);\n addParser(domToModelOption, 'container', wordContainerParser);\n addParser(domToModelOption, 'table', wordTableParser);\n}\n\nconst wordDesktopElementProcessor = (\n metadataKey: Map<string, WordMetadata>\n): ElementProcessor<HTMLElement> => {\n return (group, element, context) => {\n const styles = getStyles(element);\n // Process Word Lists or Word Commands, otherwise use the default processor on this element.\n if (\n !(\n processWordList(styles, group, element, context, metadataKey) ||\n processWordComments(styles, element)\n )\n ) {\n context.defaultElementProcessors.element(group, element, context);\n }\n };\n};\n"]}
@@ -5,7 +5,7 @@ define(["require", "exports"], function (require, exports) {
5
5
  /**
6
6
  * @internal
7
7
  */
8
- var removeNegativeTextIndentParser = function (format) {
8
+ var removeNegativeTextIndentParser = function (format, element) {
9
9
  var _a;
10
10
  if ((_a = format.textIndent) === null || _a === void 0 ? void 0 : _a.startsWith('-')) {
11
11
  delete format.textIndent;
@@ -1 +1 @@
1
- {"version":3,"file":"removeNegativeTextIndentParser.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/parsers/removeNegativeTextIndentParser.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACI,IAAM,8BAA8B,GAAmC,UAAA,MAAM;;QAChF,IAAI,MAAA,MAAM,CAAC,UAAU,0CAAE,UAAU,CAAC,GAAG,CAAC,EAAE;YACpC,OAAO,MAAM,CAAC,UAAU,CAAC;SAC5B;IACL,CAAC,CAAC;IAJW,QAAA,8BAA8B,kCAIzC","sourcesContent":["import type { FormatParser, TextIndentFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const removeNegativeTextIndentParser: FormatParser<TextIndentFormat> = format => {\n if (format.textIndent?.startsWith('-')) {\n delete format.textIndent;\n }\n};\n"]}
1
+ {"version":3,"file":"removeNegativeTextIndentParser.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/parsers/removeNegativeTextIndentParser.ts"],"names":[],"mappings":";;;;IAEA;;OAEG;IACI,IAAM,8BAA8B,GAAmC,UAAC,MAAM,EAAE,OAAO;;QAC1F,IAAI,MAAA,MAAM,CAAC,UAAU,0CAAE,UAAU,CAAC,GAAG,CAAC,EAAE;YACpC,OAAO,MAAM,CAAC,UAAU,CAAC;SAC5B;IACL,CAAC,CAAC;IAJW,QAAA,8BAA8B,kCAIzC","sourcesContent":["import type { FormatParser, TextIndentFormat } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const removeNegativeTextIndentParser: FormatParser<TextIndentFormat> = (format, element) => {\n if (format.textIndent?.startsWith('-')) {\n delete format.textIndent;\n }\n};\n"]}
@@ -0,0 +1,8 @@
1
+ import type { ContentModelFormatContainerFormat, FormatParser } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * Parser for processing container formatting specific to Word Desktop
5
+ * Removes negative margin-left values which are commonly used in Word lists
6
+ * @param format The container format to modify
7
+ */
8
+ export declare const wordContainerParser: FormatParser<ContentModelFormatContainerFormat>;
@@ -0,0 +1,19 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.wordContainerParser = void 0;
5
+ /**
6
+ * @internal
7
+ * Parser for processing container formatting specific to Word Desktop
8
+ * Removes negative margin-left values which are commonly used in Word lists
9
+ * @param format The container format to modify
10
+ */
11
+ var wordContainerParser = function (format) {
12
+ var _a;
13
+ if ((_a = format.marginLeft) === null || _a === void 0 ? void 0 : _a.startsWith('-')) {
14
+ delete format.marginLeft;
15
+ }
16
+ };
17
+ exports.wordContainerParser = wordContainerParser;
18
+ });
19
+ //# sourceMappingURL=wordContainerParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wordContainerParser.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/parsers/wordContainerParser.ts"],"names":[],"mappings":";;;;IAKA;;;;;OAKG;IACI,IAAM,mBAAmB,GAAoD,UAChF,MAAM;;QAEN,IAAI,MAAA,MAAM,CAAC,UAAU,0CAAE,UAAU,CAAC,GAAG,CAAC,EAAE;YACpC,OAAO,MAAM,CAAC,UAAU,CAAC;SAC5B;IACL,CAAC,CAAC;IANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["import type {\n ContentModelFormatContainerFormat,\n FormatParser,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Parser for processing container formatting specific to Word Desktop\n * Removes negative margin-left values which are commonly used in Word lists\n * @param format The container format to modify\n */\nexport const wordContainerParser: FormatParser<ContentModelFormatContainerFormat> = (\n format\n): void => {\n if (format.marginLeft?.startsWith('-')) {\n delete format.marginLeft;\n }\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Check whether the fragment provided contain Wac Elements
@@ -1 +1 @@
1
- {"version":3,"file":"documentContainWacElements.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/documentContainWacElements.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;QACtD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,iCAAqB,CAAC,CAAC;IAC3D,CAAC,CAAC;IAHW,QAAA,0BAA0B,8BAGrC","sourcesContent":["import { WAC_IDENTIFY_SELECTOR } from '../WacComponents/constants';\nimport type { GetSourceFunction } from './getPasteSource';\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"]}
1
+ {"version":3,"file":"documentContainWacElements.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/documentContainWacElements.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;QACtD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,iCAAqB,CAAC,CAAC;IAC3D,CAAC,CAAC;IAHW,QAAA,0BAA0B,8BAGrC","sourcesContent":["import { WAC_IDENTIFY_SELECTOR } from '../WacComponents/constants';\nimport type { GetSourceFunction } from './getDocumentSource';\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,52 @@
1
+ import type { EditorEnvironment } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ * The input parameters for getDocumentSource function
5
+ */
6
+ export declare type GetSourceInputParams = {
7
+ /**
8
+ * HTML attributes from the content that is being checked
9
+ */
10
+ htmlAttributes: Record<string, string>;
11
+ /**
12
+ * Document fragment of the checked content
13
+ */
14
+ fragment: DocumentFragment | Document;
15
+ /**
16
+ * Whether convert single image is enabled
17
+ */
18
+ shouldConvertSingleImage?: boolean;
19
+ /**
20
+ * Array of tag names of the first level child nodes
21
+ */
22
+ htmlFirstLevelChildTags?: string[];
23
+ /**
24
+ * The clipboard item types
25
+ */
26
+ clipboardItemTypes?: string[];
27
+ /**
28
+ * The editor environment
29
+ */
30
+ environment: Omit<EditorEnvironment, 'domToModelSettings' | 'modelToDomSettings'>;
31
+ /**
32
+ * The raw HTML string from clipboard
33
+ */
34
+ rawHtml?: string | null;
35
+ };
36
+ /**
37
+ * @internal
38
+ * Represent the types of sources to handle in the Paste Plugin
39
+ */
40
+ export declare type KnownPasteSourceType = 'wordDesktop' | 'excelDesktop' | 'excelOnline' | 'powerPointDesktop' | 'googleSheets' | 'wacComponents' | 'default' | 'singleImage' | 'excelNonNativeEvent' | 'oneNoteDesktop';
41
+ /**
42
+ * @internal
43
+ */
44
+ export declare type GetSourceFunction = (props: GetSourceInputParams) => boolean;
45
+ /**
46
+ * @internal
47
+ * This function tries to get the source of the Pasted content
48
+ * @param event the before paste event
49
+ * @param shouldConvertSingleImage Whether convert single image is enabled.
50
+ * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
51
+ */
52
+ export declare function getDocumentSource(param: GetSourceInputParams): KnownPasteSourceType;
@@ -1,7 +1,7 @@
1
1
  define(["require", "exports", "./documentContainWacElements", "./isExcelDesktopDocument", "./isExcelNonNativeEvent", "./isExcelOnlineDocument", "./isGoogleSheetDocument", "./isOneNoteDocument", "./isPowerPointDesktopDocument", "./isWordDesktopDocument", "./shouldConvertToSingleImage"], function (require, exports, documentContainWacElements_1, isExcelDesktopDocument_1, isExcelNonNativeEvent_1, isExcelOnlineDocument_1, isGoogleSheetDocument_1, isOneNoteDocument_1, isPowerPointDesktopDocument_1, isWordDesktopDocument_1, shouldConvertToSingleImage_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.getPasteSource = void 0;
4
+ exports.getDocumentSource = void 0;
5
5
  var getSourceFunctions = new Map([
6
6
  ['wordDesktop', isWordDesktopDocument_1.isWordDesktopDocument],
7
7
  ['excelDesktop', isExcelDesktopDocument_1.isExcelDesktopDocument],
@@ -20,16 +20,8 @@ define(["require", "exports", "./documentContainWacElements", "./isExcelDesktopD
20
20
  * @param shouldConvertSingleImage Whether convert single image is enabled.
21
21
  * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}
22
22
  */
23
- function getPasteSource(event, shouldConvertSingleImage, environment) {
24
- var htmlAttributes = event.htmlAttributes, clipboardData = event.clipboardData, fragment = event.fragment;
23
+ function getDocumentSource(param) {
25
24
  var result = null;
26
- var param = {
27
- htmlAttributes: htmlAttributes,
28
- fragment: fragment,
29
- shouldConvertSingleImage: shouldConvertSingleImage,
30
- clipboardData: clipboardData,
31
- environment: environment,
32
- };
33
25
  getSourceFunctions.forEach(function (func, key) {
34
26
  if (!result && func(param)) {
35
27
  result = key;
@@ -37,6 +29,6 @@ define(["require", "exports", "./documentContainWacElements", "./isExcelDesktopD
37
29
  });
38
30
  return result !== null && result !== void 0 ? result : 'default';
39
31
  }
40
- exports.getPasteSource = getPasteSource;
32
+ exports.getDocumentSource = getDocumentSource;
41
33
  });
42
- //# sourceMappingURL=getPasteSource.js.map
34
+ //# sourceMappingURL=getDocumentSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDocumentSource.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getDocumentSource.ts"],"names":[],"mappings":";;;;IAmEA,IAAM,kBAAkB,GAAG,IAAI,GAAG,CAA0C;QACxE,CAAC,aAAa,EAAE,6CAAqB,CAAC;QACtC,CAAC,cAAc,EAAE,+CAAsB,CAAC;QACxC,CAAC,aAAa,EAAE,6CAAqB,CAAC;QACtC,CAAC,mBAAmB,EAAE,yDAA2B,CAAC;QAClD,CAAC,eAAe,EAAE,uDAA0B,CAAC;QAC7C,CAAC,cAAc,EAAE,6CAAqB,CAAC;QACvC,CAAC,aAAa,EAAE,uDAA0B,CAAC;QAC3C,CAAC,qBAAqB,EAAE,6CAAqB,CAAC;QAC9C,CAAC,gBAAgB,EAAE,4CAAwB,CAAC;KAC/C,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,SAAgB,iBAAiB,CAAC,KAA2B;QACzD,IAAI,MAAM,GAAgC,IAAI,CAAC;QAE/C,kBAAkB,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,GAAG;YACjC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,GAAG,GAAG,CAAC;aAChB;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;IAC/B,CAAC;IAVD,8CAUC","sourcesContent":["import { documentContainWacElements } from './documentContainWacElements';\nimport { isExcelDesktopDocument } from './isExcelDesktopDocument';\nimport { isExcelNotNativeEvent } from './isExcelNonNativeEvent';\nimport { isExcelOnlineDocument } from './isExcelOnlineDocument';\nimport { isGoogleSheetDocument } from './isGoogleSheetDocument';\nimport { isOneNoteDesktopDocument } from './isOneNoteDocument';\nimport { isPowerPointDesktopDocument } from './isPowerPointDesktopDocument';\nimport { isWordDesktopDocument } from './isWordDesktopDocument';\nimport { shouldConvertToSingleImage } from './shouldConvertToSingleImage';\nimport type { EditorEnvironment } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * The input parameters for getDocumentSource function\n */\nexport type GetSourceInputParams = {\n /**\n * HTML attributes from the content that is being checked\n */\n htmlAttributes: Record<string, string>;\n /**\n * Document fragment of the checked content\n */\n fragment: DocumentFragment | Document;\n /**\n * Whether convert single image is enabled\n */\n shouldConvertSingleImage?: boolean;\n /**\n * Array of tag names of the first level child nodes\n */\n htmlFirstLevelChildTags?: string[];\n /**\n * The clipboard item types\n */\n clipboardItemTypes?: string[];\n /**\n * The editor environment\n */\n environment: Omit<EditorEnvironment, 'domToModelSettings' | 'modelToDomSettings'>;\n /**\n * The raw HTML string from clipboard\n */\n rawHtml?: string | null;\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 | 'excelNonNativeEvent'\n | 'oneNoteDesktop';\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 ['excelNonNativeEvent', isExcelNotNativeEvent],\n ['oneNoteDesktop', isOneNoteDesktopDocument],\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 getDocumentSource(param: GetSourceInputParams): KnownPasteSourceType {\n let result: KnownPasteSourceType | null = null;\n\n getSourceFunctions.forEach((func, key) => {\n if (!result && func(param)) {\n result = key;\n }\n });\n\n return result ?? 'default';\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the Array provided contains strings that identify Excel Desktop documents
@@ -1 +1 @@
1
- {"version":3,"file":"isExcelDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,qBAAqB,GAAG,wCAAwC,CAAC;IAEvE;;;;;OAKG;IACI,IAAM,sBAAsB,GAAsB,UAAA,KAAK;QAClD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,wEAAwE;QACxE,OAAO,cAAc,CAAC,8BAAkB,CAAC,4BAA4B,CAAC,IAAI,qBAAqB,CAAC;IACpG,CAAC,CAAC;IAJW,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"]}
1
+ {"version":3,"file":"isExcelDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,qBAAqB,GAAG,wCAAwC,CAAC;IAEvE;;;;;OAKG;IACI,IAAM,sBAAsB,GAAsB,UAAA,KAAK;QAClD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,wEAAwE;QACxE,OAAO,cAAc,CAAC,8BAAkB,CAAC,4BAA4B,CAAC,IAAI,qBAAqB,CAAC;IACpG,CAAC,CAAC;IAJW,QAAA,sBAAsB,0BAIjC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\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"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * When the clipboard content is retrieved programatically, the clipboard html does not contain the usual
@@ -9,11 +9,11 @@ define(["require", "exports"], function (require, exports) {
9
9
  * attributes we use to determine if the content is from Excel. This function is used to handle that case.
10
10
  */
11
11
  var isExcelNotNativeEvent = function (props) {
12
- var _a;
13
- var clipboardData = props.clipboardData;
14
- return (clipboardData.types.includes(ShadowWorkbookClipboardType) &&
15
- ((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
16
- clipboardData.htmlFirstLevelChildTags[0] == 'TABLE');
12
+ var clipboardItemTypes = props.clipboardItemTypes, htmlFirstLevelChildTags = props.htmlFirstLevelChildTags;
13
+ return !!(clipboardItemTypes &&
14
+ clipboardItemTypes.includes(ShadowWorkbookClipboardType) &&
15
+ (htmlFirstLevelChildTags === null || htmlFirstLevelChildTags === void 0 ? void 0 : htmlFirstLevelChildTags.length) == 1 &&
16
+ htmlFirstLevelChildTags[0] == 'TABLE');
17
17
  };
18
18
  exports.isExcelNotNativeEvent = isExcelNotNativeEvent;
19
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"isExcelNonNativeEvent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelNonNativeEvent.ts"],"names":[],"mappings":";;;;IAEA,IAAM,2BAA2B,GAAG,0BAA0B,CAAC;IAE/D;;;;OAIG;IACI,IAAM,qBAAqB,GAAsB,UAAC,KAA2B;;QACxE,IAAA,aAAa,GAAK,KAAK,cAAV,CAAW;QAEhC,OAAO,CACH,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YACzD,CAAA,MAAA,aAAa,CAAC,uBAAuB,0CAAE,MAAM,KAAI,CAAC;YAClD,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,OAAO,CACtD,CAAC;IACN,CAAC,CAAC;IARW,QAAA,qBAAqB,yBAQhC","sourcesContent":["import type { GetSourceFunction, GetSourceInputParams } from './getPasteSource';\n\nconst ShadowWorkbookClipboardType = 'web data/shadow-workbook';\n\n/**\n * @internal\n * When the clipboard content is retrieved programatically, the clipboard html does not contain the usual\n * attributes we use to determine if the content is from Excel. This function is used to handle that case.\n */\nexport const isExcelNotNativeEvent: GetSourceFunction = (props: GetSourceInputParams) => {\n const { clipboardData } = props;\n\n return (\n clipboardData.types.includes(ShadowWorkbookClipboardType) &&\n clipboardData.htmlFirstLevelChildTags?.length == 1 &&\n clipboardData.htmlFirstLevelChildTags[0] == 'TABLE'\n );\n};\n"]}
1
+ {"version":3,"file":"isExcelNonNativeEvent.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelNonNativeEvent.ts"],"names":[],"mappings":";;;;IAEA,IAAM,2BAA2B,GAAG,0BAA0B,CAAC;IAE/D;;;;OAIG;IACI,IAAM,qBAAqB,GAAsB,UAAC,KAA2B;QACxE,IAAA,kBAAkB,GAA8B,KAAK,mBAAnC,EAAE,uBAAuB,GAAK,KAAK,wBAAV,CAAW;QAE9D,OAAO,CAAC,CAAC,CACL,kBAAkB;YAClB,kBAAkB,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YACxD,CAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,MAAM,KAAI,CAAC;YACpC,uBAAuB,CAAC,CAAC,CAAC,IAAI,OAAO,CACxC,CAAC;IACN,CAAC,CAAC;IATW,QAAA,qBAAqB,yBAShC","sourcesContent":["import type { GetSourceFunction, GetSourceInputParams } from './getDocumentSource';\n\nconst ShadowWorkbookClipboardType = 'web data/shadow-workbook';\n\n/**\n * @internal\n * When the clipboard content is retrieved programatically, the clipboard html does not contain the usual\n * attributes we use to determine if the content is from Excel. This function is used to handle that case.\n */\nexport const isExcelNotNativeEvent: GetSourceFunction = (props: GetSourceInputParams) => {\n const { clipboardItemTypes, htmlFirstLevelChildTags } = props;\n\n return !!(\n clipboardItemTypes &&\n clipboardItemTypes.includes(ShadowWorkbookClipboardType) &&\n htmlFirstLevelChildTags?.length == 1 &&\n htmlFirstLevelChildTags[0] == 'TABLE'\n );\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the Array provided contains strings that identify Excel Online documents
@@ -1 +1 @@
1
- {"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":";;;;IAGA,wCAAwC;IACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;IAEnD;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,iJAAiJ;QACjJ,OAAO,CACH,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,4BAA4B;YAC/E,cAAc,CAAC,8BAAkB,CAAC,4BAA4B,CAAC,IAAI,SAAS,CAC/E,CAAC;IACN,CAAC,CAAC;IAPW,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"]}
1
+ {"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":";;;;IAGA,wCAAwC;IACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;IAEnD;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,iJAAiJ;QACjJ,OAAO,CACH,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,4BAA4B;YAC/E,cAAc,CAAC,8BAAkB,CAAC,4BAA4B,CAAC,IAAI,SAAS,CAC/E,CAAC;IACN,CAAC,CAAC;IAPW,QAAA,qBAAqB,yBAOhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\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"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the fragment provided contain elements from Google sheets
@@ -1 +1 @@
1
- {"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,8BAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC/E,CAAC,CAAC;IAHW,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"]}
1
+ {"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,8BAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC/E,CAAC,CAAC;IAHW,QAAA,qBAAqB,yBAGhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\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"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the provided HTML attributes identify a OneNote Desktop document
@@ -1 +1 @@
1
- {"version":3,"file":"isOneNoteDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isOneNoteDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,wBAAwB,GAAG,cAAc,CAAC;IAEhD;;;;;OAKG;IACI,IAAM,wBAAwB,GAAsB,UAAA,KAAK;QACpD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,0EAA0E;QAC1E,OAAO,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,wBAAwB,CAAC;IACvF,CAAC,CAAC;IAJW,QAAA,wBAAwB,4BAInC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst ONE_NOTE_ATTRIBUTE_VALUE = 'OneNote.File';\n\n/**\n * @internal\n * Checks whether the provided HTML attributes identify a OneNote Desktop document\n * @param props Properties related to the PasteEvent\n * @returns True if the document is identified as a OneNote Desktop document, otherwise false\n */\nexport const isOneNoteDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of this attribute confirms its origin from OneNote Desktop\n return htmlAttributes[PastePropertyNames.PROG_ID_NAME] == ONE_NOTE_ATTRIBUTE_VALUE;\n};\n"]}
1
+ {"version":3,"file":"isOneNoteDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isOneNoteDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,wBAAwB,GAAG,cAAc,CAAC;IAEhD;;;;;OAKG;IACI,IAAM,wBAAwB,GAAsB,UAAA,KAAK;QACpD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,0EAA0E;QAC1E,OAAO,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,wBAAwB,CAAC;IACvF,CAAC,CAAC;IAJW,QAAA,wBAAwB,4BAInC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\n\nconst ONE_NOTE_ATTRIBUTE_VALUE = 'OneNote.File';\n\n/**\n * @internal\n * Checks whether the provided HTML attributes identify a OneNote Desktop document\n * @param props Properties related to the PasteEvent\n * @returns True if the document is identified as a OneNote Desktop document, otherwise false\n */\nexport const isOneNoteDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of this attribute confirms its origin from OneNote Desktop\n return htmlAttributes[PastePropertyNames.PROG_ID_NAME] == ONE_NOTE_ATTRIBUTE_VALUE;\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the Array provided contains strings that identify Power Point Desktop documents
@@ -1 +1 @@
1
- {"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;IAEtD;;;;;OAKG;IACI,IAAM,2BAA2B,GAAsB,UAAA,KAAK;QAC/D,OAAO,KAAK,CAAC,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,0BAA0B,CAAC;IAC/F,CAAC,CAAC;IAFW,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"]}
1
+ {"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;IAEtD;;;;;OAKG;IACI,IAAM,2BAA2B,GAAsB,UAAA,KAAK;QAC/D,OAAO,KAAK,CAAC,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,0BAA0B,CAAC;IAC/F,CAAC,CAAC;IAFW,QAAA,2BAA2B,+BAEtC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\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"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the Array provided contains strings that identify Word Desktop documents
@@ -12,14 +12,14 @@ define(["require", "exports", "./constants"], function (require, exports, consta
12
12
  * @returns
13
13
  */
14
14
  var isWordDesktopDocument = function (props) {
15
- var _a;
16
- var htmlAttributes = props.htmlAttributes, clipboardData = props.clipboardData, environment = props.environment;
15
+ var htmlAttributes = props.htmlAttributes, rawHtml = props.rawHtml, environment = props.environment;
17
16
  return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
18
17
  htmlAttributes[constants_1.PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID ||
19
18
  // Safari removes the metadata from the clipboard html, so we need to do this check.
20
19
  !!(environment.isSafari &&
21
- clipboardData.rawHtml &&
22
- ((_a = clipboardData.rawHtml) === null || _a === void 0 ? void 0 : _a.replace(/ /g, '').indexOf(WORD_ATTRIBUTE_NAME + "=\"" + WORD_ATTRIBUTE_VALUE)) > -1));
20
+ rawHtml &&
21
+ (rawHtml === null || rawHtml === void 0 ? void 0 : rawHtml.replace(/ /g, '').indexOf(WORD_ATTRIBUTE_NAME + "=\"" + WORD_ATTRIBUTE_VALUE)) >
22
+ -1));
23
23
  };
24
24
  exports.isWordDesktopDocument = isWordDesktopDocument;
25
25
  });
@@ -1 +1 @@
1
- {"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,mBAAmB,GAAG,SAAS,CAAC;IACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;IACrE,IAAM,YAAY,GAAG,eAAe,CAAC;IAErC;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;;QACjD,IAAA,cAAc,GAAiC,KAAK,eAAtC,EAAE,aAAa,GAAkB,KAAK,cAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;QAE7D,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;YAC3D,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,YAAY;YAC/D,oFAAoF;YACpF,CAAC,CAAC,CACE,WAAW,CAAC,QAAQ;gBACpB,aAAa,CAAC,OAAO;gBACrB,CAAA,MAAA,aAAa,CAAC,OAAO,0CACf,OAAO,CAAC,IAAI,EAAE,EAAE,EACjB,OAAO,CAAI,mBAAmB,WAAK,oBAAsB,CAAC,IAAG,CAAC,CAAC,CACvE,CACJ,CAAC;IACN,CAAC,CAAC;IAfW,QAAA,qBAAqB,yBAehC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst WORD_ATTRIBUTE_NAME = 'xmlns:w';\nconst WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';\nconst WORD_PROG_ID = 'Word.Document';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Word Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isWordDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes, clipboardData, environment } = props;\n\n return (\n htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID ||\n // Safari removes the metadata from the clipboard html, so we need to do this check.\n !!(\n environment.isSafari &&\n clipboardData.rawHtml &&\n clipboardData.rawHtml\n ?.replace(/ /g, '')\n .indexOf(`${WORD_ATTRIBUTE_NAME}=\"${WORD_ATTRIBUTE_VALUE}`) > -1\n )\n );\n};\n"]}
1
+ {"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,mBAAmB,GAAG,SAAS,CAAC;IACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;IACrE,IAAM,YAAY,GAAG,eAAe,CAAC;IAErC;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAA2B,KAAK,eAAhC,EAAE,OAAO,GAAkB,KAAK,QAAvB,EAAE,WAAW,GAAK,KAAK,YAAV,CAAW;QAEvD,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;YAC3D,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,YAAY;YAC/D,oFAAoF;YACpF,CAAC,CAAC,CACE,WAAW,CAAC,QAAQ;gBACpB,OAAO;gBACP,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAI,mBAAmB,WAAK,oBAAsB,CAAC;oBACjF,CAAC,CAAC,CACT,CACJ,CAAC;IACN,CAAC,CAAC;IAdW,QAAA,qBAAqB,yBAchC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getDocumentSource';\n\nconst WORD_ATTRIBUTE_NAME = 'xmlns:w';\nconst WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';\nconst WORD_PROG_ID = 'Word.Document';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Word Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isWordDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes, rawHtml, environment } = props;\n\n return (\n htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID ||\n // Safari removes the metadata from the clipboard html, so we need to do this check.\n !!(\n environment.isSafari &&\n rawHtml &&\n rawHtml?.replace(/ /g, '').indexOf(`${WORD_ATTRIBUTE_NAME}=\"${WORD_ATTRIBUTE_VALUE}`) >\n -1\n )\n );\n};\n"]}
@@ -1,4 +1,4 @@
1
- import type { GetSourceFunction } from './getPasteSource';
1
+ import type { GetSourceFunction } from './getDocumentSource';
2
2
  /**
3
3
  * @internal
4
4
  * Checks whether the fragment only contains a single image to paste
@@ -10,11 +10,10 @@ define(["require", "exports"], function (require, exports) {
10
10
  * @returns
11
11
  */
12
12
  var shouldConvertToSingleImage = function (props) {
13
- var _a;
14
- var shouldConvertSingleImage = props.shouldConvertSingleImage, clipboardData = props.clipboardData;
15
- return (shouldConvertSingleImage &&
16
- ((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
17
- clipboardData.htmlFirstLevelChildTags[0] == 'IMG');
13
+ var shouldConvertSingleImage = props.shouldConvertSingleImage, htmlFirstLevelChildTags = props.htmlFirstLevelChildTags;
14
+ return !!(shouldConvertSingleImage &&
15
+ (htmlFirstLevelChildTags === null || htmlFirstLevelChildTags === void 0 ? void 0 : htmlFirstLevelChildTags.length) == 1 &&
16
+ htmlFirstLevelChildTags[0] == 'IMG');
18
17
  };
19
18
  exports.shouldConvertToSingleImage = shouldConvertToSingleImage;
20
19
  });
@@ -1 +1 @@
1
- {"version":3,"file":"shouldConvertToSingleImage.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.ts"],"names":[],"mappings":";;;;IAEA;;;;;;OAMG;IACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;;QACtD,IAAA,wBAAwB,GAAoB,KAAK,yBAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QAC1D,OAAO,CACH,wBAAwB;YACxB,CAAA,MAAA,aAAa,CAAC,uBAAuB,0CAAE,MAAM,KAAI,CAAC;YAClD,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,KAAK,CACpD,CAAC;IACN,CAAC,CAAC;IAPW,QAAA,0BAA0B,8BAOrC","sourcesContent":["import type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Checks whether the fragment only contains a single image to paste\n * and the editor have the ConvertSingleImageBody Experimental feature\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const shouldConvertToSingleImage: GetSourceFunction = props => {\n const { shouldConvertSingleImage, clipboardData } = props;\n return (\n shouldConvertSingleImage &&\n clipboardData.htmlFirstLevelChildTags?.length == 1 &&\n clipboardData.htmlFirstLevelChildTags[0] == 'IMG'\n );\n};\n"]}
1
+ {"version":3,"file":"shouldConvertToSingleImage.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.ts"],"names":[],"mappings":";;;;IAEA;;;;;;OAMG;IACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;QACtD,IAAA,wBAAwB,GAA8B,KAAK,yBAAnC,EAAE,uBAAuB,GAAK,KAAK,wBAAV,CAAW;QACpE,OAAO,CAAC,CAAC,CACL,wBAAwB;YACxB,CAAA,uBAAuB,aAAvB,uBAAuB,uBAAvB,uBAAuB,CAAE,MAAM,KAAI,CAAC;YACpC,uBAAuB,CAAC,CAAC,CAAC,IAAI,KAAK,CACtC,CAAC;IACN,CAAC,CAAC;IAPW,QAAA,0BAA0B,8BAOrC","sourcesContent":["import type { GetSourceFunction } from './getDocumentSource';\n\n/**\n * @internal\n * Checks whether the fragment only contains a single image to paste\n * and the editor have the ConvertSingleImageBody Experimental feature\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const shouldConvertToSingleImage: GetSourceFunction = props => {\n const { shouldConvertSingleImage, htmlFirstLevelChildTags } = props;\n return !!(\n shouldConvertSingleImage &&\n htmlFirstLevelChildTags?.length == 1 &&\n htmlFirstLevelChildTags[0] == 'IMG'\n );\n};\n"]}