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,256 +0,0 @@
|
|
|
1
|
-
define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content-model-dom", "roosterjs-editor-dom"], function (require, exports, roosterjs_content_model_core_1, roosterjs_content_model_dom_1, roosterjs_editor_dom_1) {
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.normalizeDelimitersInEditor = exports.EntityDelimiterPlugin = void 0;
|
|
5
|
-
var DELIMITER_SELECTOR = '.' + "entityDelimiterAfter" /* DELIMITER_AFTER */ + ',.' + "entityDelimiterBefore" /* DELIMITER_BEFORE */;
|
|
6
|
-
var ZERO_WIDTH_SPACE = '\u200B';
|
|
7
|
-
var INLINE_ENTITY_SELECTOR = 'span' + (0, roosterjs_editor_dom_1.getEntitySelector)();
|
|
8
|
-
/**
|
|
9
|
-
* Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
|
|
10
|
-
*/
|
|
11
|
-
var EntityDelimiterPlugin = /** @class */ (function () {
|
|
12
|
-
function EntityDelimiterPlugin() {
|
|
13
|
-
this.editor = null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Get a friendly name of this plugin
|
|
17
|
-
*/
|
|
18
|
-
EntityDelimiterPlugin.prototype.getName = function () {
|
|
19
|
-
return 'EntityDelimiter';
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
23
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
24
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
25
|
-
* @param editor The editor object
|
|
26
|
-
*/
|
|
27
|
-
EntityDelimiterPlugin.prototype.initialize = function (editor) {
|
|
28
|
-
this.editor = editor;
|
|
29
|
-
};
|
|
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
|
-
EntityDelimiterPlugin.prototype.dispose = function () {
|
|
36
|
-
this.editor = null;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
40
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
41
|
-
* exclusively by another plugin.
|
|
42
|
-
* @param event The event to handle:
|
|
43
|
-
*/
|
|
44
|
-
EntityDelimiterPlugin.prototype.onPluginEvent = function (event) {
|
|
45
|
-
if (this.editor) {
|
|
46
|
-
switch (event.eventType) {
|
|
47
|
-
case 7 /* ContentChanged */:
|
|
48
|
-
case 11 /* EditorReady */:
|
|
49
|
-
normalizeDelimitersInEditor(this.editor);
|
|
50
|
-
break;
|
|
51
|
-
case 10 /* BeforePaste */:
|
|
52
|
-
var fragment = event.fragment;
|
|
53
|
-
addDelimitersIfNeeded(fragment.querySelectorAll(INLINE_ENTITY_SELECTOR));
|
|
54
|
-
break;
|
|
55
|
-
case 8 /* ExtractContentWithDom */:
|
|
56
|
-
case 9 /* BeforeCutCopy */:
|
|
57
|
-
event.clonedRoot.querySelectorAll(DELIMITER_SELECTOR).forEach(function (node) {
|
|
58
|
-
if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(node)) {
|
|
59
|
-
removeNode(node);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
removeDelimiterAttr(node);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
break;
|
|
66
|
-
case 0 /* KeyDown */:
|
|
67
|
-
handleKeyDownEvent(this.editor, event);
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
return EntityDelimiterPlugin;
|
|
73
|
-
}());
|
|
74
|
-
exports.EntityDelimiterPlugin = EntityDelimiterPlugin;
|
|
75
|
-
function preventTypeInDelimiter(delimiter) {
|
|
76
|
-
var _a, _b, _c, _d;
|
|
77
|
-
delimiter.normalize();
|
|
78
|
-
var textNode = delimiter.firstChild;
|
|
79
|
-
var index = (_b = (_a = textNode.nodeValue) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
80
|
-
if (index >= 0) {
|
|
81
|
-
(0, roosterjs_editor_dom_1.splitTextNode)(textNode, index == 0 ? 1 : index, false /* returnFirstPart */);
|
|
82
|
-
var nodeToMove_1;
|
|
83
|
-
delimiter.childNodes.forEach(function (node) {
|
|
84
|
-
if (node.nodeValue !== ZERO_WIDTH_SPACE) {
|
|
85
|
-
nodeToMove_1 = node;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
if (nodeToMove_1) {
|
|
89
|
-
(_c = delimiter.parentElement) === null || _c === void 0 ? void 0 : _c.insertBefore(nodeToMove_1, delimiter.className == "entityDelimiterBefore" /* DELIMITER_BEFORE */
|
|
90
|
-
? delimiter
|
|
91
|
-
: delimiter.nextSibling);
|
|
92
|
-
var selection = (_d = nodeToMove_1.ownerDocument) === null || _d === void 0 ? void 0 : _d.getSelection();
|
|
93
|
-
if (selection) {
|
|
94
|
-
selection.setPosition(nodeToMove_1, new roosterjs_editor_dom_1.Position(nodeToMove_1, -1 /* End */).offset);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
function normalizeDelimitersInEditor(editor) {
|
|
103
|
-
removeInvalidDelimiters(editor.queryElements(DELIMITER_SELECTOR));
|
|
104
|
-
addDelimitersIfNeeded(editor.queryElements(INLINE_ENTITY_SELECTOR));
|
|
105
|
-
}
|
|
106
|
-
exports.normalizeDelimitersInEditor = normalizeDelimitersInEditor;
|
|
107
|
-
function addDelimitersIfNeeded(nodes) {
|
|
108
|
-
nodes.forEach(function (node) {
|
|
109
|
-
if ((0, roosterjs_content_model_dom_1.isNodeOfType)(node, 'ELEMENT_NODE') &&
|
|
110
|
-
(0, roosterjs_content_model_dom_1.isEntityElement)(node) &&
|
|
111
|
-
!node.isContentEditable) {
|
|
112
|
-
(0, roosterjs_content_model_dom_1.addDelimiters)(node.ownerDocument, node);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function removeNode(el) {
|
|
117
|
-
var _a;
|
|
118
|
-
(_a = el === null || el === void 0 ? void 0 : el.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(el);
|
|
119
|
-
}
|
|
120
|
-
function removeInvalidDelimiters(nodes) {
|
|
121
|
-
nodes.forEach(function (node) {
|
|
122
|
-
if ((0, roosterjs_editor_dom_1.getDelimiterFromElement)(node)) {
|
|
123
|
-
var sibling = node.classList.contains("entityDelimiterBefore" /* DELIMITER_BEFORE */)
|
|
124
|
-
? node.nextElementSibling
|
|
125
|
-
: node.previousElementSibling;
|
|
126
|
-
if (!((0, roosterjs_content_model_dom_1.isNodeOfType)(sibling, 'ELEMENT_NODE') && (0, roosterjs_editor_dom_1.getEntityFromElement)(sibling))) {
|
|
127
|
-
removeNode(node);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
removeDelimiterAttr(node);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function removeDelimiterAttr(node, checkEntity) {
|
|
136
|
-
if (checkEntity === void 0) { checkEntity = true; }
|
|
137
|
-
if (!node) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
var isAfter = node.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
141
|
-
var entitySibling = isAfter ? node.previousElementSibling : node.nextElementSibling;
|
|
142
|
-
if (checkEntity && entitySibling && (0, roosterjs_content_model_dom_1.isEntityElement)(entitySibling)) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
node.classList.remove("entityDelimiterAfter" /* DELIMITER_AFTER */, "entityDelimiterBefore" /* DELIMITER_BEFORE */);
|
|
146
|
-
node.normalize();
|
|
147
|
-
node.childNodes.forEach(function (cn) {
|
|
148
|
-
var _a, _b, _c;
|
|
149
|
-
var index = (_b = (_a = cn.textContent) === null || _a === void 0 ? void 0 : _a.indexOf(ZERO_WIDTH_SPACE)) !== null && _b !== void 0 ? _b : -1;
|
|
150
|
-
if (index >= 0) {
|
|
151
|
-
(_c = (0, roosterjs_editor_dom_1.createRange)(cn, index, cn, index + 1)) === null || _c === void 0 ? void 0 : _c.deleteContents();
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
function handleCollapsedEnter(editor, delimiter) {
|
|
156
|
-
var isAfter = delimiter.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
157
|
-
var entity = !isAfter ? delimiter.nextSibling : delimiter.previousSibling;
|
|
158
|
-
var block = getBlock(editor, delimiter);
|
|
159
|
-
editor.runAsync(function () {
|
|
160
|
-
if (!block) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
var blockToCheck = isAfter ? block.nextSibling : block.previousSibling;
|
|
164
|
-
if (blockToCheck && (0, roosterjs_content_model_dom_1.isNodeOfType)(blockToCheck, 'ELEMENT_NODE')) {
|
|
165
|
-
var delimiters = blockToCheck.querySelectorAll(DELIMITER_SELECTOR);
|
|
166
|
-
// Check if the last or first delimiter still contain the delimiter class and remove it.
|
|
167
|
-
var delimiterToCheck = delimiters.item(isAfter ? 0 : delimiters.length - 1);
|
|
168
|
-
removeDelimiterAttr(delimiterToCheck);
|
|
169
|
-
}
|
|
170
|
-
if (entity && (0, roosterjs_content_model_dom_1.isEntityElement)(entity)) {
|
|
171
|
-
var entityElement = entity;
|
|
172
|
-
var nextElementSibling = entityElement.nextElementSibling, previousElementSibling = entityElement.previousElementSibling;
|
|
173
|
-
[nextElementSibling, previousElementSibling].forEach(function (el) {
|
|
174
|
-
// Check if after Enter the ZWS got removed but we still have a element with the class
|
|
175
|
-
// Remove the attributes of the element if it is invalid now.
|
|
176
|
-
if (el && (0, roosterjs_editor_dom_1.matchesSelector)(el, DELIMITER_SELECTOR) && !(0, roosterjs_editor_dom_1.getDelimiterFromElement)(el)) {
|
|
177
|
-
removeDelimiterAttr(el, false /* checkEntity */);
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
// Add delimiters to the entity if needed because on Enter we can sometimes lose the ZWS of the element.
|
|
181
|
-
(0, roosterjs_content_model_dom_1.addDelimiters)(entityElement.ownerDocument, entityElement);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
var getPosition = function (container) {
|
|
186
|
-
if (container && (0, roosterjs_editor_dom_1.getDelimiterFromElement)(container)) {
|
|
187
|
-
var isAfter = container.classList.contains("entityDelimiterAfter" /* DELIMITER_AFTER */);
|
|
188
|
-
return new roosterjs_editor_dom_1.Position(container, isAfter ? -3 /* After */ : -2 /* Before */);
|
|
189
|
-
}
|
|
190
|
-
return undefined;
|
|
191
|
-
};
|
|
192
|
-
function getBlock(editor, element) {
|
|
193
|
-
var _a;
|
|
194
|
-
if (!element) {
|
|
195
|
-
return undefined;
|
|
196
|
-
}
|
|
197
|
-
var block = (_a = editor.getBlockElementAtNode(element)) === null || _a === void 0 ? void 0 : _a.getStartNode();
|
|
198
|
-
while (block && (!(0, roosterjs_content_model_dom_1.isNodeOfType)(block, 'ELEMENT_NODE') || !(0, roosterjs_content_model_dom_1.isBlockElement)(block))) {
|
|
199
|
-
block = editor.contains(block.parentElement) ? block.parentElement : undefined;
|
|
200
|
-
}
|
|
201
|
-
return block;
|
|
202
|
-
}
|
|
203
|
-
function handleSelectionNotCollapsed(editor, range, event) {
|
|
204
|
-
var startContainer = range.startContainer, endContainer = range.endContainer, startOffset = range.startOffset, endOffset = range.endOffset;
|
|
205
|
-
var startElement = editor.getElementAtCursor(DELIMITER_SELECTOR, startContainer);
|
|
206
|
-
var endElement = editor.getElementAtCursor(DELIMITER_SELECTOR, endContainer);
|
|
207
|
-
var startUpdate = getPosition(startElement);
|
|
208
|
-
var endUpdate = getPosition(endElement);
|
|
209
|
-
if (startUpdate || endUpdate) {
|
|
210
|
-
editor.select(startUpdate !== null && startUpdate !== void 0 ? startUpdate : new roosterjs_editor_dom_1.Position(startContainer, startOffset), endUpdate !== null && endUpdate !== void 0 ? endUpdate : new roosterjs_editor_dom_1.Position(endContainer, endOffset));
|
|
211
|
-
}
|
|
212
|
-
editor.runAsync(function (aEditor) {
|
|
213
|
-
var delimiter = aEditor.getElementAtCursor(DELIMITER_SELECTOR);
|
|
214
|
-
if (delimiter) {
|
|
215
|
-
preventTypeInDelimiter(delimiter);
|
|
216
|
-
if (event.which === 13 /* ENTER */) {
|
|
217
|
-
removeDelimiterAttr(delimiter);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
function handleKeyDownEvent(editor, event) {
|
|
223
|
-
var _a, _b;
|
|
224
|
-
var range = editor.getSelectionRangeEx();
|
|
225
|
-
var rawEvent = event.rawEvent;
|
|
226
|
-
if (range.type != 0 /* Normal */) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (range.areAllCollapsed && ((0, roosterjs_content_model_core_1.isCharacterValue)(rawEvent) || rawEvent.which === 13 /* ENTER */)) {
|
|
230
|
-
var position = (_a = editor.getFocusedPosition()) === null || _a === void 0 ? void 0 : _a.normalize();
|
|
231
|
-
if (!position) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
var element = position.element, node = position.node;
|
|
235
|
-
var refNode = element == node ? element.childNodes.item(position.offset) : element;
|
|
236
|
-
var delimiter_1 = editor.getElementAtCursor(DELIMITER_SELECTOR, refNode);
|
|
237
|
-
if (!delimiter_1) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (rawEvent.which === 13 /* ENTER */) {
|
|
241
|
-
handleCollapsedEnter(editor, delimiter_1);
|
|
242
|
-
}
|
|
243
|
-
else if (((_b = delimiter_1.firstChild) === null || _b === void 0 ? void 0 : _b.nodeType) == 3 /* Text */) {
|
|
244
|
-
editor.runAsync(function () { return preventTypeInDelimiter(delimiter_1); });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else if (!range.areAllCollapsed && !rawEvent.shiftKey && rawEvent.which != 16 /* SHIFT */) {
|
|
248
|
-
var currentRange = range.ranges[0];
|
|
249
|
-
if (!currentRange) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
handleSelectionNotCollapsed(editor, currentRange, rawEvent);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
//# 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":";;;;IAgCA,IAAM,kBAAkB,GACpB,GAAG,+CAAmC,GAAG,IAAI,iDAAoC,CAAC;IACtF,IAAM,gBAAgB,GAAG,QAAQ,CAAC;IAClC,IAAM,sBAAsB,GAAG,MAAM,GAAG,IAAA,wCAAiB,GAAE,CAAC;IAE5D;;OAEG;IACH;QAAA;YACY,WAAM,GAA+B,IAAI,CAAC;QAiEtD,CAAC;QA/DG;;WAEG;QACH,uCAAO,GAAP;YACI,OAAO,iBAAiB,CAAC;QAC7B,CAAC;QAED;;;;;WAKG;QACH,0CAAU,GAAV,UAAW,MAAe;YACtB,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;QAChD,CAAC;QAED;;;;WAI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MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;SAC/D;IACL,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":";;;;IAoBA;;;;;;;OAOG;IACH;QAGI;;;;WAIG;QACH,iCAAoB,uBAAiC;YAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;YAP7C,WAAM,GAA6B,IAAI,CAAC;QAOQ,CAAC;QAEzD;;WAEG;QACH,yCAAO,GAAP;YACI,OAAO,mBAAmB,CAAC;QAC/B,CAAC;QAED;;;;;WAKG;QACH,4CAAU,GAAV,UAAW,MAAyB;YAChC,gFAAgF;YAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACzB,CAAC;QAED;;;;WAIG;QACH,yCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;WAKG;QACH,+CAAa,GAAb,UAAc,KAAkB;YAC5B,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,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,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,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"]}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { keyboardDelete } from './keyboardDelete';
|
|
2
|
-
import { keyboardInput } from './keyboardInput';
|
|
3
|
-
/**
|
|
4
|
-
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
5
|
-
* This includes:
|
|
6
|
-
* 1. Delete Key
|
|
7
|
-
* 2. Backspace Key
|
|
8
|
-
*/
|
|
9
|
-
var ContentModelEditPlugin = /** @class */ (function () {
|
|
10
|
-
function ContentModelEditPlugin() {
|
|
11
|
-
this.editor = null;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get name of this plugin
|
|
15
|
-
*/
|
|
16
|
-
ContentModelEditPlugin.prototype.getName = function () {
|
|
17
|
-
return 'ContentModelEdit';
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
21
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
22
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
23
|
-
* @param editor The editor object
|
|
24
|
-
*/
|
|
25
|
-
ContentModelEditPlugin.prototype.initialize = function (editor) {
|
|
26
|
-
// TODO: Later we may need a different interface for Content Model editor plugin
|
|
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
|
-
ContentModelEditPlugin.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
|
-
ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
|
|
44
|
-
if (this.editor) {
|
|
45
|
-
switch (event.eventType) {
|
|
46
|
-
case 'keyDown':
|
|
47
|
-
this.handleKeyDownEvent(this.editor, event);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
53
|
-
var rawEvent = event.rawEvent;
|
|
54
|
-
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
55
|
-
switch (rawEvent.key) {
|
|
56
|
-
case 'Backspace':
|
|
57
|
-
case 'Delete':
|
|
58
|
-
// Use our API to handle BACKSPACE/DELETE key.
|
|
59
|
-
// No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache
|
|
60
|
-
keyboardDelete(editor, rawEvent);
|
|
61
|
-
break;
|
|
62
|
-
case 'Enter':
|
|
63
|
-
default:
|
|
64
|
-
keyboardInput(editor, rawEvent);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
return ContentModelEditPlugin;
|
|
70
|
-
}());
|
|
71
|
-
export { ContentModelEditPlugin };
|
|
72
|
-
//# sourceMappingURL=ContentModelEditPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD;;;;;GAKG;AACH;IAAA;QACY,WAAM,GAA6B,IAAI,CAAC;IAgEpD,CAAC;IA9DG;;OAEG;IACH,wCAAO,GAAP;QACI,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,2CAAU,GAAV,UAAW,MAAyB;QAChC,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,wCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,8CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,SAAS;oBACV,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,mDAAkB,GAA1B,UAA2B,MAAyB,EAAE,KAAmB;QACrE,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,QAAQ;oBACT,8CAA8C;oBAC9C,qIAAqI;oBACrI,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBACjC,MAAM;gBAEV,KAAK,OAAO,CAAC;gBACb;oBACI,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBAChC,MAAM;aACb;SACJ;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport type {\n EditorPlugin,\n IStandaloneEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * ContentModel edit plugins helps editor to do editing operation on top of content model.\n * This includes:\n * 1. Delete Key\n * 2. Backspace Key\n */\nexport class ContentModelEditPlugin implements EditorPlugin {\n private editor: IStandaloneEditor | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelEdit';\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) {\n switch (event.eventType) {\n case 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IStandaloneEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\n case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n\n case 'Enter':\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
|
|
2
|
-
/**
|
|
3
|
-
* Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
|
|
4
|
-
*/
|
|
5
|
-
export declare class EntityDelimiterPlugin implements EditorPlugin {
|
|
6
|
-
private editor;
|
|
7
|
-
/**
|
|
8
|
-
* Get a friendly name of this plugin
|
|
9
|
-
*/
|
|
10
|
-
getName(): string;
|
|
11
|
-
/**
|
|
12
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
13
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
14
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
15
|
-
* @param editor The editor object
|
|
16
|
-
*/
|
|
17
|
-
initialize(editor: IEditor): void;
|
|
18
|
-
/**
|
|
19
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
20
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
21
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
22
|
-
*/
|
|
23
|
-
dispose(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
26
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
27
|
-
* exclusively by another plugin.
|
|
28
|
-
* @param event The event to handle:
|
|
29
|
-
*/
|
|
30
|
-
onPluginEvent(event: PluginEvent): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export declare function normalizeDelimitersInEditor(editor: IEditor): void;
|