roosterjs-content-model-plugins 0.26.0 → 0.26.2
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 -53
- package/lib/autoFormat/AutoFormatPlugin.js +80 -80
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib/autoFormat/keyboardListTrigger.js +45 -45
- package/lib/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib/autoFormat/utils/convertAlphaToDecimals.js +22 -22
- package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib/autoFormat/utils/getIndex.js +13 -13
- package/lib/autoFormat/utils/getIndex.js.map +1 -1
- package/lib/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib/autoFormat/utils/getListTypeStyle.js +87 -87
- package/lib/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib/autoFormat/utils/getNumberingListStyle.js +153 -153
- package/lib/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/lib/edit/EditPlugin.d.ts +39 -39
- package/lib/edit/EditPlugin.js +128 -128
- package/lib/edit/EditPlugin.js.map +1 -1
- 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 -5
- package/lib/edit/inputSteps/handleEnterOnList.js +67 -67
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +9 -9
- package/lib/edit/keyboardDelete.js +71 -71
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +5 -5
- package/lib/edit/keyboardInput.js +58 -58
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.d.ts +5 -5
- package/lib/edit/keyboardTab.js +34 -34
- package/lib/edit/keyboardTab.js.map +1 -1
- 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/paste/PastePlugin.d.ts +43 -43
- package/lib/paste/PastePlugin.js +130 -130
- package/lib/paste/PastePlugin.js.map +1 -1
- 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 -35
- package/lib/pluginUtils/CreateElement/CreateElementData.js +2 -2
- package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib/pluginUtils/CreateElement/createElement.d.ts +9 -9
- package/lib/pluginUtils/CreateElement/createElement.js +50 -50
- package/lib/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib/pluginUtils/Disposable.d.ts +10 -10
- package/lib/pluginUtils/Disposable.js +2 -2
- package/lib/pluginUtils/Disposable.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -45
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js +2 -2
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -39
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +119 -119
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +27 -27
- package/lib/pluginUtils/Rect/getIntersectedRect.js +44 -44
- package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib/pluginUtils/Rect/normalizeRect.d.ts +7 -7
- package/lib/pluginUtils/Rect/normalizeRect.js +19 -19
- package/lib/pluginUtils/Rect/normalizeRect.js.map +1 -1
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +53 -53
- package/lib-amd/autoFormat/AutoFormatPlugin.js +81 -81
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib-amd/autoFormat/keyboardListTrigger.js +43 -43
- package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js +24 -24
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib-amd/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib-amd/autoFormat/utils/getIndex.js +14 -14
- package/lib-amd/autoFormat/utils/getIndex.js.map +1 -1
- package/lib-amd/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib-amd/autoFormat/utils/getListTypeStyle.js +86 -86
- package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib-amd/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js +153 -153
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/lib-amd/edit/EditPlugin.d.ts +39 -39
- package/lib-amd/edit/EditPlugin.js +127 -127
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- 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 -5
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +66 -66
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +9 -9
- package/lib-amd/edit/keyboardDelete.js +66 -66
- 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 -57
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.d.ts +5 -5
- package/lib-amd/edit/keyboardTab.js +34 -34
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- 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-amd/paste/PastePlugin.d.ts +43 -43
- package/lib-amd/paste/PastePlugin.js +122 -122
- package/lib-amd/paste/PastePlugin.js.map +1 -1
- 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 -35
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js +4 -4
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +9 -9
- package/lib-amd/pluginUtils/CreateElement/createElement.js +51 -51
- package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-amd/pluginUtils/Disposable.d.ts +10 -10
- package/lib-amd/pluginUtils/Disposable.js +4 -4
- package/lib-amd/pluginUtils/Disposable.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -45
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js +4 -4
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -39
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +120 -120
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +27 -27
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +44 -44
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +7 -7
- package/lib-amd/pluginUtils/Rect/normalizeRect.js +21 -21
- package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +1 -1
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +53 -53
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +77 -77
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +5 -5
- package/lib-mjs/autoFormat/keyboardListTrigger.js +41 -41
- package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.d.ts +7 -7
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js +18 -18
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getIndex.d.ts +4 -4
- package/lib-mjs/autoFormat/utils/getIndex.js +9 -9
- package/lib-mjs/autoFormat/utils/getIndex.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getListTypeStyle.d.ts +14 -14
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js +83 -83
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +1 -1
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.d.ts +4 -4
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js +149 -149
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +1 -1
- package/lib-mjs/edit/EditPlugin.d.ts +39 -39
- package/lib-mjs/edit/EditPlugin.js +125 -125
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- 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 -5
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +63 -63
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +9 -9
- package/lib-mjs/edit/keyboardDelete.js +67 -67
- 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 -54
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.d.ts +5 -5
- package/lib-mjs/edit/keyboardTab.js +30 -30
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/index.d.ts +3 -3
- package/lib-mjs/index.js +3 -3
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +12 -12
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PastePlugin.d.ts +43 -43
- package/lib-mjs/paste/PastePlugin.js +127 -127
- package/lib-mjs/paste/PastePlugin.js.map +1 -1
- 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 -35
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +9 -9
- package/lib-mjs/pluginUtils/CreateElement/createElement.js +47 -47
- package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-mjs/pluginUtils/Disposable.d.ts +10 -10
- package/lib-mjs/pluginUtils/Disposable.js +1 -1
- package/lib-mjs/pluginUtils/Disposable.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +45 -45
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +39 -39
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +117 -117
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +27 -27
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +41 -41
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +7 -7
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js +16 -16
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleEnterOnList = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
6
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
var handleEnterOnList = function (context) {
|
|
11
|
-
if (context.deleteResult == 'nothingToDelete' ||
|
|
12
|
-
context.deleteResult == 'notDeleted' ||
|
|
13
|
-
context.deleteResult == 'range') {
|
|
14
|
-
var insertPoint = context.insertPoint, formatContext = context.formatContext;
|
|
15
|
-
var path = insertPoint.path;
|
|
16
|
-
var rawEvent = formatContext === null || formatContext === void 0 ? void 0 : formatContext.rawEvent;
|
|
17
|
-
var index = (0, roosterjs_content_model_core_1.getClosestAncestorBlockGroupIndex)(path, ['ListItem'], ['TableCell']);
|
|
18
|
-
var listItem = path[index];
|
|
19
|
-
if (listItem && listItem.blockGroupType === 'ListItem') {
|
|
20
|
-
var listParent = path[index + 1];
|
|
21
|
-
if (isEmptyListItem(listItem)) {
|
|
22
|
-
listItem.levels.pop();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
createNewListItem(context, listItem, listParent);
|
|
26
|
-
}
|
|
27
|
-
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
28
|
-
context.deleteResult = 'range';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.handleEnterOnList = handleEnterOnList;
|
|
33
|
-
var isEmptyListItem = function (listItem) {
|
|
34
|
-
return (listItem.blocks.length === 1 &&
|
|
35
|
-
listItem.blocks[0].blockType === 'Paragraph' &&
|
|
36
|
-
listItem.blocks[0].segments.length === 2 &&
|
|
37
|
-
listItem.blocks[0].segments[0].segmentType === 'SelectionMarker' &&
|
|
38
|
-
listItem.blocks[0].segments[1].segmentType === 'Br');
|
|
39
|
-
};
|
|
40
|
-
var createNewListItem = function (context, listItem, listParent) {
|
|
41
|
-
var insertPoint = context.insertPoint;
|
|
42
|
-
var listIndex = listParent.blocks.indexOf(listItem);
|
|
43
|
-
var newParagraph = createNewParagraph(insertPoint);
|
|
44
|
-
var levels = createNewListLevel(listItem);
|
|
45
|
-
var newListItem = (0, roosterjs_content_model_dom_1.createListItem)(levels, insertPoint.marker.format);
|
|
46
|
-
newListItem.blocks.push(newParagraph);
|
|
47
|
-
listParent.blocks.splice(listIndex + 1, 0, newListItem);
|
|
48
|
-
};
|
|
49
|
-
var createNewListLevel = function (listItem) {
|
|
50
|
-
return listItem.levels.map(function (level) {
|
|
51
|
-
return (0, roosterjs_content_model_dom_1.createListLevel)(level.listType, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, level.format), { startNumberOverride: undefined }), level.dataset);
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
var createNewParagraph = function (insertPoint) {
|
|
55
|
-
var _a;
|
|
56
|
-
var paragraph = insertPoint.paragraph, marker = insertPoint.marker;
|
|
57
|
-
var newParagraph = (0, roosterjs_content_model_dom_1.createParagraph)(false /*isImplicit*/, paragraph.format, paragraph.segmentFormat);
|
|
58
|
-
var markerIndex = paragraph.segments.indexOf(marker);
|
|
59
|
-
var segments = paragraph.segments.splice(markerIndex, paragraph.segments.length - markerIndex);
|
|
60
|
-
(_a = newParagraph.segments).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(segments), false));
|
|
61
|
-
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
|
|
62
|
-
if (paragraph.segments.every(function (x) { return x.segmentType == 'SelectionMarker'; })) {
|
|
63
|
-
paragraph.segments.push((0, roosterjs_content_model_dom_1.createBr)(marker.format));
|
|
64
|
-
}
|
|
65
|
-
(0, roosterjs_content_model_dom_1.normalizeParagraph)(newParagraph);
|
|
66
|
-
return newParagraph;
|
|
67
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleEnterOnList = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
6
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
var handleEnterOnList = function (context) {
|
|
11
|
+
if (context.deleteResult == 'nothingToDelete' ||
|
|
12
|
+
context.deleteResult == 'notDeleted' ||
|
|
13
|
+
context.deleteResult == 'range') {
|
|
14
|
+
var insertPoint = context.insertPoint, formatContext = context.formatContext;
|
|
15
|
+
var path = insertPoint.path;
|
|
16
|
+
var rawEvent = formatContext === null || formatContext === void 0 ? void 0 : formatContext.rawEvent;
|
|
17
|
+
var index = (0, roosterjs_content_model_core_1.getClosestAncestorBlockGroupIndex)(path, ['ListItem'], ['TableCell']);
|
|
18
|
+
var listItem = path[index];
|
|
19
|
+
if (listItem && listItem.blockGroupType === 'ListItem') {
|
|
20
|
+
var listParent = path[index + 1];
|
|
21
|
+
if (isEmptyListItem(listItem)) {
|
|
22
|
+
listItem.levels.pop();
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
createNewListItem(context, listItem, listParent);
|
|
26
|
+
}
|
|
27
|
+
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
28
|
+
context.deleteResult = 'range';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.handleEnterOnList = handleEnterOnList;
|
|
33
|
+
var isEmptyListItem = function (listItem) {
|
|
34
|
+
return (listItem.blocks.length === 1 &&
|
|
35
|
+
listItem.blocks[0].blockType === 'Paragraph' &&
|
|
36
|
+
listItem.blocks[0].segments.length === 2 &&
|
|
37
|
+
listItem.blocks[0].segments[0].segmentType === 'SelectionMarker' &&
|
|
38
|
+
listItem.blocks[0].segments[1].segmentType === 'Br');
|
|
39
|
+
};
|
|
40
|
+
var createNewListItem = function (context, listItem, listParent) {
|
|
41
|
+
var insertPoint = context.insertPoint;
|
|
42
|
+
var listIndex = listParent.blocks.indexOf(listItem);
|
|
43
|
+
var newParagraph = createNewParagraph(insertPoint);
|
|
44
|
+
var levels = createNewListLevel(listItem);
|
|
45
|
+
var newListItem = (0, roosterjs_content_model_dom_1.createListItem)(levels, insertPoint.marker.format);
|
|
46
|
+
newListItem.blocks.push(newParagraph);
|
|
47
|
+
listParent.blocks.splice(listIndex + 1, 0, newListItem);
|
|
48
|
+
};
|
|
49
|
+
var createNewListLevel = function (listItem) {
|
|
50
|
+
return listItem.levels.map(function (level) {
|
|
51
|
+
return (0, roosterjs_content_model_dom_1.createListLevel)(level.listType, (0, tslib_1.__assign)((0, tslib_1.__assign)({}, level.format), { startNumberOverride: undefined }), level.dataset);
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
var createNewParagraph = function (insertPoint) {
|
|
55
|
+
var _a;
|
|
56
|
+
var paragraph = insertPoint.paragraph, marker = insertPoint.marker;
|
|
57
|
+
var newParagraph = (0, roosterjs_content_model_dom_1.createParagraph)(false /*isImplicit*/, paragraph.format, paragraph.segmentFormat);
|
|
58
|
+
var markerIndex = paragraph.segments.indexOf(marker);
|
|
59
|
+
var segments = paragraph.segments.splice(markerIndex, paragraph.segments.length - markerIndex);
|
|
60
|
+
(_a = newParagraph.segments).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(segments), false));
|
|
61
|
+
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
|
|
62
|
+
if (paragraph.segments.every(function (x) { return x.segmentType == 'SelectionMarker'; })) {
|
|
63
|
+
paragraph.segments.push((0, roosterjs_content_model_dom_1.createBr)(marker.format));
|
|
64
|
+
}
|
|
65
|
+
(0, roosterjs_content_model_dom_1.normalizeParagraph)(newParagraph);
|
|
66
|
+
return newParagraph;
|
|
67
|
+
};
|
|
68
68
|
//# sourceMappingURL=handleEnterOnList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts"],"names":[],"mappings":";;;;AAAA,6EAAiF;AACjF,2EAOqC;AASrC;;GAEG;AACI,IAAM,iBAAiB,GAAwB,UAAA,OAAO;IACzD,IACI,OAAO,CAAC,YAAY,IAAI,iBAAiB;QACzC,OAAO,CAAC,YAAY,IAAI,YAAY;QACpC,OAAO,CAAC,YAAY,IAAI,OAAO,EACjC;QACU,IAAA,WAAW,GAAoB,OAAO,YAA3B,EAAE,aAAa,GAAK,OAAO,cAAZ,CAAa;QACvC,IAAA,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAC7B,IAAM,QAAQ,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,CAAC;QACzC,IAAM,KAAK,GAAG,IAAA,gEAAiC,EAAC,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC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SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,EAAE;QACnE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAA,sCAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;KACpD;IAED,IAAA,gDAAkB,EAAC,YAAY,CAAC,CAAC;IACjC,OAAO,YAAY,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from 'roosterjs-content-model-core';\
|
|
1
|
+
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts"],"names":[],"mappings":";;;;AAAA,6EAAiF;AACjF,2EAOqC;AASrC;;GAEG;AACI,IAAM,iBAAiB,GAAwB,UAAA,OAAO;IACzD,IACI,OAAO,CAAC,YAAY,IAAI,iBAAiB;QACzC,OAAO,CAAC,YAAY,IAAI,YAAY;QACpC,OAAO,CAAC,YAAY,IAAI,OAAO,EACjC;QACU,IAAA,WAAW,GAAoB,OAAO,YAA3B,EAAE,aAAa,GAAK,OAAO,cAAZ,CAAa;QACvC,IAAA,IAAI,GAAK,WAAW,KAAhB,CAAiB;QAC7B,IAAM,QAAQ,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAQ,CAAC;QACzC,IAAM,KAAK,GAAG,IAAA,gEAAiC,EAAC,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;QAEnF,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,KAAK,UAAU,EAAE;YACpD,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACnC,IAAI,eAAe,CAAC,QAAQ,CAAC,EA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AAkB,EAAC,YAAY,CAAC,CAAC;IACjC,OAAO,YAAY,CAAC;AACxB,CAAC,CAAC","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from 'roosterjs-content-model-core';\nimport {\n createBr,\n createListItem,\n createListLevel,\n createParagraph,\n normalizeParagraph,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockGroup,\n ContentModelListItem,\n DeleteSelectionStep,\n InsertPoint,\n ValidDeleteSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleEnterOnList: DeleteSelectionStep = context => {\n if (\n context.deleteResult == 'nothingToDelete' ||\n context.deleteResult == 'notDeleted' ||\n context.deleteResult == 'range'\n ) {\n const { insertPoint, formatContext } = context;\n const { path } = insertPoint;\n const rawEvent = formatContext?.rawEvent;\n const index = getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell']);\n\n const listItem = path[index];\n\n if (listItem && listItem.blockGroupType === 'ListItem') {\n const listParent = path[index + 1];\n if (isEmptyListItem(listItem)) {\n listItem.levels.pop();\n } else {\n createNewListItem(context, listItem, listParent);\n }\n rawEvent?.preventDefault();\n context.deleteResult = 'range';\n }\n }\n};\n\nconst isEmptyListItem = (listItem: ContentModelListItem) => {\n return (\n listItem.blocks.length === 1 &&\n listItem.blocks[0].blockType === 'Paragraph' &&\n listItem.blocks[0].segments.length === 2 &&\n listItem.blocks[0].segments[0].segmentType === 'SelectionMarker' &&\n listItem.blocks[0].segments[1].segmentType === 'Br'\n );\n};\n\nconst createNewListItem = (\n context: ValidDeleteSelectionContext,\n listItem: ContentModelListItem,\n listParent: ContentModelBlockGroup\n) => {\n const { insertPoint } = context;\n const listIndex = listParent.blocks.indexOf(listItem);\n const newParagraph = createNewParagraph(insertPoint);\n const levels = createNewListLevel(listItem);\n const newListItem = createListItem(levels, insertPoint.marker.format);\n newListItem.blocks.push(newParagraph);\n listParent.blocks.splice(listIndex + 1, 0, newListItem);\n};\n\nconst createNewListLevel = (listItem: ContentModelListItem) => {\n return listItem.levels.map(level => {\n return createListLevel(\n level.listType,\n {\n ...level.format,\n startNumberOverride: undefined,\n },\n level.dataset\n );\n });\n};\n\nconst createNewParagraph = (insertPoint: InsertPoint) => {\n const { paragraph, marker } = insertPoint;\n const newParagraph = createParagraph(\n false /*isImplicit*/,\n paragraph.format,\n paragraph.segmentFormat\n );\n\n const markerIndex = paragraph.segments.indexOf(marker);\n const segments = paragraph.segments.splice(\n markerIndex,\n paragraph.segments.length - markerIndex\n );\n\n newParagraph.segments.push(...segments);\n\n setParagraphNotImplicit(paragraph);\n\n if (paragraph.segments.every(x => x.segmentType == 'SelectionMarker')) {\n paragraph.segments.push(createBr(marker.format));\n }\n\n normalizeParagraph(newParagraph);\n return newParagraph;\n};\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
5
|
-
* @param editor The Content Model Editor
|
|
6
|
-
* @param rawEvent DOM keyboard event
|
|
7
|
-
* @returns True if the event is handled by content model, otherwise false
|
|
8
|
-
*/
|
|
9
|
-
export declare function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent): boolean;
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
5
|
+
* @param editor The Content Model Editor
|
|
6
|
+
* @param rawEvent DOM keyboard event
|
|
7
|
+
* @returns True if the event is handled by content model, otherwise false
|
|
8
|
+
*/
|
|
9
|
+
export declare function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent): boolean;
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyboardDelete = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var deleteAllSegmentBefore_1 = require("./deleteSteps/deleteAllSegmentBefore");
|
|
6
|
-
var deleteList_1 = require("./deleteSteps/deleteList");
|
|
7
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
8
|
-
var handleKeyboardEventCommon_1 = require("./handleKeyboardEventCommon");
|
|
9
|
-
var deleteWordSelection_1 = require("./deleteSteps/deleteWordSelection");
|
|
10
|
-
var deleteCollapsedSelection_1 = require("./deleteSteps/deleteCollapsedSelection");
|
|
11
|
-
/**
|
|
12
|
-
* @internal
|
|
13
|
-
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
14
|
-
* @param editor The Content Model Editor
|
|
15
|
-
* @param rawEvent DOM keyboard event
|
|
16
|
-
* @returns True if the event is handled by content model, otherwise false
|
|
17
|
-
*/
|
|
18
|
-
function keyboardDelete(editor, rawEvent) {
|
|
19
|
-
var handled = false;
|
|
20
|
-
var selection = editor.getDOMSelection();
|
|
21
|
-
if (shouldDeleteWithContentModel(selection, rawEvent)) {
|
|
22
|
-
editor.formatContentModel(function (model, context) {
|
|
23
|
-
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
|
|
24
|
-
handled = (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
|
|
25
|
-
return handled;
|
|
26
|
-
}, {
|
|
27
|
-
rawEvent: rawEvent,
|
|
28
|
-
changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
|
|
29
|
-
getChangeData: function () { return rawEvent.which; },
|
|
30
|
-
apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return handled;
|
|
34
|
-
}
|
|
35
|
-
exports.keyboardDelete = keyboardDelete;
|
|
36
|
-
function getDeleteSteps(rawEvent, isMac) {
|
|
37
|
-
var isForward = rawEvent.key == 'Delete';
|
|
38
|
-
var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
|
|
39
|
-
var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
|
|
40
|
-
? isForward
|
|
41
|
-
? deleteWordSelection_1.forwardDeleteWordSelection
|
|
42
|
-
: deleteWordSelection_1.backwardDeleteWordSelection
|
|
43
|
-
: null;
|
|
44
|
-
var deleteCollapsedSelection = isForward
|
|
45
|
-
? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
|
|
46
|
-
: deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
|
|
47
|
-
return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection, deleteList_1.deleteList];
|
|
48
|
-
}
|
|
49
|
-
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
50
|
-
if (!selection) {
|
|
51
|
-
return false; // Nothing to delete
|
|
52
|
-
}
|
|
53
|
-
else if (selection.type != 'range' || !selection.range.collapsed) {
|
|
54
|
-
return true; // Selection is not collapsed, need to delete all selections
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
var range = selection.range;
|
|
58
|
-
// When selection is collapsed and is in middle of text node, no need to use Content Model to delete
|
|
59
|
-
return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
|
|
60
|
-
!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
61
|
-
(canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function canDeleteBefore(rawEvent, range) {
|
|
65
|
-
return rawEvent.key == 'Backspace' && range.startOffset > 1;
|
|
66
|
-
}
|
|
67
|
-
function canDeleteAfter(rawEvent, range) {
|
|
68
|
-
var _a, _b;
|
|
69
|
-
return (rawEvent.key == 'Delete' &&
|
|
70
|
-
range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
|
|
71
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyboardDelete = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var deleteAllSegmentBefore_1 = require("./deleteSteps/deleteAllSegmentBefore");
|
|
6
|
+
var deleteList_1 = require("./deleteSteps/deleteList");
|
|
7
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
8
|
+
var handleKeyboardEventCommon_1 = require("./handleKeyboardEventCommon");
|
|
9
|
+
var deleteWordSelection_1 = require("./deleteSteps/deleteWordSelection");
|
|
10
|
+
var deleteCollapsedSelection_1 = require("./deleteSteps/deleteCollapsedSelection");
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
14
|
+
* @param editor The Content Model Editor
|
|
15
|
+
* @param rawEvent DOM keyboard event
|
|
16
|
+
* @returns True if the event is handled by content model, otherwise false
|
|
17
|
+
*/
|
|
18
|
+
function keyboardDelete(editor, rawEvent) {
|
|
19
|
+
var handled = false;
|
|
20
|
+
var selection = editor.getDOMSelection();
|
|
21
|
+
if (shouldDeleteWithContentModel(selection, rawEvent)) {
|
|
22
|
+
editor.formatContentModel(function (model, context) {
|
|
23
|
+
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
|
|
24
|
+
handled = (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
|
|
25
|
+
return handled;
|
|
26
|
+
}, {
|
|
27
|
+
rawEvent: rawEvent,
|
|
28
|
+
changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
|
|
29
|
+
getChangeData: function () { return rawEvent.which; },
|
|
30
|
+
apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return handled;
|
|
34
|
+
}
|
|
35
|
+
exports.keyboardDelete = keyboardDelete;
|
|
36
|
+
function getDeleteSteps(rawEvent, isMac) {
|
|
37
|
+
var isForward = rawEvent.key == 'Delete';
|
|
38
|
+
var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
|
|
39
|
+
var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
|
|
40
|
+
? isForward
|
|
41
|
+
? deleteWordSelection_1.forwardDeleteWordSelection
|
|
42
|
+
: deleteWordSelection_1.backwardDeleteWordSelection
|
|
43
|
+
: null;
|
|
44
|
+
var deleteCollapsedSelection = isForward
|
|
45
|
+
? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
|
|
46
|
+
: deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
|
|
47
|
+
return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection, deleteList_1.deleteList];
|
|
48
|
+
}
|
|
49
|
+
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
50
|
+
if (!selection) {
|
|
51
|
+
return false; // Nothing to delete
|
|
52
|
+
}
|
|
53
|
+
else if (selection.type != 'range' || !selection.range.collapsed) {
|
|
54
|
+
return true; // Selection is not collapsed, need to delete all selections
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
var range = selection.range;
|
|
58
|
+
// When selection is collapsed and is in middle of text node, no need to use Content Model to delete
|
|
59
|
+
return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
|
|
60
|
+
!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
61
|
+
(canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function canDeleteBefore(rawEvent, range) {
|
|
65
|
+
return rawEvent.key == 'Backspace' && range.startOffset > 1;
|
|
66
|
+
}
|
|
67
|
+
function canDeleteAfter(rawEvent, range) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
return (rawEvent.key == 'Delete' &&
|
|
70
|
+
range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
|
|
71
|
+
}
|
|
72
72
|
//# sourceMappingURL=keyboardDelete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;AAAA,6EAA4F;AAC5F,+EAA8E;AAC9E,uDAAsD;AACtD,2EAA2D;AAC3D,yEAIqC;AACrC,yEAG2C;AAC3C,mFAGgD;AAOhD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,MAAyB,EAAE,QAAuB;IAC7E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,EACzD,OAAO,CACV,CAAC,YAAY,CAAC;YAEf,OAAO,GAAG,IAAA,qDAAyB,EAAC,MAAM,EAAE,KAAK,EAAE,QAAQ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AC5E;SAAM;QACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAE9B,oGAAoG;QACpG,OAAO,CAAC,CACJ,IAAA,0CAAY,EAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;YAC/C,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CACxE,CAAC;KACL;AACL,CAAC;AAED,SAAS,eAAe,CAAC,QAAuB,EAAE,KAAY;IAC1D,OAAO,QAAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;IACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;QACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;AACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\
|
|
1
|
+
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;AAAA,6EAA4F;AAC5F,+EAA8E;AAC9E,uDAAsD;AACtD,2EAA2D;AAC3D,yEAIqC;AACrC,yEAG2C;AAC3C,mFAGgD;AAOhD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,MAAyB,EAAE,QAAuB;IAC7E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QACnD,MAAM,CAAC,kBAAkB,CACr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AACnG,CAAC;AAED,SAAS,4BAA4B,CAAC,SAA8B,EAAE,QAAuB;IACzF,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;QAChE,OAAO,IAAI,CAAC,CAAC,4DAA4D;KAC5E;SAAM;QACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAE9B,oGAAoG;QACpG,OAAO,CAAC,CACJ,IAAA,0CAAY,EAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;YAC/C,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CACxE,CAAC;KACL;AACL,CAAC;AAED,SAAS,eAAe,CAAC,QAAuB,EAAE,KAAY;IAC1D,OAAO,QAAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;IACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;QACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;AACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { deleteList } from './deleteSteps/deleteList';\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\nimport {\n handleKeyboardEventResult,\n shouldDeleteAllSegmentsBefore,\n shouldDeleteWord,\n} from './handleKeyboardEventCommon';\nimport {\n backwardDeleteWordSelection,\n forwardDeleteWordSelection,\n} from './deleteSteps/deleteWordSelection';\nimport {\n backwardDeleteCollapsedSelection,\n forwardDeleteCollapsedSelection,\n} from './deleteSteps/deleteCollapsedSelection';\nimport type {\n DOMSelection,\n DeleteSelectionStep,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Do keyboard event handling for DELETE/BACKSPACE key\n * @param editor The Content Model Editor\n * @param rawEvent DOM keyboard event\n * @returns True if the event is handled by content model, otherwise false\n */\nexport function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n let handled = false;\n const selection = editor.getDOMSelection();\n\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(\n model,\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\n context\n ).deleteResult;\n\n handled = handleKeyboardEventResult(editor, model, rawEvent, result, context);\n return handled;\n },\n {\n rawEvent,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\n }\n );\n }\n\n return handled;\n}\n\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\n const isForward = rawEvent.key == 'Delete';\n const deleteAllSegmentBeforeStep =\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\n ? isForward\n ? forwardDeleteWordSelection\n : backwardDeleteWordSelection\n : null;\n const deleteCollapsedSelection = isForward\n ? forwardDeleteCollapsedSelection\n : backwardDeleteCollapsedSelection;\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection, deleteList];\n}\n\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (selection.type != 'range' || !selection.range.collapsed) {\n return true; // Selection is not collapsed, need to delete all selections\n } else {\n const range = selection.range;\n\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\n return !(\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\n !isModifierKey(rawEvent) &&\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\n );\n }\n}\n\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\n}\n\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\n return (\n rawEvent.key == 'Delete' &&\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\n );\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyboardInput = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var handleEnterOnList_1 = require("./inputSteps/handleEnterOnList");
|
|
6
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
-
/**
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
function keyboardInput(editor, rawEvent) {
|
|
11
|
-
var selection = editor.getDOMSelection();
|
|
12
|
-
if (shouldInputWithContentModel(selection, rawEvent)) {
|
|
13
|
-
editor.takeSnapshot();
|
|
14
|
-
editor.formatContentModel(function (model, context) {
|
|
15
|
-
var _a;
|
|
16
|
-
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getInputSteps(selection, rawEvent), context);
|
|
17
|
-
// We have deleted selection then we will let browser to handle the input.
|
|
18
|
-
// With this combined operation, we don't wan to mass up the cached model so clear it
|
|
19
|
-
context.clearModelCache = true;
|
|
20
|
-
// Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
|
|
21
|
-
context.skipUndoSnapshot = true;
|
|
22
|
-
if (result.deleteResult == 'range') {
|
|
23
|
-
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
24
|
-
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
25
|
-
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
26
|
-
// Do not preventDefault since we still want browser to handle the final input for now
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
rawEvent: rawEvent,
|
|
34
|
-
});
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.keyboardInput = keyboardInput;
|
|
39
|
-
function getInputSteps(selection, rawEvent) {
|
|
40
|
-
return shouldHandleEnterKey(selection, rawEvent) ? [handleEnterOnList_1.handleEnterOnList] : [];
|
|
41
|
-
}
|
|
42
|
-
function shouldInputWithContentModel(selection, rawEvent) {
|
|
43
|
-
if (!selection) {
|
|
44
|
-
return false; // Nothing to delete
|
|
45
|
-
}
|
|
46
|
-
else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
47
|
-
(rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
|
|
48
|
-
return (selection.type != 'range' ||
|
|
49
|
-
!selection.range.collapsed ||
|
|
50
|
-
shouldHandleEnterKey(selection, rawEvent));
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var shouldHandleEnterKey = function (selection, rawEvent) {
|
|
57
|
-
return selection && selection.type == 'range' && rawEvent.key == 'Enter' && !rawEvent.shiftKey;
|
|
58
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyboardInput = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var handleEnterOnList_1 = require("./inputSteps/handleEnterOnList");
|
|
6
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
function keyboardInput(editor, rawEvent) {
|
|
11
|
+
var selection = editor.getDOMSelection();
|
|
12
|
+
if (shouldInputWithContentModel(selection, rawEvent)) {
|
|
13
|
+
editor.takeSnapshot();
|
|
14
|
+
editor.formatContentModel(function (model, context) {
|
|
15
|
+
var _a;
|
|
16
|
+
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getInputSteps(selection, rawEvent), context);
|
|
17
|
+
// We have deleted selection then we will let browser to handle the input.
|
|
18
|
+
// With this combined operation, we don't wan to mass up the cached model so clear it
|
|
19
|
+
context.clearModelCache = true;
|
|
20
|
+
// Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
|
|
21
|
+
context.skipUndoSnapshot = true;
|
|
22
|
+
if (result.deleteResult == 'range') {
|
|
23
|
+
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
24
|
+
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
25
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
26
|
+
// Do not preventDefault since we still want browser to handle the final input for now
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
rawEvent: rawEvent,
|
|
34
|
+
});
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.keyboardInput = keyboardInput;
|
|
39
|
+
function getInputSteps(selection, rawEvent) {
|
|
40
|
+
return shouldHandleEnterKey(selection, rawEvent) ? [handleEnterOnList_1.handleEnterOnList] : [];
|
|
41
|
+
}
|
|
42
|
+
function shouldInputWithContentModel(selection, rawEvent) {
|
|
43
|
+
if (!selection) {
|
|
44
|
+
return false; // Nothing to delete
|
|
45
|
+
}
|
|
46
|
+
else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
47
|
+
(rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
|
|
48
|
+
return (selection.type != 'range' ||
|
|
49
|
+
!selection.range.collapsed ||
|
|
50
|
+
shouldHandleEnterKey(selection, rawEvent));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
var shouldHandleEnterKey = function (selection, rawEvent) {
|
|
57
|
+
return selection && selection.type == 'range' && rawEvent.key == 'Enter' && !rawEvent.shiftKey;
|
|
58
|
+
};
|
|
59
59
|
//# sourceMappingURL=keyboardInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;AAC9E,oEAAmE;AACnE,2EAAoE;AAGpE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAyB,EAAE,QAAuB;IAC5E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QAClD,MAAM,CAAC,YAAY,EAAE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AAI,OAAO;YACzB,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS;YAC1B,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC5C,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AAED,IAAM,oBAAoB,GAAG,UAAC,SAA8B,EAAE,QAAuB;IACjF,OAAO,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACnG,CAAC,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;AAC9E,oEAAmE;AACnE,2EAAoE;AAGpE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAyB,EAAE,QAAuB;IAC5E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QAClD,MAAM,CAAC,YAAY,EAAE,CAAC;QAEtB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;YAEnF,0EAA0E;YAC1E,qFAAqF;YACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,oJAAoJ;YACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;gBAChC,2HAA2H;gBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;gBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;gBAE7B,sFAAsF;gBACtF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,QAAQ,UAAA;SACX,CACJ,CAAC;QAEF,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AApCD,sCAoCC;AAED,SAAS,aAAa,CAAC,SAA8B,EAAE,QAAuB;IAC1E,OAAO,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,qCAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChF,CAAC;AAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;IACxF,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;QACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;QACE,OAAO,CACH,SAAS,CAAC,IAAI,IAAI,OAAO;YACzB,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS;YAC1B,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC5C,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC;AAED,IAAM,oBAAoB,GAAG,UAAC,SAA8B,EAAE,QAAuB;IACjF,OAAO,SAAS,IAAI,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACnG,CAAC,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { handleEnterOnList } from './inputSteps/handleEnterOnList';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { DOMSelection, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.takeSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, getInputSteps(selection, rawEvent), context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction getInputSteps(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n return shouldHandleEnterKey(selection, rawEvent) ? [handleEnterOnList] : [];\n}\n\nfunction shouldInputWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return (\n selection.type != 'range' ||\n !selection.range.collapsed ||\n shouldHandleEnterKey(selection, rawEvent)\n );\n } else {\n return false;\n }\n}\n\nconst shouldHandleEnterKey = (selection: DOMSelection | null, rawEvent: KeyboardEvent) => {\n return selection && selection.type == 'range' && rawEvent.key == 'Enter' && !rawEvent.shiftKey;\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare function keyboardTab(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function keyboardTab(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
package/lib/edit/keyboardTab.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyboardTab = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
function keyboardTab(editor, rawEvent) {
|
|
10
|
-
var selection = editor.getDOMSelection();
|
|
11
|
-
if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
|
|
12
|
-
editor.takeSnapshot();
|
|
13
|
-
editor.formatContentModel(function (model, _context) {
|
|
14
|
-
return handleTabOnList(model, rawEvent);
|
|
15
|
-
});
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.keyboardTab = keyboardTab;
|
|
20
|
-
function isMarkerAtStartOfBlock(listItem) {
|
|
21
|
-
return (listItem.blocks[0].blockType == 'Paragraph' &&
|
|
22
|
-
listItem.blocks[0].segments[0].segmentType == 'SelectionMarker');
|
|
23
|
-
}
|
|
24
|
-
function handleTabOnList(model, rawEvent) {
|
|
25
|
-
var blocks = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['ListItem'], ['TableCell']);
|
|
26
|
-
var listItem = blocks[0].block;
|
|
27
|
-
if ((0, roosterjs_content_model_core_1.isBlockGroupOfType)(listItem, 'ListItem') &&
|
|
28
|
-
isMarkerAtStartOfBlock(listItem)) {
|
|
29
|
-
(0, roosterjs_content_model_api_1.setModelIndentation)(model, rawEvent.shiftKey ? 'outdent' : 'indent');
|
|
30
|
-
rawEvent.preventDefault();
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyboardTab = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var roosterjs_content_model_api_1 = require("roosterjs-content-model-api");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function keyboardTab(editor, rawEvent) {
|
|
10
|
+
var selection = editor.getDOMSelection();
|
|
11
|
+
if ((selection === null || selection === void 0 ? void 0 : selection.type) == 'range') {
|
|
12
|
+
editor.takeSnapshot();
|
|
13
|
+
editor.formatContentModel(function (model, _context) {
|
|
14
|
+
return handleTabOnList(model, rawEvent);
|
|
15
|
+
});
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.keyboardTab = keyboardTab;
|
|
20
|
+
function isMarkerAtStartOfBlock(listItem) {
|
|
21
|
+
return (listItem.blocks[0].blockType == 'Paragraph' &&
|
|
22
|
+
listItem.blocks[0].segments[0].segmentType == 'SelectionMarker');
|
|
23
|
+
}
|
|
24
|
+
function handleTabOnList(model, rawEvent) {
|
|
25
|
+
var blocks = (0, roosterjs_content_model_core_1.getOperationalBlocks)(model, ['ListItem'], ['TableCell']);
|
|
26
|
+
var listItem = blocks[0].block;
|
|
27
|
+
if ((0, roosterjs_content_model_core_1.isBlockGroupOfType)(listItem, 'ListItem') &&
|
|
28
|
+
isMarkerAtStartOfBlock(listItem)) {
|
|
29
|
+
(0, roosterjs_content_model_api_1.setModelIndentation)(model, rawEvent.shiftKey ? 'outdent' : 'indent');
|
|
30
|
+
rawEvent.preventDefault();
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
35
|
//# sourceMappingURL=keyboardTab.js.map
|