roosterjs-content-model-plugins 0.23.0 → 0.24.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/lib/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib/edit/ContentModelEditPlugin.js +1 -2
- package/lib/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib/edit/deleteSteps/deleteList.js +24 -0
- package/lib/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib/edit/handleKeyboardEventCommon.js +1 -1
- package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib/edit/keyboardDelete.d.ts +2 -2
- package/lib/edit/keyboardDelete.js +8 -1
- package/lib/edit/keyboardDelete.js.map +1 -1
- package/lib/edit/keyboardInput.d.ts +2 -2
- package/lib/edit/keyboardInput.js.map +1 -1
- package/lib/paste/ContentModelPastePlugin.d.ts +2 -2
- package/lib/paste/ContentModelPastePlugin.js +16 -25
- package/lib/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib/paste/WacComponents/processPastedContentWacComponents.js +59 -61
- package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -0
- package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib/paste/WordDesktop/processWordLists.js +2 -0
- package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +14 -0
- package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib/paste/pasteSourceValidations/constants.js +5 -6
- package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib/paste/utils/addParser.d.ts +2 -2
- package/lib/paste/utils/addParser.js.map +1 -1
- package/lib-amd/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-amd/edit/ContentModelEditPlugin.js +1 -2
- package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-amd/edit/deleteSteps/deleteList.js +25 -0
- package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-amd/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-amd/edit/keyboardDelete.d.ts +2 -2
- package/lib-amd/edit/keyboardDelete.js +8 -2
- package/lib-amd/edit/keyboardDelete.js.map +1 -1
- package/lib-amd/edit/keyboardInput.d.ts +2 -2
- package/lib-amd/edit/keyboardInput.js.map +1 -1
- package/lib-amd/paste/ContentModelPastePlugin.d.ts +2 -2
- package/lib-amd/paste/ContentModelPastePlugin.js +16 -26
- package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +58 -62
- package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -1
- package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js +2 -1
- package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +16 -0
- package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-amd/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-amd/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -3
- package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -2
- package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-amd/paste/utils/addParser.d.ts +2 -2
- package/lib-amd/paste/utils/addParser.js.map +1 -1
- package/lib-mjs/edit/ContentModelEditPlugin.d.ts +2 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js +1 -2
- package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
- package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js +20 -0
- package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -0
- package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -3
- package/lib-mjs/edit/handleKeyboardEventCommon.js +1 -1
- package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
- package/lib-mjs/edit/keyboardDelete.d.ts +2 -2
- package/lib-mjs/edit/keyboardDelete.js +8 -1
- package/lib-mjs/edit/keyboardDelete.js.map +1 -1
- package/lib-mjs/edit/keyboardInput.d.ts +2 -2
- package/lib-mjs/edit/keyboardInput.js.map +1 -1
- package/lib-mjs/paste/ContentModelPastePlugin.d.ts +2 -2
- package/lib-mjs/paste/ContentModelPastePlugin.js +16 -25
- package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
- package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
- package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +59 -61
- package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +2 -0
- package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/processWordLists.js +2 -0
- package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +10 -0
- package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
- package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +5 -5
- package/lib-mjs/paste/pasteSourceValidations/constants.js +5 -6
- package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
- package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
- package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
- package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
- package/lib-mjs/paste/utils/addParser.d.ts +2 -2
- package/lib-mjs/paste/utils/addParser.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":";;;;IAGA,wCAAwC;IACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;IAEnD;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,iJAAiJ;QACjJ,OAAO,CACH,cAAc,
|
|
1
|
+
{"version":3,"file":"isExcelOnlineDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isExcelOnlineDocument.ts"],"names":[],"mappings":";;;;IAGA,wCAAwC;IACxC,IAAM,4BAA4B,GAAG,aAAa,CAAC;IAEnD;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,iJAAiJ;QACjJ,OAAO,CACH,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,4BAA4B;YAC/E,cAAc,CAAC,8BAAkB,CAAC,4BAA4B,CAAC,IAAI,SAAS,CAC/E,CAAC;IACN,CAAC,CAAC;IAPW,QAAA,qBAAqB,yBAOhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n// Excel Desktop also has this attribute\nconst EXCEL_ONLINE_ATTRIBUTE_VALUE = 'Excel.Sheet';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Excel Online documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isExcelOnlineDocument: GetSourceFunction = props => {\n const { htmlAttributes } = props;\n // The presence of Excel.Sheet confirms its origin from Excel, the absence of EXCEL_DESKTOP_ATTRIBUTE_NAME confirms it is from the Online version\n return (\n htmlAttributes[PastePropertyNames.PROG_ID_NAME] == EXCEL_ONLINE_ATTRIBUTE_VALUE &&\n htmlAttributes[PastePropertyNames.EXCEL_DESKTOP_ATTRIBUTE_NAME] == undefined\n );\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports"], function (require, exports) {
|
|
1
|
+
define(["require", "exports", "./constants"], function (require, exports, constants_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.isGoogleSheetDocument = void 0;
|
|
@@ -10,7 +10,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
10
10
|
*/
|
|
11
11
|
var isGoogleSheetDocument = function (props) {
|
|
12
12
|
var fragment = props.fragment;
|
|
13
|
-
return !!fragment.querySelector(
|
|
13
|
+
return !!fragment.querySelector(constants_1.PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
14
14
|
};
|
|
15
15
|
exports.isGoogleSheetDocument = isGoogleSheetDocument;
|
|
16
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"isGoogleSheetDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isGoogleSheetDocument.ts"],"names":[],"mappings":";;;;IAGA;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;QAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,8BAAkB,CAAC,sBAAsB,CAAC,CAAC;IAC/E,CAAC,CAAC;IAHW,QAAA,qBAAqB,yBAGhC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Checks whether the fragment provided contain elements from Google sheets\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isGoogleSheetDocument: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports"], function (require, exports) {
|
|
1
|
+
define(["require", "exports", "./constants"], function (require, exports, constants_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.isPowerPointDesktopDocument = void 0;
|
|
@@ -10,7 +10,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
var isPowerPointDesktopDocument = function (props) {
|
|
13
|
-
return props.htmlAttributes[
|
|
13
|
+
return props.htmlAttributes[constants_1.PastePropertyNames.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;
|
|
14
14
|
};
|
|
15
15
|
exports.isPowerPointDesktopDocument = isPowerPointDesktopDocument;
|
|
16
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;IAEtD;;;;;OAKG;IACI,IAAM,2BAA2B,GAAsB,UAAA,KAAK;QAC/D,OAAO,KAAK,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"isPowerPointDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,0BAA0B,GAAG,kBAAkB,CAAC;IAEtD;;;;;OAKG;IACI,IAAM,2BAA2B,GAAsB,UAAA,KAAK;QAC/D,OAAO,KAAK,CAAC,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,0BAA0B,CAAC;IAC/F,CAAC,CAAC;IAFW,QAAA,2BAA2B,+BAEtC","sourcesContent":["import { PastePropertyNames } from './constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\nconst POWERPOINT_ATTRIBUTE_VALUE = 'PowerPoint.Slide';\n\n/**\n * @internal\n * Checks whether the Array provided contains strings that identify Power Point Desktop documents\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const isPowerPointDesktopDocument: GetSourceFunction = props => {\n return props.htmlAttributes[PastePropertyNames.PROG_ID_NAME] == POWERPOINT_ATTRIBUTE_VALUE;\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
define(["require", "exports"], function (require, exports) {
|
|
1
|
+
define(["require", "exports", "./constants"], function (require, exports, constants_1) {
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.isWordDesktopDocument = void 0;
|
|
@@ -14,7 +14,7 @@ define(["require", "exports"], function (require, exports) {
|
|
|
14
14
|
var isWordDesktopDocument = function (props) {
|
|
15
15
|
var htmlAttributes = props.htmlAttributes;
|
|
16
16
|
return (htmlAttributes[WORD_ATTRIBUTE_NAME] == WORD_ATTRIBUTE_VALUE ||
|
|
17
|
-
htmlAttributes[
|
|
17
|
+
htmlAttributes[constants_1.PastePropertyNames.PROG_ID_NAME] == WORD_PROG_ID);
|
|
18
18
|
};
|
|
19
19
|
exports.isWordDesktopDocument = isWordDesktopDocument;
|
|
20
20
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,mBAAmB,GAAG,SAAS,CAAC;IACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;IACrE,IAAM,YAAY,GAAG,eAAe,CAAC;IAErC;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;YAC3D,cAAc,
|
|
1
|
+
{"version":3,"file":"isWordDesktopDocument.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/isWordDesktopDocument.ts"],"names":[],"mappings":";;;;IAGA,IAAM,mBAAmB,GAAG,SAAS,CAAC;IACtC,IAAM,oBAAoB,GAAG,uCAAuC,CAAC;IACrE,IAAM,YAAY,GAAG,eAAe,CAAC;IAErC;;;;;OAKG;IACI,IAAM,qBAAqB,GAAsB,UAAA,KAAK;QACjD,IAAA,cAAc,GAAK,KAAK,eAAV,CAAW;QACjC,OAAO,CACH,cAAc,CAAC,mBAAmB,CAAC,IAAI,oBAAoB;YAC3D,cAAc,CAAC,8BAAkB,CAAC,YAAY,CAAC,IAAI,YAAY,CAClE,CAAC;IACN,CAAC,CAAC;IANW,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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentModelFormatMap, DomToModelOption, FormatParser,
|
|
1
|
+
import type { ContentModelFormatMap, DomToModelOption, FormatParser, ElementFormatParserPerCategory } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export default function addParser<TKey extends keyof
|
|
5
|
+
export default function addParser<TKey extends keyof ElementFormatParserPerCategory>(domToModelOption: DomToModelOption, entry: TKey, additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/addParser.ts"],"names":[],"mappings":";;;IAOA;;OAEG;IACH,SAAwB,SAAS,CAC7B,gBAAkC,EAClC,KAAW,EACX,uBAAkE;;QAElE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;YAC3C,gBAAgB,CAAC,uBAAuB,GAAG,EAAE,CAAC;SACjD;QACD,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;YAClD,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SACxD;QAED,MAAA,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,0CAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACnF,CAAC;IAbD,4BAaC","sourcesContent":["import type {\n ContentModelFormatMap,\n DomToModelOption,\n FormatParser,\n
|
|
1
|
+
{"version":3,"file":"addParser.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/utils/addParser.ts"],"names":[],"mappings":";;;IAOA;;OAEG;IACH,SAAwB,SAAS,CAC7B,gBAAkC,EAClC,KAAW,EACX,uBAAkE;;QAElE,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,EAAE;YAC3C,gBAAgB,CAAC,uBAAuB,GAAG,EAAE,CAAC;SACjD;QACD,IAAI,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;YAClD,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;SACxD;QAED,MAAA,gBAAgB,CAAC,uBAAuB,CAAC,KAAK,CAAC,0CAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACnF,CAAC;IAbD,4BAaC","sourcesContent":["import type {\n ContentModelFormatMap,\n DomToModelOption,\n FormatParser,\n ElementFormatParserPerCategory,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport default function addParser<TKey extends keyof ElementFormatParserPerCategory>(\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorPlugin,
|
|
1
|
+
import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* ContentModel edit plugins helps editor to do editing operation on top of content model.
|
|
4
4
|
* This includes:
|
|
@@ -17,7 +17,7 @@ export declare class ContentModelEditPlugin implements EditorPlugin {
|
|
|
17
17
|
* editor reference so that it can call to any editor method or format API later.
|
|
18
18
|
* @param editor The editor object
|
|
19
19
|
*/
|
|
20
|
-
initialize(editor:
|
|
20
|
+
initialize(editor: IStandaloneEditor): void;
|
|
21
21
|
/**
|
|
22
22
|
* The last method that editor will call to a plugin before it is disposed.
|
|
23
23
|
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
@@ -43,7 +43,7 @@ var ContentModelEditPlugin = /** @class */ (function () {
|
|
|
43
43
|
ContentModelEditPlugin.prototype.onPluginEvent = function (event) {
|
|
44
44
|
if (this.editor) {
|
|
45
45
|
switch (event.eventType) {
|
|
46
|
-
case
|
|
46
|
+
case 'keyDown':
|
|
47
47
|
this.handleKeyDownEvent(this.editor, event);
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
@@ -52,7 +52,6 @@ var ContentModelEditPlugin = /** @class */ (function () {
|
|
|
52
52
|
ContentModelEditPlugin.prototype.handleKeyDownEvent = function (editor, event) {
|
|
53
53
|
var rawEvent = event.rawEvent;
|
|
54
54
|
if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {
|
|
55
|
-
// TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model
|
|
56
55
|
switch (rawEvent.key) {
|
|
57
56
|
case 'Backspace':
|
|
58
57
|
case 'Delete':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/ContentModelEditPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD;;;;;GAKG;AACH;IAAA;QACY,WAAM,GAA6B,IAAI,CAAC;IAgEpD,CAAC;IA9DG;;OAEG;IACH,wCAAO,GAAP;QACI,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,2CAAU,GAAV,UAAW,MAAyB;QAChC,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,wCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,8CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB,KAAK,SAAS;oBACV,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,mDAAkB,GAA1B,UAA2B,MAAyB,EAAE,KAAmB;QACrE,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,QAAQ;oBACT,8CAA8C;oBAC9C,qIAAqI;oBACrI,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBACjC,MAAM;gBAEV,KAAK,OAAO,CAAC;gBACb;oBACI,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBAChC,MAAM;aACb;SACJ;IACL,CAAC;IACL,6BAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport type {\n EditorPlugin,\n IStandaloneEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-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: IStandaloneEditor | 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: IStandaloneEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor;\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 'keyDown':\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IStandaloneEditor, event: KeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n switch (rawEvent.key) {\n case 'Backspace':\n case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n\n case 'Enter':\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getClosestAncestorBlockGroupIndex } from 'roosterjs-content-model-core';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export var deleteList = function (context) {
|
|
6
|
+
var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker, path = _a.path;
|
|
7
|
+
if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') {
|
|
8
|
+
var index = getClosestAncestorBlockGroupIndex(path, ['ListItem', 'TableCell']);
|
|
9
|
+
var item = path[index];
|
|
10
|
+
if (index >= 0 &&
|
|
11
|
+
paragraph.segments[0] == marker &&
|
|
12
|
+
item.blockGroupType == 'ListItem' &&
|
|
13
|
+
(paragraph.segments.length == 1 ||
|
|
14
|
+
(paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))) {
|
|
15
|
+
item.levels = [];
|
|
16
|
+
context.deleteResult = 'range';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=deleteList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteList.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,8BAA8B,CAAC;AAGjF;;GAEG;AACH,MAAM,CAAC,IAAM,UAAU,GAAwB,UAAA,OAAO;IAC5C,IAAA,KAA8B,OAAO,CAAC,WAAW,EAA/C,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAwB,CAAC;IAExD,IAAI,OAAO,CAAC,YAAY,IAAI,iBAAiB,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;QACnF,IAAM,KAAK,GAAG,iCAAiC,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;QACjF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,IACI,KAAK,IAAI,CAAC;YACV,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM;YAC/B,IAAI,CAAC,cAAc,IAAI,UAAU;YACjC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC;gBAC3B,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,EACpF;YACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACjB,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;SAClC;KACJ;AACL,CAAC,CAAC","sourcesContent":["import { getClosestAncestorBlockGroupIndex } from 'roosterjs-content-model-core';\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteList: DeleteSelectionStep = context => {\n const { paragraph, marker, path } = context.insertPoint;\n\n if (context.deleteResult == 'nothingToDelete' || context.deleteResult == 'notDeleted') {\n const index = getClosestAncestorBlockGroupIndex(path, ['ListItem', 'TableCell']);\n const item = path[index];\n if (\n index >= 0 &&\n paragraph.segments[0] == marker &&\n item.blockGroupType == 'ListItem' &&\n (paragraph.segments.length == 1 ||\n (paragraph.segments.length == 2 && paragraph.segments[1].segmentType == 'Br'))\n ) {\n item.levels = [];\n context.deleteResult = 'range';\n }\n }\n};\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ContentModelDocument, DeleteResult, FormatWithContentModelContext } from 'roosterjs-content-model-types';
|
|
1
|
+
import type { ContentModelDocument, DeleteResult, FormatWithContentModelContext, IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
* @return True means content is changed, so need to rewrite content model to editor. Otherwise false
|
|
6
5
|
*/
|
|
7
|
-
export declare function handleKeyboardEventResult(editor:
|
|
6
|
+
export declare function handleKeyboardEventResult(editor: IStandaloneEditor, model: ContentModelDocument, rawEvent: KeyboardEvent, result: DeleteResult, context: FormatWithContentModelContext): boolean;
|
|
8
7
|
/**
|
|
9
8
|
* @internal
|
|
10
9
|
*/
|
|
@@ -27,7 +27,7 @@ export function handleKeyboardEventResult(editor, model, rawEvent, result, conte
|
|
|
27
27
|
}
|
|
28
28
|
// Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.
|
|
29
29
|
// So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.
|
|
30
|
-
editor.
|
|
30
|
+
editor.triggerEvent('beforeKeyboardEditing', {
|
|
31
31
|
rawEvent: rawEvent,
|
|
32
32
|
});
|
|
33
33
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/handleKeyboardEventCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"handleKeyboardEventCommon.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/handleKeyboardEventCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAQpE;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACrC,MAAyB,EACzB,KAA2B,EAC3B,QAAuB,EACvB,MAAoB,EACpB,OAAsC;IAEtC,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,eAAe,GAAG,KAAK,CAAC;IAEhC,QAAQ,MAAM,EAAE;QACZ,KAAK,YAAY;YACb,kHAAkH;YAClH,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;YAE/B,6GAA6G;YAC7G,OAAO,KAAK,CAAC;QAEjB,KAAK,iBAAiB;YAClB,sFAAsF;YACtF,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QAEjB,KAAK,OAAO,CAAC;QACb,KAAK,YAAY;YACb,kGAAkG;YAClG,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAE7B,IAAI,MAAM,IAAI,OAAO,EAAE;gBACnB,sEAAsE;gBACtE,OAAO,CAAC,gBAAgB,GAAG,KAAK,CAAC;aACpC;YAED,6GAA6G;YAC7G,oHAAoH;YACpH,MAAM,CAAC,YAAY,CAAC,uBAAuB,EAAE;gBACzC,QAAQ,UAAA;aACX,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;KACnB;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAuB,EAAE,KAAc;IACpE,OAAO,CACH,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC/C,CAAC,CAAC,KAAK,IAAI,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACnD,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,QAAuB;IACjE,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AAChD,CAAC","sourcesContent":["import { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelDocument,\n DeleteResult,\n FormatWithContentModelContext,\n IStandaloneEditor,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * @return True means content is changed, so need to rewrite content model to editor. Otherwise false\n */\nexport function handleKeyboardEventResult(\n editor: IStandaloneEditor,\n model: ContentModelDocument,\n rawEvent: KeyboardEvent,\n result: DeleteResult,\n context: FormatWithContentModelContext\n): boolean {\n context.skipUndoSnapshot = true;\n context.clearModelCache = false;\n\n switch (result) {\n case 'notDeleted':\n // We have not delete anything, we will let browser handle this event, so that current cached model may be invalid\n context.clearModelCache = true;\n\n // Return false here since we didn't do any change to Content Model, so no need to rewrite with Content Model\n return false;\n\n case 'nothingToDelete':\n // We known there is nothing to delete, no need to let browser keep handling the event\n rawEvent.preventDefault();\n return false;\n\n case 'range':\n case 'singleChar':\n // We have deleted what we need from content model, no need to let browser keep handling the event\n rawEvent.preventDefault();\n normalizeContentModel(model);\n\n if (result == 'range') {\n // A range is about to be deleted, so add an undo snapshot immediately\n context.skipUndoSnapshot = false;\n }\n\n // Trigger an event to let plugins know the content is about to be changed by Content Model keyboard editing.\n // So plugins can do proper handling. e.g. UndoPlugin can decide whether take a snapshot before this change happens.\n editor.triggerEvent('beforeKeyboardEditing', {\n rawEvent,\n });\n\n return true;\n }\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteWord(rawEvent: KeyboardEvent, isMac: boolean) {\n return (\n (isMac && rawEvent.altKey && !rawEvent.metaKey) ||\n (!isMac && rawEvent.ctrlKey && !rawEvent.altKey)\n );\n}\n\n/**\n * @internal\n */\nexport function shouldDeleteAllSegmentsBefore(rawEvent: KeyboardEvent) {\n return rawEvent.metaKey && !rawEvent.altKey;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
* Do keyboard event handling for DELETE/BACKSPACE key
|
|
5
5
|
* @param editor The Content Model Editor
|
|
6
6
|
* @param rawEvent DOM keyboard event
|
|
7
7
|
*/
|
|
8
|
-
export declare function keyboardDelete(editor:
|
|
8
|
+
export declare function keyboardDelete(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChangeSource, deleteSelection, isModifierKey } from 'roosterjs-content-model-core';
|
|
2
2
|
import { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';
|
|
3
|
+
import { deleteList } from './deleteSteps/deleteList';
|
|
3
4
|
import { isNodeOfType } from 'roosterjs-content-model-dom';
|
|
4
5
|
import { handleKeyboardEventResult, shouldDeleteAllSegmentsBefore, shouldDeleteWord, } from './handleKeyboardEventCommon';
|
|
5
6
|
import { backwardDeleteWordSelection, forwardDeleteWordSelection, } from './deleteSteps/deleteWordSelection';
|
|
@@ -36,7 +37,13 @@ function getDeleteSteps(rawEvent, isMac) {
|
|
|
36
37
|
var deleteCollapsedSelection = isForward
|
|
37
38
|
? forwardDeleteCollapsedSelection
|
|
38
39
|
: backwardDeleteCollapsedSelection;
|
|
39
|
-
|
|
40
|
+
var deleteListStep = !isForward ? deleteList : null;
|
|
41
|
+
return [
|
|
42
|
+
deleteAllSegmentBeforeStep,
|
|
43
|
+
deleteWordSelection,
|
|
44
|
+
deleteCollapsedSelection,
|
|
45
|
+
deleteListStep,
|
|
46
|
+
];
|
|
40
47
|
}
|
|
41
48
|
function shouldDeleteWithContentModel(selection, rawEvent) {
|
|
42
49
|
if (!selection) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACH,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gCAAgC,EAChC,+BAA+B,GAClC,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACH,yBAAyB,EACzB,6BAA6B,EAC7B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,2BAA2B,EAC3B,0BAA0B,GAC7B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gCAAgC,EAChC,+BAA+B,GAClC,MAAM,wCAAwC,CAAC;AAOhD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAAyB,EAAE,QAAuB;IAC7E,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,eAAe,CAC1B,KAAK,EACL,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,EACzD,OAAO,CACV,CAAC,YAAY,CAAC;YAEf,OAAO,yBAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC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D;KAC5E;SAAM;QACH,IAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC;QAE9B,oGAAoG;QACpG,OAAO,CAAC,CACJ,YAAY,CAAC,KAAK,CAAC,cAAc,EAAE,WAAW,CAAC;YAC/C,CAAC,aAAa,CAAC,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';\nimport { deleteAllSegmentBefore } from './deleteSteps/deleteAllSegmentBefore';\nimport { deleteList } from './deleteSteps/deleteList';\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 {\n DOMSelection,\n DeleteSelectionStep,\n IStandaloneEditor,\n} 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: IStandaloneEditor, 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 const deleteListStep = !isForward ? deleteList : null;\n return [\n deleteAllSegmentBeforeStep,\n deleteWordSelection,\n deleteCollapsedSelection,\n deleteListStep,\n ];\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,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IStandaloneEditor } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
5
|
-
export declare function keyboardInput(editor:
|
|
5
|
+
export declare function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent): true | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGpE;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,QAAuB;IAC5E,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,YAAY,EAAE,CAAC;QAEtB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;YACX,IAAM,MAAM,GAAG,eAAe,CAAC,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,qBAAqB,CAAC,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;AAED,SAAS,2BAA2B,CAChC,SAA8B,EAC9B,QAAuB,EACvB,OAAgB;IAEhB,IAAI,CAAC,SAAS,EAAE;QACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;KACrC;SAAM,IACH,CAAC,aAAa,CAAC,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';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { DOMSelection, IStandaloneEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IStandaloneEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent, editor.isInIME())) {\n editor.takeSnapshot();\n\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(model, [], context);\n\n // We have deleted selection then we will let browser to handle the input.\n // With this combined operation, we don't wan to mass up the cached model so clear it\n context.clearModelCache = true;\n\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\n context.skipUndoSnapshot = true;\n\n if (result.deleteResult == 'range') {\n // We have deleted something, next input should inherit the segment format from deleted content, so set pending format here\n context.newPendingFormat = result.insertPoint?.marker.format;\n\n normalizeContentModel(model);\n\n // Do not preventDefault since we still want browser to handle the final input for now\n return true;\n } else {\n return false;\n }\n },\n {\n rawEvent,\n }\n );\n\n return true;\n }\n}\n\nfunction shouldInputWithContentModel(\n selection: DOMSelection | null,\n rawEvent: KeyboardEvent,\n isInIME: boolean\n) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (\n !isModifierKey(rawEvent) &&\n (rawEvent.key == 'Enter' || rawEvent.key == 'Space' || rawEvent.key.length == 1)\n ) {\n return (\n selection.type != 'range' ||\n (!selection.range.collapsed && !rawEvent.isComposing && !isInIME)\n ); // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorPlugin,
|
|
1
|
+
import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
4
4
|
* 1. Content copied from Word
|
|
@@ -26,7 +26,7 @@ export declare class ContentModelPastePlugin implements EditorPlugin {
|
|
|
26
26
|
* editor reference so that it can call to any editor method or format API later.
|
|
27
27
|
* @param editor The editor object
|
|
28
28
|
*/
|
|
29
|
-
initialize(editor:
|
|
29
|
+
initialize(editor: IStandaloneEditor): void;
|
|
30
30
|
/**
|
|
31
31
|
* The last method that editor will call to a plugin before it is disposed.
|
|
32
32
|
* Plugin can take this chance to clear the reference to editor. After this method is
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import addParser from './utils/addParser';
|
|
3
2
|
import { BorderKeys } from 'roosterjs-content-model-dom';
|
|
4
3
|
import { deprecatedBorderColorParser } from './utils/deprecatedColorParser';
|
|
5
4
|
import { getPasteSource } from './pasteSourceValidations/getPasteSource';
|
|
6
5
|
import { parseLink } from './utils/linkParser';
|
|
6
|
+
import { PastePropertyNames } from './pasteSourceValidations/constants';
|
|
7
7
|
import { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';
|
|
8
8
|
import { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';
|
|
9
9
|
import { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';
|
|
10
10
|
import { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';
|
|
11
|
-
// Map old PasteType to new PasteType
|
|
12
|
-
// TODO: We can remove this once we have standalone editor
|
|
13
|
-
var PasteTypeMap = (_a = {},
|
|
14
|
-
_a[3 /* AsImage */] = 'asImage',
|
|
15
|
-
_a[1 /* AsPlainText */] = 'asPlainText',
|
|
16
|
-
_a[2 /* MergeFormat */] = 'mergeFormat',
|
|
17
|
-
_a[0 /* Normal */] = 'normal',
|
|
18
|
-
_a);
|
|
19
11
|
/**
|
|
20
12
|
* Paste plugin, handles BeforePaste event and reformat some special content, including:
|
|
21
13
|
* 1. Content copied from Word
|
|
@@ -65,43 +57,42 @@ var ContentModelPastePlugin = /** @class */ (function () {
|
|
|
65
57
|
* @param event The event to handle:
|
|
66
58
|
*/
|
|
67
59
|
ContentModelPastePlugin.prototype.onPluginEvent = function (event) {
|
|
68
|
-
if (!this.editor || event.eventType !=
|
|
60
|
+
if (!this.editor || event.eventType != 'beforePaste') {
|
|
69
61
|
return;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
|
-
if (!ev.domToModelOption) {
|
|
63
|
+
if (!event.domToModelOption) {
|
|
73
64
|
return;
|
|
74
65
|
}
|
|
75
|
-
var pasteSource = getPasteSource(
|
|
76
|
-
var pasteType =
|
|
66
|
+
var pasteSource = getPasteSource(event, false);
|
|
67
|
+
var pasteType = event.pasteType;
|
|
77
68
|
switch (pasteSource) {
|
|
78
69
|
case 'wordDesktop':
|
|
79
|
-
processPastedContentFromWordDesktop(
|
|
70
|
+
processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());
|
|
80
71
|
break;
|
|
81
72
|
case 'wacComponents':
|
|
82
|
-
processPastedContentWacComponents(
|
|
73
|
+
processPastedContentWacComponents(event);
|
|
83
74
|
break;
|
|
84
75
|
case 'excelOnline':
|
|
85
76
|
case 'excelDesktop':
|
|
86
77
|
if (pasteType === 'normal' || pasteType === 'mergeFormat') {
|
|
87
78
|
// Handle HTML copied from Excel
|
|
88
|
-
processPastedContentFromExcel(
|
|
79
|
+
processPastedContentFromExcel(event, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
|
|
89
80
|
}
|
|
90
81
|
break;
|
|
91
82
|
case 'googleSheets':
|
|
92
|
-
|
|
83
|
+
event.domToModelOption.additionalAllowedTags.push(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
|
|
93
84
|
break;
|
|
94
85
|
case 'powerPointDesktop':
|
|
95
|
-
processPastedContentFromPowerPoint(
|
|
86
|
+
processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());
|
|
96
87
|
break;
|
|
97
88
|
}
|
|
98
|
-
addParser(
|
|
99
|
-
addParser(
|
|
100
|
-
addParser(
|
|
101
|
-
addParser(
|
|
89
|
+
addParser(event.domToModelOption, 'link', parseLink);
|
|
90
|
+
addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);
|
|
91
|
+
addParser(event.domToModelOption, 'tableCell', tableBorderParser);
|
|
92
|
+
addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);
|
|
102
93
|
if (pasteType === 'mergeFormat') {
|
|
103
|
-
addParser(
|
|
104
|
-
addParser(
|
|
94
|
+
addParser(event.domToModelOption, 'block', blockElementParser);
|
|
95
|
+
addParser(event.domToModelOption, 'listLevel', blockElementParser);
|
|
105
96
|
}
|
|
106
97
|
};
|
|
107
98
|
return ContentModelPastePlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAE,mCAAmC,EAAE,MAAM,mDAAmD,CAAC;AACxG,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AAYtG,qCAAqC;AACrC,0DAA0D;AAC1D,IAAM,YAAY;IACd,sBAAwB,SAAS;IACjC,0BAA4B,aAAa;IACzC,0BAA4B,aAAa;IACzC,qBAAuB,QAAQ;OAClC,CAAC;AAEF;;;;;;;GAOG;AACH;IAGI;;;;OAIG;IACH,iCAAoB,uBAAiC;QAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;QAP7C,WAAM,GAA+B,IAAI,CAAC;IAOM,CAAC;IAEzD;;OAEG;IACH,yCAAO,GAAP;QACI,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,4CAAU,GAAV,UAAW,MAAe;QAC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,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;IAChF,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5C,IACI,QAAQ;gBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;gBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;aAC7E;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { PasteType as OldPasteType, PluginEventType } from 'roosterjs-editor-types';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n BorderFormat,\n ContentModelBeforePasteEvent,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n FormatParser,\n PasteType,\n} from 'roosterjs-content-model-types';\nimport type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types';\n\n// Map old PasteType to new PasteType\n// TODO: We can remove this once we have standalone editor\nconst PasteTypeMap: Record<OldPasteType, PasteType> = {\n [OldPasteType.AsImage]: 'asImage',\n [OldPasteType.AsPlainText]: 'asPlainText',\n [OldPasteType.MergeFormat]: 'mergeFormat',\n [OldPasteType.Normal]: 'normal',\n};\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(private allowExcelNoBorderTable?: boolean) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\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 || event.eventType != PluginEventType.BeforePaste) {\n return;\n }\n\n const ev = event as ContentModelBeforePasteEvent;\n\n if (!ev.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(ev, false);\n const pasteType = PasteTypeMap[ev.pasteType];\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(ev, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(ev);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n ev,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\n );\n }\n break;\n case 'googleSheets':\n ev.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(ev, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(ev.domToModelOption, 'link', parseLink);\n addParser(ev.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(ev.domToModelOption, 'tableCell', tableBorderParser);\n addParser(ev.domToModelOption, 'table', deprecatedBorderColorParser);\n\n if (pasteType === 'mergeFormat') {\n addParser(ev.domToModelOption, 'block', blockElementParser);\n addParser(ev.domToModelOption, 'listLevel', blockElementParser);\n }\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAE,mCAAmC,EAAE,MAAM,mDAAmD,CAAC;AACxG,OAAO,EAAE,iCAAiC,EAAE,MAAM,mDAAmD,CAAC;AAWtG;;;;;;;GAOG;AACH;IAGI;;;;OAIG;IACH,iCAAoB,uBAAiC;QAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;QAP7C,WAAM,GAA6B,IAAI,CAAC;IAOQ,CAAC;IAEzD;;OAEG;IACH,yCAAO,GAAP;QACI,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,4CAAU,GAAV,UAAW,MAAyB;QAChC,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,yCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG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iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5C,IACI,QAAQ;gBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;gBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;aAC7E;SACJ;IACL,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { deprecatedBorderColorParser } from './utils/deprecatedColorParser';\nimport { getPasteSource } from './pasteSourceValidations/getPasteSource';\nimport { parseLink } from './utils/linkParser';\nimport { PastePropertyNames } from './pasteSourceValidations/constants';\nimport { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';\nimport { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';\nimport { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';\nimport { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';\nimport type {\n BorderFormat,\n ContentModelBlockFormat,\n ContentModelTableCellFormat,\n EditorPlugin,\n FormatParser,\n IStandaloneEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * Paste plugin, handles BeforePaste event and reformat some special content, including:\n * 1. Content copied from Word\n * 2. Content copied from Excel\n * 3. Content copied from Word Online or OneNote Online\n * 4. Content copied from Power Point\n * (This class is still under development, and may still be changed in the future with some breaking changes)\n */\nexport class ContentModelPastePlugin implements EditorPlugin {\n private editor: IStandaloneEditor | null = null;\n\n /**\n * Construct a new instance of Paste class\n * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN\n * @param allowExcelNoBorderTable Allow table copied from Excel without border\n */\n constructor(private allowExcelNoBorderTable?: boolean) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelPaste';\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: IStandaloneEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor;\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 || event.eventType != 'beforePaste') {\n return;\n }\n\n if (!event.domToModelOption) {\n return;\n }\n\n const pasteSource = getPasteSource(event, false);\n const pasteType = event.pasteType;\n\n switch (pasteSource) {\n case 'wordDesktop':\n processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());\n break;\n case 'wacComponents':\n processPastedContentWacComponents(event);\n break;\n case 'excelOnline':\n case 'excelDesktop':\n if (pasteType === 'normal' || pasteType === 'mergeFormat') {\n // Handle HTML copied from Excel\n processPastedContentFromExcel(\n event,\n this.editor.getTrustedHTMLHandler(),\n this.allowExcelNoBorderTable\n );\n }\n break;\n case 'googleSheets':\n event.domToModelOption.additionalAllowedTags.push(\n PastePropertyNames.GOOGLE_SHEET_NODE_NAME as Lowercase<string>\n );\n break;\n case 'powerPointDesktop':\n processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());\n break;\n }\n\n addParser(event.domToModelOption, 'link', parseLink);\n addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);\n addParser(event.domToModelOption, 'tableCell', tableBorderParser);\n addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);\n\n if (pasteType === 'mergeFormat') {\n addParser(event.domToModelOption, 'block', blockElementParser);\n addParser(event.domToModelOption, 'listLevel', blockElementParser);\n }\n }\n}\n\n/**\n * For block elements that have background color style, remove the background color when user selects the merge current format\n * paste option\n */\nconst blockElementParser: FormatParser<ContentModelBlockFormat> = (\n format: ContentModelBlockFormat,\n element: HTMLElement\n) => {\n if (element.style.backgroundColor) {\n delete format.backgroundColor;\n }\n};\n\nconst ElementBorderKeys = new Map<\n keyof BorderFormat,\n {\n c: keyof CSSStyleDeclaration;\n s: keyof CSSStyleDeclaration;\n w: keyof CSSStyleDeclaration;\n }\n>([\n ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],\n ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],\n ['borderBottom', { w: 'borderBottomWidth', s: 'borderBottomStyle', c: 'borderBottomColor' }],\n ['borderLeft', { w: 'borderLeftWidth', s: 'borderLeftStyle', c: 'borderLeftColor' }],\n]);\n\nfunction tableBorderParser(format: ContentModelTableCellFormat, element: HTMLElement): void {\n BorderKeys.forEach(key => {\n if (!format[key]) {\n const styleSet = ElementBorderKeys.get(key);\n if (\n styleSet &&\n element.style[styleSet.w] &&\n element.style[styleSet.s] &&\n !element.style[styleSet.c]\n ) {\n format[key] = `${element.style[styleSet.w]} ${element.style[styleSet.s]}`;\n }\n }\n });\n}\n"]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { TrustedHTMLHandler } from 'roosterjs-
|
|
2
|
-
import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types';
|
|
1
|
+
import type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
* Convert pasted content from Excel, add borders when source doc doesn't have a border
|
|
6
5
|
* @param event The BeforePaste event
|
|
7
6
|
*/
|
|
8
|
-
export declare function processPastedContentFromExcel(event:
|
|
7
|
+
export declare function processPastedContentFromExcel(event: BeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
|
|
9
8
|
/**
|
|
10
9
|
* @internal Export for test only
|
|
11
10
|
* @param html Source html
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";AAAA,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;AACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;AACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAEjD;;;;GAIG;AAEH,MAAM,UAAU,6BAA6B,CACzC,KAAuB,EACvB,kBAAsC,EACtC,uBAAiC;IAEzB,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,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IAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACtD,IAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;KACpC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\nconst LAST_TD_END_REGEX = /<\\/\\s*td\\s*>((?!<\\/\\s*tr\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_END_REGEX = /<\\/\\s*tr\\s*>((?!<\\/\\s*table\\s*>)[\\s\\S])*$/i;\nconst LAST_TR_REGEX = /<tr[^>]*>[^<]*/i;\nconst LAST_TABLE_REGEX = /<table[^>]*>[^<]*/i;\nconst DEFAULT_BORDER_STYLE = 'solid 1px #d4d4d4';\n\n/**\n * @internal\n * Convert pasted content from Excel, add borders when source doc doesn't have a border\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromExcel(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler,\n allowExcelNoBorderTable?: boolean\n) {\n const { fragment, htmlBefore, clipboardData } = event;\n const html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;\n\n if (html && clipboardData.html != html) {\n const doc = new DOMParser().parseFromString(trustedHTMLHandler(html), 'text/html');\n moveChildNodes(fragment, doc?.body);\n }\n\n // For Excel Online\n const firstChild = fragment.firstChild;\n if (\n isNodeOfType(firstChild, 'ELEMENT_NODE') &&\n firstChild.tagName == 'div' &&\n firstChild.firstChild\n ) {\n const tableFound = Array.from(firstChild.childNodes).every((child: Node) => {\n // Tables pasted from Excel Online should be of the format: 0 to N META tags and 1 TABLE tag\n const tagName = isNodeOfType(child, 'ELEMENT_NODE') && child.tagName;\n\n return tagName == 'META'\n ? true\n : tagName == 'TABLE'\n ? child == firstChild.lastChild\n : false;\n });\n\n // Extract Table from Div\n if (tableFound && firstChild.lastChild) {\n event.fragment.replaceChildren(firstChild.lastChild);\n }\n }\n\n addParser(event.domToModelOption, 'tableCell', (format, element) => {\n if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {\n format.borderBottom = DEFAULT_BORDER_STYLE;\n format.borderLeft = DEFAULT_BORDER_STYLE;\n format.borderRight = DEFAULT_BORDER_STYLE;\n format.borderTop = DEFAULT_BORDER_STYLE;\n }\n });\n\n setProcessor(event.domToModelOption, 'child', (group, element, context) => {\n const segmentFormat = { ...context.segmentFormat };\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat.textColor = group.format.textColor;\n }\n\n context.defaultElementProcessors.child(group, element, context);\n\n if (group.blockGroupType === 'TableCell' && group.format.textColor) {\n context.segmentFormat = segmentFormat;\n delete group.format.textColor;\n }\n });\n}\n\n/**\n * @internal Export for test only\n * @param html Source html\n */\n\nexport function excelHandler(html: string, htmlBefore: string): string {\n if (html.match(LAST_TD_END_REGEX)) {\n const trMatch = htmlBefore.match(LAST_TR_REGEX);\n const tr = trMatch ? trMatch[0] : '<TR>';\n html = tr + html + '</TR>';\n }\n if (html.match(LAST_TR_END_REGEX)) {\n const tableMatch = htmlBefore.match(LAST_TABLE_REGEX);\n const table = tableMatch ? tableMatch[0] : '<TABLE>';\n html = table + html + '</TABLE>';\n }\n\n return html;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;;;GAIG;AAEH,MAAM,UAAU,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;IAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;QAClE,gFAAgF;QAChF,gCAAgC;QAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;QAEF,cAAc,CAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;KACvC;AACL,CAAC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-
|
|
1
|
+
{"version":3,"file":"processPastedContentFromPowerPoint.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PowerPoint/processPastedContentFromPowerPoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D;;;;GAIG;AAEH,MAAM,UAAU,kCAAkC,CAC9C,KAAuB,EACvB,kBAAsC;IAE9B,IAAA,QAAQ,GAAoB,KAAK,SAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;IAE1C,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,aAAa,CAAC,KAAK,EAAE;QAClE,gFAAgF;QAChF,gCAAgC;QAChC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CACvC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,EACtC,WAAW,CACd,CAAC;QAEF,cAAc,CAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;KACvC;AACL,CAAC","sourcesContent":["import { moveChildNodes } from 'roosterjs-content-model-dom';\nimport type { BeforePasteEvent, TrustedHTMLHandler } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Convert pasted content from PowerPoint\n * @param event The BeforePaste event\n */\n\nexport function processPastedContentFromPowerPoint(\n event: BeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\n) {\n const { fragment, clipboardData } = event;\n\n if (clipboardData.html && !clipboardData.text && clipboardData.image) {\n // It is possible that PowerPoint copied both image and HTML but not plain text.\n // We always prefer HTML if any.\n const doc = new DOMParser().parseFromString(\n trustedHTMLHandler(clipboardData.html),\n 'text/html'\n );\n\n moveChildNodes(fragment, doc?.body);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BeforePasteEvent } from 'roosterjs-content-model-types';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
* Convert pasted content from Office Online
|
|
@@ -6,4 +6,4 @@ import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types
|
|
|
6
6
|
* We need to remove the display property and margin from all the list item
|
|
7
7
|
* @param ev ContentModelBeforePasteEvent
|
|
8
8
|
*/
|
|
9
|
-
export declare function processPastedContentWacComponents(ev:
|
|
9
|
+
export declare function processPastedContentWacComponents(ev: BeforePasteEvent): void;
|