roosterjs-content-model-plugins 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/autoFormat/AutoFormatPlugin.d.ts +9 -0
- package/lib/autoFormat/AutoFormatPlugin.js +24 -4
- package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib/autoFormat/link/createLink.d.ts +5 -0
- package/lib/autoFormat/link/createLink.js +26 -0
- package/lib/autoFormat/link/createLink.js.map +1 -0
- package/lib/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib/autoFormat/link/createLinkAfterSpace.js +39 -0
- package/lib/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib/autoFormat/link/getLinkSegment.js +27 -0
- package/lib/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib/autoFormat/link/unlink.d.ts +5 -0
- package/lib/autoFormat/link/unlink.js +20 -0
- package/lib/autoFormat/link/unlink.js.map +1 -0
- package/lib/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib/autoFormat/list/getIndex.js.map +1 -0
- package/lib/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
- package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.js +84 -0
- package/lib/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib/edit/EditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteEmptyQuote.js +60 -0
- package/lib/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib/edit/deleteSteps/deleteList.js +2 -1
- package/lib/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js +1 -1
- package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib/edit/keyboardDelete.js +9 -1
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.js +2 -1
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/keyboardTab.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib/edit/tabUtils/handleTabOnParagraph.js +7 -0
- package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PastePlugin.js +6 -6
- package/lib/paste/PastePlugin.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/constants.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +6 -6
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js +2 -1
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +1 -1
- package/lib/paste/utils/addParser.js +2 -1
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib/paste/utils/getStyles.js.map +1 -1
- package/lib/paste/utils/linkParser.js.map +1 -1
- package/lib/paste/utils/setProcessor.js.map +1 -1
- package/lib/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib/pluginUtils/CreateElement/createElement.js +2 -1
- package/lib/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib/pluginUtils/Disposable.d.ts +1 -1
- package/lib/pluginUtils/Disposable.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
- package/lib/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib/pluginUtils/Rect/getIntersectedRect.js +4 -3
- package/lib/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib/shortcut/ShortcutCommand.js.map +1 -1
- package/lib/shortcut/ShortcutPlugin.js +2 -0
- package/lib/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib/shortcut/shortcuts.d.ts +12 -0
- package/lib/shortcut/shortcuts.js +34 -1
- package/lib/shortcut/shortcuts.js.map +1 -1
- package/lib/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib/shortcut/utils/setShortcutIndentationCommand.js +22 -0
- package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib/tableEdit/TableEditPlugin.js +5 -5
- package/lib/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib/tableEdit/editors/TableEditor.d.ts +1 -1
- package/lib/tableEdit/editors/TableEditor.js +17 -17
- package/lib/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib/tableEdit/editors/features/CellResizer.d.ts +2 -2
- package/lib/tableEdit/editors/features/CellResizer.js +7 -7
- package/lib/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/{lib-mjs/tableEdit/editors/features/TableEditorFeature.d.ts → lib/tableEdit/editors/features/TableEditFeature.d.ts} +2 -2
- package/lib/tableEdit/editors/features/{TableEditorFeature.js → TableEditFeature.js} +1 -1
- package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib/tableEdit/editors/features/TableInserter.d.ts +2 -2
- package/lib/tableEdit/editors/features/TableInserter.js +5 -5
- 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 +6 -6
- package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib/tableEdit/editors/features/TableResizer.d.ts +2 -2
- package/lib/tableEdit/editors/features/TableResizer.js +11 -8
- package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +9 -0
- package/lib-amd/autoFormat/AutoFormatPlugin.js +21 -4
- package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-amd/autoFormat/link/createLink.d.ts +5 -0
- package/lib-amd/autoFormat/link/createLink.js +26 -0
- package/lib-amd/autoFormat/link/createLink.js.map +1 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js +38 -0
- package/lib-amd/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib-amd/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib-amd/autoFormat/link/getLinkSegment.js +27 -0
- package/lib-amd/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib-amd/autoFormat/link/unlink.d.ts +5 -0
- package/lib-amd/autoFormat/link/unlink.js +21 -0
- package/lib-amd/autoFormat/link/unlink.js.map +1 -0
- package/lib-amd/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib-amd/autoFormat/list/getIndex.js.map +1 -0
- package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib-amd/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib-amd/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib-amd/autoFormat/list/keyboardListTrigger.js +46 -0
- package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.js +86 -0
- package/lib-amd/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib-amd/edit/EditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js +60 -0
- package/lib-amd/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteList.js +2 -1
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js +1 -1
- package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.js +9 -2
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.js +2 -2
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/keyboardTab.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +7 -0
- package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-amd/index.d.ts +2 -1
- package/lib-amd/index.js +5 -2
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PastePlugin.js +6 -6
- package/lib-amd/paste/PastePlugin.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/constants.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +6 -6
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js +2 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +5 -17
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +1 -1
- package/lib-amd/paste/utils/addParser.js +2 -1
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-amd/paste/utils/getStyles.js.map +1 -1
- package/lib-amd/paste/utils/linkParser.js.map +1 -1
- package/lib-amd/paste/utils/setProcessor.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib-amd/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-amd/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib-amd/pluginUtils/CreateElement/createElement.js +2 -1
- package/lib-amd/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-amd/pluginUtils/Disposable.d.ts +1 -1
- package/lib-amd/pluginUtils/Disposable.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js +2 -1
- package/lib-amd/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js +4 -3
- package/lib-amd/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-amd/shortcut/ShortcutCommand.js.map +1 -1
- package/lib-amd/shortcut/ShortcutPlugin.js +2 -0
- package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-amd/shortcut/shortcuts.d.ts +12 -0
- package/lib-amd/shortcut/shortcuts.js +34 -2
- package/lib-amd/shortcut/shortcuts.js.map +1 -1
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +22 -0
- package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib-amd/tableEdit/TableEditPlugin.js +5 -4
- package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-amd/tableEdit/editors/TableEditor.d.ts +1 -1
- package/lib-amd/tableEdit/editors/TableEditor.js +17 -16
- package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +2 -2
- package/lib-amd/tableEdit/editors/features/CellResizer.js +8 -7
- package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/{TableEditorFeature.d.ts → TableEditFeature.d.ts} +2 -2
- package/lib-amd/tableEdit/editors/features/{TableEditorFeature.js → TableEditFeature.js} +1 -1
- package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +2 -2
- package/lib-amd/tableEdit/editors/features/TableInserter.js +6 -5
- 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 +7 -6
- package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +2 -2
- package/lib-amd/tableEdit/editors/features/TableResizer.js +12 -8
- package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +9 -0
- package/lib-mjs/autoFormat/AutoFormatPlugin.js +24 -4
- package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
- package/lib-mjs/autoFormat/link/createLink.d.ts +5 -0
- package/lib-mjs/autoFormat/link/createLink.js +22 -0
- package/lib-mjs/autoFormat/link/createLink.js.map +1 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.d.ts +5 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js +35 -0
- package/lib-mjs/autoFormat/link/createLinkAfterSpace.js.map +1 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.d.ts +5 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.js +23 -0
- package/lib-mjs/autoFormat/link/getLinkSegment.js.map +1 -0
- package/lib-mjs/autoFormat/link/unlink.d.ts +5 -0
- package/lib-mjs/autoFormat/link/unlink.js +16 -0
- package/lib-mjs/autoFormat/link/unlink.js.map +1 -0
- package/lib-mjs/autoFormat/list/convertAlphaToDecimals.js.map +1 -0
- package/lib-mjs/autoFormat/list/getIndex.js.map +1 -0
- package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.js +3 -0
- package/lib-mjs/autoFormat/list/getListTypeStyle.js.map +1 -0
- package/lib-mjs/autoFormat/list/getNumberingListStyle.js.map +1 -0
- package/lib-mjs/autoFormat/{keyboardListTrigger.js → list/keyboardListTrigger.js} +17 -15
- package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.d.ts +58 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js +81 -0
- package/lib-mjs/contextMenuBase/ContextMenuPluginBase.js.map +1 -0
- package/lib-mjs/edit/EditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js +56 -0
- package/lib-mjs/edit/deleteSteps/deleteEmptyQuote.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js +2 -1
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js +1 -1
- package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.js +9 -1
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.js +2 -1
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/keyboardTab.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +7 -0
- package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/index.d.ts +2 -1
- package/lib-mjs/index.js +2 -1
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PastePlugin.js +1 -1
- package/lib-mjs/paste/PastePlugin.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -14
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +1 -1
- package/lib-mjs/paste/utils/addParser.js +1 -1
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-mjs/paste/utils/getStyles.js.map +1 -1
- package/lib-mjs/paste/utils/linkParser.js.map +1 -1
- package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.d.ts +1 -1
- package/lib-mjs/pluginUtils/CreateElement/CreateElementData.js.map +1 -1
- package/lib-mjs/pluginUtils/CreateElement/createElement.d.ts +2 -2
- package/lib-mjs/pluginUtils/CreateElement/createElement.js +1 -1
- package/lib-mjs/pluginUtils/CreateElement/createElement.js.map +1 -1
- package/lib-mjs/pluginUtils/Disposable.d.ts +1 -1
- package/lib-mjs/pluginUtils/Disposable.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.d.ts +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHandler.js.map +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.d.ts +3 -3
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js +1 -1
- package/lib-mjs/pluginUtils/DragAndDrop/DragAndDropHelper.js.map +1 -1
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.d.ts +1 -1
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js +2 -2
- package/lib-mjs/pluginUtils/Rect/getIntersectedRect.js.map +1 -1
- package/lib-mjs/shortcut/ShortcutCommand.js.map +1 -1
- package/lib-mjs/shortcut/ShortcutPlugin.js +3 -1
- package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
- package/lib-mjs/shortcut/shortcuts.d.ts +12 -0
- package/lib-mjs/shortcut/shortcuts.js +33 -0
- package/lib-mjs/shortcut/shortcuts.js.map +1 -1
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.d.ts +5 -0
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +18 -0
- package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -0
- package/lib-mjs/tableEdit/TableEditPlugin.js +4 -4
- package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
- package/lib-mjs/tableEdit/editors/TableEditor.d.ts +1 -1
- package/lib-mjs/tableEdit/editors/TableEditor.js +7 -8
- package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +2 -2
- package/lib-mjs/tableEdit/editors/features/CellResizer.js +4 -5
- package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -1
- package/{lib/tableEdit/editors/features/TableEditorFeature.d.ts → lib-mjs/tableEdit/editors/features/TableEditFeature.d.ts} +2 -2
- package/lib-mjs/tableEdit/editors/features/{TableEditorFeature.js → TableEditFeature.js} +1 -1
- package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -0
- package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +2 -2
- package/lib-mjs/tableEdit/editors/features/TableInserter.js +4 -5
- 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 +4 -5
- package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
- package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +2 -2
- package/lib-mjs/tableEdit/editors/features/TableResizer.js +7 -5
- package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
- package/package.json +5 -5
- package/lib/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib/autoFormat/utils/getIndex.js.map +0 -1
- package/lib/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib/pluginUtils/Rect/normalizeRect.js +0 -20
- package/lib/pluginUtils/Rect/normalizeRect.js.map +0 -1
- package/lib/tableEdit/editors/features/TableEditorFeature.js.map +0 -1
- package/lib-amd/autoFormat/keyboardListTrigger.js +0 -44
- package/lib-amd/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib-amd/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib-amd/autoFormat/utils/getIndex.js.map +0 -1
- package/lib-amd/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib-amd/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib-amd/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib-amd/pluginUtils/Rect/normalizeRect.js +0 -22
- package/lib-amd/pluginUtils/Rect/normalizeRect.js.map +0 -1
- package/lib-amd/tableEdit/editors/features/TableEditorFeature.js.map +0 -1
- package/lib-mjs/autoFormat/keyboardListTrigger.js.map +0 -1
- package/lib-mjs/autoFormat/utils/convertAlphaToDecimals.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getIndex.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getListTypeStyle.js.map +0 -1
- package/lib-mjs/autoFormat/utils/getNumberingListStyle.js.map +0 -1
- package/lib-mjs/pluginUtils/Rect/normalizeRect.d.ts +0 -7
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js +0 -17
- package/lib-mjs/pluginUtils/Rect/normalizeRect.js.map +0 -1
- package/lib-mjs/tableEdit/editors/features/TableEditorFeature.js.map +0 -1
- /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
- /package/lib/autoFormat/{keyboardListTrigger.d.ts → list/keyboardListTrigger.d.ts} +0 -0
- /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib-amd/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
- /package/lib-amd/autoFormat/{keyboardListTrigger.d.ts → list/keyboardListTrigger.d.ts} +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/convertAlphaToDecimals.js +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getIndex.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getIndex.js +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getListTypeStyle.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.d.ts +0 -0
- /package/lib-mjs/autoFormat/{utils → list}/getNumberingListStyle.js +0 -0
- /package/lib-mjs/autoFormat/{keyboardListTrigger.d.ts → list/keyboardListTrigger.d.ts} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
define(["require", "exports", "./getListTypeStyle", "roosterjs-content-model-core", "roosterjs-content-model-dom", "roosterjs-content-model-api"], function (require, exports, getListTypeStyle_1, roosterjs_content_model_core_1, roosterjs_content_model_dom_1, roosterjs_content_model_api_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.keyboardListTrigger = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
function keyboardListTrigger(editor, rawEvent, shouldSearchForBullet, shouldSearchForNumbering) {
|
|
9
|
+
if (shouldSearchForBullet === void 0) { shouldSearchForBullet = true; }
|
|
10
|
+
if (shouldSearchForNumbering === void 0) { shouldSearchForNumbering = true; }
|
|
11
|
+
if (shouldSearchForBullet || shouldSearchForNumbering) {
|
|
12
|
+
editor.formatContentModel(function (model, _context) {
|
|
13
|
+
var listStyleType = (0, getListTypeStyle_1.getListTypeStyle)(model, shouldSearchForBullet, shouldSearchForNumbering);
|
|
14
|
+
if (listStyleType) {
|
|
15
|
+
var segmentsAndParagraphs = (0, roosterjs_content_model_core_1.getSelectedSegmentsAndParagraphs)(model, false);
|
|
16
|
+
if (segmentsAndParagraphs[0] && segmentsAndParagraphs[0][1]) {
|
|
17
|
+
segmentsAndParagraphs[0][1].segments.splice(0, 1);
|
|
18
|
+
}
|
|
19
|
+
var listType = listStyleType.listType, styleType = listStyleType.styleType, index = listStyleType.index;
|
|
20
|
+
triggerList(editor, model, listType, styleType, index);
|
|
21
|
+
rawEvent.preventDefault();
|
|
22
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.keyboardListTrigger = keyboardListTrigger;
|
|
30
|
+
var triggerList = function (editor, model, listType, styleType, index) {
|
|
31
|
+
(0, roosterjs_content_model_api_1.setListType)(model, listType);
|
|
32
|
+
var isOrderedList = listType == 'OL';
|
|
33
|
+
// If the index < 1, it is a new list, so it will be starting by 1, then no need to set startNumber
|
|
34
|
+
if (index && index > 1 && isOrderedList) {
|
|
35
|
+
(0, roosterjs_content_model_api_1.setListStartNumber)(editor, index);
|
|
36
|
+
}
|
|
37
|
+
(0, roosterjs_content_model_api_1.setListStyle)(editor, isOrderedList
|
|
38
|
+
? {
|
|
39
|
+
orderedStyleType: styleType,
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
unorderedStyleType: styleType,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=keyboardListTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboardListTrigger.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/autoFormat/list/keyboardListTrigger.ts"],"names":[],"mappings":";;;;IAMA;;OAEG;IACH,SAAgB,mBAAmB,CAC/B,MAAe,EACf,QAAuB,EACvB,qBAAqC,EACrC,wBAAwC;QADxC,sCAAA,EAAA,4BAAqC;QACrC,yCAAA,EAAA,+BAAwC;QAExC,IAAI,qBAAqB,IAAI,wBAAwB,EAAE;YACnD,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,QAAQ;gBACtC,IAAM,aAAa,GAAG,IAAA,mCAAgB,EAClC,KAAK,EACL,qBAAqB,EACrB,wBAAwB,CAC3B,CAAC;gBACF,IAAI,aAAa,EAAE;oBACf,IAAM,qBAAqB,GAAG,IAAA,+DAAgC,EAAC,KAAK,EAAE,KAAK,CAAC,CAAC;oBAC7E,IAAI,qBAAqB,CAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;wBACzD,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;qBACrD;oBACO,IAAA,QAAQ,GAAuB,aAAa,SAApC,EAAE,SAAS,GAAY,aAAa,UAAzB,EAAE,KAAK,GAAK,aAAa,MAAlB,CAAmB;oBACrD,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;oBACvD,QAAQ,CAAC,cAAc,EAAE,CAAC;oBAC1B,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,OAAO,IAAI,CAAC;iBACf;gBACD,OAAO,KAAK,CAAC;YACjB,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IA5BD,kDA4BC;IAED,IAAM,WAAW,GAAG,UAChB,MAAe,EACf,KAA2B,EAC3B,QAAqB,EACrB,SAAiB,EACjB,KAAc;QAEd,IAAA,yCAAW,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC7B,IAAM,aAAa,GAAG,QAAQ,IAAI,IAAI,CAAC;QACvC,mGAAmG;QACnG,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC,IAAI,aAAa,EAAE;YACrC,IAAA,gDAAkB,EAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SACrC;QACD,IAAA,0CAAY,EACR,MAAM,EACN,aAAa;YACT,CAAC,CAAC;gBACI,gBAAgB,EAAE,SAAS;aAC9B;YACH,CAAC,CAAC;gBACI,kBAAkB,EAAE,SAAS;aAChC,CACV,CAAC;IACN,CAAC,CAAC","sourcesContent":["import { getListTypeStyle } from './getListTypeStyle';\nimport { getSelectedSegmentsAndParagraphs } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport { setListStartNumber, setListStyle, setListType } from 'roosterjs-content-model-api';\nimport type { ContentModelDocument, IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardListTrigger(\n editor: IEditor,\n rawEvent: KeyboardEvent,\n shouldSearchForBullet: boolean = true,\n shouldSearchForNumbering: boolean = true\n) {\n if (shouldSearchForBullet || shouldSearchForNumbering) {\n editor.formatContentModel((model, _context) => {\n const listStyleType = getListTypeStyle(\n model,\n shouldSearchForBullet,\n shouldSearchForNumbering\n );\n if (listStyleType) {\n const segmentsAndParagraphs = getSelectedSegmentsAndParagraphs(model, false);\n if (segmentsAndParagraphs[0] && segmentsAndParagraphs[0][1]) {\n segmentsAndParagraphs[0][1].segments.splice(0, 1);\n }\n const { listType, styleType, index } = listStyleType;\n triggerList(editor, model, listType, styleType, index);\n rawEvent.preventDefault();\n normalizeContentModel(model);\n\n return true;\n }\n return false;\n });\n }\n}\n\nconst triggerList = (\n editor: IEditor,\n model: ContentModelDocument,\n listType: 'OL' | 'UL',\n styleType: number,\n index?: number\n) => {\n setListType(model, listType);\n const isOrderedList = listType == 'OL';\n // If the index < 1, it is a new list, so it will be starting by 1, then no need to set startNumber\n if (index && index > 1 && isOrderedList) {\n setListStartNumber(editor, index);\n }\n setListStyle(\n editor,\n isOrderedList\n ? {\n orderedStyleType: styleType,\n }\n : {\n unorderedStyleType: styleType,\n }\n );\n};\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* Context Menu options for ContextMenu plugin
|
|
4
|
+
*/
|
|
5
|
+
export interface ContextMenuOptions<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Render function for the context menu
|
|
8
|
+
* @param container The container HTML element, it will be located at the mouse click position,
|
|
9
|
+
* so the callback just need to render menu content into this container
|
|
10
|
+
* @param onDismiss The onDismiss callback, some menu render need to know this callback so that
|
|
11
|
+
* it can handle the dismiss event
|
|
12
|
+
*/
|
|
13
|
+
render: (container: HTMLElement, items: (T | null)[], onDismiss: () => void) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Dismiss function for the context menu, it will be called when user wants to dismiss this context menu
|
|
16
|
+
* e.g. user click away so the menu should be dismissed
|
|
17
|
+
* @param container The container HTML element
|
|
18
|
+
*/
|
|
19
|
+
dismiss?: (container: HTMLElement) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the default context menu is allowed. @default false
|
|
22
|
+
*/
|
|
23
|
+
allowDefaultMenu?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* An editor plugin that support showing a context menu using render() function from options parameter
|
|
27
|
+
*/
|
|
28
|
+
export declare class ContextMenuPluginBase<T> implements EditorPlugin {
|
|
29
|
+
private options;
|
|
30
|
+
private container;
|
|
31
|
+
private editor;
|
|
32
|
+
private isMenuShowing;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new instance of ContextMenu class
|
|
35
|
+
* @param options An options object to determine how to show/hide the context menu
|
|
36
|
+
*/
|
|
37
|
+
constructor(options: ContextMenuOptions<T>);
|
|
38
|
+
/**
|
|
39
|
+
* Get a friendly name of this plugin
|
|
40
|
+
*/
|
|
41
|
+
getName(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Initialize this plugin
|
|
44
|
+
* @param editor The editor instance
|
|
45
|
+
*/
|
|
46
|
+
initialize(editor: IEditor): void;
|
|
47
|
+
/**
|
|
48
|
+
* Dispose this plugin
|
|
49
|
+
*/
|
|
50
|
+
dispose(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Handle events triggered from editor
|
|
53
|
+
* @param event PluginEvent object
|
|
54
|
+
*/
|
|
55
|
+
onPluginEvent(event: PluginEvent): void;
|
|
56
|
+
private initContainer;
|
|
57
|
+
private onDismiss;
|
|
58
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
define(["require", "exports"], function (require, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ContextMenuPluginBase = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* An editor plugin that support showing a context menu using render() function from options parameter
|
|
7
|
+
*/
|
|
8
|
+
var ContextMenuPluginBase = /** @class */ (function () {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new instance of ContextMenu class
|
|
11
|
+
* @param options An options object to determine how to show/hide the context menu
|
|
12
|
+
*/
|
|
13
|
+
function ContextMenuPluginBase(options) {
|
|
14
|
+
var _this = this;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.container = null;
|
|
17
|
+
this.editor = null;
|
|
18
|
+
this.isMenuShowing = false;
|
|
19
|
+
this.onDismiss = function () {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if (_this.container && _this.isMenuShowing) {
|
|
22
|
+
(_b = (_a = _this.options).dismiss) === null || _b === void 0 ? void 0 : _b.call(_a, _this.container);
|
|
23
|
+
_this.isMenuShowing = false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get a friendly name of this plugin
|
|
29
|
+
*/
|
|
30
|
+
ContextMenuPluginBase.prototype.getName = function () {
|
|
31
|
+
return 'ContextMenu';
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Initialize this plugin
|
|
35
|
+
* @param editor The editor instance
|
|
36
|
+
*/
|
|
37
|
+
ContextMenuPluginBase.prototype.initialize = function (editor) {
|
|
38
|
+
this.editor = editor;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Dispose this plugin
|
|
42
|
+
*/
|
|
43
|
+
ContextMenuPluginBase.prototype.dispose = function () {
|
|
44
|
+
var _a;
|
|
45
|
+
this.onDismiss();
|
|
46
|
+
if ((_a = this.container) === null || _a === void 0 ? void 0 : _a.parentNode) {
|
|
47
|
+
this.container.parentNode.removeChild(this.container);
|
|
48
|
+
this.container = null;
|
|
49
|
+
}
|
|
50
|
+
this.editor = null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Handle events triggered from editor
|
|
54
|
+
* @param event PluginEvent object
|
|
55
|
+
*/
|
|
56
|
+
ContextMenuPluginBase.prototype.onPluginEvent = function (event) {
|
|
57
|
+
if (event.eventType == 'contextMenu' && event.items.length > 0) {
|
|
58
|
+
var rawEvent = event.rawEvent, items = event.items;
|
|
59
|
+
this.onDismiss();
|
|
60
|
+
if (!this.options.allowDefaultMenu) {
|
|
61
|
+
rawEvent.preventDefault();
|
|
62
|
+
}
|
|
63
|
+
if (this.initContainer(rawEvent.pageX, rawEvent.pageY)) {
|
|
64
|
+
this.options.render(this.container, items, this.onDismiss);
|
|
65
|
+
this.isMenuShowing = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
ContextMenuPluginBase.prototype.initContainer = function (x, y) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
if (!this.container && this.editor) {
|
|
72
|
+
this.container = this.editor.getDocument().createElement('div');
|
|
73
|
+
this.container.style.position = 'fixed';
|
|
74
|
+
this.container.style.width = '0';
|
|
75
|
+
this.container.style.height = '0';
|
|
76
|
+
this.editor.getDocument().body.appendChild(this.container);
|
|
77
|
+
}
|
|
78
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.style.setProperty('left', x + 'px');
|
|
79
|
+
(_b = this.container) === null || _b === void 0 ? void 0 : _b.style.setProperty('top', y + 'px');
|
|
80
|
+
return !!this.container;
|
|
81
|
+
};
|
|
82
|
+
return ContextMenuPluginBase;
|
|
83
|
+
}());
|
|
84
|
+
exports.ContextMenuPluginBase = ContextMenuPluginBase;
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=ContextMenuPluginBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuPluginBase.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/contextMenuBase/ContextMenuPluginBase.ts"],"names":[],"mappings":";;;;IA4BA;;OAEG;IACH;QAKI;;;WAGG;QACH,+BAAoB,OAA8B;YAAlD,iBAAsD;YAAlC,YAAO,GAAP,OAAO,CAAuB;YAR1C,cAAS,GAAuB,IAAI,CAAC;YACrC,WAAM,GAAmB,IAAI,CAAC;YAC9B,kBAAa,GAAY,KAAK,CAAC;YAuE/B,cAAS,GAAG;;gBAChB,IAAI,KAAI,CAAC,SAAS,IAAI,KAAI,CAAC,aAAa,EAAE;oBACtC,MAAA,MAAA,KAAI,CAAC,OAAO,EAAC,OAAO,mDAAG,KAAI,CAAC,SAAS,CAAC,CAAC;oBACvC,KAAI,CAAC,aAAa,GAAG,KAAK,CAAC;iBAC9B;YACL,CAAC,CAAC;QAtEmD,CAAC;QAEtD;;WAEG;QACH,uCAAO,GAAP;YACI,O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AAC,WAAW,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAEhE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC;gBACxC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC;gBACjC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;gBAClC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;aAC9D;YACD,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACpD,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACnD,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QAC5B,CAAC;QAQL,4BAAC;IAAD,CAAC,AAhFD,IAgFC;IAhFY,sDAAqB","sourcesContent":["import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';\n\n/**\n * Context Menu options for ContextMenu plugin\n */\nexport interface ContextMenuOptions<T> {\n /**\n * Render function for the context menu\n * @param container The container HTML element, it will be located at the mouse click position,\n * so the callback just need to render menu content into this container\n * @param onDismiss The onDismiss callback, some menu render need to know this callback so that\n * it can handle the dismiss event\n */\n render: (container: HTMLElement, items: (T | null)[], onDismiss: () => void) => void;\n\n /**\n * Dismiss function for the context menu, it will be called when user wants to dismiss this context menu\n * e.g. user click away so the menu should be dismissed\n * @param container The container HTML element\n */\n dismiss?: (container: HTMLElement) => void;\n\n /**\n * Whether the default context menu is allowed. @default false\n */\n allowDefaultMenu?: boolean;\n}\n\n/**\n * An editor plugin that support showing a context menu using render() function from options parameter\n */\nexport class ContextMenuPluginBase<T> implements EditorPlugin {\n private container: HTMLElement | null = null;\n private editor: IEditor | null = null;\n private isMenuShowing: boolean = false;\n\n /**\n * Create a new instance of ContextMenu class\n * @param options An options object to determine how to show/hide the context menu\n */\n constructor(private options: ContextMenuOptions<T>) {}\n\n /**\n * Get a friendly name of this plugin\n */\n getName() {\n return 'ContextMenu';\n }\n\n /**\n * Initialize this plugin\n * @param editor The editor instance\n */\n initialize(editor: IEditor) {\n this.editor = editor;\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n this.onDismiss();\n\n if (this.container?.parentNode) {\n this.container.parentNode.removeChild(this.container);\n this.container = null;\n }\n this.editor = null;\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(event: PluginEvent) {\n if (event.eventType == 'contextMenu' && event.items.length > 0) {\n const { rawEvent, items } = event;\n\n this.onDismiss();\n\n if (!this.options.allowDefaultMenu) {\n rawEvent.preventDefault();\n }\n\n if (this.initContainer(rawEvent.pageX, rawEvent.pageY)) {\n this.options.render(this.container!, items as T[], this.onDismiss);\n this.isMenuShowing = true;\n }\n }\n }\n\n private initContainer(x: number, y: number) {\n if (!this.container && this.editor) {\n this.container = this.editor.getDocument().createElement('div');\n\n this.container.style.position = 'fixed';\n this.container.style.width = '0';\n this.container.style.height = '0';\n this.editor.getDocument().body.appendChild(this.container);\n }\n this.container?.style.setProperty('left', x + 'px');\n this.container?.style.setProperty('top', y + 'px');\n return !!this.container;\n }\n\n private onDismiss = () => {\n if (this.container && this.isMenuShowing) {\n this.options.dismiss?.(this.container);\n this.isMenuShowing = false;\n }\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditPlugin.js","sourceRoot":"","sources":["../../../../packages
|
|
1
|
+
{"version":3,"file":"EditPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts"],"names":[],"mappings":";;;;IAUA,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,UAAU,GAAG,EAAE,CA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KAAK,EAAE,UAAU;qBACpB,CAAC,CACL,CAAC;oBACF,MAAM;aACb;YAED,IAAI,OAAO,EAAE;gBACT,QAAQ,CAAC,cAAc,EAAE,CAAC;aAC7B;QACL,CAAC;QACL,iBAAC;IAAD,CAAC,AA7HD,IA6HC;IA7HY,gCAAU","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport { keyboardTab } from './keyboardTab';\nimport type {\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\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 }\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 case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n\n case '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 }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;QAC9D,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,SAAS,eAAA,EAAE,MAAM,YAAwB,CAAC;QAClD,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;YAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;gBAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;aAClC;SACJ;IACL,CAAC,CAAC;IAjBW,QAAA,sBAAsB,0BAiBjC","sourcesContent":["import { deleteSegment } from 'roosterjs-content-model-core';\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\n for (let i = index - 1; i >= 0; i--) {\n const segment = paragraph.segments[i];\n\n segment.isSelected = true;\n\n if (deleteSegment(paragraph, segment, context.formatContext)) {\n context.deleteResult = 'range';\n }\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;;IAiBA,SAAS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,SAAS,CAAC,CAAC;IAEtF;;OAEG;IACU,QAAA,gCAAgC,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport {\n deleteBlock,\n deleteSegment,\n getClosestAncestorBlockGroupIndex,\n} from 'roosterjs-content-model-core';\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type {\n ContentModelBlockGroup,\n ContentModelDocument,\n ContentModelParagraph,\n ContentModelSegment,\n DeleteSelectionStep,\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(segments);\n\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\n const segmentToDelete = segments[index];\n let blockToDelete: BlockAndPath | null;\n let root: ContentModelDocument | 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, path, siblingSegment } = blockToDelete;\n\n if (block.blockType == 'Paragraph') {\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 block.segments.pop();\n }\n\n context.insertPoint = {\n marker,\n paragraph: block,\n path,\n tableContext,\n };\n context.lastParagraph = paragraph;\n delete block.cachedElement;\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 path[0].blocks,\n block,\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: ContentModelBlockGroup[]): ContentModelDocument | null {\n const lastInPath = path[path.length - 1];\n return lastInPath.blockGroupType == 'Document' ? lastInPath : null;\n}\n\nfunction shouldOutdentParagraph(\n isForward: boolean,\n segments: ContentModelSegment[],\n paragraph: ContentModelParagraph,\n path: ContentModelBlockGroup[]\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(segments: ContentModelSegment[]) {\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 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"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-dom", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_dom_1, roosterjs_content_model_core_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.deleteEmptyQuote = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
var deleteEmptyQuote = function (context) {
|
|
9
|
+
var deleteResult = context.deleteResult;
|
|
10
|
+
if (deleteResult == 'nothingToDelete' ||
|
|
11
|
+
deleteResult == 'notDeleted' ||
|
|
12
|
+
deleteResult == 'range') {
|
|
13
|
+
var insertPoint = context.insertPoint, formatContext = context.formatContext;
|
|
14
|
+
var path = insertPoint.path;
|
|
15
|
+
var rawEvent = formatContext === null || formatContext === void 0 ? void 0 : formatContext.rawEvent;
|
|
16
|
+
var index = (0, roosterjs_content_model_core_1.getClosestAncestorBlockGroupIndex)(path, ['FormatContainer', 'ListItem'], ['TableCell']);
|
|
17
|
+
var quote = path[index];
|
|
18
|
+
if (quote && quote.blockGroupType === 'FormatContainer' && quote.tagName == 'blockquote') {
|
|
19
|
+
var parent_1 = path[index + 1];
|
|
20
|
+
var quoteBlockIndex = parent_1.blocks.indexOf(quote);
|
|
21
|
+
var blockQuote = parent_1.blocks[quoteBlockIndex];
|
|
22
|
+
if ((0, roosterjs_content_model_core_1.isBlockGroupOfType)(blockQuote, 'FormatContainer') &&
|
|
23
|
+
blockQuote.tagName === 'blockquote') {
|
|
24
|
+
if (isEmptyQuote(blockQuote)) {
|
|
25
|
+
(0, roosterjs_content_model_dom_1.unwrapBlock)(parent_1, blockQuote);
|
|
26
|
+
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
27
|
+
context.deleteResult = 'range';
|
|
28
|
+
}
|
|
29
|
+
else if (isSelectionOnEmptyLine(blockQuote) && (rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.key) === 'Enter') {
|
|
30
|
+
insertNewLine(blockQuote, parent_1, quoteBlockIndex);
|
|
31
|
+
rawEvent === null || rawEvent === void 0 ? void 0 : rawEvent.preventDefault();
|
|
32
|
+
context.deleteResult = 'range';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.deleteEmptyQuote = deleteEmptyQuote;
|
|
39
|
+
var isEmptyQuote = function (quote) {
|
|
40
|
+
return (quote.blocks.length === 1 &&
|
|
41
|
+
quote.blocks[0].blockType === 'Paragraph' &&
|
|
42
|
+
quote.blocks[0].segments.every(function (s) { return s.segmentType === 'SelectionMarker' || s.segmentType === 'Br'; }));
|
|
43
|
+
};
|
|
44
|
+
var isSelectionOnEmptyLine = function (quote) {
|
|
45
|
+
var quoteLength = quote.blocks.length;
|
|
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
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var insertNewLine = function (quote, parent, index) {
|
|
52
|
+
var quoteLength = quote.blocks.length;
|
|
53
|
+
quote.blocks.splice(quoteLength - 1, 1);
|
|
54
|
+
var marker = (0, roosterjs_content_model_dom_1.createSelectionMarker)();
|
|
55
|
+
var newParagraph = (0, roosterjs_content_model_dom_1.createParagraph)(false /* isImplicit */);
|
|
56
|
+
newParagraph.segments.push(marker);
|
|
57
|
+
parent.blocks.splice(index + 1, 0, newParagraph);
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
//# sourceMappingURL=deleteEmptyQuote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteEmptyQuote.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteEmptyQuote.ts"],"names":[],"mappings":";;;;IAWA;;OAEG;IACI,IAAM,gBAAgB,GAAwB,UAAA,OAAO;QAChD,IAAA,YAAY,GAAK,OAAO,aAAZ,CAAa;QACjC,IACI,YAAY,IAAI,iBAAiB;YACjC,YAAY,IAAI,YAAY;YAC5B,YAAY,IAAI,OAAO,EACzB;YACU,IAAA,WAAW,GAAoB,OAAO,YAA3B,EAAE,aAAa,GAAK,OAAO,cAAZ,CAAa;YACvC,IAAA,IAAI,GAAK,WAAW,KAAhB,CAAiB;YAC7B,IAAM,QAAQ,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,QAAyB,CAAC;YAC1D,IAAM,KAAK,GAAG,IAAA,gEAAiC,EAC3C,IAAI,EACJ,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAC/B,CAAC,WAAW,CAAC,CAChB,CAAC;YACF,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YAE1B,IAAI,KAAK,IAAI,KAAK,CAAC,cAAc,KAAK,iBAAiB,IAAI,KAAK,CAAC,OAAO,IAAI,YAAY,EAAE;gBACtF,IAAM,QAAM,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;gBAC/B,IAAM,eAAe,GAAG,QAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACrD,IAAM,UAAU,GAAG,QAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;gBAClD,IACI,IAAA,iDAAkB,EAA8B,UAAU,EAAE,iBAAiB,CAAC;oBAC9E,UAAU,CAAC,OAAO,KAAK,YAAY,EACrC;oBACE,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE;wBAC1B,IAAA,yCAAW,EAAC,QAAM,EAAE,UAAU,CAAC,CAAC;wBAChC,QAAQ,aAAR,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A6D,CACrE,CAAC;SACL;IACL,CAAC,CAAC;IAEF,IAAM,aAAa,GAAG,UAClB,KAAkC,EAClC,MAA8B,EAC9B,KAAa;QAEb,IAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QACxC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,IAAM,MAAM,GAAG,IAAA,mDAAqB,GAAE,CAAC;QACvC,IAAM,YAAY,GAAG,IAAA,6CAAe,EAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC7D,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;IACrD,CAAC,CAAC","sourcesContent":["import { createParagraph, createSelectionMarker, unwrapBlock } from 'roosterjs-content-model-dom';\nimport {\n getClosestAncestorBlockGroupIndex,\n isBlockGroupOfType,\n} from 'roosterjs-content-model-core';\nimport type {\n ContentModelBlockGroup,\n ContentModelFormatContainer,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteEmptyQuote: DeleteSelectionStep = context => {\n const { deleteResult } = context;\n if (\n deleteResult == 'nothingToDelete' ||\n deleteResult == 'notDeleted' ||\n deleteResult == 'range'\n ) {\n const { insertPoint, formatContext } = context;\n const { path } = insertPoint;\n const rawEvent = formatContext?.rawEvent as KeyboardEvent;\n const index = getClosestAncestorBlockGroupIndex(\n path,\n ['FormatContainer', 'ListItem'],\n ['TableCell']\n );\n const quote = path[index];\n\n if (quote && quote.blockGroupType === 'FormatContainer' && quote.tagName == 'blockquote') {\n const parent = path[index + 1];\n const quoteBlockIndex = parent.blocks.indexOf(quote);\n const blockQuote = parent.blocks[quoteBlockIndex];\n if (\n isBlockGroupOfType<ContentModelFormatContainer>(blockQuote, 'FormatContainer') &&\n blockQuote.tagName === 'blockquote'\n ) {\n if (isEmptyQuote(blockQuote)) {\n unwrapBlock(parent, blockQuote);\n rawEvent?.preventDefault();\n context.deleteResult = 'range';\n } else if (isSelectionOnEmptyLine(blockQuote) && rawEvent?.key === 'Enter') {\n insertNewLine(blockQuote, parent, quoteBlockIndex);\n rawEvent?.preventDefault();\n context.deleteResult = 'range';\n }\n }\n }\n }\n};\n\nconst isEmptyQuote = (quote: ContentModelFormatContainer) => {\n return (\n quote.blocks.length === 1 &&\n quote.blocks[0].blockType === 'Paragraph' &&\n quote.blocks[0].segments.every(\n s => s.segmentType === 'SelectionMarker' || s.segmentType === 'Br'\n )\n );\n};\n\nconst isSelectionOnEmptyLine = (quote: ContentModelFormatContainer) => {\n const quoteLength = quote.blocks.length;\n const lastParagraph = quote.blocks[quoteLength - 1];\n if (lastParagraph && lastParagraph.blockType === 'Paragraph') {\n return lastParagraph.segments.every(\n s => s.segmentType === 'SelectionMarker' || s.segmentType === 'Br'\n );\n }\n};\n\nconst insertNewLine = (\n quote: ContentModelFormatContainer,\n parent: ContentModelBlockGroup,\n index: number\n) => {\n const quoteLength = quote.blocks.length;\n quote.blocks.splice(quoteLength - 1, 1);\n const marker = createSelectionMarker();\n const newParagraph = createParagraph(false /* isImplicit */);\n newParagraph.segments.push(marker);\n parent.blocks.splice(index + 1, 0, newParagraph);\n};\n"]}
|
|
@@ -10,7 +10,8 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
|
|
|
10
10
|
if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') {
|
|
11
11
|
var index = (0, roosterjs_content_model_core_1.getClosestAncestorBlockGroupIndex)(path, ['ListItem', 'TableCell']);
|
|
12
12
|
var item = path[index];
|
|
13
|
-
if (
|
|
13
|
+
if (item &&
|
|
14
|
+
index >= 0 &&
|
|
14
15
|
paragraph.segments[0] == marker &&
|
|
15
16
|
item.blockGroupType == 'ListItem' &&
|
|
16
17
|
(paragraph.segments.length == 1 ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteList.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"deleteList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteList.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACI,IAAM,UAAU,GAAwB,UAAA,OAAO;QAC5C,IAAA,KAA8B,OAAO,CAAC,WAAW,EAA/C,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAwB,CAAC;QAExD,IAAI,OAAO,CAAC,YAAY,IAAI,iBAAiB,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACnF,IAAM,KAAK,GAAG,IAAA,gEAAiC,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;YACjF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,IACI,IAAI;gBACJ,KAAK,IAAI,CAAC;gBACV,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM;gBAC/B,IAAI,CAAC,cAAc,IAAI,UAAU;gBACjC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;oBAC3B,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,EACpF;gBACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;gBACjB,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;aAClC;SACJ;IACL,CAAC,CAAC;IAlBW,QAAA,UAAU,cAkBrB","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from 'roosterjs-content-model-core';\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteList: DeleteSelectionStep = context => {\n const { paragraph, marker, path } = context.insertPoint;\n\n if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') {\n const index = getClosestAncestorBlockGroupIndex(path, ['ListItem', 'TableCell']);\n const item = path[index];\n if (\n item &&\n index >= 0 &&\n paragraph.segments[0] == marker &&\n item.blockGroupType == 'ListItem' &&\n (paragraph.segments.length == 1 ||\n (paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))\n ) {\n item.levels = [];\n context.deleteResult = 'range';\n }\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";;;;IAQA,IAAW,eAOV;IAPD,WAAW,eAAe;QACtB,uDAAK,CAAA;QACL,mEAAW,CAAA;QACX,qDAAI,CAAA;QACJ,2DAAO,CAAA;QACP,uDAAK,CAAA;QACL,mDAAG,CAAA;IACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;IAQD,SAAS,sBAAsB,CAAC,SAAiC;QAC7D,OAAO,UAAA,OAAO;YACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;gBACtC,OAAO;aACV;YAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;YAClD,IAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,IAAM,UAAU,GAAG,SAAS,IAAI,SAAS,CAAC;YAE1C,IAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC7E,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE3B,KAAK,IAAI,KAAK,gBAAwB,EAAE,KAAK,eAAuB,IAAI,CAAC,IAAI,CAAC,IAAI,GAAI;gBAC5E,IAAA,KAA+B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AAC,IAAI,IAAI,CAAC;yBACb;wBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;oBACD,yBAAM;wBAGN,yBAAM;yBAGN,sBAAO,IAAI,EAAC;;oBA/DwC,CAAC,IAAI,IAAI,CAAA;;yBAmEzE,sBAAO,IAAI,EAAC;;;KACf;IAED;;OAEG;IACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAE5E;;OAEG;IACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { isPunctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n DeleteSelectionContext,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\nconst enum DeleteWordState {\n Start,\n Punctuation,\n Text,\n NonText,\n Space,\n End,\n}\n\ninterface CharInfo {\n text: boolean;\n space: boolean;\n punctuation: boolean;\n}\n\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const { marker, paragraph } = context.insertPoint;\n const startIndex = paragraph.segments.indexOf(marker);\n const deleteNext = direction == 'forward';\n\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\n let curr = iterator.next();\n\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\n const { punctuation, space, text } = curr.value;\n\n // This is a state machine of how to delete a whole word together with space and punctuations.\n // For a full state machine chart, see\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\n switch (state) {\n case DeleteWordState.Start:\n state = space\n ? DeleteWordState.Space\n : punctuation\n ? DeleteWordState.Punctuation\n : DeleteWordState.Text;\n curr = iterator.next(true /*delete*/);\n break;\n\n case DeleteWordState.Punctuation:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.Text:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (text) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.NonText:\n if (punctuation || !space) {\n state = DeleteWordState.End;\n } else {\n curr = iterator.next(true /*delete*/);\n }\n break;\n\n case DeleteWordState.Space:\n if (space) {\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\n curr = iterator.next(true /*delete*/);\n } else {\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\n }\n break;\n }\n }\n };\n}\n\nfunction* iterateSegments(\n paragraph: ContentModelParagraph,\n markerIndex: number,\n forward: boolean,\n context: DeleteSelectionContext\n): Generator<CharInfo, null, boolean> {\n const step = forward ? 1 : -1;\n const segments = paragraph.segments;\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph.format.whiteSpace);\n\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\n const segment = segments[i];\n\n switch (segment.segmentType) {\n case 'Text':\n for (\n let j = forward ? 0 : segment.text.length - 1;\n j >= 0 && j < segment.text.length;\n j += step\n ) {\n const c = segment.text[j];\n const punctuation = isPunctuation(c);\n const space = isSpace(c);\n const text = !punctuation && !space;\n\n if (yield { punctuation, space, text }) {\n let newText = segment.text;\n\n newText = newText.substring(0, j) + newText.substring(j + 1);\n\n if (!preserveWhiteSpace) {\n newText = normalizeText(newText, forward);\n }\n\n context.deleteResult = 'range';\n\n if (newText) {\n segment.text = newText;\n\n if (step > 0) {\n j -= step;\n }\n } else {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n break;\n }\n }\n }\n break;\n\n case 'Image':\n if (\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\n ) {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n context.deleteResult = 'range';\n }\n break;\n\n case 'SelectionMarker':\n break;\n\n default:\n return null;\n }\n }\n\n return null;\n}\n\n/**\n * @internal\n */\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\n\n/**\n * @internal\n */\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\n"]}
|
|
1
|
+
{"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";;;;IAQA,IAAW,eAOV;IAPD,WAAW,eAAe;QACtB,uDAAK,CAAA;QACL,mEAAW,CAAA;QACX,qDAAI,CAAA;QACJ,2DAAO,CAAA;QACP,uDAAK,CAAA;QACL,mDAAG,CAAA;IACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;IAQD,SAAS,sBAAsB,CAAC,SAAiC;QAC7D,OAAO,UAAA,OAAO;YACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;gBACtC,OAAO;aACV;YAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;YAClD,IAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,IAAM,UAAU,GAAG,SAAS,IAAI,SAAS,CAAC;YAE1C,IAAM,QAAQ,GAAG,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC7E,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE3B,KAAK,IAAI,KAAK,gBAAwB,EAAE,KAAK,eAAuB,IAAI,CAAC,IAAI,CAAC,IAAI,GAAI;gBAC5E,IAAA,KAA+B,IA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,IAAI,IAAI,CAAC;yBACb;wBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;oBACD,yBAAM;wBAGN,yBAAM;yBAGN,sBAAO,IAAI,EAAC;;oBA/DwC,CAAC,IAAI,IAAI,CAAA;;yBAmEzE,sBAAO,IAAI,EAAC;;;KACf;IAED;;OAEG;IACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAE5E;;OAEG;IACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { isPunctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n DeleteSelectionContext,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\nconst enum DeleteWordState {\n Start,\n Punctuation,\n Text,\n NonText,\n Space,\n End,\n}\n\ninterface CharInfo {\n text: boolean;\n space: boolean;\n punctuation: boolean;\n}\n\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const { marker, paragraph } = context.insertPoint;\n const startIndex = paragraph.segments.indexOf(marker);\n const deleteNext = direction == 'forward';\n\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\n let curr = iterator.next();\n\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\n const { punctuation, space, text } = curr.value;\n\n // This is a state machine of how to delete a whole word together with space and punctuations.\n // For a full state machine chart, see\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\n switch (state) {\n case DeleteWordState.Start:\n state = space\n ? DeleteWordState.Space\n : punctuation\n ? DeleteWordState.Punctuation\n : DeleteWordState.Text;\n curr = iterator.next(true /*delete*/);\n break;\n\n case DeleteWordState.Punctuation:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.Text:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (text) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.NonText:\n if (punctuation || !space) {\n state = DeleteWordState.End;\n } else {\n curr = iterator.next(true /*delete*/);\n }\n break;\n\n case DeleteWordState.Space:\n if (space) {\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\n curr = iterator.next(true /*delete*/);\n } else {\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\n }\n break;\n }\n }\n };\n}\n\nfunction* iterateSegments(\n paragraph: ContentModelParagraph,\n markerIndex: number,\n forward: boolean,\n context: DeleteSelectionContext\n): Generator<CharInfo, null, boolean> {\n const step = forward ? 1 : -1;\n const segments = paragraph.segments;\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph.format.whiteSpace);\n\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\n const segment = segments[i];\n\n switch (segment.segmentType) {\n case 'Text':\n for (\n let j = forward ? 0 : segment.text.length - 1;\n j >= 0 && j < segment.text.length;\n j += step\n ) {\n const c = segment.text[j];\n const punctuation = isPunctuation(c);\n const space = isSpace(c);\n const text = !punctuation && !space;\n\n if (yield { punctuation, space, text }) {\n let newText = segment.text;\n\n newText = newText.substring(0, j) + newText.substring(j + 1);\n\n if (!preserveWhiteSpace) {\n newText = normalizeText(newText, forward);\n }\n\n context.deleteResult = 'range';\n\n if (newText) {\n segment.text = newText;\n\n if (step > 0) {\n j -= step;\n }\n } else {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n break;\n }\n }\n }\n break;\n\n case 'Image':\n if (\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\n ) {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n context.deleteResult = 'range';\n }\n break;\n\n case 'SelectionMarker':\n break;\n\n default:\n return null;\n }\n }\n\n return null;\n}\n\n/**\n * @internal\n */\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\n\n/**\n * @internal\n */\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages
|
|
1
|
+
{"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/edit/handleKeyboardEventCommon.ts"],"names":[],"mappings":";;;;IAQA;;;OAGG;IACH,SAAgB,yBAAyB,CACrC,MAAe,EACf,KAA2B,EAC3B,QAAuB,EACvB,MAAoB,EACpB,OAAkC;QAElC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAChC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;QAEhC,QAAQ,MAAM,EAAE;YACZ,KAAK,YAAY;gBACb,kHAAkH;gBAClH,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,6GAA6G;gBAC7G,OAAO,KAAK,CAAC;YAEjB,KAAK,iBAAiB;gBAClB,sFAAsF;gBACtF,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC1B,OAAO,KAAK,CAAC;YAEjB,KAAK,OAAO,CAAC;YACb,KAAK,YAAY;gBACb,kGAAkG;gBAClG,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC1B,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;gBAE7B,IAAI,MAAM,IAAI,OAAO,EAAE;oBACnB,sEAAsE;oBACtE,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC;iBACpC;gBAED,6GAA6G;gBAC7G,oHAAoH;gBACpH,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE;oBACzC,QAAQ,UAAA;iBACX,CAAC,CAAC;gBAEH,OAAO,IAAI,CAAC;SACnB;IACL,CAAC;IA1CD,8DA0CC;IAED;;OAEG;IACH,SAAgB,gBAAgB,CAAC,QAAuB,EAAE,KAAc;QACpE,OAAO,CACH,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC/C,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACnD,CAAC;IACN,CAAC;IALD,4CAKC;IAED;;OAEG;IACH,SAAgB,6BAA6B,CAAC,QAAuB;QACjE,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChD,CAAC;IAFD,sEAEC","sourcesContent":["import { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n DeleteResult,\n FormatContentModelContext,\n IEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @return True means content is changed, so need to rewrite content model to editor. Otherwise false\n */\nexport function handleKeyboardEventResult(\n editor: IEditor,\n model: ContentModelDocument,\n rawEvent: KeyboardEvent,\n result: DeleteResult,\n context: FormatContentModelContext\n): boolean {\n context.skipUndoSnapshot = true;\n context.clearModelCache = false;\n\n switch (result) {\n case 'notDeleted':\n // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid\n context.clearModelCache = true;\n\n // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model\n return false;\n\n case 'nothingToDelete':\n // We known there is nothing to delete, no need to let browser keep handling the event\n rawEvent.preventDefault();\n return false;\n\n case 'range':\n case 'singleChar':\n // We have deleted what we need from content model, no need to let browser keep handling the event\n rawEvent.preventDefault();\n normalizeContentModel(model);\n\n if (result == 'range') {\n // A range is about to be deleted, so add an undo snapshot immediately\n context.skipUndoSnapshot = false;\n }\n\n // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.\n // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.\n editor.triggerEvent('beforeKeyboardEditing', {\n rawEvent,\n });\n\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean) {\n return (\n (isMac && rawEvent.altKey && !rawEvent.metaKey) ||\n (!isMac && rawEvent.ctrlKey && !rawEvent.altKey)\n );\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent) {\n return rawEvent.metaKey && !rawEvent.altKey;\n}\n"]}
|
|
@@ -16,7 +16,7 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core", "roosterj
|
|
|
16
16
|
var index = (0, roosterjs_content_model_core_1.getClosestAncestorBlockGroupIndex)(path, ['ListItem'], ['TableCell']);
|
|
17
17
|
var listItem_1 = path[index];
|
|
18
18
|
var listParent = path[index + 1];
|
|
19
|
-
if (listItem_1 && listItem_1.blockGroupType === 'ListItem') {
|
|
19
|
+
if (listItem_1 && listItem_1.blockGroupType === 'ListItem' && listParent) {
|
|
20
20
|
var listIndex = listParent.blocks.indexOf(listItem_1);
|
|
21
21
|
var nextBlock = listParent.blocks[listIndex + 1];
|
|
22
22
|
if (deleteResult == 'range' && nextBlock) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages
|
|
1
|
+
{"version":3,"file":"handleEnterOnList.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/edit/inputSteps/handleEnterOnList.ts"],"names":[],"mappings":";;;;IAsBA;;OAEG;IACI,IAAM,iBAAiB,GAAwB,UAAA,OAAO;QACjD,IAAA,YAAY,GAAK,OAAO,aAAZ,CAAa;QACjC,IACI,YAAY,IAAI,iBAAiB;YACjC,YAAY,IAAI,YAAY;YAC5B,YAAY,IAAI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IAAM,kBAAkB,GAAG,UAAC,WAAwB;;QACxC,IAAA,SAAS,GAAa,WAAW,UAAxB,EAAE,MAAM,GAAK,WAAW,OAAhB,CAAiB;QAC1C,IAAM,YAAY,GAAG,IAAA,6CAAe,EAChC,KAAK,CAAC,cAAc,EACpB,SAAS,CAAC,MAAM,EAChB,SAAS,CAAC,aAAa,CAC1B,CAAC;QAEF,IAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvD,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CACtC,WAAW,EACX,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,WAAW,CAC1C,CAAC;QAEF,CAAA,KAAA,YAAY,CAAC,QAAQ,CAAA,CAAC,IAAI,8DAAI,QAAQ,WAAE;QAExC,IAAA,qDAAuB,EAAC,SAAS,CAAC,CAAC;QAEnC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,EAAE;YACnE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAA,sCAAQ,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;SACpD;QAED,IAAA,gDAAkB,EAAC,YAAY,CAAC,CAAC;QAEjC,OAAO,YAAY,CAAC;IACxB,CAAC,CAAC","sourcesContent":["import {\n getClosestAncestorBlockGroupIndex,\n isBlockGroupOfType,\n} from 'roosterjs-content-model-core';\nimport {\n createBr,\n createListItem,\n createListLevel,\n createParagraph,\n createSelectionMarker,\n normalizeContentModel,\n normalizeParagraph,\n setParagraphNotImplicit,\n} from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlockGroup,\n ContentModelListItem,\n DeleteSelectionStep,\n InsertPoint,\n ValidDeleteSelectionContext,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const handleEnterOnList: DeleteSelectionStep = context => {\n const { deleteResult } = context;\n if (\n deleteResult == 'nothingToDelete' ||\n deleteResult == 'notDeleted' ||\n deleteResult == 'range'\n ) {\n const { insertPoint, formatContext } = context;\n const { path } = insertPoint;\n const rawEvent = formatContext?.rawEvent;\n const index = getClosestAncestorBlockGroupIndex(path, ['ListItem'], ['TableCell']);\n\n const listItem = path[index];\n const listParent = path[index + 1];\n\n if (listItem && listItem.blockGroupType === 'ListItem' && listParent) {\n const listIndex = listParent.blocks.indexOf(listItem);\n const nextBlock = listParent.blocks[listIndex + 1];\n if (deleteResult == 'range' && nextBlock) {\n normalizeContentModel(listParent);\n const nextListItem = listParent.blocks[listIndex + 1];\n if (\n isBlockGroupOfType<ContentModelListItem>(nextListItem, 'ListItem') &&\n nextListItem.levels[0]\n ) {\n nextListItem.levels.forEach((level, index) => {\n level.format.startNumberOverride = undefined;\n level.dataset = listItem.levels[index]\n ? listItem.levels[index].dataset\n : {};\n });\n const lastParagraph = listItem.blocks[listItem.blocks.length - 1];\n const nextParagraph = nextListItem.blocks[0];\n if (\n nextParagraph.blockType === 'Paragraph' &&\n lastParagraph.blockType === 'Paragraph' &&\n lastParagraph.segments[lastParagraph.segments.length - 1].segmentType ===\n 'SelectionMarker'\n ) {\n lastParagraph.segments.pop();\n\n nextParagraph.segments.unshift(\n createSelectionMarker(insertPoint.marker.format)\n );\n }\n context.lastParagraph = undefined;\n }\n } else if (deleteResult !== 'range') {\n if (isEmptyListItem(listItem)) {\n listItem.levels.pop();\n } else {\n createNewListItem(context, listItem, listParent);\n }\n }\n rawEvent?.preventDefault();\n context.deleteResult = 'range';\n }\n }\n};\n\nconst isEmptyListItem = (listItem: ContentModelListItem) => {\n return (\n listItem.blocks.length === 1 &&\n listItem.blocks[0].blockType === 'Paragraph' &&\n listItem.blocks[0].segments.length === 2 &&\n listItem.blocks[0].segments[0].segmentType === 'SelectionMarker' &&\n listItem.blocks[0].segments[1].segmentType === 'Br'\n );\n};\n\nconst createNewListItem = (\n context: ValidDeleteSelectionContext,\n listItem: ContentModelListItem,\n listParent: ContentModelBlockGroup\n) => {\n const { insertPoint } = context;\n const listIndex = listParent.blocks.indexOf(listItem);\n const newParagraph = createNewParagraph(insertPoint);\n\n const levels = createNewListLevel(listItem);\n const newListItem = createListItem(levels, insertPoint.marker.format);\n newListItem.blocks.push(newParagraph);\n insertPoint.paragraph = newParagraph;\n context.lastParagraph = newParagraph;\n listParent.blocks.splice(listIndex + 1, 0, newListItem);\n};\n\nconst createNewListLevel = (listItem: ContentModelListItem) => {\n return listItem.levels.map(level => {\n return createListLevel(\n level.listType,\n {\n ...level.format,\n startNumberOverride: undefined,\n },\n level.dataset\n );\n });\n};\n\nconst createNewParagraph = (insertPoint: InsertPoint) => {\n const { paragraph, marker } = insertPoint;\n const newParagraph = createParagraph(\n false /*isImplicit*/,\n paragraph.format,\n paragraph.segmentFormat\n );\n\n const markerIndex = paragraph.segments.indexOf(marker);\n const segments = paragraph.segments.splice(\n markerIndex,\n paragraph.segments.length - markerIndex\n );\n\n newParagraph.segments.push(...segments);\n\n setParagraphNotImplicit(paragraph);\n\n if (paragraph.segments.every(x => x.segmentType == 'SelectionMarker')) {\n paragraph.segments.push(createBr(marker.format));\n }\n\n normalizeParagraph(newParagraph);\n\n return newParagraph;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports", "roosterjs-content-model-core", "./deleteSteps/deleteAllSegmentBefore", "./deleteSteps/deleteList", "roosterjs-content-model-dom", "./handleKeyboardEventCommon", "./deleteSteps/deleteWordSelection", "./deleteSteps/deleteCollapsedSelection"], function (require, exports, roosterjs_content_model_core_1, deleteAllSegmentBefore_1, deleteList_1, roosterjs_content_model_dom_1, handleKeyboardEventCommon_1, deleteWordSelection_1, deleteCollapsedSelection_1) {
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-core", "./deleteSteps/deleteAllSegmentBefore", "./deleteSteps/deleteEmptyQuote", "./deleteSteps/deleteList", "roosterjs-content-model-dom", "./handleKeyboardEventCommon", "./deleteSteps/deleteWordSelection", "./deleteSteps/deleteCollapsedSelection"], function (require, exports, roosterjs_content_model_core_1, deleteAllSegmentBefore_1, deleteEmptyQuote_1, deleteList_1, roosterjs_content_model_dom_1, handleKeyboardEventCommon_1, deleteWordSelection_1, deleteCollapsedSelection_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.keyboardDelete = void 0;
|
|
@@ -38,7 +38,14 @@ define(["require", "exports", "roosterjs-content-model-core", "./deleteSteps/del
|
|
|
38
38
|
var deleteCollapsedSelection = isForward
|
|
39
39
|
? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
|
|
40
40
|
: deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
|
|
41
|
-
|
|
41
|
+
var deleteQuote = !isForward ? deleteEmptyQuote_1.deleteEmptyQuote : null;
|
|
42
|
+
return [
|
|
43
|
+
deleteAllSegmentBeforeStep,
|
|
44
|
+
deleteWordSelection,
|
|
45
|
+
deleteCollapsedSelection,
|
|
46
|
+
deleteList_1.deleteList,
|
|
47
|
+
deleteQuote,
|
|
48
|
+
];
|
|
42
49
|
}
|
|
43
50
|
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
44
51
|
if (!selection) {
|