roosterjs-content-model-plugins 0.24.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/autoFormat/AutoFormatPlugin.d.ts +53 -0
- package/lib/autoFormat/AutoFormatPlugin.js +81 -0
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib/autoFormat/keyboardListTrigger.d.ts +5 -0
- package/lib/autoFormat/keyboardListTrigger.js +46 -0
- package/lib/autoFormat/keyboardListTrigger.js.map +1 -0
- package/lib/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
- package/lib/autoFormat/utils/convertAlphaToDecimals.js +23 -0
- package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
- package/lib/autoFormat/utils/getIndex.d.ts +4 -0
- package/lib/autoFormat/utils/getIndex.js +14 -0
- package/lib/autoFormat/utils/getIndex.js.map +1 -0
- package/lib/autoFormat/utils/getListTypeStyle.d.ts +14 -0
- package/lib/autoFormat/utils/getListTypeStyle.js +88 -0
- package/lib/autoFormat/utils/getListTypeStyle.js.map +1 -0
- package/lib/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
- package/lib/autoFormat/utils/getNumberingListStyle.js +154 -0
- package/lib/autoFormat/utils/getNumberingListStyle.js.map +1 -0
- package/{lib-mjs/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-mjs/paste/ContentModelPastePlugin.d.ts → lib/paste/PastePlugin.d.ts} +43 -43
- package/lib/paste/{ContentModelPastePlugin.js → PastePlugin.js} +131 -132
- 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/AutoFormatPlugin.d.ts +53 -0
- package/lib-amd/autoFormat/AutoFormatPlugin.js +82 -0
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib-amd/autoFormat/keyboardListTrigger.d.ts +5 -0
- package/lib-amd/autoFormat/keyboardListTrigger.js +44 -0
- package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -0
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js +25 -0
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
- package/lib-amd/autoFormat/utils/getIndex.d.ts +4 -0
- package/lib-amd/autoFormat/utils/getIndex.js +15 -0
- package/lib-amd/autoFormat/utils/getIndex.js.map +1 -0
- package/lib-amd/autoFormat/utils/getListTypeStyle.d.ts +14 -0
- package/lib-amd/autoFormat/utils/getListTypeStyle.js +87 -0
- package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +1 -0
- package/lib-amd/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js +154 -0
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +1 -0
- package/lib-amd/edit/{ContentModelEditPlugin.d.ts → 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 -124
- 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-mjs/autoFormat/AutoFormatPlugin.d.ts +53 -0
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +78 -0
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -0
- package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +5 -0
- package/lib-mjs/autoFormat/keyboardListTrigger.js +42 -0
- package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -0
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -0
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js +19 -0
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +1 -0
- package/lib-mjs/autoFormat/utils/getIndex.d.ts +4 -0
- package/lib-mjs/autoFormat/utils/getIndex.js +10 -0
- package/lib-mjs/autoFormat/utils/getIndex.js.map +1 -0
- package/lib-mjs/autoFormat/utils/getListTypeStyle.d.ts +14 -0
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js +84 -0
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +1 -0
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.d.ts +4 -0
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js +150 -0
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +1 -0
- 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-amd/paste/ContentModelPastePlugin.d.ts → lib-mjs/paste/PastePlugin.d.ts} +43 -43
- package/lib-mjs/paste/{ContentModelPastePlugin.js → PastePlugin.js} +128 -129
- 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 -7
- package/lib/edit/ContentModelEditPlugin.js +0 -75
- package/lib/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
- package/lib/entityDelimiter/EntityDelimiterPlugin.js +0 -257
- package/lib/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
- package/lib/paste/ContentModelPastePlugin.js.map +0 -1
- package/lib-amd/edit/ContentModelEditPlugin.js +0 -75
- package/lib-amd/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js +0 -256
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
- package/lib-amd/paste/ContentModelPastePlugin.js.map +0 -1
- package/lib-mjs/edit/ContentModelEditPlugin.js +0 -72
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +0 -1
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.d.ts +0 -35
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js +0 -253
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js.map +0 -1
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +0 -1
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { isCharacterValue } from 'roosterjs-content-model-core';
|
|
2
|
-
import { addDelimiters, isBlockElement, isEntityElement, isNodeOfType, } from 'roosterjs-content-model-dom';
|
|
3
|
-
import { Position, createRange, getDelimiterFromElement, getEntityFromElement, getEntitySelector, matchesSelector, splitTextNode, } from 'roosterjs-editor-dom';
|
|
4
|
-
var DELIMITER_SELECTOR = '.' + "entityDelimiterAfter" /* DELIMITER_AFTER */ + ',.' + "entityDelimiterBefore" /* DELIMITER_BEFORE */;
|
|
5
|
-
var ZERO_WIDTH_SPACE = '\u200B';
|
|
6
|
-
var INLINE_ENTITY_SELECTOR = 'span' + getEntitySelector();
|
|
7
|
-
/**
|
|
8
|
-
* Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
|
|
9
|
-
*/
|
|
10
|
-
var EntityDelimiterPlugin = /** @class */ (function () {
|
|
11
|
-
function EntityDelimiterPlugin() {
|
|
12
|
-
this.editor = null;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get a friendly name of this plugin
|
|
16
|
-
*/
|
|
17
|
-
EntityDelimiterPlugin.prototype.getName = function () {
|
|
18
|
-
return 'EntityDelimiter';
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
22
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
23
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
24
|
-
* @param editor The editor object
|
|
25
|
-
*/
|
|
26
|
-
EntityDelimiterPlugin.prototype.initialize = function (editor) {
|
|
27
|
-
this.editor = editor;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
31
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
32
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
33
|
-
*/
|
|
34
|
-
EntityDelimiterPlugin.prototype.dispose = function () {
|
|
35
|
-
this.editor = null;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
39
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
40
|
-
* exclusively by another plugin.
|
|
41
|
-
* @param event The event to handle:
|
|
42
|
-
*/
|
|
43
|
-
EntityDelimiterPlugin.prototype.onPluginEvent = function (event) {
|
|
44
|
-
if (this.editor) {
|
|
45
|
-
switch (event.eventType) {
|
|
46
|
-
case 7 /* ContentChanged */:
|
|
47
|
-
case 11 /* EditorReady */:
|
|
48
|
-
normalizeDelimitersInEditor(this.editor);
|
|
49
|
-
break;
|
|
50
|
-
case 10 /* BeforePaste */:
|
|
51
|
-
var fragment = event.fragment;
|
|
52
|
-
addDelimitersIfNeeded(fragment.querySelectorAll(INLINE_ENTITY_SELECTOR));
|
|
53
|
-
break;
|
|
54
|
-
case 8 /* ExtractContentWithDom */:
|
|
55
|
-
case 9 /* BeforeCutCopy */:
|
|
56
|
-
event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(function (node) {
|
|
57
|
-
if (getDelimiterFromElement(node)) {
|
|
58
|
-
removeNode(node);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
removeDelimiterAttr(node);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
break;
|
|
65
|
-
case 0 /* KeyDown */:
|
|
66
|
-
handleKeyDownEvent(this.editor, event);
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
return EntityDelimiterPlugin;
|
|
72
|
-
}());
|
|
73
|
-
export { EntityDelimiterPlugin };
|
|
74
|
-
function preventTypeInDelimiter(delimiter) {
|
|
75
|
-
var _a, _b, _c, _d;
|
|
76
|
-
delimiter.normalize();
|
|
77
|
-
var textNode = delimiter.firstChild;
|
|
78
|
-
var index = (_b = (_a = textNode.nodeValue) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
79
|
-
if (index >= 0) {
|
|
80
|
-
splitTextNode(textNode, index == 0 ? 1 : index, false /* returnFirstPart */);
|
|
81
|
-
var nodeToMove_1;
|
|
82
|
-
delimiter.childNodes.forEach(function (node) {
|
|
83
|
-
if (node.nodeValue !== ZERO_WIDTH_SPACE) {
|
|
84
|
-
nodeToMove_1 = node;
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
if (nodeToMove_1) {
|
|
88
|
-
(_c = delimiter.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(nodeToMove_1, delimiter.className == "entityDelimiterBefore" /* DELIMITER_BEFORE */
|
|
89
|
-
? delimiter
|
|
90
|
-
: delimiter.nextSibling);
|
|
91
|
-
var selection = (_d = nodeToMove_1.ownerDocument) === null || _d === void 0 ? void 0 : _d.getSelection();
|
|
92
|
-
if (selection) {
|
|
93
|
-
selection.setPosition(nodeToMove_1, new Position(nodeToMove_1, -1 /* End */).offset);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @internal
|
|
100
|
-
*/
|
|
101
|
-
export function normalizeDelimitersInEditor(editor) {
|
|
102
|
-
removeInvalidDelimiters(editor.queryElements(DELIMITER_SELECTOR));
|
|
103
|
-
addDelimitersIfNeeded(editor.queryElements(INLINE_ENTITY_SELECTOR));
|
|
104
|
-
}
|
|
105
|
-
function addDelimitersIfNeeded(nodes) {
|
|
106
|
-
nodes.forEach(function (node) {
|
|
107
|
-
if (isNodeOfType(node, 'ELEMENT_NODE') &&
|
|
108
|
-
isEntityElement(node) &&
|
|
109
|
-
!node.isContentEditable) {
|
|
110
|
-
addDelimiters(node.ownerDocument, node);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function removeNode(el) {
|
|
115
|
-
var _a;
|
|
116
|
-
(_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(el);
|
|
117
|
-
}
|
|
118
|
-
function removeInvalidDelimiters(nodes) {
|
|
119
|
-
nodes.forEach(function (node) {
|
|
120
|
-
if (getDelimiterFromElement(node)) {
|
|
121
|
-
var sibling = node.classList.contains("entityDelimiterBefore" /* DELIMITER_BEFORE */)
|
|
122
|
-
? node.nextElementSibling
|
|
123
|
-
: node.previousElementSibling;
|
|
124
|
-
if (!(isNodeOfType(sibling, 'ELEMENT_NODE') && getEntityFromElement(sibling))) {
|
|
125
|
-
removeNode(node);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
removeDelimiterAttr(node);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function removeDelimiterAttr(node, checkEntity) {
|
|
134
|
-
if (checkEntity === void 0) { checkEntity = true; }
|
|
135
|
-
if (!node) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
var isAfter = node.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
139
|
-
var entitySibling = isAfter ? node.previousElementSibling : node.nextElementSibling;
|
|
140
|
-
if (checkEntity && entitySibling && isEntityElement(entitySibling)) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
node.classList.remove("entityDelimiterAfter" /* DELIMITER_AFTER */, "entityDelimiterBefore" /* DELIMITER_BEFORE */);
|
|
144
|
-
node.normalize();
|
|
145
|
-
node.childNodes.forEach(function (cn) {
|
|
146
|
-
var _a, _b, _c;
|
|
147
|
-
var index = (_b = (_a = cn.textContent) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
148
|
-
if (index >= 0) {
|
|
149
|
-
(_c = createRange(cn, index, cn, index + 1)) === null || _c === void 0 ? void 0 : _c.deleteContents();
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function handleCollapsedEnter(editor, delimiter) {
|
|
154
|
-
var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
155
|
-
var entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;
|
|
156
|
-
var block = getBlock(editor, delimiter);
|
|
157
|
-
editor.runAsync(function () {
|
|
158
|
-
if (!block) {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
var blockToCheck = isAfter ? block.nextSibling : block.previousSibling;
|
|
162
|
-
if (blockToCheck && isNodeOfType(blockToCheck, 'ELEMENT_NODE')) {
|
|
163
|
-
var delimiters = blockToCheck.querySelectorAll(DELIMITER_SELECTOR);
|
|
164
|
-
// Check if the last or first delimiter still contain the delimiter class and remove it.
|
|
165
|
-
var delimiterToCheck = delimiters.item(isAfter ? 0 : delimiters.length - 1);
|
|
166
|
-
removeDelimiterAttr(delimiterToCheck);
|
|
167
|
-
}
|
|
168
|
-
if (entity && isEntityElement(entity)) {
|
|
169
|
-
var entityElement = entity;
|
|
170
|
-
var nextElementSibling = entityElement.nextElementSibling, previousElementSibling = entityElement.previousElementSibling;
|
|
171
|
-
[nextElementSibling, previousElementSibling].forEach(function (el) {
|
|
172
|
-
// Check if after Enter the ZWS got removed but we still have a element with the class
|
|
173
|
-
// Remove the attributes of the element if it is invalid now.
|
|
174
|
-
if (el && matchesSelector(el, DELIMITER_SELECTOR) && !getDelimiterFromElement(el)) {
|
|
175
|
-
removeDelimiterAttr(el, false /* checkEntity */);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
// Add delimiters to the entity if needed because on Enter we can sometimes lose the ZWS of the element.
|
|
179
|
-
addDelimiters(entityElement.ownerDocument, entityElement);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
var getPosition = function (container) {
|
|
184
|
-
if (container && getDelimiterFromElement(container)) {
|
|
185
|
-
var isAfter = container.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
186
|
-
return new Position(container, isAfter ? -3 /* After */ : -2 /* Before */);
|
|
187
|
-
}
|
|
188
|
-
return undefined;
|
|
189
|
-
};
|
|
190
|
-
function getBlock(editor, element) {
|
|
191
|
-
var _a;
|
|
192
|
-
if (!element) {
|
|
193
|
-
return undefined;
|
|
194
|
-
}
|
|
195
|
-
var block = (_a = editor.getBlockElementAtNode(element)) === null || _a === void 0 ? void 0 : _a.getStartNode();
|
|
196
|
-
while (block && (!isNodeOfType(block, 'ELEMENT_NODE') || !isBlockElement(block))) {
|
|
197
|
-
block = editor.contains(block.parentElement) ? block.parentElement : undefined;
|
|
198
|
-
}
|
|
199
|
-
return block;
|
|
200
|
-
}
|
|
201
|
-
function handleSelectionNotCollapsed(editor, range, event) {
|
|
202
|
-
var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
|
|
203
|
-
var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
|
|
204
|
-
var endElement = editor.getElementAtCursor(DELIMITER_SELECTOR, endContainer);
|
|
205
|
-
var startUpdate = getPosition(startElement);
|
|
206
|
-
var endUpdate = getPosition(endElement);
|
|
207
|
-
if (startUpdate || endUpdate) {
|
|
208
|
-
editor.select(startUpdate !== null && startUpdate !== void 0 ? startUpdate : new Position(startContainer, startOffset), endUpdate !== null && endUpdate !== void 0 ? endUpdate : new Position(endContainer, endOffset));
|
|
209
|
-
}
|
|
210
|
-
editor.runAsync(function (aEditor) {
|
|
211
|
-
var delimiter = aEditor.getElementAtCursor(DELIMITER_SELECTOR);
|
|
212
|
-
if (delimiter) {
|
|
213
|
-
preventTypeInDelimiter(delimiter);
|
|
214
|
-
if (event.which === 13 /* ENTER */) {
|
|
215
|
-
removeDelimiterAttr(delimiter);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
function handleKeyDownEvent(editor, event) {
|
|
221
|
-
var _a, _b;
|
|
222
|
-
var range = editor.getSelectionRangeEx();
|
|
223
|
-
var rawEvent = event.rawEvent;
|
|
224
|
-
if (range.type != 0 /* Normal */) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
if (range.areAllCollapsed && (isCharacterValue(rawEvent) || rawEvent.which === 13 /* ENTER */)) {
|
|
228
|
-
var position = (_a = editor.getFocusedPosition()) === null || _a === void 0 ? void 0 : _a.normalize();
|
|
229
|
-
if (!position) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
var element = position.element, node = position.node;
|
|
233
|
-
var refNode = element == node ? element.childNodes.item(position.offset) : element;
|
|
234
|
-
var delimiter_1 = editor.getElementAtCursor(DELIMITER_SELECTOR, refNode);
|
|
235
|
-
if (!delimiter_1) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (rawEvent.which === 13 /* ENTER */) {
|
|
239
|
-
handleCollapsedEnter(editor, delimiter_1);
|
|
240
|
-
}
|
|
241
|
-
else if (((_b = delimiter_1.firstChild) === null || _b === void 0 ? void 0 : _b.nodeType) == 3 /* Text */) {
|
|
242
|
-
editor.runAsync(function () { return preventTypeInDelimiter(delimiter_1); });
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
else if (!range.areAllCollapsed && !rawEvent.shiftKey && rawEvent.which != 16 /* SHIFT */) {
|
|
246
|
-
var currentRange = range.ranges[0];
|
|
247
|
-
if (!currentRange) {
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
handleSelectionNotCollapsed(editor, currentRange, rawEvent);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
//# sourceMappingURL=EntityDelimiterPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EntityDelimiterPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/entityDelimiter/EntityDelimiterPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACH,aAAa,EACb,cAAc,EACd,eAAe,EACf,YAAY,GACf,MAAM,6BAA6B,CAAC;AASrC,OAAO,EACH,QAAQ,EACR,WAAW,EACX,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,aAAa,GAChB,MAAM,sBAAsB,CAAC;AAS9B,IAAM,kBAAkB,GACpB,GAAG,+CAAmC,GAAG,IAAI,iDAAoC,CAAC;AACtF,IAAM,gBAAgB,GAAG,QAAQ,CAAC;AAClC,IAAM,sBAAsB,GAAG,MAAM,GAAG,iBAAiB,EAAE,CAAC;AAE5D;;GAEG;AACH;IAAA;QACY,WAAM,GAA+B,IAAI,CAAC;IAiEtD,CAAC;IA/DG;;OAEG;IACH,uCAAO,GAAP;QACI,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,0CAAU,GAAV,UAAW,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,uCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,6CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,4BAAoC;gBACpC;oBACI,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACzC,MAAM;gBAEV;oBACY,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;oBAC3B,qBAAqB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,sBAA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M,WAAS,GAAG,MAAM,CAAC,kBAAkB,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,CAAC,WAAS,EAAE;YACZ,OAAO;SACV;QAED,IAAI,QAAQ,CAAC,KAAK,mBAAe,EAAE;YAC/B,oBAAoB,CAAC,MAAM,EAAE,WAAS,CAAC,CAAC;SAC3C;aAAM,IAAI,CAAA,MAAA,WAAS,CAAC,UAAU,0CAAE,QAAQ,iBAAiB,EAAE;YACxD,MAAM,CAAC,QAAQ,CAAC,cAAM,OAAA,sBAAsB,CAAC,WAAS,CAAC,EAAjC,CAAiC,CAAC,CAAC;SAC5D;KACJ;SAAM,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,kBAAc,EAAE;QACrF,IAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,CAAC,YAAY,EAAE;YACf,OAAO;SACV;QACD,2BAA2B,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;KAC/D;AACL,CAAC","sourcesContent":["import { isCharacterValue } from 'roosterjs-content-model-core';\nimport {\n addDelimiters,\n isBlockElement,\n isEntityElement,\n isNodeOfType,\n} from 'roosterjs-content-model-dom';\nimport {\n DelimiterClasses,\n Keys,\n NodeType,\n PluginEventType,\n PositionType,\n SelectionRangeTypes,\n} from 'roosterjs-editor-types';\nimport {\n Position,\n createRange,\n getDelimiterFromElement,\n getEntityFromElement,\n getEntitySelector,\n matchesSelector,\n splitTextNode,\n} from 'roosterjs-editor-dom';\nimport type {\n EditorPlugin,\n IEditor,\n PluginEvent,\n PluginKeyDownEvent,\n} from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\n\nconst DELIMITER_SELECTOR =\n '.' + DelimiterClasses.DELIMITER_AFTER + ',.' + DelimiterClasses.DELIMITER_BEFORE;\nconst ZERO_WIDTH_SPACE = '\\u200B';\nconst INLINE_ENTITY_SELECTOR = 'span' + getEntitySelector();\n\n/**\n * Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity\n */\nexport class EntityDelimiterPlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'EntityDelimiter';\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 as IContentModelEditor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case PluginEventType.ContentChanged:\n case PluginEventType.EditorReady:\n normalizeDelimitersInEditor(this.editor);\n break;\n\n case PluginEventType.BeforePaste:\n const { fragment } = event;\n addDelimitersIfNeeded(fragment.querySelectorAll(INLINE_ENTITY_SELECTOR));\n\n break;\n\n case PluginEventType.ExtractContentWithDom:\n case PluginEventType.BeforeCutCopy:\n event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(node => {\n if (getDelimiterFromElement(node)) {\n removeNode(node);\n } else {\n removeDelimiterAttr(node);\n }\n });\n break;\n\n case PluginEventType.KeyDown:\n handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n}\n\nfunction preventTypeInDelimiter(delimiter: HTMLElement) {\n delimiter.normalize();\n const textNode = delimiter.firstChild as Node;\n const index = textNode.nodeValue?.indexOf(ZERO_WIDTH_SPACE) ?? -1;\n if (index >= 0) {\n splitTextNode(<Text>textNode, index == 0 ? 1 : index, false /* returnFirstPart */);\n let nodeToMove: Node | undefined;\n delimiter.childNodes.forEach(node => {\n if (node.nodeValue !== ZERO_WIDTH_SPACE) {\n nodeToMove = node;\n }\n });\n if (nodeToMove) {\n delimiter.parentElement?.insertBefore(\n nodeToMove,\n delimiter.className == DelimiterClasses.DELIMITER_BEFORE\n ? delimiter\n : delimiter.nextSibling\n );\n const selection = nodeToMove.ownerDocument?.getSelection();\n\n if (selection) {\n selection.setPosition(\n nodeToMove,\n new Position(nodeToMove, PositionType.End).offset\n );\n }\n }\n }\n}\n\n/**\n * @internal\n */\nexport function normalizeDelimitersInEditor(editor: IEditor) {\n removeInvalidDelimiters(editor.queryElements(DELIMITER_SELECTOR));\n addDelimitersIfNeeded(editor.queryElements(INLINE_ENTITY_SELECTOR));\n}\n\nfunction addDelimitersIfNeeded(nodes: Element[] | NodeListOf<Element>) {\n nodes.forEach(node => {\n if (\n isNodeOfType(node, 'ELEMENT_NODE') &&\n isEntityElement(node) &&\n !node.isContentEditable\n ) {\n addDelimiters(node.ownerDocument, node as HTMLElement);\n }\n });\n}\n\nfunction removeNode(el: Node | undefined | null) {\n el?.parentElement?.removeChild(el);\n}\n\nfunction removeInvalidDelimiters(nodes: Element[] | NodeListOf<Element>) {\n nodes.forEach(node => {\n if (getDelimiterFromElement(node)) {\n const sibling = node.classList.contains(DelimiterClasses.DELIMITER_BEFORE)\n ? node.nextElementSibling\n : node.previousElementSibling;\n if (!(isNodeOfType(sibling, 'ELEMENT_NODE') && getEntityFromElement(sibling))) {\n removeNode(node);\n }\n } else {\n removeDelimiterAttr(node);\n }\n });\n}\n\nfunction removeDelimiterAttr(node: Element | undefined | null, checkEntity: boolean = true) {\n if (!node) {\n return;\n }\n\n const isAfter = node.classList.contains(DelimiterClasses.DELIMITER_AFTER);\n const entitySibling = isAfter ? node.previousElementSibling : node.nextElementSibling;\n if (checkEntity && entitySibling && isEntityElement(entitySibling)) {\n return;\n }\n\n node.classList.remove(DelimiterClasses.DELIMITER_AFTER, DelimiterClasses.DELIMITER_BEFORE);\n\n node.normalize();\n node.childNodes.forEach(cn => {\n const index = cn.textContent?.indexOf(ZERO_WIDTH_SPACE) ?? -1;\n if (index >= 0) {\n createRange(cn, index, cn, index + 1)?.deleteContents();\n }\n });\n}\n\nfunction handleCollapsedEnter(editor: IEditor, delimiter: HTMLElement) {\n const isAfter = delimiter.classList.contains(DelimiterClasses.DELIMITER_AFTER);\n const entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;\n const block = getBlock(editor, delimiter);\n\n editor.runAsync(() => {\n if (!block) {\n return;\n }\n const blockToCheck = isAfter ? block.nextSibling : block.previousSibling;\n if (blockToCheck && isNodeOfType(blockToCheck, 'ELEMENT_NODE')) {\n const delimiters = blockToCheck.querySelectorAll(DELIMITER_SELECTOR);\n // Check if the last or first delimiter still contain the delimiter class and remove it.\n const delimiterToCheck = delimiters.item(isAfter ? 0 : delimiters.length - 1);\n removeDelimiterAttr(delimiterToCheck);\n }\n\n if (entity && isEntityElement(entity)) {\n const entityElement = entity as HTMLElement;\n const { nextElementSibling, previousElementSibling } = entityElement;\n [nextElementSibling, previousElementSibling].forEach(el => {\n // Check if after Enter the ZWS got removed but we still have a element with the class\n // Remove the attributes of the element if it is invalid now.\n if (el && matchesSelector(el, DELIMITER_SELECTOR) && !getDelimiterFromElement(el)) {\n removeDelimiterAttr(el, false /* checkEntity */);\n }\n });\n\n // Add delimiters to the entity if needed because on Enter we can sometimes lose the ZWS of the element.\n addDelimiters(entityElement.ownerDocument, entityElement);\n }\n });\n}\n\nconst getPosition = (container: HTMLElement | null) => {\n if (container && getDelimiterFromElement(container)) {\n const isAfter = container.classList.contains(DelimiterClasses.DELIMITER_AFTER);\n return new Position(container, isAfter ? PositionType.After : PositionType.Before);\n }\n return undefined;\n};\n\nfunction getBlock(editor: IEditor, element: Node | undefined) {\n if (!element) {\n return undefined;\n }\n\n let block = editor.getBlockElementAtNode(element)?.getStartNode();\n\n while (block && (!isNodeOfType(block, 'ELEMENT_NODE') || !isBlockElement(block))) {\n block = editor.contains(block.parentElement) ? block.parentElement! : undefined;\n }\n\n return block;\n}\n\nfunction handleSelectionNotCollapsed(editor: IEditor, range: Range, event: KeyboardEvent) {\n const { startContainer, endContainer, startOffset, endOffset } = range;\n\n const startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);\n const endElement = editor.getElementAtCursor(DELIMITER_SELECTOR, endContainer);\n\n const startUpdate = getPosition(startElement);\n const endUpdate = getPosition(endElement);\n\n if (startUpdate || endUpdate) {\n editor.select(\n startUpdate ?? new Position(startContainer, startOffset),\n endUpdate ?? new Position(endContainer, endOffset)\n );\n }\n editor.runAsync(aEditor => {\n const delimiter = aEditor.getElementAtCursor(DELIMITER_SELECTOR);\n if (delimiter) {\n preventTypeInDelimiter(delimiter);\n if (event.which === Keys.ENTER) {\n removeDelimiterAttr(delimiter);\n }\n }\n });\n}\n\nfunction handleKeyDownEvent(editor: IEditor, event: PluginKeyDownEvent) {\n const range = editor.getSelectionRangeEx();\n const { rawEvent } = event;\n if (range.type != SelectionRangeTypes.Normal) {\n return;\n }\n\n if (range.areAllCollapsed && (isCharacterValue(rawEvent) || rawEvent.which === Keys.ENTER)) {\n const position = editor.getFocusedPosition()?.normalize();\n if (!position) {\n return;\n }\n\n const { element, node } = position;\n const refNode = element == node ? element.childNodes.item(position.offset) : element;\n\n const delimiter = editor.getElementAtCursor(DELIMITER_SELECTOR, refNode);\n if (!delimiter) {\n return;\n }\n\n if (rawEvent.which === Keys.ENTER) {\n handleCollapsedEnter(editor, delimiter);\n } else if (delimiter.firstChild?.nodeType == NodeType.Text) {\n editor.runAsync(() => preventTypeInDelimiter(delimiter));\n }\n } else if (!range.areAllCollapsed && !rawEvent.shiftKey && rawEvent.which != Keys.SHIFT) {\n const currentRange = range.ranges[0];\n if (!currentRange) {\n return;\n }\n handleSelectionNotCollapsed(editor, currentRange, rawEvent);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.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,iCAAoB,uBAAiC;QAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;QAP7C,WAAM,GAA6B,IAAI,CAAC;IAOQ,CAAC;IAEzD;;OAEG;IACH,yCAAO,GAAP;QACI,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,4CAAU,GAAV,UAAW,MAAyB;QAChC,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,yCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,+CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,aAAa,EAAE;YAClD,OAAO;SACV;QAED,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;YACzB,OAAO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AC,CAAC,CAAC,EAC5B;gBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;aAC7E;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type {\n BorderFormat,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n EditorPlugin,\n FormatParser,\n IStandaloneEditor,\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 * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IStandaloneEditor | 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(private allowExcelNoBorderTable?: boolean) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IStandaloneEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\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(event, false);\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\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.getTrustedHTMLHandler());\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\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|