roosterjs-content-model-plugins 0.25.0 → 0.26.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.
- package/{lib-mjs/autoFormat/ContentModelAutoFormatPlugin.d.ts → lib/autoFormat/AutoFormatPlugin.d.ts} +53 -53
- package/lib/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +81 -81
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib/autoFormat/keyboardListTrigger.js +45 -45
- package/lib/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib/autoFormat/utils/convertAlphaToDecimals.js +22 -22
- package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib/autoFormat/utils/getIndex.js +13 -13
- package/lib/autoFormat/utils/getIndex.js.map +1 -1
- package/lib/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib/autoFormat/utils/getListTypeStyle.js +87 -79
- package/lib/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib/autoFormat/utils/getNumberingListStyle.js +153 -152
- package/lib/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/{lib-amd/edit/ContentModelEditPlugin.d.ts → lib/edit/EditPlugin.d.ts} +39 -35
- package/lib/edit/EditPlugin.js +129 -0
- package/lib/edit/EditPlugin.js.map +1 -0
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +22 -22
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +93 -93
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.d.ts +5 -5
- package/lib/edit/deleteSteps/deleteList.js +23 -23
- package/lib/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib/edit/deleteSteps/deleteWordSelection.js +173 -173
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +14 -14
- package/lib/edit/handleKeyboardEventCommon.js +54 -54
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.d.ts +5 -0
- package/lib/edit/inputSteps/handleEnterOnList.js +68 -0
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -0
- package/lib/edit/keyboardDelete.d.ts +9 -8
- package/lib/edit/keyboardDelete.js +71 -74
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +5 -5
- package/lib/edit/keyboardInput.js +58 -50
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.d.ts +5 -0
- package/lib/edit/keyboardTab.js +35 -0
- package/lib/edit/keyboardTab.js.map +1 -0
- package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib/edit/utils/getLeafSiblingBlock.js +75 -75
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
- package/lib/paste/Excel/processPastedContentFromExcel.js +82 -82
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/{lib-amd/paste/ContentModelPastePlugin.d.ts → lib/paste/PastePlugin.d.ts} +43 -43
- package/lib/paste/{ContentModelPastePlugin.js → PastePlugin.js} +131 -131
- package/lib/paste/PastePlugin.js.map +1 -0
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +19 -19
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/constants.d.ts +48 -48
- package/lib/paste/WacComponents/constants.js +62 -62
- package/lib/paste/WacComponents/constants.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +188 -188
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/WordMetadata.d.ts +9 -9
- package/lib/paste/WordDesktop/WordMetadata.js +2 -2
- package/lib/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
- package/lib/paste/WordDesktop/getStyleMetadata.js +78 -78
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +58 -58
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib/paste/WordDesktop/processWordComments.js +21 -21
- package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.d.ts +11 -11
- package/lib/paste/WordDesktop/processWordLists.js +179 -179
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +13 -13
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib/paste/pasteSourceValidations/constants.js +20 -20
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js +15 -15
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib/paste/pasteSourceValidations/getPasteSource.js +43 -43
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +17 -17
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +19 -19
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +15 -15
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +15 -15
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +19 -19
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +18 -18
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +5 -5
- package/lib/paste/utils/addParser.js +16 -16
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib/paste/utils/deprecatedColorParser.js +19 -19
- package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib/paste/utils/getStyles.d.ts +6 -6
- package/lib/paste/utils/getStyles.js +22 -22
- package/lib/paste/utils/getStyles.js.map +1 -1
- package/lib/paste/utils/linkParser.d.ts +5 -5
- package/lib/paste/utils/linkParser.js +27 -27
- package/lib/paste/utils/linkParser.js.map +1 -1
- package/lib/paste/utils/setProcessor.d.ts +5 -5
- package/lib/paste/utils/setProcessor.js +13 -13
- package/lib/paste/utils/setProcessor.js.map +1 -1
- package/lib/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
- package/lib/pluginUtils/CreateElement/CreateElementData.js +3 -0
- package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
- package/lib/pluginUtils/CreateElement/createElement.d.ts +9 -0
- package/lib/pluginUtils/CreateElement/createElement.js +51 -0
- package/lib/pluginUtils/CreateElement/createElement.js.map +1 -0
- package/lib/pluginUtils/Disposable.d.ts +10 -0
- package/lib/pluginUtils/Disposable.js +3 -0
- package/lib/pluginUtils/Disposable.js.map +1 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js +3 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +120 -0
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
- package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
- package/lib/pluginUtils/Rect/getIntersectedRect.js +45 -0
- package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
- package/lib/pluginUtils/Rect/normalizeRect.d.ts +7 -0
- package/lib/pluginUtils/Rect/normalizeRect.js +20 -0
- package/lib/pluginUtils/Rect/normalizeRect.js.map +1 -0
- package/lib-amd/autoFormat/{ContentModelAutoFormatPlugin.d.ts → AutoFormatPlugin.d.ts} +53 -53
- package/lib-amd/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +82 -82
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib-amd/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib-amd/autoFormat/keyboardListTrigger.js +43 -43
- package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js +24 -24
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib-amd/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib-amd/autoFormat/utils/getIndex.js +14 -14
- package/lib-amd/autoFormat/utils/getIndex.js.map +1 -1
- package/lib-amd/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib-amd/autoFormat/utils/getListTypeStyle.js +86 -78
- package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib-amd/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js +153 -152
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/{lib-mjs/edit/ContentModelEditPlugin.d.ts → lib-amd/edit/EditPlugin.d.ts} +39 -35
- package/lib-amd/edit/EditPlugin.js +128 -0
- package/lib-amd/edit/EditPlugin.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +23 -23
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +92 -92
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -5
- package/lib-amd/edit/deleteSteps/deleteList.js +24 -24
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +172 -172
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +14 -14
- package/lib-amd/edit/handleKeyboardEventCommon.js +55 -55
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.d.ts +5 -0
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +67 -0
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -0
- package/lib-amd/edit/keyboardDelete.d.ts +9 -8
- package/lib-amd/edit/keyboardDelete.js +66 -69
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +5 -5
- package/lib-amd/edit/keyboardInput.js +57 -50
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.d.ts +5 -0
- package/lib-amd/edit/keyboardTab.js +35 -0
- package/lib-amd/edit/keyboardTab.js.map +1 -0
- package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib-amd/edit/utils/getLeafSiblingBlock.js +75 -75
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-amd/index.d.ts +3 -3
- package/lib-amd/index.js +8 -8
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js +80 -80
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/{lib/paste/ContentModelPastePlugin.d.ts → lib-amd/paste/PastePlugin.d.ts} +43 -43
- package/lib-amd/paste/{ContentModelPastePlugin.js → PastePlugin.js} +123 -123
- package/lib-amd/paste/PastePlugin.js.map +1 -0
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -20
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/constants.d.ts +48 -48
- package/lib-amd/paste/WacComponents/constants.js +63 -63
- package/lib-amd/paste/WacComponents/constants.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +185 -185
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/WordMetadata.d.ts +9 -9
- package/lib-amd/paste/WordDesktop/WordMetadata.js +4 -4
- package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js +78 -78
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +53 -53
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib-amd/paste/WordDesktop/processWordComments.js +22 -22
- package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.d.ts +11 -11
- package/lib-amd/paste/WordDesktop/processWordLists.js +177 -177
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +15 -15
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib-amd/paste/pasteSourceValidations/constants.js +22 -22
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +16 -16
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +38 -38
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +18 -18
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +16 -16
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +16 -16
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +5 -5
- package/lib-amd/paste/utils/addParser.js +18 -18
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib-amd/paste/utils/deprecatedColorParser.js +20 -20
- package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-amd/paste/utils/getStyles.d.ts +6 -6
- package/lib-amd/paste/utils/getStyles.js +24 -24
- package/lib-amd/paste/utils/getStyles.js.map +1 -1
- package/lib-amd/paste/utils/linkParser.d.ts +5 -5
- package/lib-amd/paste/utils/linkParser.js +28 -28
- package/lib-amd/paste/utils/linkParser.js.map +1 -1
- package/lib-amd/paste/utils/setProcessor.d.ts +5 -5
- package/lib-amd/paste/utils/setProcessor.js +15 -15
- package/lib-amd/paste/utils/setProcessor.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js +5 -0
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
- package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +9 -0
- package/lib-amd/pluginUtils/CreateElement/createElement.js +52 -0
- package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -0
- package/lib-amd/pluginUtils/Disposable.d.ts +10 -0
- package/lib-amd/pluginUtils/Disposable.js +5 -0
- package/lib-amd/pluginUtils/Disposable.js.map +1 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js +5 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +121 -0
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +45 -0
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
- package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +7 -0
- package/lib-amd/pluginUtils/Rect/normalizeRect.js +22 -0
- package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +1 -0
- package/{lib/autoFormat/ContentModelAutoFormatPlugin.d.ts → lib-mjs/autoFormat/AutoFormatPlugin.d.ts} +53 -53
- package/lib-mjs/autoFormat/{ContentModelAutoFormatPlugin.js → AutoFormatPlugin.js} +78 -78
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib-mjs/autoFormat/keyboardListTrigger.js +41 -41
- package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js +18 -18
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib-mjs/autoFormat/utils/getIndex.js +9 -9
- package/lib-mjs/autoFormat/utils/getIndex.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js +83 -75
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js +149 -148
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/{lib/edit/ContentModelEditPlugin.d.ts → lib-mjs/edit/EditPlugin.d.ts} +39 -35
- package/lib-mjs/edit/EditPlugin.js +126 -0
- package/lib-mjs/edit/EditPlugin.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +18 -18
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +90 -90
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -5
- package/lib-mjs/edit/deleteSteps/deleteList.js +19 -19
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +170 -170
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +14 -14
- package/lib-mjs/edit/handleKeyboardEventCommon.js +48 -48
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.d.ts +5 -0
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +64 -0
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -0
- package/lib-mjs/edit/keyboardDelete.d.ts +9 -8
- package/lib-mjs/edit/keyboardDelete.js +67 -70
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +5 -5
- package/lib-mjs/edit/keyboardInput.js +54 -46
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.d.ts +5 -0
- package/lib-mjs/edit/keyboardTab.js +31 -0
- package/lib-mjs/edit/keyboardTab.js.map +1 -0
- package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/index.d.ts +3 -3
- package/lib-mjs/index.js +3 -3
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/{ContentModelPastePlugin.d.ts → PastePlugin.d.ts} +43 -43
- package/lib-mjs/paste/{ContentModelPastePlugin.js → PastePlugin.js} +128 -128
- package/lib-mjs/paste/PastePlugin.js.map +1 -0
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +15 -15
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/constants.d.ts +48 -48
- package/lib-mjs/paste/WacComponents/constants.js +59 -59
- package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +184 -184
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/WordMetadata.d.ts +9 -9
- package/lib-mjs/paste/WordDesktop/WordMetadata.js +1 -1
- package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +23 -23
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +75 -75
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +7 -7
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +54 -54
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib-mjs/paste/WordDesktop/processWordComments.js +17 -17
- package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +11 -11
- package/lib-mjs/paste/WordDesktop/processWordLists.js +175 -175
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -5
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +9 -9
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib-mjs/paste/pasteSourceValidations/constants.js +17 -17
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +11 -11
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +39 -39
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +13 -13
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +15 -15
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +11 -11
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +11 -11
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +15 -15
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +14 -14
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +5 -5
- package/lib-mjs/paste/utils/addParser.js +13 -13
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib-mjs/paste/utils/deprecatedColorParser.js +15 -15
- package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-mjs/paste/utils/getStyles.d.ts +6 -6
- package/lib-mjs/paste/utils/getStyles.js +18 -18
- package/lib-mjs/paste/utils/getStyles.js.map +1 -1
- package/lib-mjs/paste/utils/linkParser.d.ts +5 -5
- package/lib-mjs/paste/utils/linkParser.js +23 -23
- package/lib-mjs/paste/utils/linkParser.js.map +1 -1
- package/lib-mjs/paste/utils/setProcessor.d.ts +5 -5
- package/lib-mjs/paste/utils/setProcessor.js +9 -9
- package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.d.ts +35 -0
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js +2 -0
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -0
- package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +9 -0
- package/lib-mjs/pluginUtils/CreateElement/createElement.js +48 -0
- package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -0
- package/lib-mjs/pluginUtils/Disposable.d.ts +10 -0
- package/lib-mjs/pluginUtils/Disposable.js +2 -0
- package/lib-mjs/pluginUtils/Disposable.js.map +1 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js +2 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +118 -0
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -0
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +27 -0
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +42 -0
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -0
- package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +7 -0
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js +17 -0
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +1 -0
- package/package.json +5 -5
- package/lib/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
- package/lib/edit/ContentModelEditPlugin.js +0 -74
- package/lib/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib/paste/ContentModelPastePlugin.js.map +0 -1
- package/lib-amd/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
- package/lib-amd/edit/ContentModelEditPlugin.js +0 -74
- package/lib-amd/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib-amd/paste/ContentModelPastePlugin.js.map +0 -1
- package/lib-mjs/autoFormat/ContentModelAutoFormatPlugin.js.map +0 -1
- package/lib-mjs/edit/ContentModelEditPlugin.js +0 -71
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +0 -1
package/lib-mjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { PastePlugin } from './paste/PastePlugin';
|
|
2
|
+
export { EditPlugin } from './edit/EditPlugin';
|
|
3
|
+
export { AutoFormatPlugin } from './autoFormat/AutoFormatPlugin';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/lib-mjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAqB,MAAM,+BAA+B,CAAC","sourcesContent":["export { PastePlugin } from './paste/PastePlugin';\r\nexport { EditPlugin } from './edit/EditPlugin';\r\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\r\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
5
|
-
* @param event The BeforePaste event
|
|
6
|
-
*/
|
|
7
|
-
export declare function processPastedContentFromExcel(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
|
|
8
|
-
/**
|
|
9
|
-
* @internal Export for test only
|
|
10
|
-
* @param html Source html
|
|
11
|
-
*/
|
|
12
|
-
export declare function excelHandler(html: string, htmlBefore: string): string;
|
|
1
|
+
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
5
|
+
* @param event The BeforePaste event
|
|
6
|
+
*/
|
|
7
|
+
export declare function processPastedContentFromExcel(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
|
|
8
|
+
/**
|
|
9
|
+
* @internal Export for test only
|
|
10
|
+
* @param html Source html
|
|
11
|
+
*/
|
|
12
|
+
export declare function excelHandler(html: string, htmlBefore: string): string;
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import addParser from '../utils/addParser';
|
|
3
|
-
import { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';
|
|
4
|
-
import { setProcessor } from '../utils/setProcessor';
|
|
5
|
-
var LAST_TD_END_REGEX = /<\/\s*td\s*>((?!<\/\s*tr\s*>)[\s\S])*$/i;
|
|
6
|
-
var LAST_TR_END_REGEX = /<\/\s*tr\s*>((?!<\/\s*table\s*>)[\s\S])*$/i;
|
|
7
|
-
var LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;
|
|
8
|
-
var LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;
|
|
9
|
-
var DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
13
|
-
* @param event The BeforePaste event
|
|
14
|
-
*/
|
|
15
|
-
export function processPastedContentFromExcel(event, trustedHTMLHandler, allowExcelNoBorderTable) {
|
|
16
|
-
var fragment = event.fragment, htmlBefore = event.htmlBefore, clipboardData = event.clipboardData;
|
|
17
|
-
var html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;
|
|
18
|
-
if (html && clipboardData.html != html) {
|
|
19
|
-
var doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');
|
|
20
|
-
moveChildNodes(fragment, doc === null || doc === void 0 ? void 0 : doc.body);
|
|
21
|
-
}
|
|
22
|
-
// For Excel Online
|
|
23
|
-
var firstChild = fragment.firstChild;
|
|
24
|
-
if (isNodeOfType(firstChild, 'ELEMENT_NODE') &&
|
|
25
|
-
firstChild.tagName == 'div' &&
|
|
26
|
-
firstChild.firstChild) {
|
|
27
|
-
var tableFound = Array.from(firstChild.childNodes).every(function (child) {
|
|
28
|
-
// Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag
|
|
29
|
-
var tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;
|
|
30
|
-
return tagName == 'META'
|
|
31
|
-
? true
|
|
32
|
-
: tagName == 'TABLE'
|
|
33
|
-
? child == firstChild.lastChild
|
|
34
|
-
: false;
|
|
35
|
-
});
|
|
36
|
-
// Extract Table from Div
|
|
37
|
-
if (tableFound && firstChild.lastChild) {
|
|
38
|
-
event.fragment.replaceChildren(firstChild.lastChild);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
addParser(event.domToModelOption, 'tableCell', function (format, element) {
|
|
42
|
-
if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {
|
|
43
|
-
format.borderBottom = DEFAULT_BORDER_STYLE;
|
|
44
|
-
format.borderLeft = DEFAULT_BORDER_STYLE;
|
|
45
|
-
format.borderRight = DEFAULT_BORDER_STYLE;
|
|
46
|
-
format.borderTop = DEFAULT_BORDER_STYLE;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
setProcessor(event.domToModelOption, 'child', function (group, element, context) {
|
|
50
|
-
var segmentFormat = __assign({}, context.segmentFormat);
|
|
51
|
-
if (group.blockGroupType === 'TableCell' && group.format.textColor) {
|
|
52
|
-
context.segmentFormat.textColor = group.format.textColor;
|
|
53
|
-
}
|
|
54
|
-
context.defaultElementProcessors.child(group, element, context);
|
|
55
|
-
if (group.blockGroupType === 'TableCell' && group.format.textColor) {
|
|
56
|
-
context.segmentFormat = segmentFormat;
|
|
57
|
-
delete group.format.textColor;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @internal Export for test only
|
|
63
|
-
* @param html Source html
|
|
64
|
-
*/
|
|
65
|
-
export function excelHandler(html, htmlBefore) {
|
|
66
|
-
if (html.match(LAST_TD_END_REGEX)) {
|
|
67
|
-
var trMatch = htmlBefore.match(LAST_TR_REGEX);
|
|
68
|
-
var tr = trMatch ? trMatch[0] : '<TR>';
|
|
69
|
-
html = tr + html + '</TR>';
|
|
70
|
-
}
|
|
71
|
-
if (html.match(LAST_TR_END_REGEX)) {
|
|
72
|
-
var tableMatch = htmlBefore.match(LAST_TABLE_REGEX);
|
|
73
|
-
var table = tableMatch ? tableMatch[0] : '<TABLE>';
|
|
74
|
-
html = table + html + '</TABLE>';
|
|
75
|
-
}
|
|
76
|
-
return html;
|
|
77
|
-
}
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import addParser from '../utils/addParser';
|
|
3
|
+
import { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';
|
|
4
|
+
import { setProcessor } from '../utils/setProcessor';
|
|
5
|
+
var LAST_TD_END_REGEX = /<\/\s*td\s*>((?!<\/\s*tr\s*>)[\s\S])*$/i;
|
|
6
|
+
var LAST_TR_END_REGEX = /<\/\s*tr\s*>((?!<\/\s*table\s*>)[\s\S])*$/i;
|
|
7
|
+
var LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;
|
|
8
|
+
var LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;
|
|
9
|
+
var DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
13
|
+
* @param event The BeforePaste event
|
|
14
|
+
*/
|
|
15
|
+
export function processPastedContentFromExcel(event, trustedHTMLHandler, allowExcelNoBorderTable) {
|
|
16
|
+
var fragment = event.fragment, htmlBefore = event.htmlBefore, clipboardData = event.clipboardData;
|
|
17
|
+
var html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;
|
|
18
|
+
if (html && clipboardData.html != html) {
|
|
19
|
+
var doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');
|
|
20
|
+
moveChildNodes(fragment, doc === null || doc === void 0 ? void 0 : doc.body);
|
|
21
|
+
}
|
|
22
|
+
// For Excel Online
|
|
23
|
+
var firstChild = fragment.firstChild;
|
|
24
|
+
if (isNodeOfType(firstChild, 'ELEMENT_NODE') &&
|
|
25
|
+
firstChild.tagName == 'div' &&
|
|
26
|
+
firstChild.firstChild) {
|
|
27
|
+
var tableFound = Array.from(firstChild.childNodes).every(function (child) {
|
|
28
|
+
// Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag
|
|
29
|
+
var tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;
|
|
30
|
+
return tagName == 'META'
|
|
31
|
+
? true
|
|
32
|
+
: tagName == 'TABLE'
|
|
33
|
+
? child == firstChild.lastChild
|
|
34
|
+
: false;
|
|
35
|
+
});
|
|
36
|
+
// Extract Table from Div
|
|
37
|
+
if (tableFound && firstChild.lastChild) {
|
|
38
|
+
event.fragment.replaceChildren(firstChild.lastChild);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
addParser(event.domToModelOption, 'tableCell', function (format, element) {
|
|
42
|
+
if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {
|
|
43
|
+
format.borderBottom = DEFAULT_BORDER_STYLE;
|
|
44
|
+
format.borderLeft = DEFAULT_BORDER_STYLE;
|
|
45
|
+
format.borderRight = DEFAULT_BORDER_STYLE;
|
|
46
|
+
format.borderTop = DEFAULT_BORDER_STYLE;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
setProcessor(event.domToModelOption, 'child', function (group, element, context) {
|
|
50
|
+
var segmentFormat = __assign({}, context.segmentFormat);
|
|
51
|
+
if (group.blockGroupType === 'TableCell' && group.format.textColor) {
|
|
52
|
+
context.segmentFormat.textColor = group.format.textColor;
|
|
53
|
+
}
|
|
54
|
+
context.defaultElementProcessors.child(group, element, context);
|
|
55
|
+
if (group.blockGroupType === 'TableCell' && group.format.textColor) {
|
|
56
|
+
context.segmentFormat = segmentFormat;
|
|
57
|
+
delete group.format.textColor;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* @internal Export for test only
|
|
63
|
+
* @param html Source html
|
|
64
|
+
*/
|
|
65
|
+
export function excelHandler(html, htmlBefore) {
|
|
66
|
+
if (html.match(LAST_TD_END_REGEX)) {
|
|
67
|
+
var trMatch = htmlBefore.match(LAST_TR_REGEX);
|
|
68
|
+
var tr = trMatch ? trMatch[0] : '<TR>';
|
|
69
|
+
html = tr + html + '</TR>';
|
|
70
|
+
}
|
|
71
|
+
if (html.match(LAST_TR_END_REGEX)) {
|
|
72
|
+
var tableMatch = htmlBefore.match(LAST_TABLE_REGEX);
|
|
73
|
+
var table = tableMatch ? tableMatch[0] : '<TABLE>';
|
|
74
|
+
html = table + html + '</TABLE>';
|
|
75
|
+
}
|
|
76
|
+
return html;
|
|
77
|
+
}
|
|
78
78
|
//# sourceMappingURL=processPastedContentFromExcel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,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,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;YAChE,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;YACtC,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;SACjC;IACL,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;GAGG;AAEH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,UAAkB;IACzD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;QAC/B,IAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAChD,IAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACzC,IAAI,GAAG,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC;KAC9B;IACD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;QAC/B,IAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtD,IAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\n\n/**\n * @internal\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromExcel(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler,\n allowExcelNoBorderTable?: boolean\n) {\n const { fragment, htmlBefore, clipboardData } = event;\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\n\n if (html && clipboardData.html != html) {\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\n moveChildNodes(fragment, doc?.body);\n }\n\n // For Excel Online\n const firstChild = fragment.firstChild;\n if (\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\n firstChild.tagName == 'div' &&\n firstChild.firstChild\n ) {\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\n\n return tagName == 'META'\n ? true\n : tagName == 'TABLE'\n ? child == firstChild.lastChild\n : false;\n });\n\n // Extract Table from Div\n if (tableFound && firstChild.lastChild) {\n event.fragment.replaceChildren(firstChild.lastChild);\n }\n }\n\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\n if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {\n format.borderBottom = DEFAULT_BORDER_STYLE;\n format.borderLeft = DEFAULT_BORDER_STYLE;\n format.borderRight = DEFAULT_BORDER_STYLE;\n format.borderTop = DEFAULT_BORDER_STYLE;\n }\n });\n\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\n const segmentFormat = { ...context.segmentFormat };\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat.textColor = group.format.textColor;\n }\n\n context.defaultElementProcessors.child(group, element, context);\n\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat = segmentFormat;\n delete group.format.textColor;\n }\n });\n}\n\n/**\n * @internal Export for test only\n * @param html Source html\n */\n\nexport function excelHandler(html: string, htmlBefore: string): string {\n if (html.match(LAST_TD_END_REGEX)) {\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\n const tr = trMatch ? trMatch[0] : '<TR>';\n html = tr + html + '</TR>';\n }\n if (html.match(LAST_TR_END_REGEX)) {\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\n html = table + html + '</TABLE>';\n }\n\n return html;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;AACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;AACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;;;GAIG;AAEH,MAAM,UAAU,6BAA6B,CACzC,KAAuB,EACvB,kBAAsC,EACtC,uBAAiC;IAEzB,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE3F,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,IAAI,EAAE;QACpC,IA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AAC,CAAC,CAAC,SAAS,CAAC;QACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import addParser from '../utils/addParser';\r\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\r\nimport { setProcessor } from '../utils/setProcessor';\r\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\r\n\r\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\r\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\r\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\r\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\r\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\r\n\r\n/**\r\n * @internal\r\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\r\n * @param event The BeforePaste event\r\n */\r\n\r\nexport function processPastedContentFromExcel(\r\n event: BeforePasteEvent,\r\n trustedHTMLHandler: TrustedHTMLHandler,\r\n allowExcelNoBorderTable?: boolean\r\n) {\r\n const { fragment, htmlBefore, clipboardData } = event;\r\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\r\n\r\n if (html && clipboardData.html != html) {\r\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\r\n moveChildNodes(fragment, doc?.body);\r\n }\r\n\r\n // For Excel Online\r\n const firstChild = fragment.firstChild;\r\n if (\r\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\r\n firstChild.tagName == 'div' &&\r\n firstChild.firstChild\r\n ) {\r\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\r\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\r\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\r\n\r\n return tagName == 'META'\r\n ? true\r\n : tagName == 'TABLE'\r\n ? child == firstChild.lastChild\r\n : false;\r\n });\r\n\r\n // Extract Table from Div\r\n if (tableFound && firstChild.lastChild) {\r\n event.fragment.replaceChildren(firstChild.lastChild);\r\n }\r\n }\r\n\r\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\r\n if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {\r\n format.borderBottom = DEFAULT_BORDER_STYLE;\r\n format.borderLeft = DEFAULT_BORDER_STYLE;\r\n format.borderRight = DEFAULT_BORDER_STYLE;\r\n format.borderTop = DEFAULT_BORDER_STYLE;\r\n }\r\n });\r\n\r\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\r\n const segmentFormat = { ...context.segmentFormat };\r\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\r\n context.segmentFormat.textColor = group.format.textColor;\r\n }\r\n\r\n context.defaultElementProcessors.child(group, element, context);\r\n\r\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\r\n context.segmentFormat = segmentFormat;\r\n delete group.format.textColor;\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * @internal Export for test only\r\n * @param html Source html\r\n */\r\n\r\nexport function excelHandler(html: string, htmlBefore: string): string {\r\n if (html.match(LAST_TD_END_REGEX)) {\r\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\r\n const tr = trMatch ? trMatch[0] : '<TR>';\r\n html = tr + html + '</TR>';\r\n }\r\n if (html.match(LAST_TR_END_REGEX)) {\r\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\r\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\r\n html = table + html + '</TABLE>';\r\n }\r\n\r\n return html;\r\n}\r\n"]}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
4
|
-
* 1. Content copied from Word
|
|
5
|
-
* 2. Content copied from Excel
|
|
6
|
-
* 3. Content copied from Word Online or OneNote Online
|
|
7
|
-
* 4. Content copied from Power Point
|
|
8
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
9
|
-
*/
|
|
10
|
-
export declare class
|
|
11
|
-
private allowExcelNoBorderTable?;
|
|
12
|
-
private editor;
|
|
13
|
-
/**
|
|
14
|
-
* Construct a new instance of Paste class
|
|
15
|
-
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
16
|
-
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
17
|
-
*/
|
|
18
|
-
constructor(allowExcelNoBorderTable?: boolean | undefined);
|
|
19
|
-
/**
|
|
20
|
-
* Get name of this plugin
|
|
21
|
-
*/
|
|
22
|
-
getName(): string;
|
|
23
|
-
/**
|
|
24
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
25
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
26
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
27
|
-
* @param editor The editor object
|
|
28
|
-
*/
|
|
29
|
-
initialize(editor: IStandaloneEditor): void;
|
|
30
|
-
/**
|
|
31
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
32
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
33
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
34
|
-
*/
|
|
35
|
-
dispose(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
38
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
39
|
-
* exclusively by another plugin.
|
|
40
|
-
* @param event The event to handle:
|
|
41
|
-
*/
|
|
42
|
-
onPluginEvent(event: PluginEvent): void;
|
|
43
|
-
}
|
|
1
|
+
import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
4
|
+
* 1. Content copied from Word
|
|
5
|
+
* 2. Content copied from Excel
|
|
6
|
+
* 3. Content copied from Word Online or OneNote Online
|
|
7
|
+
* 4. Content copied from Power Point
|
|
8
|
+
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
9
|
+
*/
|
|
10
|
+
export declare class PastePlugin implements EditorPlugin {
|
|
11
|
+
private allowExcelNoBorderTable?;
|
|
12
|
+
private editor;
|
|
13
|
+
/**
|
|
14
|
+
* Construct a new instance of Paste class
|
|
15
|
+
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
16
|
+
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
17
|
+
*/
|
|
18
|
+
constructor(allowExcelNoBorderTable?: boolean | undefined);
|
|
19
|
+
/**
|
|
20
|
+
* Get name of this plugin
|
|
21
|
+
*/
|
|
22
|
+
getName(): string;
|
|
23
|
+
/**
|
|
24
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
25
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
26
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
27
|
+
* @param editor The editor object
|
|
28
|
+
*/
|
|
29
|
+
initialize(editor: IStandaloneEditor): void;
|
|
30
|
+
/**
|
|
31
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
32
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
33
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
34
|
+
*/
|
|
35
|
+
dispose(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
38
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
39
|
+
* exclusively by another plugin.
|
|
40
|
+
* @param event The event to handle:
|
|
41
|
+
*/
|
|
42
|
+
onPluginEvent(event: PluginEvent): void;
|
|
43
|
+
}
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
import addParser from './utils/addParser';
|
|
2
|
-
import { BorderKeys } from 'roosterjs-content-model-dom';
|
|
3
|
-
import { deprecatedBorderColorParser } from './utils/deprecatedColorParser';
|
|
4
|
-
import { getPasteSource } from './pasteSourceValidations/getPasteSource';
|
|
5
|
-
import { parseLink } from './utils/linkParser';
|
|
6
|
-
import { PastePropertyNames } from './pasteSourceValidations/constants';
|
|
7
|
-
import { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';
|
|
8
|
-
import { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';
|
|
9
|
-
import { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';
|
|
10
|
-
import { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';
|
|
11
|
-
/**
|
|
12
|
-
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
13
|
-
* 1. Content copied from Word
|
|
14
|
-
* 2. Content copied from Excel
|
|
15
|
-
* 3. Content copied from Word Online or OneNote Online
|
|
16
|
-
* 4. Content copied from Power Point
|
|
17
|
-
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
18
|
-
*/
|
|
19
|
-
var
|
|
20
|
-
/**
|
|
21
|
-
* Construct a new instance of Paste class
|
|
22
|
-
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
23
|
-
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
24
|
-
*/
|
|
25
|
-
function
|
|
26
|
-
this.allowExcelNoBorderTable = allowExcelNoBorderTable;
|
|
27
|
-
this.editor = null;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Get name of this plugin
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
return '
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
37
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
38
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
39
|
-
* @param editor The editor object
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
this.editor = editor;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
46
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
47
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
this.editor = null;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
54
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
55
|
-
* exclusively by another plugin.
|
|
56
|
-
* @param event The event to handle:
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
if (!this.editor || event.eventType != 'beforePaste') {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (!event.domToModelOption) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
var pasteSource = getPasteSource(event, false);
|
|
66
|
-
var pasteType = event.pasteType;
|
|
67
|
-
switch (pasteSource) {
|
|
68
|
-
case 'wordDesktop':
|
|
69
|
-
processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());
|
|
70
|
-
break;
|
|
71
|
-
case 'wacComponents':
|
|
72
|
-
processPastedContentWacComponents(event);
|
|
73
|
-
break;
|
|
74
|
-
case 'excelOnline':
|
|
75
|
-
case 'excelDesktop':
|
|
76
|
-
if (pasteType === 'normal' || pasteType === 'mergeFormat') {
|
|
77
|
-
// Handle HTML copied from Excel
|
|
78
|
-
processPastedContentFromExcel(event, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
|
|
79
|
-
}
|
|
80
|
-
break;
|
|
81
|
-
case 'googleSheets':
|
|
82
|
-
event.domToModelOption.additionalAllowedTags.push(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
83
|
-
break;
|
|
84
|
-
case 'powerPointDesktop':
|
|
85
|
-
processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
addParser(event.domToModelOption, 'link', parseLink);
|
|
89
|
-
addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);
|
|
90
|
-
addParser(event.domToModelOption, 'tableCell', tableBorderParser);
|
|
91
|
-
addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);
|
|
92
|
-
if (pasteType === 'mergeFormat') {
|
|
93
|
-
addParser(event.domToModelOption, 'block', blockElementParser);
|
|
94
|
-
addParser(event.domToModelOption, 'listLevel', blockElementParser);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
return
|
|
98
|
-
}());
|
|
99
|
-
export {
|
|
100
|
-
/**
|
|
101
|
-
* For block elements that have background color style, remove the background color when user selects the merge current format
|
|
102
|
-
* paste option
|
|
103
|
-
*/
|
|
104
|
-
var blockElementParser = function (format, element) {
|
|
105
|
-
if (element.style.backgroundColor) {
|
|
106
|
-
delete format.backgroundColor;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
var ElementBorderKeys = new Map([
|
|
110
|
-
['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],
|
|
111
|
-
['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],
|
|
112
|
-
['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],
|
|
113
|
-
['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],
|
|
114
|
-
]);
|
|
115
|
-
function tableBorderParser(format, element) {
|
|
116
|
-
BorderKeys.forEach(function (key) {
|
|
117
|
-
if (!format[key]) {
|
|
118
|
-
var styleSet = ElementBorderKeys.get(key);
|
|
119
|
-
if (styleSet &&
|
|
120
|
-
element.style[styleSet.w] &&
|
|
121
|
-
element.style[styleSet.s] &&
|
|
122
|
-
!element.style[styleSet.c]) {
|
|
123
|
-
format[key] = element.style[styleSet.w] + " " + element.style[styleSet.s];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=
|
|
1
|
+
import addParser from './utils/addParser';
|
|
2
|
+
import { BorderKeys } from 'roosterjs-content-model-dom';
|
|
3
|
+
import { deprecatedBorderColorParser } from './utils/deprecatedColorParser';
|
|
4
|
+
import { getPasteSource } from './pasteSourceValidations/getPasteSource';
|
|
5
|
+
import { parseLink } from './utils/linkParser';
|
|
6
|
+
import { PastePropertyNames } from './pasteSourceValidations/constants';
|
|
7
|
+
import { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';
|
|
8
|
+
import { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';
|
|
9
|
+
import { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';
|
|
10
|
+
import { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';
|
|
11
|
+
/**
|
|
12
|
+
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
13
|
+
* 1. Content copied from Word
|
|
14
|
+
* 2. Content copied from Excel
|
|
15
|
+
* 3. Content copied from Word Online or OneNote Online
|
|
16
|
+
* 4. Content copied from Power Point
|
|
17
|
+
* (This class is still under development, and may still be changed in the future with some breaking changes)
|
|
18
|
+
*/
|
|
19
|
+
var PastePlugin = /** @class */ (function () {
|
|
20
|
+
/**
|
|
21
|
+
* Construct a new instance of Paste class
|
|
22
|
+
* @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
|
|
23
|
+
* @param allowExcelNoBorderTable Allow table copied from Excel without border
|
|
24
|
+
*/
|
|
25
|
+
function PastePlugin(allowExcelNoBorderTable) {
|
|
26
|
+
this.allowExcelNoBorderTable = allowExcelNoBorderTable;
|
|
27
|
+
this.editor = null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get name of this plugin
|
|
31
|
+
*/
|
|
32
|
+
PastePlugin.prototype.getName = function () {
|
|
33
|
+
return 'Paste';
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
37
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
38
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
39
|
+
* @param editor The editor object
|
|
40
|
+
*/
|
|
41
|
+
PastePlugin.prototype.initialize = function (editor) {
|
|
42
|
+
this.editor = editor;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
46
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
47
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
48
|
+
*/
|
|
49
|
+
PastePlugin.prototype.dispose = function () {
|
|
50
|
+
this.editor = null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
54
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
55
|
+
* exclusively by another plugin.
|
|
56
|
+
* @param event The event to handle:
|
|
57
|
+
*/
|
|
58
|
+
PastePlugin.prototype.onPluginEvent = function (event) {
|
|
59
|
+
if (!this.editor || event.eventType != 'beforePaste') {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!event.domToModelOption) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var pasteSource = getPasteSource(event, false);
|
|
66
|
+
var pasteType = event.pasteType;
|
|
67
|
+
switch (pasteSource) {
|
|
68
|
+
case 'wordDesktop':
|
|
69
|
+
processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());
|
|
70
|
+
break;
|
|
71
|
+
case 'wacComponents':
|
|
72
|
+
processPastedContentWacComponents(event);
|
|
73
|
+
break;
|
|
74
|
+
case 'excelOnline':
|
|
75
|
+
case 'excelDesktop':
|
|
76
|
+
if (pasteType === 'normal' || pasteType === 'mergeFormat') {
|
|
77
|
+
// Handle HTML copied from Excel
|
|
78
|
+
processPastedContentFromExcel(event, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'googleSheets':
|
|
82
|
+
event.domToModelOption.additionalAllowedTags.push(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
83
|
+
break;
|
|
84
|
+
case 'powerPointDesktop':
|
|
85
|
+
processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
addParser(event.domToModelOption, 'link', parseLink);
|
|
89
|
+
addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);
|
|
90
|
+
addParser(event.domToModelOption, 'tableCell', tableBorderParser);
|
|
91
|
+
addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);
|
|
92
|
+
if (pasteType === 'mergeFormat') {
|
|
93
|
+
addParser(event.domToModelOption, 'block', blockElementParser);
|
|
94
|
+
addParser(event.domToModelOption, 'listLevel', blockElementParser);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return PastePlugin;
|
|
98
|
+
}());
|
|
99
|
+
export { PastePlugin };
|
|
100
|
+
/**
|
|
101
|
+
* For block elements that have background color style, remove the background color when user selects the merge current format
|
|
102
|
+
* paste option
|
|
103
|
+
*/
|
|
104
|
+
var blockElementParser = function (format, element) {
|
|
105
|
+
if (element.style.backgroundColor) {
|
|
106
|
+
delete format.backgroundColor;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var ElementBorderKeys = new Map([
|
|
110
|
+
['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],
|
|
111
|
+
['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],
|
|
112
|
+
['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],
|
|
113
|
+
['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],
|
|
114
|
+
]);
|
|
115
|
+
function tableBorderParser(format, element) {
|
|
116
|
+
BorderKeys.forEach(function (key) {
|
|
117
|
+
if (!format[key]) {
|
|
118
|
+
var styleSet = ElementBorderKeys.get(key);
|
|
119
|
+
if (styleSet &&
|
|
120
|
+
element.style[styleSet.w] &&
|
|
121
|
+
element.style[styleSet.s] &&
|
|
122
|
+
!element.style[styleSet.c]) {
|
|
123
|
+
format[key] = element.style[styleSet.w] + " " + element.style[styleSet.s];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=PastePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAE,mCAAmC,EAAE,MAAM,mDAAmD,CAAC;AACxG,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AAWtG;;;;;;;GAOG;AACH;IAGI;;;;OAIG;IACH,qBAAoB,uBAAiC;QAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;QAP7C,WAAM,GAA6B,IAAI,CAAC;IAOQ,CAAC;IAEzD;;OAEG;IACH,6BAAO,GAAP;QACI,OAAO,OAAO,CAAC;IACn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C,CAAC;AAEH,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;IAChF,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5C,IACI,QAAQ;gBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;gBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;aAC7E;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\r\nimport { BorderKeys } from 'roosterjs-content-model-dom';\r\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\r\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\r\nimport { parseLink } from './utils/linkParser';\r\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\r\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\r\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\r\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\r\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\r\nimport type {\r\n BorderFormat,\r\n ContentModelBlockFormat,\r\n ContentModelTableCellFormat,\r\n EditorPlugin,\r\n FormatParser,\r\n IStandaloneEditor,\r\n PluginEvent,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\r\n * 1. Content copied from Word\r\n * 2. Content copied from Excel\r\n * 3. Content copied from Word Online or OneNote Online\r\n * 4. Content copied from Power Point\r\n * (This class is still under development, and may still be changed in the future with some breaking changes)\r\n */\r\nexport class PastePlugin implements EditorPlugin {\r\n private editor: IStandaloneEditor | null = null;\r\n\r\n /**\r\n * Construct a new instance of Paste class\r\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\r\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\r\n */\r\n constructor(private allowExcelNoBorderTable?: boolean) {}\r\n\r\n /**\r\n * Get name of this plugin\r\n */\r\n getName() {\r\n return 'Paste';\r\n }\r\n\r\n /**\r\n * The first method that editor will call to a plugin when editor is initializing.\r\n * It will pass in the editor instance, plugin should take this chance to save the\r\n * editor reference so that it can call to any editor method or format API later.\r\n * @param editor The editor object\r\n */\r\n initialize(editor: IStandaloneEditor) {\r\n this.editor = editor;\r\n }\r\n\r\n /**\r\n * The last method that editor will call to a plugin before it is disposed.\r\n * Plugin can take this chance to clear the reference to editor. After this method is\r\n * called, plugin should not call to any editor method since it will result in error.\r\n */\r\n dispose() {\r\n this.editor = null;\r\n }\r\n\r\n /**\r\n * Core method for a plugin. Once an event happens in editor, editor will call this\r\n * method of each plugin to handle the event as long as the event is not handled\r\n * exclusively by another plugin.\r\n * @param event The event to handle:\r\n */\r\n onPluginEvent(event: PluginEvent) {\r\n if (!this.editor || event.eventType != 'beforePaste') {\r\n return;\r\n }\r\n\r\n if (!event.domToModelOption) {\r\n return;\r\n }\r\n\r\n const pasteSource = getPasteSource(event, false);\r\n const pasteType = event.pasteType;\r\n\r\n switch (pasteSource) {\r\n case 'wordDesktop':\r\n processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());\r\n break;\r\n case 'wacComponents':\r\n processPastedContentWacComponents(event);\r\n break;\r\n case 'excelOnline':\r\n case 'excelDesktop':\r\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\r\n // Handle HTML copied from Excel\r\n processPastedContentFromExcel(\r\n event,\r\n this.editor.getTrustedHTMLHandler(),\r\n this.allowExcelNoBorderTable\r\n );\r\n }\r\n break;\r\n case 'googleSheets':\r\n event.domToModelOption.additionalAllowedTags.push(\r\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\r\n );\r\n break;\r\n case 'powerPointDesktop':\r\n processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());\r\n break;\r\n }\r\n\r\n addParser(event.domToModelOption, 'link', parseLink);\r\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\r\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\r\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\r\n\r\n if (pasteType === 'mergeFormat') {\r\n addParser(event.domToModelOption, 'block', blockElementParser);\r\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * For block elements that have background color style, remove the background color when user selects the merge current format\r\n * paste option\r\n */\r\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\r\n format: ContentModelBlockFormat,\r\n element: HTMLElement\r\n) => {\r\n if (element.style.backgroundColor) {\r\n delete format.backgroundColor;\r\n }\r\n};\r\n\r\nconst ElementBorderKeys = new Map<\r\n keyof BorderFormat,\r\n {\r\n c: keyof CSSStyleDeclaration;\r\n s: keyof CSSStyleDeclaration;\r\n w: keyof CSSStyleDeclaration;\r\n }\r\n>([\r\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\r\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\r\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\r\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\r\n]);\r\n\r\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\r\n BorderKeys.forEach(key => {\r\n if (!format[key]) {\r\n const styleSet = ElementBorderKeys.get(key);\r\n if (\r\n styleSet &&\r\n element.style[styleSet.w] &&\r\n element.style[styleSet.s] &&\r\n !element.style[styleSet.c]\r\n ) {\r\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\r\n }\r\n }\r\n });\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
* Convert pasted content from PowerPoint
|
|
5
|
-
* @param event The BeforePaste event
|
|
6
|
-
*/
|
|
7
|
-
export declare function processPastedContentFromPowerPoint(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler): void;
|
|
1
|
+
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Convert pasted content from PowerPoint
|
|
5
|
+
* @param event The BeforePaste event
|
|
6
|
+
*/
|
|
7
|
+
export declare function processPastedContentFromPowerPoint(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler): void;
|