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,68 +1,68 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyboardDelete = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var deleteAllSegmentBefore_1 = require("./deleteSteps/deleteAllSegmentBefore");
|
|
6
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
-
var handleKeyboardEventCommon_1 = require("./handleKeyboardEventCommon");
|
|
8
|
-
var deleteWordSelection_1 = require("./deleteSteps/deleteWordSelection");
|
|
9
|
-
var deleteCollapsedSelection_1 = require("./deleteSteps/deleteCollapsedSelection");
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
13
|
-
* @param editor The Content Model Editor
|
|
14
|
-
* @param rawEvent DOM keyboard event
|
|
15
|
-
*/
|
|
16
|
-
function keyboardDelete(editor, rawEvent) {
|
|
17
|
-
var selection = editor.getDOMSelection();
|
|
18
|
-
if (shouldDeleteWithContentModel(selection, rawEvent)) {
|
|
19
|
-
editor.formatContentModel(function (model, context) {
|
|
20
|
-
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
|
|
21
|
-
return (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
|
|
22
|
-
}, {
|
|
23
|
-
rawEvent: rawEvent,
|
|
24
|
-
changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
|
|
25
|
-
getChangeData: function () { return rawEvent.which; },
|
|
26
|
-
apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
|
|
27
|
-
});
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.keyboardDelete = keyboardDelete;
|
|
32
|
-
function getDeleteSteps(rawEvent, isMac) {
|
|
33
|
-
var isForward = rawEvent.key == 'Delete';
|
|
34
|
-
var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
|
|
35
|
-
var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
|
|
36
|
-
? isForward
|
|
37
|
-
? deleteWordSelection_1.forwardDeleteWordSelection
|
|
38
|
-
: deleteWordSelection_1.backwardDeleteWordSelection
|
|
39
|
-
: null;
|
|
40
|
-
var deleteCollapsedSelection = isForward
|
|
41
|
-
? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
|
|
42
|
-
: deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
|
|
43
|
-
return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];
|
|
44
|
-
}
|
|
45
|
-
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
46
|
-
if (!selection) {
|
|
47
|
-
return false; // Nothing to delete
|
|
48
|
-
}
|
|
49
|
-
else if (selection.type != 'range' || !selection.range.collapsed) {
|
|
50
|
-
return true; // Selection is not collapsed, need to delete all selections
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
var range = selection.range;
|
|
54
|
-
// When selection is collapsed and is in middle of text node, no need to use Content Model to delete
|
|
55
|
-
return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
|
|
56
|
-
!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
57
|
-
(canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function canDeleteBefore(rawEvent, range) {
|
|
61
|
-
return rawEvent.key == 'Backspace' && range.startOffset > 1;
|
|
62
|
-
}
|
|
63
|
-
function canDeleteAfter(rawEvent, range) {
|
|
64
|
-
var _a, _b;
|
|
65
|
-
return (rawEvent.key == 'Delete' &&
|
|
66
|
-
range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
|
|
67
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyboardDelete = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var deleteAllSegmentBefore_1 = require("./deleteSteps/deleteAllSegmentBefore");
|
|
6
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
7
|
+
var handleKeyboardEventCommon_1 = require("./handleKeyboardEventCommon");
|
|
8
|
+
var deleteWordSelection_1 = require("./deleteSteps/deleteWordSelection");
|
|
9
|
+
var deleteCollapsedSelection_1 = require("./deleteSteps/deleteCollapsedSelection");
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
13
|
+
* @param editor The Content Model Editor
|
|
14
|
+
* @param rawEvent DOM keyboard event
|
|
15
|
+
*/
|
|
16
|
+
function keyboardDelete(editor, rawEvent) {
|
|
17
|
+
var selection = editor.getDOMSelection();
|
|
18
|
+
if (shouldDeleteWithContentModel(selection, rawEvent)) {
|
|
19
|
+
editor.formatContentModel(function (model, context) {
|
|
20
|
+
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac), context).deleteResult;
|
|
21
|
+
return (0, handleKeyboardEventCommon_1.handleKeyboardEventResult)(editor, model, rawEvent, result, context);
|
|
22
|
+
}, {
|
|
23
|
+
rawEvent: rawEvent,
|
|
24
|
+
changeSource: roosterjs_content_model_core_1.ChangeSource.Keyboard,
|
|
25
|
+
getChangeData: function () { return rawEvent.which; },
|
|
26
|
+
apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',
|
|
27
|
+
});
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.keyboardDelete = keyboardDelete;
|
|
32
|
+
function getDeleteSteps(rawEvent, isMac) {
|
|
33
|
+
var isForward = rawEvent.key == 'Delete';
|
|
34
|
+
var deleteAllSegmentBeforeStep = (0, handleKeyboardEventCommon_1.shouldDeleteAllSegmentsBefore)(rawEvent) && !isForward ? deleteAllSegmentBefore_1.deleteAllSegmentBefore : null;
|
|
35
|
+
var deleteWordSelection = (0, handleKeyboardEventCommon_1.shouldDeleteWord)(rawEvent, isMac)
|
|
36
|
+
? isForward
|
|
37
|
+
? deleteWordSelection_1.forwardDeleteWordSelection
|
|
38
|
+
: deleteWordSelection_1.backwardDeleteWordSelection
|
|
39
|
+
: null;
|
|
40
|
+
var deleteCollapsedSelection = isForward
|
|
41
|
+
? deleteCollapsedSelection_1.forwardDeleteCollapsedSelection
|
|
42
|
+
: deleteCollapsedSelection_1.backwardDeleteCollapsedSelection;
|
|
43
|
+
return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];
|
|
44
|
+
}
|
|
45
|
+
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
46
|
+
if (!selection) {
|
|
47
|
+
return false; // Nothing to delete
|
|
48
|
+
}
|
|
49
|
+
else if (selection.type != 'range' || !selection.range.collapsed) {
|
|
50
|
+
return true; // Selection is not collapsed, need to delete all selections
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
var range = selection.range;
|
|
54
|
+
// When selection is collapsed and is in middle of text node, no need to use Content Model to delete
|
|
55
|
+
return !((0, roosterjs_content_model_dom_1.isNodeOfType)(range.startContainer, 'TEXT_NODE') &&
|
|
56
|
+
!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
57
|
+
(canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range)));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function canDeleteBefore(rawEvent, range) {
|
|
61
|
+
return rawEvent.key == 'Backspace' && range.startOffset > 1;
|
|
62
|
+
}
|
|
63
|
+
function canDeleteAfter(rawEvent, range) {
|
|
64
|
+
var _a, _b;
|
|
65
|
+
return (rawEvent.key == 'Delete' &&
|
|
66
|
+
range.startOffset < ((_b = (_a = range.startContainer.nodeValue) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) - 1);
|
|
67
|
+
}
|
|
68
68
|
//# sourceMappingURL=keyboardDelete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardDelete.js","source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S,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;AACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\nimport {\n handleKeyboardEventResult,\n shouldDeleteAllSegmentsBefore,\n shouldDeleteWord,\n} from './handleKeyboardEventCommon';\nimport {\n backwardDeleteWordSelection,\n forwardDeleteWordSelection,\n} from './deleteSteps/deleteWordSelection';\nimport {\n backwardDeleteCollapsedSelection,\n forwardDeleteCollapsedSelection,\n} from './deleteSteps/deleteCollapsedSelection';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Do keyboard event handling for DELETE/BACKSPACE key\n * @param editor The Content Model Editor\n * @param rawEvent DOM keyboard event\n */\nexport function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(\n model,\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\n context\n ).deleteResult;\n\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\n },\n {\n rawEvent,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\n }\n );\n\n return true;\n }\n}\n\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\n const isForward = rawEvent.key == 'Delete';\n const deleteAllSegmentBeforeStep =\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\n ? isForward\n ? forwardDeleteWordSelection\n : backwardDeleteWordSelection\n : null;\n const deleteCollapsedSelection = isForward\n ? forwardDeleteCollapsedSelection\n : backwardDeleteCollapsedSelection;\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];\n}\n\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (selection.type != 'range' || !selection.range.collapsed) {\n return true; // Selection is not collapsed, need to delete all selections\n } else {\n const range = selection.range;\n\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\n return !(\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\n !isModifierKey(rawEvent) &&\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\n );\n }\n}\n\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\n}\n\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\n return (\n rawEvent.key == 'Delete' &&\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":";;;AAAA,6EAA4F;AAC5F,+EAA8E;AAC9E,2EAA2D;AAC3D,yEAIqC;AACrC,yEAG2C;AAC3C,mFAGgD;AAIhD;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,MAA2B,EAAE,QAAuB;IAC/E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cA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AAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE;QAChE,OAAO,IAAI,CAAC,CAAC,4DAA4D;KAC5E;SAAM;QACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAE9B,oGAAoG;QACpG,OAAO,CAAC,CACJ,IAAA,0CAAY,EAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;YAC/C,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CACxE,CAAC;KACL;AACL,CAAC;AAED,SAAS,eAAe,CAAC,QAAuB,EAAE,KAAY;IAC1D,OAAO,QAAQ,CAAC,GAAG,IAAI,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,cAAc,CAAC,QAAuB,EAAE,KAAY;;IACzD,OAAO,CACH,QAAQ,CAAC,GAAG,IAAI,QAAQ;QACxB,KAAK,CAAC,WAAW,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,cAAc,CAAC,SAAS,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,CACxE,CAAC;AACN,CAAC","sourcesContent":["import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\r\nimport { isNodeOfType } from 'roosterjs-content-model-dom';\r\nimport {\r\n handleKeyboardEventResult,\r\n shouldDeleteAllSegmentsBefore,\r\n shouldDeleteWord,\r\n} from './handleKeyboardEventCommon';\r\nimport {\r\n backwardDeleteWordSelection,\r\n forwardDeleteWordSelection,\r\n} from './deleteSteps/deleteWordSelection';\r\nimport {\r\n backwardDeleteCollapsedSelection,\r\n forwardDeleteCollapsedSelection,\r\n} from './deleteSteps/deleteCollapsedSelection';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type { DOMSelection, DeleteSelectionStep } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n * Do keyboard event handling for DELETE/BACKSPACE key\r\n * @param editor The Content Model Editor\r\n * @param rawEvent DOM keyboard event\r\n */\r\nexport function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\r\n editor.formatContentModel(\r\n (model, context) => {\r\n const result = deleteSelection(\r\n model,\r\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\r\n context\r\n ).deleteResult;\r\n\r\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\r\n },\r\n {\r\n rawEvent,\r\n changeSource: ChangeSource.Keyboard,\r\n getChangeData: () => rawEvent.which,\r\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\r\n }\r\n );\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\r\n const isForward = rawEvent.key == 'Delete';\r\n const deleteAllSegmentBeforeStep =\r\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\r\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\r\n ? isForward\r\n ? forwardDeleteWordSelection\r\n : backwardDeleteWordSelection\r\n : null;\r\n const deleteCollapsedSelection = isForward\r\n ? forwardDeleteCollapsedSelection\r\n : backwardDeleteCollapsedSelection;\r\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];\r\n}\r\n\r\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\r\n if (!selection) {\r\n return false; // Nothing to delete\r\n } else if (selection.type != 'range' || !selection.range.collapsed) {\r\n return true; // Selection is not collapsed, need to delete all selections\r\n } else {\r\n const range = selection.range;\r\n\r\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\r\n return !(\r\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\r\n !isModifierKey(rawEvent) &&\r\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\r\n );\r\n }\r\n}\r\n\r\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\r\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\r\n}\r\n\r\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\r\n return (\r\n rawEvent.key == 'Delete' &&\r\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\r\n );\r\n}\r\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IContentModelEditor } from 'roosterjs-content-model-editor';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
1
|
+
import type { IContentModelEditor } from 'roosterjs-content-model-editor';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.keyboardInput = void 0;
|
|
4
|
-
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
function keyboardInput(editor, rawEvent) {
|
|
10
|
-
var selection = editor.getDOMSelection();
|
|
11
|
-
if (shouldInputWithContentModel(selection, rawEvent)) {
|
|
12
|
-
editor.addUndoSnapshot();
|
|
13
|
-
editor.formatContentModel(function (model, context) {
|
|
14
|
-
var _a;
|
|
15
|
-
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context);
|
|
16
|
-
// We have deleted selection then we will let browser to handle the input.
|
|
17
|
-
// With this combined operation, we don't wan to mass up the cached model so clear it
|
|
18
|
-
context.clearModelCache = true;
|
|
19
|
-
// Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
|
|
20
|
-
context.skipUndoSnapshot = true;
|
|
21
|
-
if (result.deleteResult == 'range') {
|
|
22
|
-
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
23
|
-
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
24
|
-
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
25
|
-
// Do not preventDefault since we still want browser to handle the final input for now
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
rawEvent: rawEvent,
|
|
33
|
-
});
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.keyboardInput = keyboardInput;
|
|
38
|
-
function shouldInputWithContentModel(selection, rawEvent) {
|
|
39
|
-
if (!selection) {
|
|
40
|
-
return false; // Nothing to delete
|
|
41
|
-
}
|
|
42
|
-
else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
43
|
-
(rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
|
|
44
|
-
return selection.type != 'range' ||
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyboardInput = void 0;
|
|
4
|
+
var roosterjs_content_model_core_1 = require("roosterjs-content-model-core");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function keyboardInput(editor, rawEvent) {
|
|
10
|
+
var selection = editor.getDOMSelection();
|
|
11
|
+
if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {
|
|
12
|
+
editor.addUndoSnapshot();
|
|
13
|
+
editor.formatContentModel(function (model, context) {
|
|
14
|
+
var _a;
|
|
15
|
+
var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context);
|
|
16
|
+
// We have deleted selection then we will let browser to handle the input.
|
|
17
|
+
// With this combined operation, we don't wan to mass up the cached model so clear it
|
|
18
|
+
context.clearModelCache = true;
|
|
19
|
+
// Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation
|
|
20
|
+
context.skipUndoSnapshot = true;
|
|
21
|
+
if (result.deleteResult == 'range') {
|
|
22
|
+
// We have deleted something, next input should inherit the segment format from deleted content, so set pending format here
|
|
23
|
+
context.newPendingFormat = (_a = result.insertPoint) === null || _a === void 0 ? void 0 : _a.marker.format;
|
|
24
|
+
(0, roosterjs_content_model_dom_1.normalizeContentModel)(model);
|
|
25
|
+
// Do not preventDefault since we still want browser to handle the final input for now
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
rawEvent: rawEvent,
|
|
33
|
+
});
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.keyboardInput = keyboardInput;
|
|
38
|
+
function shouldInputWithContentModel(selection, rawEvent, isInIME) {
|
|
39
|
+
if (!selection) {
|
|
40
|
+
return false; // Nothing to delete
|
|
41
|
+
}
|
|
42
|
+
else if (!(0, roosterjs_content_model_core_1.isModifierKey)(rawEvent) &&
|
|
43
|
+
(rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)) {
|
|
44
|
+
return (selection.type != 'range' ||
|
|
45
|
+
(!selection.range.collapsed && !rawEvent.isComposing && !isInIME)); // TODO: Also handle Enter key even selection is collapsed
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
50
51
|
//# sourceMappingURL=keyboardInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;AAC9E,2EAAoE;AAIpE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;IAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;AAAA,6EAA8E;AAC9E,2EAAoE;AAIpE;;GAEG;AACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;IAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;QACpE,MAAM,CAAC,eAAe,EAAE,CAAC;QAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;YAEnD,0EAA0E;YAC1E,qFAAqF;YACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,oJAAoJ;YACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;gBAChC,2HAA2H;gBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;gBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;gBAE7B,sFAAsF;gBACtF,OAAO,IAAI,CAAC;aACf;iBAAM;gBACH,OAAO,KAAK,CAAC;aAChB;QACL,CAAC,EACD;YACI,QAAQ,UAAA;SACX,CACJ,CAAC;QAEF,OAAO,IAAI,CAAC;KACf;AACL,CAAC;AApCD,sCAoCC;AAED,SAAS,2BAA2B,CAChC,SAA8B,EAC9B,QAAuB,EACvB,OAAgB;IAEhB,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;QACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;QACE,OAAO,CACH,SAAS,CAAC,IAAI,IAAI,OAAO;YACzB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,CACpE,CAAC,CAAC,0DAA0D;KAChE;SAAM;QACH,OAAO,KAAK,CAAC;KAChB;AACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\r\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\r\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\r\nimport type { DOMSelection } from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\r\n const selection = editor.getDOMSelection();\r\n\r\n if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {\r\n editor.addUndoSnapshot();\r\n\r\n editor.formatContentModel(\r\n (model, context) => {\r\n const result = deleteSelection(model, [], context);\r\n\r\n // We have deleted selection then we will let browser to handle the input.\r\n // With this combined operation, we don't wan to mass up the cached model so clear it\r\n context.clearModelCache = true;\r\n\r\n // Skip undo snapshot here and add undo snapshot before the operation so that we don't add another undo snapshot in middle of this replace operation\r\n context.skipUndoSnapshot = true;\r\n\r\n if (result.deleteResult == 'range') {\r\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\r\n context.newPendingFormat = result.insertPoint?.marker.format;\r\n\r\n normalizeContentModel(model);\r\n\r\n // Do not preventDefault since we still want browser to handle the final input for now\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n },\r\n {\r\n rawEvent,\r\n }\r\n );\r\n\r\n return true;\r\n }\r\n}\r\n\r\nfunction shouldInputWithContentModel(\r\n selection: DOMSelection | null,\r\n rawEvent: KeyboardEvent,\r\n isInIME: boolean\r\n) {\r\n if (!selection) {\r\n return false; // Nothing to delete\r\n } else if (\r\n !isModifierKey(rawEvent) &&\r\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\r\n ) {\r\n return (\r\n selection.type != 'range' ||\r\n (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)\r\n ); // TODO: Also handle Enter key even selection is collapsed\r\n } else {\r\n return false;\r\n }\r\n}\r\n"]}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { ContentModelBlock, ContentModelBlockGroup, ContentModelSegment } from 'roosterjs-content-model-types';
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare type BlockAndPath = {
|
|
6
|
-
/**
|
|
7
|
-
* The sibling block
|
|
8
|
-
*/
|
|
9
|
-
block: ContentModelBlock;
|
|
10
|
-
/**
|
|
11
|
-
* Path of this sibling block
|
|
12
|
-
*/
|
|
13
|
-
path: ContentModelBlockGroup[];
|
|
14
|
-
/**
|
|
15
|
-
* If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.
|
|
16
|
-
* Use this property to return the sibling sibling under the same paragraph
|
|
17
|
-
*/
|
|
18
|
-
siblingSegment?: ContentModelSegment;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare function getLeafSiblingBlock(path: ContentModelBlockGroup[], block: ContentModelBlock, isNext: boolean): BlockAndPath | null;
|
|
1
|
+
import type { ContentModelBlock, ContentModelBlockGroup, ContentModelSegment } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare type BlockAndPath = {
|
|
6
|
+
/**
|
|
7
|
+
* The sibling block
|
|
8
|
+
*/
|
|
9
|
+
block: ContentModelBlock;
|
|
10
|
+
/**
|
|
11
|
+
* Path of this sibling block
|
|
12
|
+
*/
|
|
13
|
+
path: ContentModelBlockGroup[];
|
|
14
|
+
/**
|
|
15
|
+
* If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.
|
|
16
|
+
* Use this property to return the sibling sibling under the same paragraph
|
|
17
|
+
*/
|
|
18
|
+
siblingSegment?: ContentModelSegment;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function getLeafSiblingBlock(path: ContentModelBlockGroup[], block: ContentModelBlock, isNext: boolean): BlockAndPath | null;
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLeafSiblingBlock = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
function getLeafSiblingBlock(path, block, isNext) {
|
|
10
|
-
var _a;
|
|
11
|
-
var newPath = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(path), false);
|
|
12
|
-
var _loop_1 = function () {
|
|
13
|
-
var group = newPath[0];
|
|
14
|
-
var index = group.blocks.indexOf(block);
|
|
15
|
-
if (index < 0) {
|
|
16
|
-
return "break";
|
|
17
|
-
}
|
|
18
|
-
var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
|
|
19
|
-
if (nextBlock) {
|
|
20
|
-
while (nextBlock.blockType == 'BlockGroup') {
|
|
21
|
-
var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
|
|
22
|
-
if (!child) {
|
|
23
|
-
return { value: { block: nextBlock, path: newPath } };
|
|
24
|
-
}
|
|
25
|
-
else if (child.blockType != 'BlockGroup') {
|
|
26
|
-
newPath.unshift(nextBlock);
|
|
27
|
-
return { value: { block: child, path: newPath } };
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
newPath.unshift(nextBlock);
|
|
31
|
-
nextBlock = child;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return { value: { block: nextBlock, path: newPath } };
|
|
35
|
-
}
|
|
36
|
-
else if ((0, roosterjs_content_model_dom_1.isGeneralSegment)(group)) {
|
|
37
|
-
// For general segment, we need to check if there is sibling segment under the same paragraph
|
|
38
|
-
// First let's find the parent paragraph of this segment
|
|
39
|
-
newPath.shift();
|
|
40
|
-
var segmentIndex_1 = -1;
|
|
41
|
-
var segment_1 = group;
|
|
42
|
-
var para = (_a = newPath[0]) === null || _a === void 0 ? void 0 : _a.blocks.find(function (x) { return x.blockType == 'Paragraph' && (segmentIndex_1 = x.segments.indexOf(segment_1)) >= 0; });
|
|
43
|
-
if (para) {
|
|
44
|
-
// Now we have found the parent paragraph, so let's check if it has a sibling segment
|
|
45
|
-
var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
|
|
46
|
-
if (siblingSegment) {
|
|
47
|
-
return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
// No sibling segment, let's keep go upper level
|
|
51
|
-
block = para;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
return "break";
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
|
|
59
|
-
newPath.shift();
|
|
60
|
-
block = group;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return "break";
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
while (newPath.length > 0) {
|
|
67
|
-
var state_1 = _loop_1();
|
|
68
|
-
if (typeof state_1 === "object")
|
|
69
|
-
return state_1.value;
|
|
70
|
-
if (state_1 === "break")
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
exports.getLeafSiblingBlock = getLeafSiblingBlock;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getLeafSiblingBlock = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
function getLeafSiblingBlock(path, block, isNext) {
|
|
10
|
+
var _a;
|
|
11
|
+
var newPath = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(path), false);
|
|
12
|
+
var _loop_1 = function () {
|
|
13
|
+
var group = newPath[0];
|
|
14
|
+
var index = group.blocks.indexOf(block);
|
|
15
|
+
if (index < 0) {
|
|
16
|
+
return "break";
|
|
17
|
+
}
|
|
18
|
+
var nextBlock = group.blocks[index + (isNext ? 1 : -1)];
|
|
19
|
+
if (nextBlock) {
|
|
20
|
+
while (nextBlock.blockType == 'BlockGroup') {
|
|
21
|
+
var child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];
|
|
22
|
+
if (!child) {
|
|
23
|
+
return { value: { block: nextBlock, path: newPath } };
|
|
24
|
+
}
|
|
25
|
+
else if (child.blockType != 'BlockGroup') {
|
|
26
|
+
newPath.unshift(nextBlock);
|
|
27
|
+
return { value: { block: child, path: newPath } };
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
newPath.unshift(nextBlock);
|
|
31
|
+
nextBlock = child;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { value: { block: nextBlock, path: newPath } };
|
|
35
|
+
}
|
|
36
|
+
else if ((0, roosterjs_content_model_dom_1.isGeneralSegment)(group)) {
|
|
37
|
+
// For general segment, we need to check if there is sibling segment under the same paragraph
|
|
38
|
+
// First let's find the parent paragraph of this segment
|
|
39
|
+
newPath.shift();
|
|
40
|
+
var segmentIndex_1 = -1;
|
|
41
|
+
var segment_1 = group;
|
|
42
|
+
var para = (_a = newPath[0]) === null || _a === void 0 ? void 0 : _a.blocks.find(function (x) { return x.blockType == 'Paragraph' && (segmentIndex_1 = x.segments.indexOf(segment_1)) >= 0; });
|
|
43
|
+
if (para) {
|
|
44
|
+
// Now we have found the parent paragraph, so let's check if it has a sibling segment
|
|
45
|
+
var siblingSegment = para.segments[segmentIndex_1 + (isNext ? 1 : -1)];
|
|
46
|
+
if (siblingSegment) {
|
|
47
|
+
return { value: { block: para, path: newPath, siblingSegment: siblingSegment } };
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// No sibling segment, let's keep go upper level
|
|
51
|
+
block = para;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return "break";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {
|
|
59
|
+
newPath.shift();
|
|
60
|
+
block = group;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return "break";
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
while (newPath.length > 0) {
|
|
67
|
+
var state_1 = _loop_1();
|
|
68
|
+
if (typeof state_1 === "object")
|
|
69
|
+
return state_1.value;
|
|
70
|
+
if (state_1 === "break")
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
exports.getLeafSiblingBlock = getLeafSiblingBlock;
|
|
76
76
|
//# sourceMappingURL=getLeafSiblingBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/utils/getLeafSiblingBlock.ts"],"names":[],"mappings":";;;;AAAA,2EAA+D;AA6B/D;;GAEG;AACH,SAAgB,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;IAEf,IAAM,OAAO,sDAAO,IAAI,SAAC,CAAC;;QAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;SAEd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,SAAS,IAAI,YAAY,EAAE;gBACxC,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzE,IAAI,CAAC,KAAK,EAAE;oCACD,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;iBAC7C;qBAAM,IAAI,KAAK,CAAC,SAAS,IAAI,YAAY,EAAE;oBACxC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CA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;SACjB;aAAM;;SAEN;;IAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;KA0DxB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AApED,kDAoEC","sourcesContent":["import { isGeneralSegment } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelBlock,\n ContentModelBlockGroup,\n ContentModelParagraph,\n ContentModelSegment,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport type BlockAndPath = {\n /**\n * The sibling block\n */\n block: ContentModelBlock;\n\n /**\n * Path of this sibling block\n */\n path: ContentModelBlockGroup[];\n\n /**\n * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.\n * Use this property to return the sibling sibling under the same paragraph\n */\n siblingSegment?: ContentModelSegment;\n};\n\n/**\n * @internal\n */\nexport function getLeafSiblingBlock(\n path: ContentModelBlockGroup[],\n block: ContentModelBlock,\n isNext: boolean\n): BlockAndPath | null {\n const newPath = [...path];\n\n while (newPath.length > 0) {\n const group = newPath[0];\n const index = group.blocks.indexOf(block);\n\n if (index < 0) {\n break;\n }\n\n let nextBlock = group.blocks[index + (isNext ? 1 : -1)];\n\n if (nextBlock) {\n while (nextBlock.blockType == 'BlockGroup') {\n const child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];\n\n if (!child) {\n return { block: nextBlock, path: newPath };\n } else if (child.blockType != 'BlockGroup') {\n newPath.unshift(nextBlock);\n return { block: child, path: newPath };\n } else {\n newPath.unshift(nextBlock);\n nextBlock = child;\n }\n }\n\n return { block: nextBlock, path: newPath };\n } else if (isGeneralSegment(group)) {\n // For general segment, we need to check if there is sibling segment under the same paragraph\n // First let's find the parent paragraph of this segment\n newPath.shift();\n\n let segmentIndex = -1;\n const segment = group;\n const para = newPath[0]?.blocks.find(\n x => x.blockType == 'Paragraph' && (segmentIndex = x.segments.indexOf(segment)) >= 0\n ) as ContentModelParagraph;\n\n if (para) {\n // Now we have found the parent paragraph, so let's check if it has a sibling segment\n const siblingSegment = para.segments[segmentIndex + (isNext ? 1 : -1)];\n\n if (siblingSegment) {\n // Return this block, path and segment since we have found it\n return { block: para, path: newPath, siblingSegment };\n } else {\n // No sibling segment, let's keep go upper level\n block = para;\n }\n } else {\n // Parent sibling is not found (in theory this should never happen), just return null\n break;\n }\n } else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {\n newPath.shift();\n block = group;\n } else {\n break;\n }\n }\n\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getLeafSiblingBlock.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/utils/getLeafSiblingBlock.ts"],"names":[],"mappings":";;;;AAAA,2EAA+D;AA6B/D;;GAEG;AACH,SAAgB,mBAAmB,CAC/B,IAA8B,EAC9B,KAAwB,EACxB,MAAe;;IAEf,IAAM,OAAO,sDAAO,IAAI,SAAC,CAAC;;QAGtB,IAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACzB,IAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1C,IAAI,KAAK,GAAG,CAAC,EAAE;;SAEd;QAED,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC,SAAS,IAAI,YAAY,EAAE;gBACxC,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;gBAEzE,IAAI,CAAC,KAAK,EAAE;oCACD,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE;iBAC7C;qBAAM,IAAI,KAAK,CAAC,SAAS,IAAI,YA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O,CAAC,KAAK,EAAE,CAAC;YAChB,KAAK,GAAG,KAAK,CAAC;SACjB;aAAM;;SAEN;;IAzDL,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC;;;;;;KA0DxB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AApED,kDAoEC","sourcesContent":["import { isGeneralSegment } from 'roosterjs-content-model-dom';\r\nimport type {\r\n ContentModelBlock,\r\n ContentModelBlockGroup,\r\n ContentModelParagraph,\r\n ContentModelSegment,\r\n} from 'roosterjs-content-model-types';\r\n\r\n/**\r\n * @internal\r\n */\r\nexport type BlockAndPath = {\r\n /**\r\n * The sibling block\r\n */\r\n block: ContentModelBlock;\r\n\r\n /**\r\n * Path of this sibling block\r\n */\r\n path: ContentModelBlockGroup[];\r\n\r\n /**\r\n * If the input block is under a general segment, it is possible there are sibling segments under the same paragraph.\r\n * Use this property to return the sibling sibling under the same paragraph\r\n */\r\n siblingSegment?: ContentModelSegment;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function getLeafSiblingBlock(\r\n path: ContentModelBlockGroup[],\r\n block: ContentModelBlock,\r\n isNext: boolean\r\n): BlockAndPath | null {\r\n const newPath = [...path];\r\n\r\n while (newPath.length > 0) {\r\n const group = newPath[0];\r\n const index = group.blocks.indexOf(block);\r\n\r\n if (index < 0) {\r\n break;\r\n }\r\n\r\n let nextBlock = group.blocks[index + (isNext ? 1 : -1)];\r\n\r\n if (nextBlock) {\r\n while (nextBlock.blockType == 'BlockGroup') {\r\n const child = nextBlock.blocks[isNext ? 0 : nextBlock.blocks.length - 1];\r\n\r\n if (!child) {\r\n return { block: nextBlock, path: newPath };\r\n } else if (child.blockType != 'BlockGroup') {\r\n newPath.unshift(nextBlock);\r\n return { block: child, path: newPath };\r\n } else {\r\n newPath.unshift(nextBlock);\r\n nextBlock = child;\r\n }\r\n }\r\n\r\n return { block: nextBlock, path: newPath };\r\n } else if (isGeneralSegment(group)) {\r\n // For general segment, we need to check if there is sibling segment under the same paragraph\r\n // First let's find the parent paragraph of this segment\r\n newPath.shift();\r\n\r\n let segmentIndex = -1;\r\n const segment = group;\r\n const para = newPath[0]?.blocks.find(\r\n x => x.blockType == 'Paragraph' && (segmentIndex = x.segments.indexOf(segment)) >= 0\r\n ) as ContentModelParagraph;\r\n\r\n if (para) {\r\n // Now we have found the parent paragraph, so let's check if it has a sibling segment\r\n const siblingSegment = para.segments[segmentIndex + (isNext ? 1 : -1)];\r\n\r\n if (siblingSegment) {\r\n // Return this block, path and segment since we have found it\r\n return { block: para, path: newPath, siblingSegment };\r\n } else {\r\n // No sibling segment, let's keep go upper level\r\n block = para;\r\n }\r\n } else {\r\n // Parent sibling is not found (in theory this should never happen), just return null\r\n break;\r\n }\r\n } else if (group.blockGroupType != 'Document' && group.blockGroupType != 'TableCell') {\r\n newPath.shift();\r\n block = group;\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n"]}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
|
|
2
|
-
/**
|
|
3
|
-
* Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
|
|
4
|
-
*/
|
|
5
|
-
export declare class EntityDelimiterPlugin implements EditorPlugin {
|
|
6
|
-
private editor;
|
|
7
|
-
/**
|
|
8
|
-
* Get a friendly name of this plugin
|
|
9
|
-
*/
|
|
10
|
-
getName(): string;
|
|
11
|
-
/**
|
|
12
|
-
* The first method that editor will call to a plugin when editor is initializing.
|
|
13
|
-
* It will pass in the editor instance, plugin should take this chance to save the
|
|
14
|
-
* editor reference so that it can call to any editor method or format API later.
|
|
15
|
-
* @param editor The editor object
|
|
16
|
-
*/
|
|
17
|
-
initialize(editor: IEditor): void;
|
|
18
|
-
/**
|
|
19
|
-
* The last method that editor will call to a plugin before it is disposed.
|
|
20
|
-
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
21
|
-
* called, plugin should not call to any editor method since it will result in error.
|
|
22
|
-
*/
|
|
23
|
-
dispose(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
26
|
-
* method of each plugin to handle the event as long as the event is not handled
|
|
27
|
-
* exclusively by another plugin.
|
|
28
|
-
* @param event The event to handle:
|
|
29
|
-
*/
|
|
30
|
-
onPluginEvent(event: PluginEvent): void;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export declare function normalizeDelimitersInEditor(editor: IEditor): void;
|
|
1
|
+
import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';
|
|
2
|
+
/**
|
|
3
|
+
* Entity delimiter plugin helps maintain delimiter elements around an entity so that user can put focus before/after an entity
|
|
4
|
+
*/
|
|
5
|
+
export declare class EntityDelimiterPlugin implements EditorPlugin {
|
|
6
|
+
private editor;
|
|
7
|
+
/**
|
|
8
|
+
* Get a friendly name of this plugin
|
|
9
|
+
*/
|
|
10
|
+
getName(): string;
|
|
11
|
+
/**
|
|
12
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
13
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
14
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
15
|
+
* @param editor The editor object
|
|
16
|
+
*/
|
|
17
|
+
initialize(editor: IEditor): void;
|
|
18
|
+
/**
|
|
19
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
20
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
21
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
22
|
+
*/
|
|
23
|
+
dispose(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
26
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
27
|
+
* exclusively by another plugin.
|
|
28
|
+
* @param event The event to handle:
|
|
29
|
+
*/
|
|
30
|
+
onPluginEvent(event: PluginEvent): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeDelimitersInEditor(editor: IEditor): void;
|