roosterjs-content-model-plugins 9.4.0 → 9.5.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/README.md +10 -10
- package/lib/autoFormat/hyphen/transformHyphen.d.ts +2 -2
- package/lib/autoFormat/hyphen/transformHyphen.js.map +1 -1
- package/lib/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib/autoFormat/numbers/transformFraction.d.ts +2 -2
- package/lib/autoFormat/numbers/transformFraction.js.map +1 -1
- package/lib/autoFormat/numbers/transformOrdinals.d.ts +2 -2
- package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -1
- package/lib/customReplace/CustomReplacePlugin.d.ts +2 -2
- package/lib/customReplace/CustomReplacePlugin.js.map +1 -1
- package/lib/edit/EditPlugin.d.ts +10 -0
- package/lib/edit/EditPlugin.js +39 -0
- package/lib/edit/EditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +2 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +5 -4
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteEmptyQuote.js +33 -29
- package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +32 -56
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnParagraph.d.ts +5 -0
- package/lib/edit/inputSteps/handleEnterOnParagraph.js +22 -0
- package/lib/edit/inputSteps/handleEnterOnParagraph.js.map +1 -0
- package/lib/edit/keyboardDelete.js +1 -1
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardEnter.d.ts +5 -0
- package/lib/edit/keyboardEnter.js +44 -0
- package/lib/edit/keyboardEnter.js.map +1 -0
- package/lib/edit/keyboardInput.js +4 -18
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnParagraph.js +9 -7
- package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnTable.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnTable.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnTableCell.d.ts +2 -2
- package/lib/edit/tabUtils/handleTabOnTableCell.js +5 -4
- package/lib/edit/tabUtils/handleTabOnTableCell.js.map +1 -1
- package/lib/edit/utils/getLeafSiblingBlock.d.ts +5 -5
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib/edit/utils/splitParagraph.d.ts +9 -0
- package/lib/edit/utils/splitParagraph.js +29 -0
- package/lib/edit/utils/splitParagraph.js.map +1 -0
- package/lib/imageEdit/Cropper/createImageCropper.d.ts +10 -0
- package/lib/imageEdit/Cropper/createImageCropper.js +80 -0
- package/lib/imageEdit/Cropper/createImageCropper.js.map +1 -0
- package/lib/imageEdit/Cropper/cropperContext.d.ts +8 -0
- package/lib/imageEdit/Cropper/cropperContext.js +73 -0
- package/lib/imageEdit/Cropper/cropperContext.js.map +1 -0
- package/lib/imageEdit/ImageEditPlugin.d.ts +66 -0
- package/lib/imageEdit/ImageEditPlugin.js +328 -0
- package/lib/imageEdit/ImageEditPlugin.js.map +1 -0
- package/lib/imageEdit/Resizer/createImageResizer.d.ts +12 -0
- package/lib/imageEdit/Resizer/createImageResizer.js +89 -0
- package/lib/imageEdit/Resizer/createImageResizer.js.map +1 -0
- package/lib/imageEdit/Resizer/resizerContext.d.ts +8 -0
- package/lib/imageEdit/Resizer/resizerContext.js +61 -0
- package/lib/imageEdit/Resizer/resizerContext.js.map +1 -0
- package/lib/imageEdit/Resizer/updateSideHandlesVisibility.d.ts +4 -0
- package/lib/imageEdit/Resizer/updateSideHandlesVisibility.js +17 -0
- package/lib/imageEdit/Resizer/updateSideHandlesVisibility.js.map +1 -0
- package/lib/imageEdit/Rotator/createImageRotator.d.ts +6 -0
- package/lib/imageEdit/Rotator/createImageRotator.js +76 -0
- package/lib/imageEdit/Rotator/createImageRotator.js.map +1 -0
- package/lib/imageEdit/Rotator/rotatorContext.d.ts +8 -0
- package/lib/imageEdit/Rotator/rotatorContext.js +36 -0
- package/lib/imageEdit/Rotator/rotatorContext.js.map +1 -0
- package/lib/imageEdit/Rotator/updateRotateHandle.d.ts +7 -0
- package/lib/imageEdit/Rotator/updateRotateHandle.js +55 -0
- package/lib/imageEdit/Rotator/updateRotateHandle.js.map +1 -0
- package/lib/imageEdit/constants/constants.d.ts +73 -0
- package/lib/imageEdit/constants/constants.js +81 -0
- package/lib/imageEdit/constants/constants.js.map +1 -0
- package/lib/imageEdit/types/DragAndDropContext.d.ts +39 -0
- package/lib/imageEdit/types/DragAndDropContext.js +3 -0
- package/lib/imageEdit/types/DragAndDropContext.js.map +1 -0
- package/lib/imageEdit/types/GeneratedImageSize.d.ts +33 -0
- package/lib/imageEdit/types/GeneratedImageSize.js +3 -0
- package/lib/imageEdit/types/GeneratedImageSize.js.map +1 -0
- package/lib/imageEdit/types/ImageEditElementClass.d.ts +30 -0
- package/lib/imageEdit/types/ImageEditElementClass.js +35 -0
- package/lib/imageEdit/types/ImageEditElementClass.js.map +1 -0
- package/lib/imageEdit/types/ImageEditOptions.d.ts +55 -0
- package/lib/imageEdit/types/ImageEditOptions.js +3 -0
- package/lib/imageEdit/types/ImageEditOptions.js.map +1 -0
- package/lib/imageEdit/types/ImageHtmlOptions.d.ts +18 -0
- package/lib/imageEdit/types/ImageHtmlOptions.js +3 -0
- package/lib/imageEdit/types/ImageHtmlOptions.js.map +1 -0
- package/lib/imageEdit/utils/applyChange.d.ts +12 -0
- package/lib/imageEdit/utils/applyChange.js +77 -0
- package/lib/imageEdit/utils/applyChange.js.map +1 -0
- package/lib/imageEdit/utils/canRegenerateImage.d.ts +8 -0
- package/lib/imageEdit/utils/canRegenerateImage.js +32 -0
- package/lib/imageEdit/utils/canRegenerateImage.js.map +1 -0
- package/lib/imageEdit/utils/checkEditInfoState.d.ts +41 -0
- package/lib/imageEdit/utils/checkEditInfoState.js +54 -0
- package/lib/imageEdit/utils/checkEditInfoState.js.map +1 -0
- package/lib/imageEdit/utils/createImageWrapper.d.ts +18 -0
- package/lib/imageEdit/utils/createImageWrapper.js +87 -0
- package/lib/imageEdit/utils/createImageWrapper.js.map +1 -0
- package/lib/imageEdit/utils/doubleCheckResize.d.ts +12 -0
- package/lib/imageEdit/utils/doubleCheckResize.js +36 -0
- package/lib/imageEdit/utils/doubleCheckResize.js.map +1 -0
- package/lib/imageEdit/utils/generateDataURL.d.ts +13 -0
- package/lib/imageEdit/utils/generateDataURL.js +50 -0
- package/lib/imageEdit/utils/generateDataURL.js.map +1 -0
- package/lib/imageEdit/utils/generateImageSize.d.ts +15 -0
- package/lib/imageEdit/utils/generateImageSize.js +46 -0
- package/lib/imageEdit/utils/generateImageSize.js.map +1 -0
- package/lib/imageEdit/utils/getDropAndDragHelpers.d.ts +10 -0
- package/lib/imageEdit/utils/getDropAndDragHelpers.js +24 -0
- package/lib/imageEdit/utils/getDropAndDragHelpers.js.map +1 -0
- package/lib/imageEdit/utils/getHTMLImageOptions.d.ts +7 -0
- package/lib/imageEdit/utils/getHTMLImageOptions.js +22 -0
- package/lib/imageEdit/utils/getHTMLImageOptions.js.map +1 -0
- package/lib/imageEdit/utils/getSelectedContentModelImage.d.ts +5 -0
- package/lib/imageEdit/utils/getSelectedContentModelImage.js +16 -0
- package/lib/imageEdit/utils/getSelectedContentModelImage.js.map +1 -0
- package/lib/imageEdit/utils/imageEditUtils.d.ts +39 -0
- package/lib/imageEdit/utils/imageEditUtils.js +102 -0
- package/lib/imageEdit/utils/imageEditUtils.js.map +1 -0
- package/lib/imageEdit/utils/updateHandleCursor.d.ts +7 -0
- package/lib/imageEdit/utils/updateHandleCursor.js +34 -0
- package/lib/imageEdit/utils/updateHandleCursor.js.map +1 -0
- package/lib/imageEdit/utils/updateImageEditInfo.d.ts +10 -0
- package/lib/imageEdit/utils/updateImageEditInfo.js +49 -0
- package/lib/imageEdit/utils/updateImageEditInfo.js.map +1 -0
- package/lib/imageEdit/utils/updateWrapper.d.ts +6 -0
- package/lib/imageEdit/utils/updateWrapper.js +87 -0
- package/lib/imageEdit/utils/updateWrapper.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/paste/DefaultSanitizers.d.ts +10 -0
- package/lib/paste/DefaultSanitizers.js +25 -0
- package/lib/paste/DefaultSanitizers.js.map +1 -0
- package/lib/paste/PastePlugin.d.ts +4 -2
- package/lib/paste/PastePlugin.js +26 -1
- package/lib/paste/PastePlugin.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -0
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/utils/chainSanitizerCallback.d.ts +9 -0
- package/lib/paste/utils/chainSanitizerCallback.js +36 -0
- package/lib/paste/utils/chainSanitizerCallback.js.map +1 -0
- package/lib/picker/getQueryString.d.ts +2 -2
- package/lib/picker/getQueryString.js.map +1 -1
- package/lib/pluginUtils/splitTextSegment.d.ts +2 -2
- package/lib/pluginUtils/splitTextSegment.js.map +1 -1
- package/lib/tableEdit/editors/TableEditor.d.ts +3 -0
- package/lib/tableEdit/editors/TableEditor.js +4 -0
- package/lib/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib/tableEdit/editors/features/CellResizer.d.ts +39 -1
- package/lib/tableEdit/editors/features/CellResizer.js +27 -11
- package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib/tableEdit/editors/features/TableInserter.d.ts +17 -0
- package/lib/tableEdit/editors/features/TableInserter.js +6 -1
- package/lib/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib/tableEdit/editors/features/TableMover.d.ts +2 -2
- package/lib/tableEdit/editors/features/TableMover.js +4 -4
- package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib/tableEdit/editors/features/TableResizer.d.ts +40 -1
- package/lib/tableEdit/editors/features/TableResizer.js +25 -7
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib/tableEdit/editors/utils/getTableFromContentModel.d.ts +2 -2
- package/lib/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
- package/lib-amd/autoFormat/hyphen/transformHyphen.d.ts +2 -2
- package/lib-amd/autoFormat/hyphen/transformHyphen.js.map +1 -1
- package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-amd/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-amd/autoFormat/numbers/transformFraction.d.ts +2 -2
- package/lib-amd/autoFormat/numbers/transformFraction.js.map +1 -1
- package/lib-amd/autoFormat/numbers/transformOrdinals.d.ts +2 -2
- package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -1
- package/lib-amd/customReplace/CustomReplacePlugin.d.ts +2 -2
- package/lib-amd/customReplace/CustomReplacePlugin.js.map +1 -1
- package/lib-amd/edit/EditPlugin.d.ts +10 -0
- package/lib-amd/edit/EditPlugin.js +38 -1
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +2 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +5 -4
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +33 -30
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +32 -57
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnParagraph.d.ts +5 -0
- package/lib-amd/edit/inputSteps/handleEnterOnParagraph.js +22 -0
- package/lib-amd/edit/inputSteps/handleEnterOnParagraph.js.map +1 -0
- package/lib-amd/edit/keyboardDelete.js +1 -1
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardEnter.d.ts +5 -0
- package/lib-amd/edit/keyboardEnter.js +42 -0
- package/lib-amd/edit/keyboardEnter.js.map +1 -0
- package/lib-amd/edit/keyboardInput.js +5 -17
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +9 -7
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnTable.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnTable.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.d.ts +2 -2
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.js +5 -4
- package/lib-amd/edit/tabUtils/handleTabOnTableCell.js.map +1 -1
- package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +5 -5
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-amd/edit/utils/splitParagraph.d.ts +9 -0
- package/lib-amd/edit/utils/splitParagraph.js +29 -0
- package/lib-amd/edit/utils/splitParagraph.js.map +1 -0
- package/lib-amd/imageEdit/Cropper/createImageCropper.d.ts +10 -0
- package/lib-amd/imageEdit/Cropper/createImageCropper.js +78 -0
- package/lib-amd/imageEdit/Cropper/createImageCropper.js.map +1 -0
- package/lib-amd/imageEdit/Cropper/cropperContext.d.ts +8 -0
- package/lib-amd/imageEdit/Cropper/cropperContext.js +73 -0
- package/lib-amd/imageEdit/Cropper/cropperContext.js.map +1 -0
- package/lib-amd/imageEdit/ImageEditPlugin.d.ts +66 -0
- package/lib-amd/imageEdit/ImageEditPlugin.js +315 -0
- package/lib-amd/imageEdit/ImageEditPlugin.js.map +1 -0
- package/lib-amd/imageEdit/Resizer/createImageResizer.d.ts +12 -0
- package/lib-amd/imageEdit/Resizer/createImageResizer.js +86 -0
- package/lib-amd/imageEdit/Resizer/createImageResizer.js.map +1 -0
- package/lib-amd/imageEdit/Resizer/resizerContext.d.ts +8 -0
- package/lib-amd/imageEdit/Resizer/resizerContext.js +61 -0
- package/lib-amd/imageEdit/Resizer/resizerContext.js.map +1 -0
- package/lib-amd/imageEdit/Resizer/updateSideHandlesVisibility.d.ts +4 -0
- package/lib-amd/imageEdit/Resizer/updateSideHandlesVisibility.js +19 -0
- package/lib-amd/imageEdit/Resizer/updateSideHandlesVisibility.js.map +1 -0
- package/lib-amd/imageEdit/Rotator/createImageRotator.d.ts +6 -0
- package/lib-amd/imageEdit/Rotator/createImageRotator.js +74 -0
- package/lib-amd/imageEdit/Rotator/createImageRotator.js.map +1 -0
- package/lib-amd/imageEdit/Rotator/rotatorContext.d.ts +8 -0
- package/lib-amd/imageEdit/Rotator/rotatorContext.js +36 -0
- package/lib-amd/imageEdit/Rotator/rotatorContext.js.map +1 -0
- package/lib-amd/imageEdit/Rotator/updateRotateHandle.d.ts +7 -0
- package/lib-amd/imageEdit/Rotator/updateRotateHandle.js +56 -0
- package/lib-amd/imageEdit/Rotator/updateRotateHandle.js.map +1 -0
- package/lib-amd/imageEdit/constants/constants.d.ts +73 -0
- package/lib-amd/imageEdit/constants/constants.js +83 -0
- package/lib-amd/imageEdit/constants/constants.js.map +1 -0
- package/lib-amd/imageEdit/types/DragAndDropContext.d.ts +39 -0
- package/lib-amd/imageEdit/types/DragAndDropContext.js +5 -0
- package/lib-amd/imageEdit/types/DragAndDropContext.js.map +1 -0
- package/lib-amd/imageEdit/types/GeneratedImageSize.d.ts +33 -0
- package/lib-amd/imageEdit/types/GeneratedImageSize.js +5 -0
- package/lib-amd/imageEdit/types/GeneratedImageSize.js.map +1 -0
- package/lib-amd/imageEdit/types/ImageEditElementClass.d.ts +30 -0
- package/lib-amd/imageEdit/types/ImageEditElementClass.js +37 -0
- package/lib-amd/imageEdit/types/ImageEditElementClass.js.map +1 -0
- package/lib-amd/imageEdit/types/ImageEditOptions.d.ts +55 -0
- package/lib-amd/imageEdit/types/ImageEditOptions.js +5 -0
- package/lib-amd/imageEdit/types/ImageEditOptions.js.map +1 -0
- package/lib-amd/imageEdit/types/ImageHtmlOptions.d.ts +18 -0
- package/lib-amd/imageEdit/types/ImageHtmlOptions.js +5 -0
- package/lib-amd/imageEdit/types/ImageHtmlOptions.js.map +1 -0
- package/lib-amd/imageEdit/utils/applyChange.d.ts +12 -0
- package/lib-amd/imageEdit/utils/applyChange.js +75 -0
- package/lib-amd/imageEdit/utils/applyChange.js.map +1 -0
- package/lib-amd/imageEdit/utils/canRegenerateImage.d.ts +8 -0
- package/lib-amd/imageEdit/utils/canRegenerateImage.js +34 -0
- package/lib-amd/imageEdit/utils/canRegenerateImage.js.map +1 -0
- package/lib-amd/imageEdit/utils/checkEditInfoState.d.ts +41 -0
- package/lib-amd/imageEdit/utils/checkEditInfoState.js +55 -0
- package/lib-amd/imageEdit/utils/checkEditInfoState.js.map +1 -0
- package/lib-amd/imageEdit/utils/createImageWrapper.d.ts +18 -0
- package/lib-amd/imageEdit/utils/createImageWrapper.js +86 -0
- package/lib-amd/imageEdit/utils/createImageWrapper.js.map +1 -0
- package/lib-amd/imageEdit/utils/doubleCheckResize.d.ts +12 -0
- package/lib-amd/imageEdit/utils/doubleCheckResize.js +38 -0
- package/lib-amd/imageEdit/utils/doubleCheckResize.js.map +1 -0
- package/lib-amd/imageEdit/utils/generateDataURL.d.ts +13 -0
- package/lib-amd/imageEdit/utils/generateDataURL.js +51 -0
- package/lib-amd/imageEdit/utils/generateDataURL.js.map +1 -0
- package/lib-amd/imageEdit/utils/generateImageSize.d.ts +15 -0
- package/lib-amd/imageEdit/utils/generateImageSize.js +48 -0
- package/lib-amd/imageEdit/utils/generateImageSize.js.map +1 -0
- package/lib-amd/imageEdit/utils/getDropAndDragHelpers.d.ts +10 -0
- package/lib-amd/imageEdit/utils/getDropAndDragHelpers.js +24 -0
- package/lib-amd/imageEdit/utils/getDropAndDragHelpers.js.map +1 -0
- package/lib-amd/imageEdit/utils/getHTMLImageOptions.d.ts +7 -0
- package/lib-amd/imageEdit/utils/getHTMLImageOptions.js +23 -0
- package/lib-amd/imageEdit/utils/getHTMLImageOptions.js.map +1 -0
- package/lib-amd/imageEdit/utils/getSelectedContentModelImage.d.ts +5 -0
- package/lib-amd/imageEdit/utils/getSelectedContentModelImage.js +17 -0
- package/lib-amd/imageEdit/utils/getSelectedContentModelImage.js.map +1 -0
- package/lib-amd/imageEdit/utils/imageEditUtils.d.ts +39 -0
- package/lib-amd/imageEdit/utils/imageEditUtils.js +103 -0
- package/lib-amd/imageEdit/utils/imageEditUtils.js.map +1 -0
- package/lib-amd/imageEdit/utils/updateHandleCursor.d.ts +7 -0
- package/lib-amd/imageEdit/utils/updateHandleCursor.js +36 -0
- package/lib-amd/imageEdit/utils/updateHandleCursor.js.map +1 -0
- package/lib-amd/imageEdit/utils/updateImageEditInfo.d.ts +10 -0
- package/lib-amd/imageEdit/utils/updateImageEditInfo.js +48 -0
- package/lib-amd/imageEdit/utils/updateImageEditInfo.js.map +1 -0
- package/lib-amd/imageEdit/utils/updateWrapper.d.ts +6 -0
- package/lib-amd/imageEdit/utils/updateWrapper.js +82 -0
- package/lib-amd/imageEdit/utils/updateWrapper.js.map +1 -0
- package/lib-amd/index.d.ts +2 -1
- package/lib-amd/index.js +3 -3
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/DefaultSanitizers.d.ts +10 -0
- package/lib-amd/paste/DefaultSanitizers.js +27 -0
- package/lib-amd/paste/DefaultSanitizers.js.map +1 -0
- package/lib-amd/paste/PastePlugin.d.ts +4 -2
- package/lib-amd/paste/PastePlugin.js +24 -2
- package/lib-amd/paste/PastePlugin.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -0
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/utils/chainSanitizerCallback.d.ts +9 -0
- package/lib-amd/paste/utils/chainSanitizerCallback.js +38 -0
- package/lib-amd/paste/utils/chainSanitizerCallback.js.map +1 -0
- package/lib-amd/picker/getQueryString.d.ts +2 -2
- package/lib-amd/picker/getQueryString.js.map +1 -1
- package/lib-amd/pluginUtils/splitTextSegment.d.ts +2 -2
- package/lib-amd/pluginUtils/splitTextSegment.js.map +1 -1
- package/lib-amd/tableEdit/editors/TableEditor.d.ts +3 -0
- package/lib-amd/tableEdit/editors/TableEditor.js +4 -0
- package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +39 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.js +27 -11
- package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +17 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.js +6 -1
- package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableMover.d.ts +2 -2
- package/lib-amd/tableEdit/editors/features/TableMover.js +4 -4
- package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +40 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.js +25 -7
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-amd/tableEdit/editors/utils/getTableFromContentModel.d.ts +2 -2
- package/lib-amd/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
- package/lib-mjs/autoFormat/hyphen/transformHyphen.d.ts +2 -2
- package/lib-mjs/autoFormat/hyphen/transformHyphen.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +2 -2
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -1
- package/lib-mjs/autoFormat/list/keyboardListTrigger.d.ts +2 -2
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
- package/lib-mjs/autoFormat/numbers/transformFraction.d.ts +2 -2
- package/lib-mjs/autoFormat/numbers/transformFraction.js.map +1 -1
- package/lib-mjs/autoFormat/numbers/transformOrdinals.d.ts +2 -2
- package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -1
- package/lib-mjs/customReplace/CustomReplacePlugin.d.ts +2 -2
- package/lib-mjs/customReplace/CustomReplacePlugin.js.map +1 -1
- package/lib-mjs/edit/EditPlugin.d.ts +10 -0
- package/lib-mjs/edit/EditPlugin.js +39 -0
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +3 -2
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +5 -4
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +34 -30
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +2 -2
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -2
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +33 -57
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnParagraph.d.ts +5 -0
- package/lib-mjs/edit/inputSteps/handleEnterOnParagraph.js +18 -0
- package/lib-mjs/edit/inputSteps/handleEnterOnParagraph.js.map +1 -0
- package/lib-mjs/edit/keyboardDelete.js +1 -1
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardEnter.d.ts +5 -0
- package/lib-mjs/edit/keyboardEnter.js +40 -0
- package/lib-mjs/edit/keyboardEnter.js.map +1 -0
- package/lib-mjs/edit/keyboardInput.js +4 -18
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +9 -7
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnTable.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnTable.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.d.ts +2 -2
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js +6 -5
- package/lib-mjs/edit/tabUtils/handleTabOnTableCell.js.map +1 -1
- package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +5 -5
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/edit/utils/splitParagraph.d.ts +9 -0
- package/lib-mjs/edit/utils/splitParagraph.js +25 -0
- package/lib-mjs/edit/utils/splitParagraph.js.map +1 -0
- package/lib-mjs/imageEdit/Cropper/createImageCropper.d.ts +10 -0
- package/lib-mjs/imageEdit/Cropper/createImageCropper.js +75 -0
- package/lib-mjs/imageEdit/Cropper/createImageCropper.js.map +1 -0
- package/lib-mjs/imageEdit/Cropper/cropperContext.d.ts +8 -0
- package/lib-mjs/imageEdit/Cropper/cropperContext.js +70 -0
- package/lib-mjs/imageEdit/Cropper/cropperContext.js.map +1 -0
- package/lib-mjs/imageEdit/ImageEditPlugin.d.ts +66 -0
- package/lib-mjs/imageEdit/ImageEditPlugin.js +325 -0
- package/lib-mjs/imageEdit/ImageEditPlugin.js.map +1 -0
- package/lib-mjs/imageEdit/Resizer/createImageResizer.d.ts +12 -0
- package/lib-mjs/imageEdit/Resizer/createImageResizer.js +85 -0
- package/lib-mjs/imageEdit/Resizer/createImageResizer.js.map +1 -0
- package/lib-mjs/imageEdit/Resizer/resizerContext.d.ts +8 -0
- package/lib-mjs/imageEdit/Resizer/resizerContext.js +58 -0
- package/lib-mjs/imageEdit/Resizer/resizerContext.js.map +1 -0
- package/lib-mjs/imageEdit/Resizer/updateSideHandlesVisibility.d.ts +4 -0
- package/lib-mjs/imageEdit/Resizer/updateSideHandlesVisibility.js +13 -0
- package/lib-mjs/imageEdit/Resizer/updateSideHandlesVisibility.js.map +1 -0
- package/lib-mjs/imageEdit/Rotator/createImageRotator.d.ts +6 -0
- package/lib-mjs/imageEdit/Rotator/createImageRotator.js +72 -0
- package/lib-mjs/imageEdit/Rotator/createImageRotator.js.map +1 -0
- package/lib-mjs/imageEdit/Rotator/rotatorContext.d.ts +8 -0
- package/lib-mjs/imageEdit/Rotator/rotatorContext.js +33 -0
- package/lib-mjs/imageEdit/Rotator/rotatorContext.js.map +1 -0
- package/lib-mjs/imageEdit/Rotator/updateRotateHandle.d.ts +7 -0
- package/lib-mjs/imageEdit/Rotator/updateRotateHandle.js +51 -0
- package/lib-mjs/imageEdit/Rotator/updateRotateHandle.js.map +1 -0
- package/lib-mjs/imageEdit/constants/constants.d.ts +73 -0
- package/lib-mjs/imageEdit/constants/constants.js +78 -0
- package/lib-mjs/imageEdit/constants/constants.js.map +1 -0
- package/lib-mjs/imageEdit/types/DragAndDropContext.d.ts +39 -0
- package/lib-mjs/imageEdit/types/DragAndDropContext.js +2 -0
- package/lib-mjs/imageEdit/types/DragAndDropContext.js.map +1 -0
- package/lib-mjs/imageEdit/types/GeneratedImageSize.d.ts +33 -0
- package/lib-mjs/imageEdit/types/GeneratedImageSize.js +2 -0
- package/lib-mjs/imageEdit/types/GeneratedImageSize.js.map +1 -0
- package/lib-mjs/imageEdit/types/ImageEditElementClass.d.ts +30 -0
- package/lib-mjs/imageEdit/types/ImageEditElementClass.js +32 -0
- package/lib-mjs/imageEdit/types/ImageEditElementClass.js.map +1 -0
- package/lib-mjs/imageEdit/types/ImageEditOptions.d.ts +55 -0
- package/lib-mjs/imageEdit/types/ImageEditOptions.js +2 -0
- package/lib-mjs/imageEdit/types/ImageEditOptions.js.map +1 -0
- package/lib-mjs/imageEdit/types/ImageHtmlOptions.d.ts +18 -0
- package/lib-mjs/imageEdit/types/ImageHtmlOptions.js +2 -0
- package/lib-mjs/imageEdit/types/ImageHtmlOptions.js.map +1 -0
- package/lib-mjs/imageEdit/utils/applyChange.d.ts +12 -0
- package/lib-mjs/imageEdit/utils/applyChange.js +73 -0
- package/lib-mjs/imageEdit/utils/applyChange.js.map +1 -0
- package/lib-mjs/imageEdit/utils/canRegenerateImage.d.ts +8 -0
- package/lib-mjs/imageEdit/utils/canRegenerateImage.js +28 -0
- package/lib-mjs/imageEdit/utils/canRegenerateImage.js.map +1 -0
- package/lib-mjs/imageEdit/utils/checkEditInfoState.d.ts +41 -0
- package/lib-mjs/imageEdit/utils/checkEditInfoState.js +50 -0
- package/lib-mjs/imageEdit/utils/checkEditInfoState.js.map +1 -0
- package/lib-mjs/imageEdit/utils/createImageWrapper.d.ts +18 -0
- package/lib-mjs/imageEdit/utils/createImageWrapper.js +83 -0
- package/lib-mjs/imageEdit/utils/createImageWrapper.js.map +1 -0
- package/lib-mjs/imageEdit/utils/doubleCheckResize.d.ts +12 -0
- package/lib-mjs/imageEdit/utils/doubleCheckResize.js +32 -0
- package/lib-mjs/imageEdit/utils/doubleCheckResize.js.map +1 -0
- package/lib-mjs/imageEdit/utils/generateDataURL.d.ts +13 -0
- package/lib-mjs/imageEdit/utils/generateDataURL.js +46 -0
- package/lib-mjs/imageEdit/utils/generateDataURL.js.map +1 -0
- package/lib-mjs/imageEdit/utils/generateImageSize.d.ts +15 -0
- package/lib-mjs/imageEdit/utils/generateImageSize.js +42 -0
- package/lib-mjs/imageEdit/utils/generateImageSize.js.map +1 -0
- package/lib-mjs/imageEdit/utils/getDropAndDragHelpers.d.ts +10 -0
- package/lib-mjs/imageEdit/utils/getDropAndDragHelpers.js +20 -0
- package/lib-mjs/imageEdit/utils/getDropAndDragHelpers.js.map +1 -0
- package/lib-mjs/imageEdit/utils/getHTMLImageOptions.d.ts +7 -0
- package/lib-mjs/imageEdit/utils/getHTMLImageOptions.js +18 -0
- package/lib-mjs/imageEdit/utils/getHTMLImageOptions.js.map +1 -0
- package/lib-mjs/imageEdit/utils/getSelectedContentModelImage.d.ts +5 -0
- package/lib-mjs/imageEdit/utils/getSelectedContentModelImage.js +12 -0
- package/lib-mjs/imageEdit/utils/getSelectedContentModelImage.js.map +1 -0
- package/lib-mjs/imageEdit/utils/imageEditUtils.d.ts +39 -0
- package/lib-mjs/imageEdit/utils/imageEditUtils.js +91 -0
- package/lib-mjs/imageEdit/utils/imageEditUtils.js.map +1 -0
- package/lib-mjs/imageEdit/utils/updateHandleCursor.d.ts +7 -0
- package/lib-mjs/imageEdit/utils/updateHandleCursor.js +30 -0
- package/lib-mjs/imageEdit/utils/updateHandleCursor.js.map +1 -0
- package/lib-mjs/imageEdit/utils/updateImageEditInfo.d.ts +10 -0
- package/lib-mjs/imageEdit/utils/updateImageEditInfo.js +44 -0
- package/lib-mjs/imageEdit/utils/updateImageEditInfo.js.map +1 -0
- package/lib-mjs/imageEdit/utils/updateWrapper.d.ts +6 -0
- package/lib-mjs/imageEdit/utils/updateWrapper.js +83 -0
- package/lib-mjs/imageEdit/utils/updateWrapper.js.map +1 -0
- package/lib-mjs/index.d.ts +2 -1
- package/lib-mjs/index.js +1 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/DefaultSanitizers.d.ts +10 -0
- package/lib-mjs/paste/DefaultSanitizers.js +21 -0
- package/lib-mjs/paste/DefaultSanitizers.js.map +1 -0
- package/lib-mjs/paste/PastePlugin.d.ts +4 -2
- package/lib-mjs/paste/PastePlugin.js +27 -2
- package/lib-mjs/paste/PastePlugin.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -0
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/utils/chainSanitizerCallback.d.ts +9 -0
- package/lib-mjs/paste/utils/chainSanitizerCallback.js +32 -0
- package/lib-mjs/paste/utils/chainSanitizerCallback.js.map +1 -0
- package/lib-mjs/picker/getQueryString.d.ts +2 -2
- package/lib-mjs/picker/getQueryString.js.map +1 -1
- package/lib-mjs/pluginUtils/splitTextSegment.d.ts +2 -2
- package/lib-mjs/pluginUtils/splitTextSegment.js.map +1 -1
- package/lib-mjs/tableEdit/editors/TableEditor.d.ts +3 -0
- package/lib-mjs/tableEdit/editors/TableEditor.js +4 -0
- package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +39 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.js +27 -14
- package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +17 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.js +5 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +2 -2
- package/lib-mjs/tableEdit/editors/features/TableMover.js +5 -5
- package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +40 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +25 -10
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-mjs/tableEdit/editors/utils/getTableFromContentModel.d.ts +2 -2
- package/lib-mjs/tableEdit/editors/utils/getTableFromContentModel.js.map +1 -1
- package/package.json +5 -5
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.d.ts +0 -7
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js +0 -57
- package/lib/pluginUtils/Rect/getDOMInsertPointRect.js.map +0 -1
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.d.ts +0 -7
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js +0 -58
- package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js.map +0 -1
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.d.ts +0 -7
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js +0 -53
- package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js.map +0 -1
package/README.md
CHANGED
|
@@ -51,22 +51,22 @@ There are also some extension packages to provide additional functionalities.
|
|
|
51
51
|
1. [roosterjs-color-utils](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_color_utils.html):
|
|
52
52
|
Provide color transformation utility to make editor work under dark mode.
|
|
53
53
|
|
|
54
|
-
2. [roosterjs-react](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_react.html):
|
|
55
|
-
Provide a React wrapper of roosterjs so it can be easily used with React.
|
|
56
|
-
|
|
57
54
|
To be compatible with old (8.\*) versions, you can use `EditorAdapter` class from the following package which can act as a 8.\* Editor:
|
|
58
55
|
|
|
59
56
|
1. [roosterjs-editor-adapter](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_adapter.html):
|
|
60
57
|
Provide a adapter class `EditorAdapter` to work with Editor (9.\*) and legacy plugins (via [EditorAdapterOptions.legacyPlugins](https://microsoft.github.io/roosterjs/docs/interfaces/roosterjs_editor_adapter.editoradapteroptions.html#legacyplugins))
|
|
61
58
|
|
|
62
|
-
|
|
59
|
+
All old packages (8.\*) are moved to branch [roosterjsv8](https://github.com/microsoft/roosterjs/tree/roosterjsv8), including
|
|
60
|
+
|
|
61
|
+
1. roosterjs-editor-core
|
|
62
|
+
2. roosterjs-editor-api
|
|
63
|
+
3. roosterjs-editor-dom
|
|
64
|
+
4. roosterjs-editor-plugins
|
|
65
|
+
5. roosterjs-editor-types
|
|
66
|
+
6. roosterjs-editor-types-compatible
|
|
67
|
+
7. roosterjs-react
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
2. [roosterjs-editor-api](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_api.html):
|
|
66
|
-
3. [roosterjs-editor-dom](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_dom.html):
|
|
67
|
-
4. [roosterjs-editor-plugins](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_plugins.html):
|
|
68
|
-
5. [roosterjs-editor-types](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types.html):
|
|
69
|
-
6. [roosterjs-editor-types-compatible](https://microsoft.github.io/roosterjs/docs/modules/roosterjs_editor_types_compatible.html):
|
|
69
|
+
We will not update these branches any more unless there are new security bugs.
|
|
70
70
|
|
|
71
71
|
### APIs
|
|
72
72
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelText, FormatContentModelContext, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function transformHyphen(previousSegment: ContentModelText, paragraph:
|
|
5
|
+
export declare function transformHyphen(previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformHyphen.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE;;GAEG;AACH,SAAgB,eAAe,CAC3B,eAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"transformHyphen.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/hyphen/transformHyphen.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE;;GAEG;AACH,SAAgB,eAAe,CAC3B,eAAiC,EACjC,SAA8C,EAC9C,OAAkC;IAElC,IAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjD,IAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,IAAI,MAAM,KAAK,IAAI,EAAE;QACjB,IAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACzD,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAAC,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;QAE3F,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACvD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;KACf;SAAM;QACH,IAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAM,SAAS,GAAG,IAAI,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC,IAAI,CAAC,IAAG,CAAC,CAAC,CAAC;QACnD,IAAI,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;YACnC,IAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACrD,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,eAAe,EACf,SAAS,EACT,SAAS,EACT,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAC9B,CAAC;YAEF,IAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;YAC3C,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;gBACzE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;gBACvD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;gBAClC,OAAO,IAAI,CAAC;aACf;SACJ;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAnCD,0CAmCC","sourcesContent":["import { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelText,\n FormatContentModelContext,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function transformHyphen(\n previousSegment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n context: FormatContentModelContext\n): boolean {\n const segments = previousSegment.text.split(' ');\n const dashes = segments[segments.length - 2];\n if (dashes === '--') {\n const textIndex = previousSegment.text.lastIndexOf('--');\n const textSegment = splitTextSegment(previousSegment, paragraph, textIndex, textIndex + 2);\n\n textSegment.text = textSegment.text.replace('--', '—');\n context.canUndoByBackspace = true;\n return true;\n } else {\n const text = segments.pop();\n const hasDashes = text && text?.indexOf('--') > -1;\n if (hasDashes && text.trim() !== '--') {\n const textIndex = previousSegment.text.indexOf(text);\n const textSegment = splitTextSegment(\n previousSegment,\n paragraph,\n textIndex,\n textIndex + text.length - 1\n );\n\n const textLength = textSegment.text.length;\n if (textSegment.text[0] !== '-' && textSegment.text[textLength - 1] !== '-') {\n textSegment.text = textSegment.text.replace('--', '—');\n context.canUndoByBackspace = true;\n return true;\n }\n }\n }\n return false;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelText, FormatContentModelContext, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function createLinkAfterSpace(previousSegment: ContentModelText, paragraph:
|
|
5
|
+
export declare function createLinkAfterSpace(previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":";;;AAAA,2EAAwD;AACxD,uEAAsE;AAQtE;;GAEG;AACH,SAAgB,oBAAoB,CAChC,eAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"createLinkAfterSpace.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/link/createLinkAfterSpace.ts"],"names":[],"mappings":";;;AAAA,2EAAwD;AACxD,uEAAsE;AAQtE;;GAEG;AACH,SAAgB,oBAAoB,CAChC,eAAiC,EACjC,SAA8C,EAC9C,OAAkC;IAElC,IAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACnD,IAAM,GAAG,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAC;IACzB,IAAI,QAAQ,GAAoB,IAAI,CAAC;IACrC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,QAAQ,GAAG,IAAA,uCAAS,EAAC,GAAG,CAAC,CAAC,EAAE;QAC5C,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAChC,eAAe,EACf,SAAS,EACT,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EACpD,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAC1C,CAAC;QACF,WAAW,CAAC,IAAI,GAAG;YACf,MAAM,EAAE;gBACJ,IAAI,EAAE,QAAQ,CAAC,aAAa;gBAC5B,SAAS,EAAE,IAAI;aAClB;YACD,OAAO,EAAE,EAAE;SACd,CAAC;QAEF,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAElC,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AA5BD,oDA4BC","sourcesContent":["import { matchLink } from 'roosterjs-content-model-api';\nimport { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelText,\n FormatContentModelContext,\n LinkData,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function createLinkAfterSpace(\n previousSegment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n context: FormatContentModelContext\n) {\n const link = previousSegment.text.split(' ').pop();\n const url = link?.trim();\n let linkData: LinkData | null = null;\n if (url && link && (linkData = matchLink(url))) {\n const linkSegment = splitTextSegment(\n previousSegment,\n paragraph,\n previousSegment.text.length - link.trimLeft().length,\n previousSegment.text.trimRight().length\n );\n linkSegment.link = {\n format: {\n href: linkData.normalizedUrl,\n underline: true,\n },\n dataset: {},\n };\n\n context.canUndoByBackspace = true;\n\n return true;\n }\n return false;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormatContentModelContext, ReadonlyContentModelDocument, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function keyboardListTrigger(model:
|
|
5
|
+
export declare function keyboardListTrigger(model: ReadonlyContentModelDocument, paragraph: ShallowMutableContentModelParagraph, context: FormatContentModelContext, shouldSearchForBullet?: boolean, shouldSearchForNumbering?: boolean): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardListTrigger.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/list/keyboardListTrigger.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD,2EAIqC;AAOrC;;GAEG;AACH,SAAgB,mBAAmB,CAC/B,
|
|
1
|
+
{"version":3,"file":"keyboardListTrigger.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/list/keyboardListTrigger.ts"],"names":[],"mappings":";;;AAAA,uDAAsD;AACtD,2EAIqC;AAOrC;;GAEG;AACH,SAAgB,mBAAmB,CAC/B,KAAmC,EACnC,SAA8C,EAC9C,OAAkC,EAClC,qBAAqC,EACrC,wBAAwC;IADxC,sCAAA,EAAA,4BAAqC;IACrC,yCAAA,EAAA,+BAAwC;IAExC,IAAM,aAAa,GAAG,IAAA,mCAAgB,EAAC,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,CAAC,CAAC;IAC/F,IAAI,aAAa,EAAE;QACf,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,IAAA,QAAQ,GAAuB,aAAa,SAApC,EAAE,SAAS,GAAY,aAAa,UAAzB,EAAE,KAAK,GAAK,aAAa,MAAlB,CAAmB;QACrD,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAElC,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAjBD,kDAiBC;AAED,IAAM,WAAW,GAAG,UAChB,KAAmC,EACnC,QAAqB,EACrB,SAAiB,EACjB,KAAc;IAEd,IAAA,yCAAW,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7B,IAAM,aAAa,GAAG,QAAQ,IAAI,IAAI,CAAC;IACvC,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,IAAI,aAAa,EAAE;QACrC,IAAA,qDAAuB,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACzC;IACD,IAAA,+CAAiB,EACb,KAAK,EACL,aAAa;QACT,CAAC,CAAC;YACI,gBAAgB,EAAE,SAAS;SAC9B;QACH,CAAC,CAAC;YACI,kBAAkB,EAAE,SAAS;SAChC,CACV,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { getListTypeStyle } from './getListTypeStyle';\nimport {\n setListType,\n setModelListStartNumber,\n setModelListStyle,\n} from 'roosterjs-content-model-api';\nimport type {\n FormatContentModelContext,\n ReadonlyContentModelDocument,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardListTrigger(\n model: ReadonlyContentModelDocument,\n paragraph: ShallowMutableContentModelParagraph,\n context: FormatContentModelContext,\n shouldSearchForBullet: boolean = true,\n shouldSearchForNumbering: boolean = true\n) {\n const listStyleType = getListTypeStyle(model, shouldSearchForBullet, shouldSearchForNumbering);\n if (listStyleType) {\n paragraph.segments.splice(0, 1);\n const { listType, styleType, index } = listStyleType;\n triggerList(model, listType, styleType, index);\n context.canUndoByBackspace = true;\n\n return true;\n }\n return false;\n}\n\nconst triggerList = (\n model: ReadonlyContentModelDocument,\n listType: 'OL' | 'UL',\n styleType: number,\n index?: number\n) => {\n setListType(model, listType);\n const isOrderedList = listType == 'OL';\n if (index && index > 1 && isOrderedList) {\n setModelListStartNumber(model, index);\n }\n setModelListStyle(\n model,\n isOrderedList\n ? {\n orderedStyleType: styleType,\n }\n : {\n unorderedStyleType: styleType,\n }\n );\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelText, FormatContentModelContext, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function transformFraction(previousSegment: ContentModelText, paragraph:
|
|
5
|
+
export declare function transformFraction(previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformFraction.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE,IAAM,SAAS,GAA2B;IACtC,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;CACb,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,eAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"transformFraction.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformFraction.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE,IAAM,SAAS,GAA2B;IACtC,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;CACb,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,eAAiC,EACjC,SAA8C,EAC9C,OAAkC;;IAElC,IAAM,QAAQ,GAAG,MAAA,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,IAAI,EAAE,CAAC;IAC/D,IAAI,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE;QACjC,IAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACnD,IAAM,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;QAC/C,IAAM,WAAW,GAAG,IAAA,mCAAgB,EAAC,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;QACxF,WAAW,CAAC,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEvC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAClC,OAAO,IAAI,CAAC;KACf;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAjBD,8CAiBC","sourcesContent":["import { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelText,\n FormatContentModelContext,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\nconst FRACTIONS: Record<string, string> = {\n '1/2': '½',\n '1/4': '¼',\n '3/4': '¾',\n};\n\n/**\n * @internal\n */\nexport function transformFraction(\n previousSegment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n context: FormatContentModelContext\n): boolean {\n const fraction = previousSegment.text.split(' ').pop()?.trim();\n if (fraction && FRACTIONS[fraction]) {\n const textLength = previousSegment.text.length - 1;\n const textIndex = textLength - fraction.length;\n const textSegment = splitTextSegment(previousSegment, paragraph, textIndex, textLength);\n textSegment.text = FRACTIONS[fraction];\n\n context.canUndoByBackspace = true;\n return true;\n }\n\n return false;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelText, FormatContentModelContext, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function transformOrdinals(previousSegment: ContentModelText, paragraph:
|
|
5
|
+
export declare function transformOrdinals(previousSegment: ContentModelText, paragraph: ShallowMutableContentModelParagraph, context: FormatContentModelContext): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformOrdinals.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE,IAAM,UAAU,GAAG,UAAC,KAAa;IAC7B,IAAM,QAAQ,GAA2B;QACrC,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;KACV,CAAC;IACF,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;AACnC,CAAC,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,eAAiC,EACjC,
|
|
1
|
+
{"version":3,"file":"transformOrdinals.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/numbers/transformOrdinals.ts"],"names":[],"mappings":";;;AAAA,uEAAsE;AAOtE,IAAM,UAAU,GAAG,UAAC,KAAa;IAC7B,IAAM,QAAQ,GAA2B;QACrC,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI;KACV,CAAC;IACF,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;AACnC,CAAC,CAAC;AAEF;;GAEG;AACH,SAAgB,iBAAiB,CAC7B,eAAiC,EACjC,SAA8C,EAC9C,OAAkC;;IAElC,IAAM,KAAK,GAAG,MAAA,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,0CAAE,IAAI,EAAE,CAAC;IAC5D,IAAI,KAAK,EAAE;QACP,IAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAClD,IAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,KAAK,OAAO,EAAE;YACtD,IAAM,cAAc,GAAG,IAAA,mCAAgB,EACnC,eAAe,EACf,SAAS,EACT,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAC/B,eAAe,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAClC,CAAC;YAEF,cAAc,CAAC,MAAM,CAAC,wBAAwB,GAAG,OAAO,CAAC;YACzD,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;YAClC,OAAO,IAAI,CAAC;SACf;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAvBD,8CAuBC","sourcesContent":["import { splitTextSegment } from '../../pluginUtils/splitTextSegment';\nimport type {\n ContentModelText,\n FormatContentModelContext,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\nconst getOrdinal = (value: number) => {\n const ORDINALS: Record<number, string> = {\n 1: 'st',\n 2: 'nd',\n 3: 'rd',\n };\n return ORDINALS[value] || 'th';\n};\n\n/**\n * @internal\n */\nexport function transformOrdinals(\n previousSegment: ContentModelText,\n paragraph: ShallowMutableContentModelParagraph,\n context: FormatContentModelContext\n): boolean {\n const value = previousSegment.text.split(' ').pop()?.trim();\n if (value) {\n const ordinal = value.substring(value.length - 2);\n const ordinalValue = parseInt(value);\n if (ordinalValue && getOrdinal(ordinalValue) === ordinal) {\n const ordinalSegment = splitTextSegment(\n previousSegment,\n paragraph,\n previousSegment.text.length - 3,\n previousSegment.text.length - 1\n );\n\n ordinalSegment.format.superOrSubScriptSequence = 'super';\n context.canUndoByBackspace = true;\n return true;\n }\n }\n return false;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentModelText, EditorPlugin, IEditor, PluginEvent, ShallowMutableContentModelParagraph } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* The CustomReplace interface defines a custom replacement that can be used in CustomReplacePlugin.
|
|
4
4
|
*/
|
|
@@ -19,7 +19,7 @@ export interface CustomReplace {
|
|
|
19
19
|
* @param paragraph The paragraph that contains the text segment.
|
|
20
20
|
* @returns True if the string is replaced successfully, otherwise false.
|
|
21
21
|
*/
|
|
22
|
-
replacementHandler: (previousSegment: ContentModelText, stringToReplace: string, replacementString: string, paragraph?:
|
|
22
|
+
replacementHandler: (previousSegment: ContentModelText, stringToReplace: string, replacementString: string, paragraph?: ShallowMutableContentModelParagraph) => boolean;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* CustomReplacePlugin is a plugin that allows you to replace a string with another string in the editor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomReplacePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/customReplace/CustomReplacePlugin.ts"],"names":[],"mappings":";;;AAAA,2EAAqF;AAwCrF;;GAEG;AACH;IAII;;;OAGG;IACH,6BAAoB,kBAAmC;QAAnC,uBAAkB,GAAlB,kBAAkB,CAAiB;QAP/C,WAAM,GAAmB,IAAI,CAAC;QAC9B,gBAAW,GAAa,EAAE,CAAC;IAMuB,CAAC;IAE3D;;OAEG;IACH,qCAAO,GAAP;QACI,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,wCAAU,GAAV,UAAW,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,UAAA,WAAW;YACtD,OAAA,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAArC,CAAqC,CACxC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,qCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,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AAC,CACJ,CAAC;SACL;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,kDAAmB","sourcesContent":["import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport type {\n
|
|
1
|
+
{"version":3,"file":"CustomReplacePlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/customReplace/CustomReplacePlugin.ts"],"names":[],"mappings":";;;AAAA,2EAAqF;AAwCrF;;GAEG;AACH;IAII;;;OAGG;IACH,6BAAoB,kBAAmC;QAAnC,uBAAkB,GAAlB,kBAAkB,CAAiB;QAP/C,WAAM,GAAmB,IAAI,CAAC;QAC9B,gBAAW,GAAa,EAAE,CAAC;IAMuB,CAAC;IAE3D;;OAEG;IACH,qCAAO,GAAP;QACI,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,wCAAU,GAAV,UAAW,MAAe;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,UAAA,WAAW;YACtD,OAAA,WAAW,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAArC,CAAqC,CACxC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,qCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,2CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,OAAO;oBACR,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAChD,MAAM;aACb;SACJ;IACL,CAAC;IAEO,oDAAsB,GAA9B,UAA+B,MAAe,EAAE,KAAuB;QAAvE,iBAkCC;QAjCG,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3C,IAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC1B,IACI,IAAI,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC;YAClC,QAAQ,CAAC,SAAS,KAAK,YAAY;YACnC,SAAS;YACT,SAAS,CAAC,IAAI,KAAK,OAAO;YAC1B,SAAS,CAAC,KAAK,CAAC,SAAS;YACzB,GAAG;YACH,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EACpC;YACE,IAAA,oEAAsC,EAClC,MAAM,EACN,UAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO;gBACvD,IAAM,QAAQ,GAAG,KAAI,CAAC,kBAAkB,CAAC,IAAI,CACzC,UAAC,EAA0D;wBAAxD,eAAe,qBAAA,EAAE,iBAAiB,uBAAA,EAAE,kBAAkB,wBAAA;oBACrD,OAAO,kBAAkB,CACrB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,SAAS,CACZ,CAAC;gBACN,CAAC,CACJ,CAAC;gBACF,IAAI,QAAQ,EAAE;oBACV,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;oBAClC,OAAO,IAAI,CAAC;iBACf;gBACD,OAAO,KAAK,CAAC;YACjB,CAAC,CACJ,CAAC;SACL;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AA1FD,IA0FC;AA1FY,kDAAmB","sourcesContent":["import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport type {\n ContentModelText,\n EditorInputEvent,\n EditorPlugin,\n IEditor,\n PluginEvent,\n ShallowMutableContentModelParagraph,\n} from 'roosterjs-content-model-types';\n\n/**\n * The CustomReplace interface defines a custom replacement that can be used in CustomReplacePlugin.\n */\nexport interface CustomReplace {\n /**\n * The string to replace in the editor.\n */\n stringToReplace: string;\n\n /**\n * The string to replace with.\n */\n replacementString: string;\n\n /**\n * The handler to replace the string.\n * @param previousSegment The text segment to replace.\n * @param stringToReplace The string to replace.\n * @param replacementString The string to replace with.\n * @param paragraph The paragraph that contains the text segment.\n * @returns True if the string is replaced successfully, otherwise false.\n */\n replacementHandler: (\n previousSegment: ContentModelText,\n stringToReplace: string,\n replacementString: string,\n paragraph?: ShallowMutableContentModelParagraph\n ) => boolean;\n}\n\n/**\n * CustomReplacePlugin is a plugin that allows you to replace a string with another string in the editor.\n */\nexport class CustomReplacePlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private triggerKeys: string[] = [];\n\n /**\n * @param customReplacements Custom replacement rules.\n * Ex: [{ stringToReplace: ':)', replacementString: '🙂', replacementHandler: replaceEmojis }]\n */\n constructor(private customReplacements: CustomReplace[]) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'CustomReplace';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n this.triggerKeys = this.customReplacements.map(replacement =>\n replacement.stringToReplace.slice(-1)\n );\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 'input':\n this.handleEditorInputEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleEditorInputEvent(editor: IEditor, event: EditorInputEvent) {\n const rawEvent = event.rawEvent;\n const selection = editor.getDOMSelection();\n const key = rawEvent.data;\n if (\n this.customReplacements.length > 0 &&\n rawEvent.inputType === 'insertText' &&\n selection &&\n selection.type === 'range' &&\n selection.range.collapsed &&\n key &&\n this.triggerKeys.indexOf(key) > -1\n ) {\n formatTextSegmentBeforeSelectionMarker(\n editor,\n (_model, previousSegment, paragraph, _markerFormat, context) => {\n const replaced = this.customReplacements.some(\n ({ stringToReplace, replacementString, replacementHandler }) => {\n return replacementHandler(\n previousSegment,\n stringToReplace,\n replacementString,\n paragraph\n );\n }\n );\n if (replaced) {\n context.canUndoByBackspace = true;\n return true;\n }\n return false;\n }\n );\n }\n }\n}\n"]}
|
package/lib/edit/EditPlugin.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class EditPlugin implements EditorPlugin {
|
|
|
11
11
|
private disposer;
|
|
12
12
|
private shouldHandleNextInputEvent;
|
|
13
13
|
private selectionAfterDelete;
|
|
14
|
+
private handleNormalEnter;
|
|
14
15
|
/**
|
|
15
16
|
* Get name of this plugin
|
|
16
17
|
*/
|
|
@@ -35,6 +36,15 @@ export declare class EditPlugin implements EditorPlugin {
|
|
|
35
36
|
* @param event The event to handle:
|
|
36
37
|
*/
|
|
37
38
|
onPluginEvent(event: PluginEvent): void;
|
|
39
|
+
/**
|
|
40
|
+
* Check if the plugin should handle the given event exclusively.
|
|
41
|
+
* Handle an event exclusively means other plugin will not receive this event in
|
|
42
|
+
* onPluginEvent method.
|
|
43
|
+
* If two plugins will return true in willHandleEventExclusively() for the same event,
|
|
44
|
+
* the final result depends on the order of the plugins are added into editor
|
|
45
|
+
* @param event The event to check:
|
|
46
|
+
*/
|
|
47
|
+
willHandleEventExclusively(event: PluginEvent): boolean;
|
|
38
48
|
private handleKeyDownEvent;
|
|
39
49
|
private handleBeforeInputEvent;
|
|
40
50
|
}
|
package/lib/edit/EditPlugin.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EditPlugin = void 0;
|
|
4
4
|
var keyboardDelete_1 = require("./keyboardDelete");
|
|
5
|
+
var keyboardEnter_1 = require("./keyboardEnter");
|
|
5
6
|
var keyboardInput_1 = require("./keyboardInput");
|
|
6
7
|
var keyboardTab_1 = require("./keyboardTab");
|
|
8
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
9
|
var BACKSPACE_KEY = 8;
|
|
8
10
|
var DELETE_KEY = 46;
|
|
9
11
|
/**
|
|
@@ -19,6 +21,7 @@ var EditPlugin = /** @class */ (function () {
|
|
|
19
21
|
this.disposer = null;
|
|
20
22
|
this.shouldHandleNextInputEvent = false;
|
|
21
23
|
this.selectionAfterDelete = null;
|
|
24
|
+
this.handleNormalEnter = false;
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Get name of this plugin
|
|
@@ -35,6 +38,7 @@ var EditPlugin = /** @class */ (function () {
|
|
|
35
38
|
EditPlugin.prototype.initialize = function (editor) {
|
|
36
39
|
var _this = this;
|
|
37
40
|
this.editor = editor;
|
|
41
|
+
this.handleNormalEnter = this.editor.isExperimentalFeatureEnabled('PersistCache');
|
|
38
42
|
if (editor.getEnvironment().isAndroid) {
|
|
39
43
|
this.disposer = this.editor.attachDomEvent({
|
|
40
44
|
beforeinput: {
|
|
@@ -75,6 +79,39 @@ var EditPlugin = /** @class */ (function () {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Check if the plugin should handle the given event exclusively.
|
|
84
|
+
* Handle an event exclusively means other plugin will not receive this event in
|
|
85
|
+
* onPluginEvent method.
|
|
86
|
+
* If two plugins will return true in willHandleEventExclusively() for the same event,
|
|
87
|
+
* the final result depends on the order of the plugins are added into editor
|
|
88
|
+
* @param event The event to check:
|
|
89
|
+
*/
|
|
90
|
+
EditPlugin.prototype.willHandleEventExclusively = function (event) {
|
|
91
|
+
if (this.editor &&
|
|
92
|
+
event.eventType == 'keyDown' &&
|
|
93
|
+
event.rawEvent.key == 'Tab' &&
|
|
94
|
+
!event.rawEvent.shiftKey) {
|
|
95
|
+
var selection = this.editor.getDOMSelection();
|
|
96
|
+
var startContainer = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' && selection.range.collapsed
|
|
97
|
+
? selection.range.startContainer
|
|
98
|
+
: null;
|
|
99
|
+
var table = startContainer
|
|
100
|
+
? this.editor.getDOMHelper().findClosestElementAncestor(startContainer, 'table')
|
|
101
|
+
: null;
|
|
102
|
+
var parsedTable = table && (0, roosterjs_content_model_dom_1.parseTableCells)(table);
|
|
103
|
+
if (parsedTable) {
|
|
104
|
+
var lastRow = parsedTable[parsedTable.length - 1];
|
|
105
|
+
var lastCell = lastRow && lastRow[lastRow.length - 1];
|
|
106
|
+
if (typeof lastCell == 'object' && lastCell.contains(startContainer)) {
|
|
107
|
+
// When TAB in the last cell of a table, we will generate new table row, so prevent other plugins handling this event
|
|
108
|
+
// e.g. SelectionPlugin will move the focus out of table, which is conflict with this behavior
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
};
|
|
78
115
|
EditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
79
116
|
var rawEvent = event.rawEvent;
|
|
80
117
|
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
@@ -101,6 +138,8 @@ var EditPlugin = /** @class */ (function () {
|
|
|
101
138
|
}
|
|
102
139
|
break;
|
|
103
140
|
case 'Enter':
|
|
141
|
+
(0, keyboardEnter_1.keyboardEnter)(editor, rawEvent, this.handleNormalEnter);
|
|
142
|
+
break;
|
|
104
143
|
default:
|
|
105
144
|
(0, keyboardInput_1.keyboardInput)(editor, rawEvent);
|
|
106
145
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,iDAAgD;AAChD,6CAA4C;AAS5C,IAAM,aAAa,GAAG,CAAC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,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,QAAQ,QAAQ,CAAC,SAAS,EAAE;YACxB,KAAK,uBAAuB;gBACxB,OAAO,GAAG,IAAA,+BAAc,EACpB,MAAM,EACN,IAAI,aAAa,CAAC,SAAS,EAAE;oBACzB,GAAG,EAAE,WAAW;oBAChB,OAAO,EAAE,aAAa;oBACtB,KAAK,EAAE,aAAa;iBACvB,CAAC,CACL,CAAC;gBACF,MAAM;YACV,KAAK,sBAAsB;gBACvB,OAAO,GAAG,IAAA,+BAAc,EACpB,MAAM,EACN,IAAI,aAAa,CAAC,SAAS,EAAE;oBACzB,GAAG,EAAE,QAAQ;oBACb,OAAO,EAAE,UAAU;oBACnB,KAAK,EAAE,UAAU;iBACpB,CAAC,CACL,CAAC;gBACF,MAAM;SACb;QAED,IAAI,OAAO,EAAE;YACT,QAAQ,CAAC,cAAc,EAAE,CAAC;YAE1B,sEAAsE;YACtE,oDAAoD;YACpD,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;SACxD;IACL,CAAC;IACL,iBAAC;AAAD,CAAC,AAhJD,IAgJC;AAhJY,gCAAU","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport { keyboardTab } from './keyboardTab';\nimport type {\n DOMSelection,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\nconst BACKSPACE_KEY = 8;\nconst DELETE_KEY = 46;\n\n/**\n * 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 * 3. Tab Key\n */\nexport class EditPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private disposer: (() => void) | null = null;\n private shouldHandleNextInputEvent = false;\n private selectionAfterDelete: DOMSelection | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Edit';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n if (editor.getEnvironment().isAndroid) {\n this.disposer = this.editor.attachDomEvent({\n beforeinput: {\n beforeDispatch: e => this.handleBeforeInputEvent(editor, e),\n },\n });\n }\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 this.disposer?.();\n this.disposer = 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 case 'keyUp':\n if (this.selectionAfterDelete) {\n this.editor.setDOMSelection(this.selectionAfterDelete);\n this.selectionAfterDelete = null;\n }\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\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 '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 // And leave it to browser when shift key is pressed so that browser will trigger cut event\n if (!event.rawEvent.shiftKey) {\n keyboardDelete(editor, rawEvent);\n }\n break;\n\n case 'Tab':\n keyboardTab(editor, rawEvent);\n break;\n case 'Unidentified':\n if (editor.getEnvironment().isAndroid) {\n this.shouldHandleNextInputEvent = true;\n }\n break;\n\n case 'Enter':\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n\n private handleBeforeInputEvent(editor: IEditor, rawEvent: Event) {\n // Some Android IMEs doesn't fire correct keydown event for BACKSPACE/DELETE key\n // Here we translate input event to BACKSPACE/DELETE keydown event to be compatible with existing logic\n if (\n !this.shouldHandleNextInputEvent ||\n !(rawEvent instanceof InputEvent) ||\n rawEvent.defaultPrevented\n ) {\n return;\n }\n this.shouldHandleNextInputEvent = false;\n\n let handled = false;\n switch (rawEvent.inputType) {\n case 'deleteContentBackward':\n handled = keyboardDelete(\n editor,\n new KeyboardEvent('keydown', {\n key: 'Backspace',\n keyCode: BACKSPACE_KEY,\n which: BACKSPACE_KEY,\n })\n );\n break;\n case 'deleteContentForward':\n handled = keyboardDelete(\n editor,\n new KeyboardEvent('keydown', {\n key: 'Delete',\n keyCode: DELETE_KEY,\n which: DELETE_KEY,\n })\n );\n break;\n }\n\n if (handled) {\n rawEvent.preventDefault();\n\n // Restore the selection on keyup event to avoid the cursor jump issue\n // See: https://issues.chromium.org/issues/330596261\n this.selectionAfterDelete = editor.getDOMSelection();\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,iDAAgD;AAChD,iDAAgD;AAChD,6CAA4C;AAC5C,2EAA8D;AAS9D,IAAM,aAAa,GAAG,CAAC,CAAC;AACxB,IAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;;;;GAMG;AACH;IAAA;QACY,WAAM,GAAmB,IAAI,CAAC;QAC9B,aAAQ,GAAwB,IAAI,CAAC;QACrC,+BAA0B,GAAG,KAAK,CAAC;QACnC,yBAAoB,GAAwB,IAAI,CAAC;QACjD,sBAAiB,GAAG,KAAK,CAAC;IAyLtC,CAAC;IAvLG;;OAEG;IACH,4BAAO,GAAP;QACI,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;;OAKG;IACH,+BAAU,GAAV,UAAW,M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CACL,CAAC;gBACF,MAAM;YACV,KAAK,sBAAsB;gBACvB,OAAO,GAAG,IAAA,+BAAc,EACpB,MAAM,EACN,IAAI,aAAa,CAAC,SAAS,EAAE;oBACzB,GAAG,EAAE,QAAQ;oBACb,OAAO,EAAE,UAAU;oBACnB,KAAK,EAAE,UAAU;iBACpB,CAAC,CACL,CAAC;gBACF,MAAM;SACb;QAED,IAAI,OAAO,EAAE;YACT,QAAQ,CAAC,cAAc,EAAE,CAAC;YAE1B,sEAAsE;YACtE,oDAAoD;YACpD,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;SACxD;IACL,CAAC;IACL,iBAAC;AAAD,CAAC,AA9LD,IA8LC;AA9LY,gCAAU","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardEnter } from './keyboardEnter';\nimport { keyboardInput } from './keyboardInput';\nimport { keyboardTab } from './keyboardTab';\nimport { parseTableCells } from 'roosterjs-content-model-dom';\nimport type {\n DOMSelection,\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\nconst BACKSPACE_KEY = 8;\nconst DELETE_KEY = 46;\n\n/**\n * 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 * 3. Tab Key\n */\nexport class EditPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private disposer: (() => void) | null = null;\n private shouldHandleNextInputEvent = false;\n private selectionAfterDelete: DOMSelection | null = null;\n private handleNormalEnter = false;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Edit';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n this.handleNormalEnter = this.editor.isExperimentalFeatureEnabled('PersistCache');\n\n if (editor.getEnvironment().isAndroid) {\n this.disposer = this.editor.attachDomEvent({\n beforeinput: {\n beforeDispatch: e => this.handleBeforeInputEvent(editor, e),\n },\n });\n }\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 this.disposer?.();\n this.disposer = 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 case 'keyUp':\n if (this.selectionAfterDelete) {\n this.editor.setDOMSelection(this.selectionAfterDelete);\n this.selectionAfterDelete = null;\n }\n break;\n }\n }\n }\n\n /**\n * Check if the plugin should handle the given event exclusively.\n * Handle an event exclusively means other plugin will not receive this event in\n * onPluginEvent method.\n * If two plugins will return true in willHandleEventExclusively() for the same event,\n * the final result depends on the order of the plugins are added into editor\n * @param event The event to check:\n */\n willHandleEventExclusively(event: PluginEvent) {\n if (\n this.editor &&\n event.eventType == 'keyDown' &&\n event.rawEvent.key == 'Tab' &&\n !event.rawEvent.shiftKey\n ) {\n const selection = this.editor.getDOMSelection();\n const startContainer =\n selection?.type == 'range' && selection.range.collapsed\n ? selection.range.startContainer\n : null;\n const table = startContainer\n ? this.editor.getDOMHelper().findClosestElementAncestor(startContainer, 'table')\n : null;\n const parsedTable = table && parseTableCells(table);\n\n if (parsedTable) {\n const lastRow = parsedTable[parsedTable.length - 1];\n const lastCell = lastRow && lastRow[lastRow.length - 1];\n\n if (typeof lastCell == 'object' && lastCell.contains(startContainer)) {\n // When TAB in the last cell of a table, we will generate new table row, so prevent other plugins handling this event\n // e.g. SelectionPlugin will move the focus out of table, which is conflict with this behavior\n return true;\n }\n }\n }\n\n return false;\n }\n\n private handleKeyDownEvent(editor: IEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\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 '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 // And leave it to browser when shift key is pressed so that browser will trigger cut event\n if (!event.rawEvent.shiftKey) {\n keyboardDelete(editor, rawEvent);\n }\n break;\n\n case 'Tab':\n keyboardTab(editor, rawEvent);\n break;\n case 'Unidentified':\n if (editor.getEnvironment().isAndroid) {\n this.shouldHandleNextInputEvent = true;\n }\n break;\n\n case 'Enter':\n keyboardEnter(editor, rawEvent, this.handleNormalEnter);\n break;\n\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n\n private handleBeforeInputEvent(editor: IEditor, rawEvent: Event) {\n // Some Android IMEs doesn't fire correct keydown event for BACKSPACE/DELETE key\n // Here we translate input event to BACKSPACE/DELETE keydown event to be compatible with existing logic\n if (\n !this.shouldHandleNextInputEvent ||\n !(rawEvent instanceof InputEvent) ||\n rawEvent.defaultPrevented\n ) {\n return;\n }\n this.shouldHandleNextInputEvent = false;\n\n let handled = false;\n switch (rawEvent.inputType) {\n case 'deleteContentBackward':\n handled = keyboardDelete(\n editor,\n new KeyboardEvent('keydown', {\n key: 'Backspace',\n keyCode: BACKSPACE_KEY,\n which: BACKSPACE_KEY,\n })\n );\n break;\n case 'deleteContentForward':\n handled = keyboardDelete(\n editor,\n new KeyboardEvent('keydown', {\n key: 'Delete',\n keyCode: DELETE_KEY,\n which: DELETE_KEY,\n })\n );\n break;\n }\n\n if (handled) {\n rawEvent.preventDefault();\n\n // Restore the selection on keyup event to avoid the cursor jump issue\n // See: https://issues.chromium.org/issues/330596261\n this.selectionAfterDelete = editor.getDOMSelection();\n }\n }\n}\n"]}
|
|
@@ -11,8 +11,9 @@ var deleteAllSegmentBefore = function (context) {
|
|
|
11
11
|
}
|
|
12
12
|
var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker;
|
|
13
13
|
var index = paragraph.segments.indexOf(marker);
|
|
14
|
+
var mutableParagraph = (0, roosterjs_content_model_dom_1.mutateBlock)(paragraph);
|
|
14
15
|
for (var i = index - 1; i >= 0; i--) {
|
|
15
|
-
var segment =
|
|
16
|
+
var segment = mutableParagraph.segments[i];
|
|
16
17
|
segment.isSelected = true;
|
|
17
18
|
if ((0, roosterjs_content_model_dom_1.deleteSegment)(paragraph, segment, context.formatContext)) {
|
|
18
19
|
context.deleteResult = 'range';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;AAAA,2EAAyE;AAGzE;;GAEG;AACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;IAC9D,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;QACtC,OAAO;KACV;IAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,SAAS,eAAA,EAAE,MAAM,YAAwB,CAAC;IAClD,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,IAAM,gBAAgB,GAAG,IAAA,yCAAW,EAAC,SAAS,CAAC,CAAC;IAEhD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjC,IAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE7C,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAE1B,IAAI,IAAA,2CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;YAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;SAClC;KACJ;AACL,CAAC,CAAC;AAlBW,QAAA,sBAAsB,0BAkBjC","sourcesContent":["import { deleteSegment, mutateBlock } from 'roosterjs-content-model-dom';\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteAllSegmentBefore: DeleteSelectionStep = context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const { paragraph, marker } = context.insertPoint;\n const index = paragraph.segments.indexOf(marker);\n const mutableParagraph = mutateBlock(paragraph);\n\n for (let i = index - 1; i >= 0; i--) {\n const segment = mutableParagraph.segments[i];\n\n segment.isSelected = true;\n\n if (deleteSegment(paragraph, segment, context.formatContext)) {\n context.deleteResult = 'range';\n }\n }\n};\n"]}
|
|
@@ -13,7 +13,7 @@ function getDeleteCollapsedSelection(direction) {
|
|
|
13
13
|
var isForward = direction == 'forward';
|
|
14
14
|
var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
|
|
15
15
|
var segments = paragraph.segments;
|
|
16
|
-
fixupBr(
|
|
16
|
+
fixupBr(paragraph);
|
|
17
17
|
var index = segments.indexOf(marker) + (isForward ? 1 : -1);
|
|
18
18
|
var segmentToDelete = segments[index];
|
|
19
19
|
var blockToDelete;
|
|
@@ -47,7 +47,7 @@ function getDeleteCollapsedSelection(direction) {
|
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
if (((_a = block.segments[block.segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
50
|
-
block.segments.pop();
|
|
50
|
+
(0, roosterjs_content_model_dom_1.mutateBlock)(block).segments.pop();
|
|
51
51
|
}
|
|
52
52
|
context.insertPoint = {
|
|
53
53
|
marker: marker,
|
|
@@ -92,12 +92,13 @@ function shouldOutdentParagraph(isForward, segments, paragraph, path) {
|
|
|
92
92
|
* If the last segment is BR, remove it for now. We may add it back later when normalize model.
|
|
93
93
|
* So that if this is an empty paragraph, it will start to delete next block
|
|
94
94
|
*/
|
|
95
|
-
function fixupBr(
|
|
95
|
+
function fixupBr(paragraph) {
|
|
96
96
|
var _a, _b;
|
|
97
|
+
var segments = paragraph.segments;
|
|
97
98
|
if (((_a = segments[segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
98
99
|
var segmentsWithoutBr = segments.filter(function (x) { return x.segmentType != 'SelectionMarker'; });
|
|
99
100
|
if (((_b = segmentsWithoutBr[segmentsWithoutBr.length - 2]) === null || _b === void 0 ? void 0 : _b.segmentType) != 'Br') {
|
|
100
|
-
segments.pop();
|
|
101
|
+
(0, roosterjs_content_model_dom_1.mutateBlock)(paragraph).segments.pop();
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;AAAA,oEAAmE;AACnE,2EAAkE;AAClE,2EAMqC;AAUrC,SAAS,2BAA2B,CAAC,SAAiC;IAClE,OAAO,UAAA,OAAO;;QACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAED,IAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;QACnC,IAAA,KAA4C,OAAO,CAAC,WAAW,EAA7D,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,YAAY,kBAAwB,CAAC;QACtE,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEpC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;AAAA,oEAAmE;AACnE,2EAAkE;AAClE,2EAMqC;AAUrC,SAAS,2BAA2B,CAAC,SAAiC;IAClE,OAAO,UAAA,OAAO;;QACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAED,IAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;QACnC,IAAA,KAA4C,OAAO,CAAC,WAAW,EAA7D,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,YAAY,kBAAwB,CAAC;QACtE,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;QAEpC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEnB,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC9D,IAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,aAA0C,CAAC;QAC/C,IAAI,IAAyC,CAAC;QAE9C,IAAI,eAAe,EAAE;YACjB,IAAI,IAAA,2CAAa,EAAC,SAAS,EAAE,eAAe,EAAE,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE;gBAC7E,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;gBAEpC,4GAA4G;gBAC5G,qFAAqF;gBACrF,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;aACtC;SACJ;aAAM,IACH,sBAAsB,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC;YAC5D,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,EACxB;YACE,IAAA,iDAAmB,EAAC,IAAI,EAAE,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AAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC;QAEnF,IAAI,CAAA,MAAA,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,WAAW,KAAI,IAAI,EAAE;YACtE,IAAA,yCAAW,EAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;SACzC;KACJ;AACL,CAAC;AAED;;GAEG;AACU,QAAA,+BAA+B,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;AAEtF;;GAEG;AACU,QAAA,gCAAgC,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport {\n deleteBlock,\n deleteSegment,\n getClosestAncestorBlockGroupIndex,\n mutateBlock,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type { ReadonlyBlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type {\n DeleteSelectionStep,\n ReadonlyContentModelBlockGroup,\n ReadonlyContentModelDocument,\n ReadonlyContentModelParagraph,\n ReadonlyContentModelSegment,\n} from 'roosterjs-content-model-types';\n\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const isForward = direction == 'forward';\n const { paragraph, marker, path, tableContext } = context.insertPoint;\n const segments = paragraph.segments;\n\n fixupBr(paragraph);\n\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\n const segmentToDelete = segments[index];\n let blockToDelete: ReadonlyBlockAndPath | null;\n let root: ReadonlyContentModelDocument | null;\n\n if (segmentToDelete) {\n if (deleteSegment(paragraph, segmentToDelete, context.formatContext, direction)) {\n context.deleteResult = 'singleChar';\n\n // It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit\n // to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953\n setParagraphNotImplicit(paragraph);\n }\n } else if (\n shouldOutdentParagraph(isForward, segments, paragraph, path) &&\n (root = getRoot(path))\n ) {\n setModelIndentation(root, 'outdent');\n context.deleteResult = 'range';\n } else if ((blockToDelete = getLeafSiblingBlock(path, paragraph, isForward))) {\n const { block: readonlyBlock, path, siblingSegment } = blockToDelete;\n\n if (readonlyBlock.blockType == 'Paragraph') {\n const block = mutateBlock(readonlyBlock);\n\n if (siblingSegment) {\n // When selection is under general segment, need to check if it has a sibling sibling, and delete from it\n if (deleteSegment(block, siblingSegment, context.formatContext, direction)) {\n context.deleteResult = 'range';\n }\n } else {\n if (isForward) {\n context.lastParagraph = block;\n } else {\n if (block.segments[block.segments.length - 1]?.segmentType == 'Br') {\n mutateBlock(block).segments.pop();\n }\n\n context.insertPoint = {\n marker,\n paragraph: block,\n path,\n tableContext,\n };\n context.lastParagraph = paragraph;\n }\n\n context.deleteResult = 'range';\n }\n\n // When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context\n context.lastTableContext = tableContext;\n } else {\n if (\n deleteBlock(\n mutateBlock(path[0]).blocks,\n readonlyBlock,\n undefined /*replacement*/,\n context.formatContext,\n direction\n )\n ) {\n context.deleteResult = 'range';\n }\n }\n } else {\n // We have nothing to delete, in this case we don't want browser handle it as well.\n // Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes\n // editor is really empty. We don't want that happen. So the handling should stop here.\n context.deleteResult = 'nothingToDelete';\n }\n };\n}\n\nfunction getRoot(path: ReadonlyContentModelBlockGroup[]): ReadonlyContentModelDocument | null {\n const lastInPath = path[path.length - 1];\n return lastInPath.blockGroupType == 'Document' ? lastInPath : null;\n}\n\nfunction shouldOutdentParagraph(\n isForward: boolean,\n segments: ReadonlyContentModelSegment[],\n paragraph: ReadonlyContentModelParagraph,\n path: ReadonlyContentModelBlockGroup[]\n) {\n return (\n !isForward &&\n segments.length == 1 &&\n segments[0].segmentType == 'SelectionMarker' &&\n paragraph.format.marginLeft &&\n parseInt(paragraph.format.marginLeft) &&\n getClosestAncestorBlockGroupIndex(path, ['Document', 'TableCell'], ['ListItem']) > -1\n );\n}\n\n/**\n * If the last segment is BR, remove it for now. We may add it back later when normalize model.\n * So that if this is an empty paragraph, it will start to delete next block\n */\nfunction fixupBr(paragraph: ReadonlyContentModelParagraph) {\n const { segments } = paragraph;\n\n if (segments[segments.length - 1]?.segmentType == 'Br') {\n const segmentsWithoutBr = segments.filter(x => x.segmentType != 'SelectionMarker');\n\n if (segmentsWithoutBr[segmentsWithoutBr.length - 2]?.segmentType != 'Br') {\n mutateBlock(paragraph).segments.pop();\n }\n }\n}\n\n/**\n * @internal if we didn't delete anything, and we want to delete forward, now perform it\n */\nexport const forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');\n\n/**\n * @internal if we didn't delete anything, and we want to delete backward, now perform it\n */\nexport const backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deleteEmptyQuote = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
4
5
|
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
@@ -11,26 +12,24 @@ var deleteEmptyQuote = function (context) {
|
|
|
11
12
|
deleteResult == 'notDeleted' ||
|
|
12
13
|
deleteResult == 'range') {
|
|
13
14
|
var insertPoint = context.insertPoint, formatContext = context.formatContext;
|
|
14
|
-
var path = insertPoint.path;
|
|
15
|
+
var path = insertPoint.path, paragraph = insertPoint.paragraph;
|
|
15
16
|
var rawEvent = formatContext === null || formatContext === void 0 ? void 0 : formatContext.rawEvent;
|
|
16
|
-
var index = (0, roosterjs_content_model_dom_1.getClosestAncestorBlockGroupIndex)(path, ['FormatContainer', '
|
|
17
|
+
var index = (0, roosterjs_content_model_dom_1.getClosestAncestorBlockGroupIndex)(path, ['FormatContainer'], ['TableCell', 'ListItem']);
|
|
17
18
|
var quote = path[index];
|
|
18
19
|
if (quote && quote.blockGroupType === 'FormatContainer' && quote.tagName == 'blockquote') {
|
|
19
20
|
var parent_1 = path[index + 1];
|
|
20
21
|
var quoteBlockIndex = parent_1.blocks.indexOf(quote);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
context.deleteResult = 'range';
|
|
33
|
-
}
|
|
22
|
+
if (isEmptyQuote(quote)) {
|
|
23
|
+
(0, roosterjs_content_model_dom_1.unwrapBlock)(parent_1, quote);
|
|
24
|
+
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
25
|
+
context.deleteResult = 'range';
|
|
26
|
+
}
|
|
27
|
+
else if ((rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.key) === 'Enter' &&
|
|
28
|
+
quote.blocks.indexOf(paragraph) >= 0 &&
|
|
29
|
+
isEmptyParagraph(paragraph)) {
|
|
30
|
+
insertNewLine((0, roosterjs_content_model_dom_1.mutateBlock)(quote), parent_1, quoteBlockIndex, paragraph);
|
|
31
|
+
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
32
|
+
context.deleteResult = 'range';
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
}
|
|
@@ -39,21 +38,26 @@ exports.deleteEmptyQuote = deleteEmptyQuote;
|
|
|
39
38
|
var isEmptyQuote = function (quote) {
|
|
40
39
|
return (quote.blocks.length === 1 &&
|
|
41
40
|
quote.blocks[0].blockType === 'Paragraph' &&
|
|
42
|
-
quote.blocks[0]
|
|
41
|
+
isEmptyParagraph(quote.blocks[0]));
|
|
43
42
|
};
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
var lastParagraph = quote.blocks[quoteLength - 1];
|
|
47
|
-
if (lastParagraph && lastParagraph.blockType === 'Paragraph') {
|
|
48
|
-
return lastParagraph.segments.every(function (s) { return s.segmentType === 'SelectionMarker' || s.segmentType === 'Br'; });
|
|
49
|
-
}
|
|
43
|
+
var isEmptyParagraph = function (paragraph) {
|
|
44
|
+
return paragraph.segments.every(function (s) { return s.segmentType === 'SelectionMarker' || s.segmentType === 'Br'; });
|
|
50
45
|
};
|
|
51
|
-
var insertNewLine = function (quote, parent,
|
|
52
|
-
var
|
|
53
|
-
quote.blocks.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
var insertNewLine = function (quote, parent, quoteIndex, paragraph) {
|
|
47
|
+
var _a;
|
|
48
|
+
var paraIndex = quote.blocks.indexOf(paragraph);
|
|
49
|
+
if (paraIndex >= 0) {
|
|
50
|
+
var mutableParent = (0, roosterjs_content_model_dom_1.mutateBlock)(parent);
|
|
51
|
+
if (paraIndex < quote.blocks.length - 1) {
|
|
52
|
+
var newQuote = (0, roosterjs_content_model_dom_1.createFormatContainer)(quote.tagName, quote.format);
|
|
53
|
+
(_a = newQuote.blocks).push.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(quote.blocks.splice(paraIndex + 1, quote.blocks.length - paraIndex - 1)), false));
|
|
54
|
+
mutableParent.blocks.splice(quoteIndex + 1, 0, newQuote);
|
|
55
|
+
}
|
|
56
|
+
mutableParent.blocks.splice(quoteIndex + 1, 0, paragraph);
|
|
57
|
+
quote.blocks.splice(paraIndex, 1);
|
|
58
|
+
if (quote.blocks.length == 0) {
|
|
59
|
+
mutableParent.blocks.splice(quoteIndex, 0);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
58
62
|
};
|
|
59
63
|
//# sourceMappingURL=deleteEmptyQuote.js.map
|