roosterjs-content-model-plugins 0.21.2 → 0.21.4
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/edit/ContentModelEditPlugin.d.ts +35 -35
- package/lib/edit/ContentModelEditPlugin.js +75 -75
- package/lib/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +19 -19
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +90 -90
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib/edit/deleteSteps/deleteWordSelection.js +170 -170
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib/edit/handleKeyboardEventCommon.d.ts +15 -15
- package/lib/edit/handleKeyboardEventCommon.js +54 -54
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +8 -8
- package/lib/edit/keyboardDelete.js +67 -67
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +5 -5
- package/lib/edit/keyboardInput.js +50 -49
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib/edit/utils/getLeafSiblingBlock.js +75 -75
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
- package/lib/entityDelimiter/EntityDelimiterPlugin.js +256 -254
- package/lib/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/paste/ContentModelPastePlugin.d.ts +42 -42
- package/lib/paste/ContentModelPastePlugin.js +148 -148
- package/lib/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
- package/lib/paste/Excel/processPastedContentFromExcel.js +82 -82
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +19 -19
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +207 -207
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +69 -69
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib/paste/WordDesktop/processWordComments.js +21 -21
- package/lib/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.d.ts +10 -10
- package/lib/paste/WordDesktop/processWordLists.js +154 -154
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib/paste/pasteSourceValidations/constants.js +21 -21
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js +24 -24
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib/paste/pasteSourceValidations/getPasteSource.js +43 -43
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +16 -16
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +18 -18
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +14 -14
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +14 -14
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +18 -18
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +18 -18
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +5 -5
- package/lib/paste/utils/addParser.js +16 -16
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib/paste/utils/deprecatedColorParser.js +19 -19
- package/lib/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib/paste/utils/getStyles.d.ts +6 -6
- package/lib/paste/utils/getStyles.js +22 -22
- package/lib/paste/utils/getStyles.js.map +1 -1
- package/lib/paste/utils/linkParser.d.ts +5 -5
- package/lib/paste/utils/linkParser.js +27 -27
- package/lib/paste/utils/linkParser.js.map +1 -1
- package/lib/paste/utils/setProcessor.d.ts +5 -5
- package/lib/paste/utils/setProcessor.js +13 -13
- package/lib/paste/utils/setProcessor.js.map +1 -1
- package/lib-amd/edit/ContentModelEditPlugin.d.ts +35 -35
- package/lib-amd/edit/ContentModelEditPlugin.js +75 -75
- package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +20 -20
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +89 -89
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +169 -169
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +15 -15
- package/lib-amd/edit/handleKeyboardEventCommon.js +55 -55
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +8 -8
- package/lib-amd/edit/keyboardDelete.js +63 -63
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +5 -5
- package/lib-amd/edit/keyboardInput.js +50 -49
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib-amd/edit/utils/getLeafSiblingBlock.js +75 -75
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js +255 -253
- package/lib-amd/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
- package/lib-amd/index.d.ts +3 -3
- package/lib-amd/index.js +8 -8
- package/lib-amd/index.js.map +1 -1
- package/lib-amd/paste/ContentModelPastePlugin.d.ts +42 -42
- package/lib-amd/paste/ContentModelPastePlugin.js +140 -140
- package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js +80 -80
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -20
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +206 -206
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib-amd/paste/WordDesktop/processWordComments.js +22 -22
- package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.d.ts +10 -10
- package/lib-amd/paste/WordDesktop/processWordLists.js +153 -153
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib-amd/paste/pasteSourceValidations/constants.js +23 -23
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +26 -26
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +38 -38
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +18 -18
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +16 -16
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +16 -16
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +20 -20
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +5 -5
- package/lib-amd/paste/utils/addParser.js +18 -18
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib-amd/paste/utils/deprecatedColorParser.js +20 -20
- package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-amd/paste/utils/getStyles.d.ts +6 -6
- package/lib-amd/paste/utils/getStyles.js +24 -24
- package/lib-amd/paste/utils/getStyles.js.map +1 -1
- package/lib-amd/paste/utils/linkParser.d.ts +5 -5
- package/lib-amd/paste/utils/linkParser.js +28 -28
- package/lib-amd/paste/utils/linkParser.js.map +1 -1
- package/lib-amd/paste/utils/setProcessor.d.ts +5 -5
- package/lib-amd/paste/utils/setProcessor.js +15 -15
- package/lib-amd/paste/utils/setProcessor.js.map +1 -1
- package/lib-mjs/edit/ContentModelEditPlugin.d.ts +35 -35
- package/lib-mjs/edit/ContentModelEditPlugin.js +72 -72
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -5
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +15 -15
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -9
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +87 -87
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -9
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +167 -167
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +15 -15
- package/lib-mjs/edit/handleKeyboardEventCommon.js +48 -48
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +8 -8
- package/lib-mjs/edit/keyboardDelete.js +63 -63
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +5 -5
- package/lib-mjs/edit/keyboardInput.js +46 -45
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -23
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js +71 -71
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -1
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.d.ts +35 -35
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js +252 -250
- package/lib-mjs/entityDelimiter/EntityDelimiterPlugin.js.map +1 -1
- package/lib-mjs/index.d.ts +3 -3
- package/lib-mjs/index.js +3 -3
- package/lib-mjs/index.js.map +1 -1
- package/lib-mjs/paste/ContentModelPastePlugin.d.ts +42 -42
- package/lib-mjs/paste/ContentModelPastePlugin.js +145 -145
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +13 -13
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +77 -77
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -7
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +15 -15
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -9
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +203 -203
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -12
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +64 -64
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -7
- package/lib-mjs/paste/WordDesktop/processWordComments.js +17 -17
- package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +10 -10
- package/lib-mjs/paste/WordDesktop/processWordLists.js +150 -150
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -17
- package/lib-mjs/paste/pasteSourceValidations/constants.js +18 -18
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +20 -20
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -27
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +39 -39
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +12 -12
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +14 -14
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +10 -10
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +10 -10
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -8
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +14 -14
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -9
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +14 -14
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +5 -5
- package/lib-mjs/paste/utils/addParser.js +13 -13
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -5
- package/lib-mjs/paste/utils/deprecatedColorParser.js +15 -15
- package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -1
- package/lib-mjs/paste/utils/getStyles.d.ts +6 -6
- package/lib-mjs/paste/utils/getStyles.js +18 -18
- package/lib-mjs/paste/utils/getStyles.js.map +1 -1
- package/lib-mjs/paste/utils/linkParser.d.ts +5 -5
- package/lib-mjs/paste/utils/linkParser.js +23 -23
- package/lib-mjs/paste/utils/linkParser.js.map +1 -1
- package/lib-mjs/paste/utils/setProcessor.d.ts +5 -5
- package/lib-mjs/paste/utils/setProcessor.js +9 -9
- package/lib-mjs/paste/utils/setProcessor.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
|
|
2
|
-
/**
|
|
3
|
-
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
4
|
-
* This includes:
|
|
5
|
-
* 1. Delete Key
|
|
6
|
-
* 2. Backspace Key
|
|
7
|
-
*/
|
|
8
|
-
export declare class ContentModelEditPlugin implements EditorPlugin {
|
|
9
|
-
private editor;
|
|
10
|
-
/**
|
|
11
|
-
* Get name of this plugin
|
|
12
|
-
*/
|
|
13
|
-
getName(): string;
|
|
14
|
-
/**
|
|
15
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
16
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
17
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
18
|
-
* @param editor The editor object
|
|
19
|
-
*/
|
|
20
|
-
initialize(editor: IEditor): void;
|
|
21
|
-
/**
|
|
22
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
23
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
24
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
25
|
-
*/
|
|
26
|
-
dispose(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
29
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
30
|
-
* exclusively by another plugin.
|
|
31
|
-
* @param event The event to handle:
|
|
32
|
-
*/
|
|
33
|
-
onPluginEvent(event: PluginEvent): void;
|
|
34
|
-
private handleKeyDownEvent;
|
|
35
|
-
}
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
|
|
2
|
+
/**
|
|
3
|
+
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
4
|
+
* This includes:
|
|
5
|
+
* 1. Delete Key
|
|
6
|
+
* 2. Backspace Key
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContentModelEditPlugin implements EditorPlugin {
|
|
9
|
+
private editor;
|
|
10
|
+
/**
|
|
11
|
+
* Get name of this plugin
|
|
12
|
+
*/
|
|
13
|
+
getName(): string;
|
|
14
|
+
/**
|
|
15
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
16
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
17
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
18
|
+
* @param editor The editor object
|
|
19
|
+
*/
|
|
20
|
+
initialize(editor: IEditor): void;
|
|
21
|
+
/**
|
|
22
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
23
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
24
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
25
|
+
*/
|
|
26
|
+
dispose(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
29
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
30
|
+
* exclusively by another plugin.
|
|
31
|
+
* @param event The event to handle:
|
|
32
|
+
*/
|
|
33
|
+
onPluginEvent(event: PluginEvent): void;
|
|
34
|
+
private handleKeyDownEvent;
|
|
35
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContentModelEditPlugin = void 0;
|
|
4
|
-
var keyboardDelete_1 = require("./keyboardDelete");
|
|
5
|
-
var keyboardInput_1 = require("./keyboardInput");
|
|
6
|
-
/**
|
|
7
|
-
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
8
|
-
* This includes:
|
|
9
|
-
* 1. Delete Key
|
|
10
|
-
* 2. Backspace Key
|
|
11
|
-
*/
|
|
12
|
-
var ContentModelEditPlugin = /** @class */ (function () {
|
|
13
|
-
function ContentModelEditPlugin() {
|
|
14
|
-
this.editor = null;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Get name of this plugin
|
|
18
|
-
*/
|
|
19
|
-
ContentModelEditPlugin.prototype.getName = function () {
|
|
20
|
-
return 'ContentModelEdit';
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
24
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
25
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
26
|
-
* @param editor The editor object
|
|
27
|
-
*/
|
|
28
|
-
ContentModelEditPlugin.prototype.initialize = function (editor) {
|
|
29
|
-
// TODO: Later we may need a different interface for Content Model editor plugin
|
|
30
|
-
this.editor = editor;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
34
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
35
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
36
|
-
*/
|
|
37
|
-
ContentModelEditPlugin.prototype.dispose = function () {
|
|
38
|
-
this.editor = null;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
42
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
43
|
-
* exclusively by another plugin.
|
|
44
|
-
* @param event The event to handle:
|
|
45
|
-
*/
|
|
46
|
-
ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
|
|
47
|
-
if (this.editor) {
|
|
48
|
-
switch (event.eventType) {
|
|
49
|
-
case 0 /* KeyDown */:
|
|
50
|
-
this.handleKeyDownEvent(this.editor, event);
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
56
|
-
var rawEvent = event.rawEvent;
|
|
57
|
-
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
58
|
-
// TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model
|
|
59
|
-
switch (rawEvent.key) {
|
|
60
|
-
case 'Backspace':
|
|
61
|
-
case 'Delete':
|
|
62
|
-
// Use our API to handle BACKSPACE/DELETE key.
|
|
63
|
-
// 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
|
|
64
|
-
(0, keyboardDelete_1.keyboardDelete)(editor, rawEvent);
|
|
65
|
-
break;
|
|
66
|
-
case 'Enter':
|
|
67
|
-
default:
|
|
68
|
-
(0, keyboardInput_1.keyboardInput)(editor, rawEvent);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
return ContentModelEditPlugin;
|
|
74
|
-
}());
|
|
75
|
-
exports.ContentModelEditPlugin = ContentModelEditPlugin;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentModelEditPlugin = void 0;
|
|
4
|
+
var keyboardDelete_1 = require("./keyboardDelete");
|
|
5
|
+
var keyboardInput_1 = require("./keyboardInput");
|
|
6
|
+
/**
|
|
7
|
+
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
8
|
+
* This includes:
|
|
9
|
+
* 1. Delete Key
|
|
10
|
+
* 2. Backspace Key
|
|
11
|
+
*/
|
|
12
|
+
var ContentModelEditPlugin = /** @class */ (function () {
|
|
13
|
+
function ContentModelEditPlugin() {
|
|
14
|
+
this.editor = null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Get name of this plugin
|
|
18
|
+
*/
|
|
19
|
+
ContentModelEditPlugin.prototype.getName = function () {
|
|
20
|
+
return 'ContentModelEdit';
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
24
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
25
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
26
|
+
* @param editor The editor object
|
|
27
|
+
*/
|
|
28
|
+
ContentModelEditPlugin.prototype.initialize = function (editor) {
|
|
29
|
+
// TODO: Later we may need a different interface for Content Model editor plugin
|
|
30
|
+
this.editor = editor;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
34
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
35
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
36
|
+
*/
|
|
37
|
+
ContentModelEditPlugin.prototype.dispose = function () {
|
|
38
|
+
this.editor = null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
42
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
43
|
+
* exclusively by another plugin.
|
|
44
|
+
* @param event The event to handle:
|
|
45
|
+
*/
|
|
46
|
+
ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
|
|
47
|
+
if (this.editor) {
|
|
48
|
+
switch (event.eventType) {
|
|
49
|
+
case 0 /* KeyDown */:
|
|
50
|
+
this.handleKeyDownEvent(this.editor, event);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
56
|
+
var rawEvent = event.rawEvent;
|
|
57
|
+
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
58
|
+
// TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model
|
|
59
|
+
switch (rawEvent.key) {
|
|
60
|
+
case 'Backspace':
|
|
61
|
+
case 'Delete':
|
|
62
|
+
// Use our API to handle BACKSPACE/DELETE key.
|
|
63
|
+
// 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
|
|
64
|
+
(0, keyboardDelete_1.keyboardDelete)(editor, rawEvent);
|
|
65
|
+
break;
|
|
66
|
+
case 'Enter':
|
|
67
|
+
default:
|
|
68
|
+
(0, keyboardInput_1.keyboardInput)(editor, rawEvent);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return ContentModelEditPlugin;
|
|
74
|
+
}());
|
|
75
|
+
exports.ContentModelEditPlugin = ContentModelEditPlugin;
|
|
76
76
|
//# sourceMappingURL=ContentModelEditPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAClD,iDAAgD;AAUhD;;;;;GAKG;AACH;IAAA;QACY,WAAM,GAA+B,IAAI,CAAC;IAiEtD,CAAC;IA/DG;;OAEG;IACH,wCAAO,GAAP;QACI,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,2CAAU,GAAV,UAAW,MAAe;QACtB,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,wCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,8CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB;oBACI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,mDAAkB,GAA1B,UAA2B,MAA2B,EAAE,KAAyB;QAC7E,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,qHAAqH;YACrH,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,QAAQ;oBACT,8CAA8C;oBAC9C,qIAAqI;oBACrI,IAAA,+BAAc,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBACjC,MAAM;gBAEV,KAAK,OAAO,CAAC;gBACb;oBACI,IAAA,6BAAa,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBAChC,MAAM;aACb;SACJ;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AAlED,IAkEC;AAlEY,wDAAsB","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n EditorPlugin,\n IEditor,\n PluginEvent,\n PluginKeyDownEvent,\n} from 'roosterjs-editor-types';\n\n/**\n * ContentModel edit plugins helps editor to do editing operation on top of content model.\n * This includes:\n * 1. Delete Key\n * 2. Backspace Key\n */\nexport class ContentModelEditPlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelEdit';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor as IContentModelEditor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case PluginEventType.KeyDown:\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IContentModelEditor, event: PluginKeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n // TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model\n switch (rawEvent.key) {\n case 'Backspace':\n case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n\n case 'Enter':\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEdit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r\nimport { keyboardInput } from './keyboardInput';\r\nimport { PluginEventType } from 'roosterjs-editor-types';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type {\r\n EditorPlugin,\r\n IEditor,\r\n PluginEvent,\r\n PluginKeyDownEvent,\r\n} from 'roosterjs-editor-types';\r\n\r\n/**\r\n * ContentModel edit plugins helps editor to do editing operation on top of content model.\r\n * This includes:\r\n * 1. Delete Key\r\n * 2. Backspace Key\r\n */\r\nexport class ContentModelEditPlugin implements EditorPlugin {\r\n private editor: IContentModelEditor | null = null;\r\n\r\n /**\r\n * Get name of this plugin\r\n */\r\n getName() {\r\n return 'ContentModelEdit';\r\n }\r\n\r\n /**\r\n * The first method that editor will call to a plugin when editor is initializing.\r\n * It will pass in the editor instance, plugin should take this chance to save the\r\n * editor reference so that it can call to any editor method or format API later.\r\n * @param editor The editor object\r\n */\r\n initialize(editor: IEditor) {\r\n // TODO: Later we may need a different interface for Content Model editor plugin\r\n this.editor = editor as IContentModelEditor;\r\n }\r\n\r\n /**\r\n * The last method that editor will call to a plugin before it is disposed.\r\n * Plugin can take this chance to clear the reference to editor. After this method is\r\n * called, plugin should not call to any editor method since it will result in error.\r\n */\r\n dispose() {\r\n this.editor = null;\r\n }\r\n\r\n /**\r\n * Core method for a plugin. Once an event happens in editor, editor will call this\r\n * method of each plugin to handle the event as long as the event is not handled\r\n * exclusively by another plugin.\r\n * @param event The event to handle:\r\n */\r\n onPluginEvent(event: PluginEvent) {\r\n if (this.editor) {\r\n switch (event.eventType) {\r\n case PluginEventType.KeyDown:\r\n this.handleKeyDownEvent(this.editor, event);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n private handleKeyDownEvent(editor: IContentModelEditor, event: PluginKeyDownEvent) {\r\n const rawEvent = event.rawEvent;\r\n\r\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\r\n // TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model\r\n switch (rawEvent.key) {\r\n case 'Backspace':\r\n case 'Delete':\r\n // Use our API to handle BACKSPACE/DELETE key.\r\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\r\n keyboardDelete(editor, rawEvent);\r\n break;\r\n\r\n case 'Enter':\r\n default:\r\n keyboardInput(editor, rawEvent);\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const deleteAllSegmentBefore: DeleteSelectionStep;
|
|
1
|
+
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const deleteAllSegmentBefore: DeleteSelectionStep;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteAllSegmentBefore = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
/**
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
var deleteAllSegmentBefore = function (context) {
|
|
9
|
-
var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker;
|
|
10
|
-
var index = paragraph.segments.indexOf(marker);
|
|
11
|
-
for (var i = index - 1; i >= 0; i--) {
|
|
12
|
-
var segment = paragraph.segments[i];
|
|
13
|
-
segment.isSelected = true;
|
|
14
|
-
if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segment, context.formatContext)) {
|
|
15
|
-
context.deleteResult = 'range';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.deleteAllSegmentBefore = deleteAllSegmentBefore;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteAllSegmentBefore = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
var deleteAllSegmentBefore = function (context) {
|
|
9
|
+
var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker;
|
|
10
|
+
var index = paragraph.segments.indexOf(marker);
|
|
11
|
+
for (var i = index - 1; i >= 0; i--) {
|
|
12
|
+
var segment = paragraph.segments[i];
|
|
13
|
+
segment.isSelected = true;
|
|
14
|
+
if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segment, context.formatContext)) {
|
|
15
|
+
context.deleteResult = 'range';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.deleteAllSegmentBefore = deleteAllSegmentBefore;
|
|
20
20
|
//# sourceMappingURL=deleteAllSegmentBefore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;AAAA,6EAA6D;AAG7D;;GAEG;AACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;IACxD,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;IAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;YAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;SAClC;KACJ;AACL,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC","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 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
|
+
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;AAAA,6EAA6D;AAG7D;;GAEG;AACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;IACxD,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;IAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;YAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;SAClC;KACJ;AACL,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC","sourcesContent":["import { deleteSegment } from 'roosterjs-content-model-core';\r\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const deleteAllSegmentBefore: DeleteSelectionStep = context => {\r\n const { paragraph, marker } = context.insertPoint;\r\n const index = paragraph.segments.indexOf(marker);\r\n\r\n for (let i = index - 1; i >= 0; i--) {\r\n const segment = paragraph.segments[i];\r\n\r\n segment.isSelected = true;\r\n\r\n if (deleteSegment(paragraph, segment, context.formatContext)) {\r\n context.deleteResult = 'range';\r\n }\r\n }\r\n};\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal if we didn't delete anything, and we want to delete forward, now perform it
|
|
4
|
-
*/
|
|
5
|
-
export declare const forwardDeleteCollapsedSelection: DeleteSelectionStep;
|
|
6
|
-
/**
|
|
7
|
-
* @internal if we didn't delete anything, and we want to delete backward, now perform it
|
|
8
|
-
*/
|
|
9
|
-
export declare const backwardDeleteCollapsedSelection: DeleteSelectionStep;
|
|
1
|
+
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal if we didn't delete anything, and we want to delete forward, now perform it
|
|
4
|
+
*/
|
|
5
|
+
export declare const forwardDeleteCollapsedSelection: DeleteSelectionStep;
|
|
6
|
+
/**
|
|
7
|
+
* @internal if we didn't delete anything, and we want to delete backward, now perform it
|
|
8
|
+
*/
|
|
9
|
+
export declare const backwardDeleteCollapsedSelection: DeleteSelectionStep;
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backwardDeleteCollapsedSelection = exports.forwardDeleteCollapsedSelection = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var getLeafSiblingBlock_1 = require("../utils/getLeafSiblingBlock");
|
|
6
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
-
function getDeleteCollapsedSelection(direction) {
|
|
8
|
-
return function (context) {
|
|
9
|
-
var _a;
|
|
10
|
-
var isForward = direction == 'forward';
|
|
11
|
-
var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
|
|
12
|
-
var segments = paragraph.segments;
|
|
13
|
-
fixupBr(segments);
|
|
14
|
-
var index = segments.indexOf(marker) + (isForward ? 1 : -1);
|
|
15
|
-
var segmentToDelete = segments[index];
|
|
16
|
-
var blockToDelete;
|
|
17
|
-
if (segmentToDelete) {
|
|
18
|
-
if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segmentToDelete, context.formatContext, direction)) {
|
|
19
|
-
context.deleteResult = 'singleChar';
|
|
20
|
-
// It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit
|
|
21
|
-
// to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953
|
|
22
|
-
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else if ((blockToDelete = (0, getLeafSiblingBlock_1.getLeafSiblingBlock)(path, paragraph, isForward))) {
|
|
26
|
-
var block = blockToDelete.block, path_1 = blockToDelete.path, siblingSegment = blockToDelete.siblingSegment;
|
|
27
|
-
if (block.blockType == 'Paragraph') {
|
|
28
|
-
if (siblingSegment) {
|
|
29
|
-
// When selection is under general segment, need to check if it has a sibling sibling, and delete from it
|
|
30
|
-
if ((0, roosterjs_content_model_core_1.deleteSegment)(block, siblingSegment, context.formatContext, direction)) {
|
|
31
|
-
context.deleteResult = 'range';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
if (isForward) {
|
|
36
|
-
context.lastParagraph = block;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
if (((_a = block.segments[block.segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
40
|
-
block.segments.pop();
|
|
41
|
-
}
|
|
42
|
-
context.insertPoint = {
|
|
43
|
-
marker: marker,
|
|
44
|
-
paragraph: block,
|
|
45
|
-
path: path_1,
|
|
46
|
-
tableContext: tableContext,
|
|
47
|
-
};
|
|
48
|
-
context.lastParagraph = paragraph;
|
|
49
|
-
delete block.cachedElement;
|
|
50
|
-
}
|
|
51
|
-
context.deleteResult = 'range';
|
|
52
|
-
}
|
|
53
|
-
// When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context
|
|
54
|
-
context.lastTableContext = tableContext;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if ((0, roosterjs_content_model_core_1.deleteBlock)(path_1[0].blocks, block, undefined /*replacement*/, context.formatContext, direction)) {
|
|
58
|
-
context.deleteResult = 'range';
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// We have nothing to delete, in this case we don't want browser handle it as well.
|
|
64
|
-
// Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes
|
|
65
|
-
// editor is really empty. We don't want that happen. So the handling should stop here.
|
|
66
|
-
context.deleteResult = 'nothingToDelete';
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* If the last segment is BR, remove it for now. We may add it back later when normalize model.
|
|
72
|
-
* So that if this is an empty paragraph, it will start to delete next block
|
|
73
|
-
*/
|
|
74
|
-
function fixupBr(segments) {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
if (((_a = segments[segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
77
|
-
var segmentsWithoutBr = segments.filter(function (x) { return x.segmentType != 'SelectionMarker'; });
|
|
78
|
-
if (((_b = segmentsWithoutBr[segmentsWithoutBr.length - 2]) === null || _b === void 0 ? void 0 : _b.segmentType) != 'Br') {
|
|
79
|
-
segments.pop();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @internal if we didn't delete anything, and we want to delete forward, now perform it
|
|
85
|
-
*/
|
|
86
|
-
exports.forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');
|
|
87
|
-
/**
|
|
88
|
-
* @internal if we didn't delete anything, and we want to delete backward, now perform it
|
|
89
|
-
*/
|
|
90
|
-
exports.backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.backwardDeleteCollapsedSelection = exports.forwardDeleteCollapsedSelection = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var getLeafSiblingBlock_1 = require("../utils/getLeafSiblingBlock");
|
|
6
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
+
function getDeleteCollapsedSelection(direction) {
|
|
8
|
+
return function (context) {
|
|
9
|
+
var _a;
|
|
10
|
+
var isForward = direction == 'forward';
|
|
11
|
+
var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
|
|
12
|
+
var segments = paragraph.segments;
|
|
13
|
+
fixupBr(segments);
|
|
14
|
+
var index = segments.indexOf(marker) + (isForward ? 1 : -1);
|
|
15
|
+
var segmentToDelete = segments[index];
|
|
16
|
+
var blockToDelete;
|
|
17
|
+
if (segmentToDelete) {
|
|
18
|
+
if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segmentToDelete, context.formatContext, direction)) {
|
|
19
|
+
context.deleteResult = 'singleChar';
|
|
20
|
+
// It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit
|
|
21
|
+
// to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953
|
|
22
|
+
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if ((blockToDelete = (0, getLeafSiblingBlock_1.getLeafSiblingBlock)(path, paragraph, isForward))) {
|
|
26
|
+
var block = blockToDelete.block, path_1 = blockToDelete.path, siblingSegment = blockToDelete.siblingSegment;
|
|
27
|
+
if (block.blockType == 'Paragraph') {
|
|
28
|
+
if (siblingSegment) {
|
|
29
|
+
// When selection is under general segment, need to check if it has a sibling sibling, and delete from it
|
|
30
|
+
if ((0, roosterjs_content_model_core_1.deleteSegment)(block, siblingSegment, context.formatContext, direction)) {
|
|
31
|
+
context.deleteResult = 'range';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (isForward) {
|
|
36
|
+
context.lastParagraph = block;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (((_a = block.segments[block.segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
40
|
+
block.segments.pop();
|
|
41
|
+
}
|
|
42
|
+
context.insertPoint = {
|
|
43
|
+
marker: marker,
|
|
44
|
+
paragraph: block,
|
|
45
|
+
path: path_1,
|
|
46
|
+
tableContext: tableContext,
|
|
47
|
+
};
|
|
48
|
+
context.lastParagraph = paragraph;
|
|
49
|
+
delete block.cachedElement;
|
|
50
|
+
}
|
|
51
|
+
context.deleteResult = 'range';
|
|
52
|
+
}
|
|
53
|
+
// When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context
|
|
54
|
+
context.lastTableContext = tableContext;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
if ((0, roosterjs_content_model_core_1.deleteBlock)(path_1[0].blocks, block, undefined /*replacement*/, context.formatContext, direction)) {
|
|
58
|
+
context.deleteResult = 'range';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// We have nothing to delete, in this case we don't want browser handle it as well.
|
|
64
|
+
// Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes
|
|
65
|
+
// editor is really empty. We don't want that happen. So the handling should stop here.
|
|
66
|
+
context.deleteResult = 'nothingToDelete';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* If the last segment is BR, remove it for now. We may add it back later when normalize model.
|
|
72
|
+
* So that if this is an empty paragraph, it will start to delete next block
|
|
73
|
+
*/
|
|
74
|
+
function fixupBr(segments) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
if (((_a = segments[segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
77
|
+
var segmentsWithoutBr = segments.filter(function (x) { return x.segmentType != 'SelectionMarker'; });
|
|
78
|
+
if (((_b = segmentsWithoutBr[segmentsWithoutBr.length - 2]) === null || _b === void 0 ? void 0 : _b.segmentType) != 'Br') {
|
|
79
|
+
segments.pop();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @internal if we didn't delete anything, and we want to delete forward, now perform it
|
|
85
|
+
*/
|
|
86
|
+
exports.forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');
|
|
87
|
+
/**
|
|
88
|
+
* @internal if we didn't delete anything, and we want to delete backward, now perform it
|
|
89
|
+
*/
|
|
90
|
+
exports.backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');
|
|
91
91
|
//# sourceMappingURL=deleteCollapsedSelection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAC1E,oEAAmE;AACnE,2EAAsE;AAItE,SAAS,2BAA2B,CAAC,SAAiC;IAClE,OAAO,UAAA,OAAO;;QACV,IAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;QACnC,IAAA,KAA4C,OAAO,CAAC,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,QAAQ,CAAC,GAAG,EAAE,CAAC;SAClB;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 { deleteBlock, deleteSegment } from 'roosterjs-content-model-core';\nimport { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type { ContentModelSegment, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\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\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 ((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\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"]}
|
|
1
|
+
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAC1E,oEAAmE;AACnE,2EAAsE;AAItE,SAAS,2BAA2B,CAAC,SAAiC;IAClE,OAAO,UAAA,OAAO;;QACV,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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;AAEtF;;GAEG;AACU,QAAA,gCAAgC,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { deleteBlock, deleteSegment } from 'roosterjs-content-model-core';\r\nimport { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\r\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\r\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\r\nimport type { ContentModelSegment, DeleteSelectionStep } from 'roosterjs-content-model-types';\r\n\r\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\r\n return context => {\r\n const isForward = direction == 'forward';\r\n const { paragraph, marker, path, tableContext } = context.insertPoint;\r\n const segments = paragraph.segments;\r\n\r\n fixupBr(segments);\r\n\r\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\r\n const segmentToDelete = segments[index];\r\n let blockToDelete: BlockAndPath | null;\r\n\r\n if (segmentToDelete) {\r\n if (deleteSegment(paragraph, segmentToDelete, context.formatContext, direction)) {\r\n context.deleteResult = 'singleChar';\r\n\r\n // It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit\r\n // to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953\r\n setParagraphNotImplicit(paragraph);\r\n }\r\n } else if ((blockToDelete = getLeafSiblingBlock(path, paragraph, isForward))) {\r\n const { block, path, siblingSegment } = blockToDelete;\r\n\r\n if (block.blockType == 'Paragraph') {\r\n if (siblingSegment) {\r\n // When selection is under general segment, need to check if it has a sibling sibling, and delete from it\r\n if (deleteSegment(block, siblingSegment, context.formatContext, direction)) {\r\n context.deleteResult = 'range';\r\n }\r\n } else {\r\n if (isForward) {\r\n context.lastParagraph = block;\r\n } else {\r\n if (block.segments[block.segments.length - 1]?.segmentType == 'Br') {\r\n block.segments.pop();\r\n }\r\n\r\n context.insertPoint = {\r\n marker,\r\n paragraph: block,\r\n path,\r\n tableContext,\r\n };\r\n context.lastParagraph = paragraph;\r\n delete block.cachedElement;\r\n }\r\n\r\n context.deleteResult = 'range';\r\n }\r\n\r\n // When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context\r\n context.lastTableContext = tableContext;\r\n } else {\r\n if (\r\n deleteBlock(\r\n path[0].blocks,\r\n block,\r\n undefined /*replacement*/,\r\n context.formatContext,\r\n direction\r\n )\r\n ) {\r\n context.deleteResult = 'range';\r\n }\r\n }\r\n } else {\r\n // We have nothing to delete, in this case we don't want browser handle it as well.\r\n // Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes\r\n // editor is really empty. We don't want that happen. So the handling should stop here.\r\n context.deleteResult = 'nothingToDelete';\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * If the last segment is BR, remove it for now. We may add it back later when normalize model.\r\n * So that if this is an empty paragraph, it will start to delete next block\r\n */\r\nfunction fixupBr(segments: ContentModelSegment[]) {\r\n if (segments[segments.length - 1]?.segmentType == 'Br') {\r\n const segmentsWithoutBr = segments.filter(x => x.segmentType != 'SelectionMarker');\r\n\r\n if (segmentsWithoutBr[segmentsWithoutBr.length - 2]?.segmentType != 'Br') {\r\n segments.pop();\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal if we didn't delete anything, and we want to delete forward, now perform it\r\n */\r\nexport const forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');\r\n\r\n/**\r\n * @internal if we didn't delete anything, and we want to delete backward, now perform it\r\n */\r\nexport const backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const forwardDeleteWordSelection: DeleteSelectionStep;
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare const backwardDeleteWordSelection: DeleteSelectionStep;
|
|
1
|
+
import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const forwardDeleteWordSelection: DeleteSelectionStep;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const backwardDeleteWordSelection: DeleteSelectionStep;
|