roosterjs-content-model-plugins 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/README.md +262 -0
- package/lib/edit/ContentModelEditPlugin.d.ts +35 -0
- package/lib/edit/ContentModelEditPlugin.js +71 -0
- package/lib/edit/ContentModelEditPlugin.js.map +1 -0
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +20 -0
- package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
- package/lib/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js +91 -0
- package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
- package/lib/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
- package/lib/edit/deleteSteps/deleteWordSelection.js +171 -0
- package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -0
- package/lib/edit/handleKeyboardEventCommon.d.ts +15 -0
- package/lib/edit/handleKeyboardEventCommon.js +55 -0
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -0
- package/lib/edit/keyboardDelete.d.ts +9 -0
- package/lib/edit/keyboardDelete.js +64 -0
- package/lib/edit/keyboardDelete.js.map +1 -0
- package/lib/edit/utils/getLeafSiblingBlock.d.ts +23 -0
- package/lib/edit/utils/getLeafSiblingBlock.js +76 -0
- package/lib/edit/utils/getLeafSiblingBlock.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/paste/ContentModelPastePlugin.d.ts +42 -0
- package/lib/paste/ContentModelPastePlugin.js +149 -0
- package/lib/paste/ContentModelPastePlugin.js.map +1 -0
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
- package/lib/paste/Excel/processPastedContentFromExcel.js +83 -0
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -0
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js +20 -0
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +208 -0
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +70 -0
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
- package/lib/paste/WordDesktop/processWordComments.d.ts +7 -0
- package/lib/paste/WordDesktop/processWordComments.js +22 -0
- package/lib/paste/WordDesktop/processWordComments.js.map +1 -0
- package/lib/paste/WordDesktop/processWordLists.d.ts +10 -0
- package/lib/paste/WordDesktop/processWordLists.js +155 -0
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -0
- package/lib/paste/pasteSourceValidations/constants.d.ts +17 -0
- package/lib/paste/pasteSourceValidations/constants.js +22 -0
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -0
- package/lib/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js +25 -0
- package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
- package/lib/paste/pasteSourceValidations/getPasteSource.js +44 -0
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +17 -0
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +19 -0
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +15 -0
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +15 -0
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +19 -0
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js +19 -0
- package/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
- package/lib/paste/utils/addParser.d.ts +5 -0
- package/lib/paste/utils/addParser.js +17 -0
- package/lib/paste/utils/addParser.js.map +1 -0
- package/lib/paste/utils/deprecatedColorParser.d.ts +5 -0
- package/lib/paste/utils/deprecatedColorParser.js +20 -0
- package/lib/paste/utils/deprecatedColorParser.js.map +1 -0
- package/lib/paste/utils/getStyles.d.ts +6 -0
- package/lib/paste/utils/getStyles.js +23 -0
- package/lib/paste/utils/getStyles.js.map +1 -0
- package/lib/paste/utils/linkParser.d.ts +5 -0
- package/lib/paste/utils/linkParser.js +28 -0
- package/lib/paste/utils/linkParser.js.map +1 -0
- package/lib/paste/utils/setProcessor.d.ts +5 -0
- package/lib/paste/utils/setProcessor.js +14 -0
- package/lib/paste/utils/setProcessor.js.map +1 -0
- package/lib-amd/edit/ContentModelEditPlugin.d.ts +35 -0
- package/lib-amd/edit/ContentModelEditPlugin.js +72 -0
- package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +21 -0
- package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +90 -0
- package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
- package/lib-amd/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js +170 -0
- package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -0
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +15 -0
- package/lib-amd/edit/handleKeyboardEventCommon.js +56 -0
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -0
- package/lib-amd/edit/keyboardDelete.d.ts +9 -0
- package/lib-amd/edit/keyboardDelete.js +60 -0
- package/lib-amd/edit/keyboardDelete.js.map +1 -0
- package/lib-amd/edit/utils/getLeafSiblingBlock.d.ts +23 -0
- package/lib-amd/edit/utils/getLeafSiblingBlock.js +76 -0
- package/lib-amd/edit/utils/getLeafSiblingBlock.js.map +1 -0
- package/lib-amd/index.d.ts +2 -0
- package/lib-amd/index.js +8 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/paste/ContentModelPastePlugin.d.ts +42 -0
- package/lib-amd/paste/ContentModelPastePlugin.js +141 -0
- package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -0
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js +81 -0
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -0
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js +21 -0
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +207 -0
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +65 -0
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
- package/lib-amd/paste/WordDesktop/processWordComments.d.ts +7 -0
- package/lib-amd/paste/WordDesktop/processWordComments.js +23 -0
- package/lib-amd/paste/WordDesktop/processWordComments.js.map +1 -0
- package/lib-amd/paste/WordDesktop/processWordLists.d.ts +10 -0
- package/lib-amd/paste/WordDesktop/processWordLists.js +154 -0
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +17 -0
- package/lib-amd/paste/pasteSourceValidations/constants.js +24 -0
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +27 -0
- package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js +39 -0
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +19 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +21 -0
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +17 -0
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +17 -0
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +21 -0
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js +21 -0
- package/lib-amd/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
- package/lib-amd/paste/utils/addParser.d.ts +5 -0
- package/lib-amd/paste/utils/addParser.js +19 -0
- package/lib-amd/paste/utils/addParser.js.map +1 -0
- package/lib-amd/paste/utils/deprecatedColorParser.d.ts +5 -0
- package/lib-amd/paste/utils/deprecatedColorParser.js +21 -0
- package/lib-amd/paste/utils/deprecatedColorParser.js.map +1 -0
- package/lib-amd/paste/utils/getStyles.d.ts +6 -0
- package/lib-amd/paste/utils/getStyles.js +25 -0
- package/lib-amd/paste/utils/getStyles.js.map +1 -0
- package/lib-amd/paste/utils/linkParser.d.ts +5 -0
- package/lib-amd/paste/utils/linkParser.js +29 -0
- package/lib-amd/paste/utils/linkParser.js.map +1 -0
- package/lib-amd/paste/utils/setProcessor.d.ts +5 -0
- package/lib-amd/paste/utils/setProcessor.js +16 -0
- package/lib-amd/paste/utils/setProcessor.js.map +1 -0
- package/lib-mjs/edit/ContentModelEditPlugin.d.ts +35 -0
- package/lib-mjs/edit/ContentModelEditPlugin.js +68 -0
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +16 -0
- package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.d.ts +9 -0
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +88 -0
- package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -0
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.d.ts +9 -0
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +168 -0
- package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -0
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +15 -0
- package/lib-mjs/edit/handleKeyboardEventCommon.js +49 -0
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -0
- package/lib-mjs/edit/keyboardDelete.d.ts +9 -0
- package/lib-mjs/edit/keyboardDelete.js +60 -0
- package/lib-mjs/edit/keyboardDelete.js.map +1 -0
- package/lib-mjs/edit/utils/getLeafSiblingBlock.d.ts +23 -0
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js +72 -0
- package/lib-mjs/edit/utils/getLeafSiblingBlock.js.map +1 -0
- package/lib-mjs/index.d.ts +2 -0
- package/lib-mjs/index.js +3 -0
- package/lib-mjs/index.js.map +1 -0
- package/lib-mjs/paste/ContentModelPastePlugin.d.ts +42 -0
- package/lib-mjs/paste/ContentModelPastePlugin.js +146 -0
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -0
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +13 -0
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +78 -0
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -0
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +7 -0
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js +16 -0
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -0
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +9 -0
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +204 -0
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -0
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +12 -0
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +65 -0
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -0
- package/lib-mjs/paste/WordDesktop/processWordComments.d.ts +7 -0
- package/lib-mjs/paste/WordDesktop/processWordComments.js +18 -0
- package/lib-mjs/paste/WordDesktop/processWordComments.js.map +1 -0
- package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +10 -0
- package/lib-mjs/paste/WordDesktop/processWordLists.js +151 -0
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +17 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.js +19 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +21 -0
- package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +27 -0
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js +40 -0
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +13 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +15 -0
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +11 -0
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +11 -0
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.d.ts +8 -0
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +15 -0
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.d.ts +9 -0
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js +15 -0
- package/lib-mjs/paste/pasteSourceValidations/shouldConvertToSingleImage.js.map +1 -0
- package/lib-mjs/paste/utils/addParser.d.ts +5 -0
- package/lib-mjs/paste/utils/addParser.js +14 -0
- package/lib-mjs/paste/utils/addParser.js.map +1 -0
- package/lib-mjs/paste/utils/deprecatedColorParser.d.ts +5 -0
- package/lib-mjs/paste/utils/deprecatedColorParser.js +16 -0
- package/lib-mjs/paste/utils/deprecatedColorParser.js.map +1 -0
- package/lib-mjs/paste/utils/getStyles.d.ts +6 -0
- package/lib-mjs/paste/utils/getStyles.js +19 -0
- package/lib-mjs/paste/utils/getStyles.js.map +1 -0
- package/lib-mjs/paste/utils/linkParser.d.ts +5 -0
- package/lib-mjs/paste/utils/linkParser.js +24 -0
- package/lib-mjs/paste/utils/linkParser.js.map +1 -0
- package/lib-mjs/paste/utils/setProcessor.d.ts +5 -0
- package/lib-mjs/paste/utils/setProcessor.js +10 -0
- package/lib-mjs/paste/utils/setProcessor.js.map +1 -0
- package/package.json +22 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GetSourceFunction } from './getPasteSource';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Checks whether the Array provided contains strings that identify Word Desktop documents
|
|
5
|
+
* @param props Properties related to the PasteEvent
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const isWordDesktopDocument: GetSourceFunction;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isWordDesktopDocument = void 0;
|
|
4
|
+
var WORD_ATTRIBUTE_NAME = 'xmlns:w';
|
|
5
|
+
var WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';
|
|
6
|
+
var WORD_PROG_ID = 'Word.Document';
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
* Checks whether the Array provided contains strings that identify Word Desktop documents
|
|
10
|
+
* @param props Properties related to the PasteEvent
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
var isWordDesktopDocument = function (props) {
|
|
14
|
+
var htmlAttributes = props.htmlAttributes;
|
|
15
|
+
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
16
|
+
htmlAttributes["ProgId" /* PROG_ID_NAME */] == WORD_PROG_ID);
|
|
17
|
+
};
|
|
18
|
+
exports.isWordDesktopDocument = isWordDesktopDocument;
|
|
19
|
+
//# sourceMappingURL=isWordDesktopDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":";;;AAGA,IAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;AACrE,IAAM,YAAY,GAAG,eAAe,CAAC;AAErC;;;;;GAKG;AACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;IACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;IACjC,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;QAC3D,cAAc,6BAAiC,IAAI,YAAY,CAClE,CAAC;AACN,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst WORD_ATTRIBUTE_NAME = 'xmlns:w';\nconst WORD_ATTRIBUTE_VALUE = 'urn:schemas-microsoft-com:office:word';\nconst WORD_PROG_ID = 'Word.Document';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Word Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isWordDesktopDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n return (\n htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID\n );\n};\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GetSourceFunction } from './getPasteSource';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Checks whether the fragment only contains a single image to paste
|
|
5
|
+
* and the editor have the ConvertSingleImageBody Experimental feature
|
|
6
|
+
* @param props Properties related to the PasteEvent
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare const shouldConvertToSingleImage: GetSourceFunction;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldConvertToSingleImage = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Checks whether the fragment only contains a single image to paste
|
|
7
|
+
* and the editor have the ConvertSingleImageBody Experimental feature
|
|
8
|
+
* @param props Properties related to the PasteEvent
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
var shouldConvertToSingleImage = function (props) {
|
|
12
|
+
var _a;
|
|
13
|
+
var shouldConvertSingleImage = props.shouldConvertSingleImage, clipboardData = props.clipboardData;
|
|
14
|
+
return (shouldConvertSingleImage &&
|
|
15
|
+
((_a = clipboardData.htmlFirstLevelChildTags) === null || _a === void 0 ? void 0 : _a.length) == 1 &&
|
|
16
|
+
clipboardData.htmlFirstLevelChildTags[0] == 'IMG');
|
|
17
|
+
};
|
|
18
|
+
exports.shouldConvertToSingleImage = shouldConvertToSingleImage;
|
|
19
|
+
//# sourceMappingURL=shouldConvertToSingleImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shouldConvertToSingleImage.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/shouldConvertToSingleImage.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;;IACtD,IAAA,wBAAwB,GAAoB,KAAK,yBAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IAC1D,OAAO,CACH,wBAAwB;QACxB,CAAA,MAAA,aAAa,CAAC,uBAAuB,0CAAE,MAAM,KAAI,CAAC;QAClD,aAAa,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,KAAK,CACpD,CAAC;AACN,CAAC,CAAC;AAPW,QAAA,0BAA0B,8BAOrC","sourcesContent":["import type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Checks whether the fragment only contains a single image to paste\n * and the editor have the ConvertSingleImageBody Experimental feature\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const shouldConvertToSingleImage: GetSourceFunction = props => {\n const { shouldConvertSingleImage, clipboardData } = props;\n return (\n shouldConvertSingleImage &&\n clipboardData.htmlFirstLevelChildTags?.length == 1 &&\n clipboardData.htmlFirstLevelChildTags[0] == 'IMG'\n );\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ContentModelFormatMap, DomToModelOption, FormatParser, FormatParsersPerCategory } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export default function addParser<TKey extends keyof FormatParsersPerCategory>(domToModelOption: DomToModelOption, entry: TKey, additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
function addParser(domToModelOption, entry, additionalFormatParsers) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (!domToModelOption.additionalFormatParsers) {
|
|
9
|
+
domToModelOption.additionalFormatParsers = {};
|
|
10
|
+
}
|
|
11
|
+
if (!domToModelOption.additionalFormatParsers[entry]) {
|
|
12
|
+
domToModelOption.additionalFormatParsers[entry] = [];
|
|
13
|
+
}
|
|
14
|
+
(_a = domToModelOption.additionalFormatParsers[entry]) === null || _a === void 0 ? void 0 : _a.push(additionalFormatParsers);
|
|
15
|
+
}
|
|
16
|
+
exports.default = addParser;
|
|
17
|
+
//# sourceMappingURL=addParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/addParser.ts"],"names":[],"mappings":";;AAOA;;GAEG;AACH,SAAwB,SAAS,CAC7B,gBAAkC,EAClC,KAAW,EACX,uBAAkE;;IAElE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;QAC3C,gBAAgB,CAAC,uBAAuB,GAAG,EAAE,CAAC;KACjD;IACD,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAClD,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;KACxD;IAED,MAAA,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,0CAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACnF,CAAC;AAbD,4BAaC","sourcesContent":["import type {\n ContentModelFormatMap,\n DomToModelOption,\n FormatParser,\n FormatParsersPerCategory,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport default function addParser<TKey extends keyof FormatParsersPerCategory>(\n domToModelOption: DomToModelOption,\n entry: TKey,\n additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>\n) {\n if (!domToModelOption.additionalFormatParsers) {\n domToModelOption.additionalFormatParsers = {};\n }\n if (!domToModelOption.additionalFormatParsers[entry]) {\n domToModelOption.additionalFormatParsers[entry] = [];\n }\n\n domToModelOption.additionalFormatParsers[entry]?.push(additionalFormatParsers);\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deprecatedBorderColorParser = void 0;
|
|
4
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
var deprecatedBorderColorParser = function (format) {
|
|
9
|
+
roosterjs_content_model_dom_1.BorderKeys.forEach(function (key) {
|
|
10
|
+
var value = format[key];
|
|
11
|
+
var color = '';
|
|
12
|
+
if (value &&
|
|
13
|
+
roosterjs_content_model_dom_1.DeprecatedColors.some(function (dColor) { return value.indexOf(dColor) > -1 && (color = dColor); })) {
|
|
14
|
+
var newValue = value.replace(color, '').trimRight();
|
|
15
|
+
format[key] = newValue;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.deprecatedBorderColorParser = deprecatedBorderColorParser;
|
|
20
|
+
//# sourceMappingURL=deprecatedColorParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecatedColorParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/deprecatedColorParser.ts"],"names":[],"mappings":";;;AAAA,2EAA2E;AAG3E;;GAEG;AACI,IAAM,2BAA2B,GAA+B,UACnE,MAAoB;IAEpB,wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QAClB,IAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,GAAW,EAAE,CAAC;QACvB,IACI,KAAK;YACL,8CAAgB,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,EAA9C,CAA8C,CAAC,EACjF;YACE,IAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;YACtD,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;SAC1B;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAdW,QAAA,2BAA2B,+BActC","sourcesContent":["import { BorderKeys, DeprecatedColors } from 'roosterjs-content-model-dom';\nimport type { BorderFormat, FormatParser } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deprecatedBorderColorParser: FormatParser<BorderFormat> = (\n format: BorderFormat\n): void => {\n BorderKeys.forEach(key => {\n const value = format[key];\n let color: string = '';\n if (\n value &&\n DeprecatedColors.some(dColor => value.indexOf(dColor) > -1 && (color = dColor))\n ) {\n const newValue = value.replace(color, '').trimRight();\n format[key] = newValue;\n }\n });\n};\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStyles = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Get CSS styles of a given element in name-value pair format
|
|
7
|
+
* @param element The element to get styles from
|
|
8
|
+
*/
|
|
9
|
+
function getStyles(element) {
|
|
10
|
+
var result = {};
|
|
11
|
+
var style = (element === null || element === void 0 ? void 0 : element.getAttribute('style')) || '';
|
|
12
|
+
style.split(';').forEach(function (pair) {
|
|
13
|
+
var valueIndex = pair.indexOf(':');
|
|
14
|
+
var name = pair.slice(0, valueIndex);
|
|
15
|
+
var value = pair.slice(valueIndex + 1);
|
|
16
|
+
if (name && value) {
|
|
17
|
+
result[name.trim()] = value.trim();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
exports.getStyles = getStyles;
|
|
23
|
+
//# sourceMappingURL=getStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStyles.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/getStyles.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAoB;IAC1C,IAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,IAAM,KAAK,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;IACnD,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAA,IAAI;QACzB,IAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACvC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;QACzC,IAAI,IAAI,IAAI,KAAK,EAAE;YACf,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;SACtC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAClB,CAAC;AAZD,8BAYC","sourcesContent":["/**\n * @internal\n * Get CSS styles of a given element in name-value pair format\n * @param element The element to get styles from\n */\nexport function getStyles(element: HTMLElement): Record<string, string> {\n const result: Record<string, string> = {};\n const style = element?.getAttribute('style') || '';\n style.split(';').forEach(pair => {\n const valueIndex = pair.indexOf(':');\n const name = pair.slice(0, valueIndex);\n const value = pair.slice(valueIndex + 1);\n if (name && value) {\n result[name.trim()] = value.trim();\n }\n });\n return result;\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseLink = void 0;
|
|
4
|
+
var roosterjs_content_model_dom_1 = require("roosterjs-content-model-dom");
|
|
5
|
+
var SUPPORTED_PROTOCOLS = ['http:', 'https:', 'notes:', 'mailto:', 'onenote:'];
|
|
6
|
+
var INVALID_LINKS_REGEX = /^file:\/\/\/[a-zA-Z\/]/i;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
var parseLink = function (format, element) {
|
|
11
|
+
if (!(0, roosterjs_content_model_dom_1.isElementOfType)(element, 'a')) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
var url;
|
|
15
|
+
try {
|
|
16
|
+
url = new URL(element.href);
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
url = undefined;
|
|
20
|
+
}
|
|
21
|
+
if ((url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) === -1) ||
|
|
22
|
+
INVALID_LINKS_REGEX.test(element.href)) {
|
|
23
|
+
element.removeAttribute('href');
|
|
24
|
+
format.href = '';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.parseLink = parseLink;
|
|
28
|
+
//# sourceMappingURL=linkParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/linkParser.ts"],"names":[],"mappings":";;;AAAA,2EAA8D;AAG9D,IAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACjF,IAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAEtD;;GAEG;AACI,IAAM,SAAS,GAA8C,UAAC,MAAM,EAAE,OAAO;IAChF,IAAI,CAAC,IAAA,6CAAe,EAAC,OAAO,EAAE,GAAG,CAAC,EAAE;QAChC,OAAO;KACV;IAED,IAAI,GAAoB,CAAC;IACzB,IAAI;QACA,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/B;IAAC,WAAM;QACJ,GAAG,GAAG,SAAS,CAAC;KACnB;IAED,IACI,CAAC,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACzD,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EACxC;QACE,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;KACpB;AACL,CAAC,CAAC;AAnBW,QAAA,SAAS,aAmBpB","sourcesContent":["import { isElementOfType } from 'roosterjs-content-model-dom';\nimport type { ContentModelHyperLinkFormat, FormatParser } from 'roosterjs-content-model-types';\n\nconst SUPPORTED_PROTOCOLS = ['http:', 'https:', 'notes:', 'mailto:', 'onenote:'];\nconst INVALID_LINKS_REGEX = /^file:\\/\\/\\/[a-zA-Z\\/]/i;\n\n/**\n * @internal\n */\nexport const parseLink: FormatParser<ContentModelHyperLinkFormat> = (format, element) => {\n if (!isElementOfType(element, 'a')) {\n return;\n }\n\n let url: URL | undefined;\n try {\n url = new URL(element.href);\n } catch {\n url = undefined;\n }\n\n if (\n (url && SUPPORTED_PROTOCOLS.indexOf(url.protocol) === -1) ||\n INVALID_LINKS_REGEX.test(element.href)\n ) {\n element.removeAttribute('href');\n format.href = '';\n }\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DomToModelOption, ElementProcessorMap } from 'roosterjs-content-model-types';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare function setProcessor<TKey extends keyof ElementProcessorMap>(domToModelOption: DomToModelOption, entry: TKey, processorOverride: Partial<ElementProcessorMap>[TKey]): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setProcessor = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
function setProcessor(domToModelOption, entry, processorOverride) {
|
|
8
|
+
if (!domToModelOption.processorOverride) {
|
|
9
|
+
domToModelOption.processorOverride = {};
|
|
10
|
+
}
|
|
11
|
+
domToModelOption.processorOverride[entry] = processorOverride;
|
|
12
|
+
}
|
|
13
|
+
exports.setProcessor = setProcessor;
|
|
14
|
+
//# sourceMappingURL=setProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setProcessor.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/setProcessor.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,SAAgB,YAAY,CACxB,gBAAkC,EAClC,KAAW,EACX,iBAAqD;IAErD,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE;QACrC,gBAAgB,CAAC,iBAAiB,GAAG,EAAE,CAAC;KAC3C;IAED,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC;AAClE,CAAC;AAVD,oCAUC","sourcesContent":["import type { DomToModelOption, ElementProcessorMap } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setProcessor<TKey extends keyof ElementProcessorMap>(\n domToModelOption: DomToModelOption,\n entry: TKey,\n processorOverride: Partial<ElementProcessorMap>[TKey]\n) {\n if (!domToModelOption.processorOverride) {\n domToModelOption.processorOverride = {};\n }\n\n domToModelOption.processorOverride[entry] = processorOverride;\n}\n"]}
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
define(["require", "exports", "./keyboardDelete"], function (require, exports, keyboardDelete_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ContentModelEditPlugin = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
7
|
+
* This includes:
|
|
8
|
+
* 1. Delete Key
|
|
9
|
+
* 2. Backspace Key
|
|
10
|
+
*/
|
|
11
|
+
var ContentModelEditPlugin = /** @class */ (function () {
|
|
12
|
+
function ContentModelEditPlugin() {
|
|
13
|
+
this.editor = null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get name of this plugin
|
|
17
|
+
*/
|
|
18
|
+
ContentModelEditPlugin.prototype.getName = function () {
|
|
19
|
+
return 'ContentModelEdit';
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The first method that editor will call to a plugin when editor is initializing.
|
|
23
|
+
* It will pass in the editor instance, plugin should take this chance to save the
|
|
24
|
+
* editor reference so that it can call to any editor method or format API later.
|
|
25
|
+
* @param editor The editor object
|
|
26
|
+
*/
|
|
27
|
+
ContentModelEditPlugin.prototype.initialize = function (editor) {
|
|
28
|
+
// TODO: Later we may need a different interface for Content Model editor plugin
|
|
29
|
+
this.editor = editor;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The last method that editor will call to a plugin before it is disposed.
|
|
33
|
+
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
34
|
+
* called, plugin should not call to any editor method since it will result in error.
|
|
35
|
+
*/
|
|
36
|
+
ContentModelEditPlugin.prototype.dispose = function () {
|
|
37
|
+
this.editor = null;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Core method for a plugin. Once an event happens in editor, editor will call this
|
|
41
|
+
* method of each plugin to handle the event as long as the event is not handled
|
|
42
|
+
* exclusively by another plugin.
|
|
43
|
+
* @param event The event to handle:
|
|
44
|
+
*/
|
|
45
|
+
ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
|
|
46
|
+
if (this.editor) {
|
|
47
|
+
switch (event.eventType) {
|
|
48
|
+
case 0 /* KeyDown */:
|
|
49
|
+
this.handleKeyDownEvent(this.editor, event);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
55
|
+
var rawEvent = event.rawEvent;
|
|
56
|
+
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
57
|
+
// TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model
|
|
58
|
+
switch (rawEvent.key) {
|
|
59
|
+
case 'Backspace':
|
|
60
|
+
case 'Delete':
|
|
61
|
+
// Use our API to handle BACKSPACE/DELETE key.
|
|
62
|
+
// 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
|
|
63
|
+
(0, keyboardDelete_1.keyboardDelete)(editor, rawEvent);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return ContentModelEditPlugin;
|
|
69
|
+
}());
|
|
70
|
+
exports.ContentModelEditPlugin = ContentModelEditPlugin;
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=ContentModelEditPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":";;;;IAUA;;;;;OAKG;IACH;QAAA;YACY,WAAM,GAA+B,IAAI,CAAC;QA4DtD,CAAC;QA1DG;;WAEG;QACH,wCAAO,GAAP;YACI,OAAO,kBAAkB,CAAC;QAC9B,CAAC;QAED;;;;;WAKG;QACH,2CAAU,GAAV,UAAW,MAAe;YACtB,gFAAgF;YAChF,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;QAChD,CAAC;QAED;;;;WAIG;QACH,wCAAO,GAAP;YACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACvB,CAAC;QAED;;;;;WAKG;QACH,8CAAa,GAAb,UAAc,KAAkB;YAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,QAAQ,KAAK,CAAC,SAAS,EAAE;oBACrB;wBACI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;wBAC5C,MAAM;iBACb;aACJ;QACL,CAAC;QAEO,mDAAkB,GAA1B,UAA2B,MAA2B,EAAE,KAAyB;YAC7E,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;YAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBAC3D,qHAAqH;gBACrH,QAAQ,QAAQ,CAAC,GAAG,EAAE;oBAClB,KAAK,WAAW,CAAC;oBACjB,KAAK,QAAQ;wBACT,8CAA8C;wBAC9C,qIAAqI;wBACrI,IAAA,+BAAc,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;wBACjC,MAAM;iBACb;aACJ;QACL,CAAC;QACL,6BAAC;IAAD,CAAC,AA7DD,IA6DC;IA7DY,wDAAsB","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\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 }\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-core"], function (require, exports, roosterjs_content_model_core_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.deleteAllSegmentBefore = void 0;
|
|
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
|
+
});
|
|
21
|
+
//# sourceMappingURL=deleteAllSegmentBefore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteAllSegmentBefore.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteAllSegmentBefore.ts"],"names":[],"mappings":";;;;IAGA;;OAEG;IACI,IAAM,sBAAsB,GAAwB,UAAA,OAAO;QACxD,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,SAAS,eAAA,EAAE,MAAM,YAAwB,CAAC;QAClD,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;YAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;gBAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;aAClC;SACJ;IACL,CAAC,CAAC;IAbW,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"]}
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
define(["require", "exports", "roosterjs-content-model-core", "../utils/getLeafSiblingBlock", "roosterjs-content-model-dom"], function (require, exports, roosterjs_content_model_core_1, getLeafSiblingBlock_1, roosterjs_content_model_dom_1) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.backwardDeleteCollapsedSelection = exports.forwardDeleteCollapsedSelection = void 0;
|
|
5
|
+
function getDeleteCollapsedSelection(direction) {
|
|
6
|
+
return function (context) {
|
|
7
|
+
var _a;
|
|
8
|
+
var isForward = direction == 'forward';
|
|
9
|
+
var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
|
|
10
|
+
var segments = paragraph.segments;
|
|
11
|
+
fixupBr(segments);
|
|
12
|
+
var index = segments.indexOf(marker) + (isForward ? 1 : -1);
|
|
13
|
+
var segmentToDelete = segments[index];
|
|
14
|
+
var blockToDelete;
|
|
15
|
+
if (segmentToDelete) {
|
|
16
|
+
if ((0, roosterjs_content_model_core_1.deleteSegment)(paragraph, segmentToDelete, context.formatContext, direction)) {
|
|
17
|
+
context.deleteResult = 'singleChar';
|
|
18
|
+
// It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit
|
|
19
|
+
// to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953
|
|
20
|
+
(0, roosterjs_content_model_dom_1.setParagraphNotImplicit)(paragraph);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else if ((blockToDelete = (0, getLeafSiblingBlock_1.getLeafSiblingBlock)(path, paragraph, isForward))) {
|
|
24
|
+
var block = blockToDelete.block, path_1 = blockToDelete.path, siblingSegment = blockToDelete.siblingSegment;
|
|
25
|
+
if (block.blockType == 'Paragraph') {
|
|
26
|
+
if (siblingSegment) {
|
|
27
|
+
// When selection is under general segment, need to check if it has a sibling sibling, and delete from it
|
|
28
|
+
if ((0, roosterjs_content_model_core_1.deleteSegment)(block, siblingSegment, context.formatContext, direction)) {
|
|
29
|
+
context.deleteResult = 'range';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (isForward) {
|
|
34
|
+
context.lastParagraph = block;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
if (((_a = block.segments[block.segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
38
|
+
block.segments.pop();
|
|
39
|
+
}
|
|
40
|
+
context.insertPoint = {
|
|
41
|
+
marker: marker,
|
|
42
|
+
paragraph: block,
|
|
43
|
+
path: path_1,
|
|
44
|
+
tableContext: tableContext,
|
|
45
|
+
};
|
|
46
|
+
context.lastParagraph = paragraph;
|
|
47
|
+
delete block.cachedElement;
|
|
48
|
+
}
|
|
49
|
+
context.deleteResult = 'range';
|
|
50
|
+
}
|
|
51
|
+
// When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context
|
|
52
|
+
context.lastTableContext = tableContext;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
if ((0, roosterjs_content_model_core_1.deleteBlock)(path_1[0].blocks, block, undefined /*replacement*/, context.formatContext, direction)) {
|
|
56
|
+
context.deleteResult = 'range';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// We have nothing to delete, in this case we don't want browser handle it as well.
|
|
62
|
+
// Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes
|
|
63
|
+
// editor is really empty. We don't want that happen. So the handling should stop here.
|
|
64
|
+
context.deleteResult = 'nothingToDelete';
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* If the last segment is BR, remove it for now. We may add it back later when normalize model.
|
|
70
|
+
* So that if this is an empty paragraph, it will start to delete next block
|
|
71
|
+
*/
|
|
72
|
+
function fixupBr(segments) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
if (((_a = segments[segments.length - 1]) === null || _a === void 0 ? void 0 : _a.segmentType) == 'Br') {
|
|
75
|
+
var segmentsWithoutBr = segments.filter(function (x) { return x.segmentType != 'SelectionMarker'; });
|
|
76
|
+
if (((_b = segmentsWithoutBr[segmentsWithoutBr.length - 2]) === null || _b === void 0 ? void 0 : _b.segmentType) != 'Br') {
|
|
77
|
+
segments.pop();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @internal if we didn't delete anything, and we want to delete forward, now perform it
|
|
83
|
+
*/
|
|
84
|
+
exports.forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');
|
|
85
|
+
/**
|
|
86
|
+
* @internal if we didn't delete anything, and we want to delete backward, now perform it
|
|
87
|
+
*/
|
|
88
|
+
exports.backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');
|
|
89
|
+
});
|
|
90
|
+
//# sourceMappingURL=deleteCollapsedSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":"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","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"]}
|
|
@@ -0,0 +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;
|