roosterjs-content-model-plugins 0.21.3 → 0.22.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.
Files changed (106) hide show
  1. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js +3 -0
  2. package/lib/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  3. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +3 -0
  4. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  5. package/lib/edit/deleteSteps/deleteWordSelection.js +3 -0
  6. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  7. package/lib/edit/keyboardInput.js +1 -1
  8. package/lib/edit/keyboardInput.js.map +1 -1
  9. package/lib/paste/ContentModelPastePlugin.d.ts +3 -1
  10. package/lib/paste/ContentModelPastePlugin.js +5 -3
  11. package/lib/paste/ContentModelPastePlugin.js.map +1 -1
  12. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +1 -1
  13. package/lib/paste/Excel/processPastedContentFromExcel.js +2 -2
  14. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  15. package/lib/paste/WacComponents/constants.d.ts +56 -0
  16. package/lib/paste/WacComponents/constants.js +86 -0
  17. package/lib/paste/WacComponents/constants.js.map +1 -0
  18. package/lib/paste/WacComponents/processPastedContentWacComponents.js +19 -34
  19. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  20. package/lib/paste/WordDesktop/WordMetadata.d.ts +9 -0
  21. package/lib/paste/WordDesktop/WordMetadata.js +3 -0
  22. package/lib/paste/WordDesktop/WordMetadata.js.map +1 -0
  23. package/lib/paste/WordDesktop/getStyleMetadata.d.ts +23 -0
  24. package/lib/paste/WordDesktop/getStyleMetadata.js +79 -0
  25. package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -0
  26. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -7
  27. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +14 -14
  28. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  29. package/lib/paste/WordDesktop/processWordLists.d.ts +2 -1
  30. package/lib/paste/WordDesktop/processWordLists.js +83 -85
  31. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  32. package/lib/paste/pasteSourceValidations/documentContainWacElements.js +2 -11
  33. package/lib/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  34. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +2 -1
  35. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  36. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js +3 -0
  37. package/lib-amd/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  38. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +3 -0
  39. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  40. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +3 -0
  41. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  42. package/lib-amd/edit/keyboardInput.js +1 -1
  43. package/lib-amd/edit/keyboardInput.js.map +1 -1
  44. package/lib-amd/paste/ContentModelPastePlugin.d.ts +3 -1
  45. package/lib-amd/paste/ContentModelPastePlugin.js +5 -3
  46. package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
  47. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +1 -1
  48. package/lib-amd/paste/Excel/processPastedContentFromExcel.js +2 -2
  49. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  50. package/lib-amd/paste/WacComponents/constants.d.ts +56 -0
  51. package/lib-amd/paste/WacComponents/constants.js +87 -0
  52. package/lib-amd/paste/WacComponents/constants.js.map +1 -0
  53. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +19 -35
  54. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  55. package/lib-amd/paste/WordDesktop/WordMetadata.d.ts +9 -0
  56. package/lib-amd/paste/WordDesktop/WordMetadata.js +5 -0
  57. package/lib-amd/paste/WordDesktop/WordMetadata.js.map +1 -0
  58. package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +23 -0
  59. package/lib-amd/paste/WordDesktop/getStyleMetadata.js +79 -0
  60. package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -0
  61. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -7
  62. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +14 -15
  63. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  64. package/lib-amd/paste/WordDesktop/processWordLists.d.ts +2 -1
  65. package/lib-amd/paste/WordDesktop/processWordLists.js +83 -85
  66. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  67. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js +2 -12
  68. package/lib-amd/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  69. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +2 -1
  70. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  71. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js +3 -0
  72. package/lib-mjs/edit/deleteSteps/deleteAllSegmentBefore.js.map +1 -1
  73. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +3 -0
  74. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  75. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +3 -0
  76. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  77. package/lib-mjs/edit/keyboardInput.js +1 -1
  78. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  79. package/lib-mjs/paste/ContentModelPastePlugin.d.ts +3 -1
  80. package/lib-mjs/paste/ContentModelPastePlugin.js +5 -3
  81. package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
  82. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +1 -1
  83. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js +2 -2
  84. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  85. package/lib-mjs/paste/WacComponents/constants.d.ts +56 -0
  86. package/lib-mjs/paste/WacComponents/constants.js +83 -0
  87. package/lib-mjs/paste/WacComponents/constants.js.map +1 -0
  88. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +12 -27
  89. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  90. package/lib-mjs/paste/WordDesktop/WordMetadata.d.ts +9 -0
  91. package/lib-mjs/paste/WordDesktop/WordMetadata.js +2 -0
  92. package/lib-mjs/paste/WordDesktop/WordMetadata.js.map +1 -0
  93. package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +23 -0
  94. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +76 -0
  95. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -0
  96. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -7
  97. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +13 -12
  98. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  99. package/lib-mjs/paste/WordDesktop/processWordLists.d.ts +2 -1
  100. package/lib-mjs/paste/WordDesktop/processWordLists.js +84 -86
  101. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  102. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js +1 -10
  103. package/lib-mjs/paste/pasteSourceValidations/documentContainWacElements.js.map +1 -1
  104. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +2 -1
  105. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  106. package/package.json +5 -5
@@ -1,16 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.documentContainWacElements = void 0;
4
- var WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = [
5
- 'TableInsertRowGapBlank',
6
- 'TableColumnResizeHandle',
7
- 'TableCellTopBorderHandle',
8
- 'TableCellLeftBorderHandle',
9
- 'TableHoverColumnHandle',
10
- 'TableHoverRowHandle',
11
- ];
12
- var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[class^="NumberListStyle"]>.OutlineElement,span.WACImageContainer,' +
13
- WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(function (c) { return "table div[class^=\"" + c + "\"]"; }).join(',');
4
+ var constants_1 = require("../WacComponents/constants");
14
5
  /**
15
6
  * @internal
16
7
  * Check whether the fragment provided contain Wac Elements
@@ -19,7 +10,7 @@ var WAC_IDENTIFY_SELECTOR = 'ul[class^="BulletListStyle"]>.OutlineElement,ol[cla
19
10
  */
20
11
  var documentContainWacElements = function (props) {
21
12
  var fragment = props.fragment;
22
- return !!fragment.querySelector(WAC_IDENTIFY_SELECTOR);
13
+ return !!fragment.querySelector(constants_1.WAC_IDENTIFY_SELECTOR);
23
14
  };
24
15
  exports.documentContainWacElements = documentContainWacElements;
25
16
  //# sourceMappingURL=documentContainWacElements.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"documentContainWacElements.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/documentContainWacElements.ts"],"names":[],"mappings":";;;AAEA,IAAM,sCAAsC,GAAG;IAC3C,wBAAwB;IACxB,yBAAyB;IACzB,0BAA0B;IAC1B,2BAA2B;IAC3B,wBAAwB;IACxB,qBAAqB;CACxB,CAAC;AAEF,IAAM,qBAAqB,GACvB,mHAAmH;IACnH,sCAAsC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,wBAAqB,CAAC,QAAI,EAA1B,CAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE1F;;;;;GAKG;AACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;IACtD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC,CAAC;AAHW,QAAA,0BAA0B,8BAGrC","sourcesContent":["import type { GetSourceFunction } from './getPasteSource';\n\nconst WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n];\n\nconst WAC_IDENTIFY_SELECTOR =\n 'ul[class^=\"BulletListStyle\"]>.OutlineElement,ol[class^=\"NumberListStyle\"]>.OutlineElement,span.WACImageContainer,' +\n WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(c => `table div[class^=\"${c}\"]`).join(',');\n\n/**\n * @internal\n * Check whether the fragment provided contain Wac Elements\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const documentContainWacElements: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(WAC_IDENTIFY_SELECTOR);\n};\n"]}
1
+ {"version":3,"file":"documentContainWacElements.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/documentContainWacElements.ts"],"names":[],"mappings":";;;AAAA,wDAAmE;AAGnE;;;;;GAKG;AACI,IAAM,0BAA0B,GAAsB,UAAA,KAAK;IACtD,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAC3B,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,iCAAqB,CAAC,CAAC;AAC3D,CAAC,CAAC;AAHW,QAAA,0BAA0B,8BAGrC","sourcesContent":["import { WAC_IDENTIFY_SELECTOR } from '../WacComponents/constants';\nimport type { GetSourceFunction } from './getPasteSource';\n\n/**\n * @internal\n * Check whether the fragment provided contain Wac Elements\n * @param props Properties related to the PasteEvent\n * @returns\n */\nexport const documentContainWacElements: GetSourceFunction = props => {\n const { fragment } = props;\n return !!fragment.querySelector(WAC_IDENTIFY_SELECTOR);\n};\n"]}
@@ -1,4 +1,5 @@
1
- import type { BeforePasteEvent, ClipboardData } from 'roosterjs-editor-types';
1
+ import type { ClipboardData } from 'roosterjs-content-model-types';
2
+ import type { BeforePasteEvent } from 'roosterjs-editor-types';
2
3
  /**
3
4
  * @internal
4
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getPasteSource.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getPasteSource.ts"],"names":[],"mappings":";;;AAAA,2EAA0E;AAC1E,mEAAkE;AAClE,iEAAgE;AAChE,iEAAgE;AAChE,6EAA4E;AAC5E,iEAAgE;AAChE,2EAA0E;AAgC1E,IAAM,kBAAkB,GAAG,IAAI,GAAG,CAA0C;IACxE,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,cAAc,EAAE,+CAAsB,CAAC;IACxC,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,mBAAmB,EAAE,yDAA2B,CAAC;IAClD,CAAC,eAAe,EAAE,uDAA0B,CAAC;IAC7C,CAAC,cAAc,EAAE,6CAAqB,CAAC;IACvC,CAAC,aAAa,EAAE,uDAA0B,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAAuB,EACvB,wBAAiC;IAEzB,IAAA,cAAc,GAA8B,KAAK,eAAnC,EAAE,aAAa,GAAe,KAAK,cAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IAE1D,IAAI,MAAM,GAAgC,IAAI,CAAC;IAC/C,IAAM,KAAK,GAAyB;QAChC,cAAc,gBAAA;QACd,QAAQ,UAAA;QACR,wBAAwB,0BAAA;QACxB,aAAa,eAAA;KAChB,CAAC;IAEF,kBAAkB,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,GAAG;QACjC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,GAAG,GAAG,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;AAC/B,CAAC;AArBD,wCAqBC","sourcesContent":["import { documentContainWacElements } from './documentContainWacElements';\nimport { isExcelDesktopDocument } from './isExcelDesktopDocument';\nimport { isExcelOnlineDocument } from './isExcelOnlineDocument';\nimport { isGoogleSheetDocument } from './isGoogleSheetDocument';\nimport { isPowerPointDesktopDocument } from './isPowerPointDesktopDocument';\nimport { isWordDesktopDocument } from './isWordDesktopDocument';\nimport { shouldConvertToSingleImage } from './shouldConvertToSingleImage';\nimport type { BeforePasteEvent, ClipboardData } from 'roosterjs-editor-types';\n\n/**\n * @internal\n */\nexport type GetSourceInputParams = {\n htmlAttributes: Record<string, string>;\n fragment: DocumentFragment;\n shouldConvertSingleImage: boolean;\n clipboardData: ClipboardData;\n};\n\n/**\n * @internal\n * Represent the types of sources to handle in the Paste Plugin\n */\nexport type KnownPasteSourceType =\n | 'wordDesktop'\n | 'excelDesktop'\n | 'excelOnline'\n | 'powerPointDesktop'\n | 'googleSheets'\n | 'wacComponents'\n | 'default'\n | 'singleImage';\n\n/**\n * @internal\n */\nexport type GetSourceFunction = (props: GetSourceInputParams) => boolean;\n\nconst getSourceFunctions = new Map<KnownPasteSourceType, GetSourceFunction>([\n ['wordDesktop', isWordDesktopDocument],\n ['excelDesktop', isExcelDesktopDocument],\n ['excelOnline', isExcelOnlineDocument],\n ['powerPointDesktop', isPowerPointDesktopDocument],\n ['wacComponents', documentContainWacElements],\n ['googleSheets', isGoogleSheetDocument],\n ['singleImage', shouldConvertToSingleImage],\n]);\n\n/**\n * @internal\n * This function tries to get the source of the Pasted content\n * @param event the before paste event\n * @param shouldConvertSingleImage Whether convert single image is enabled.\n * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}\n */\nexport function getPasteSource(\n event: BeforePasteEvent,\n shouldConvertSingleImage: boolean\n): KnownPasteSourceType {\n const { htmlAttributes, clipboardData, fragment } = event;\n\n let result: KnownPasteSourceType | null = null;\n const param: GetSourceInputParams = {\n htmlAttributes,\n fragment,\n shouldConvertSingleImage,\n clipboardData,\n };\n\n getSourceFunctions.forEach((func, key) => {\n if (!result && func(param)) {\n result = key;\n }\n });\n\n return result ?? 'default';\n}\n"]}
1
+ {"version":3,"file":"getPasteSource.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/pasteSourceValidations/getPasteSource.ts"],"names":[],"mappings":";;;AAAA,2EAA0E;AAC1E,mEAAkE;AAClE,iEAAgE;AAChE,iEAAgE;AAChE,6EAA4E;AAC5E,iEAAgE;AAChE,2EAA0E;AAiC1E,IAAM,kBAAkB,GAAG,IAAI,GAAG,CAA0C;IACxE,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,cAAc,EAAE,+CAAsB,CAAC;IACxC,CAAC,aAAa,EAAE,6CAAqB,CAAC;IACtC,CAAC,mBAAmB,EAAE,yDAA2B,CAAC;IAClD,CAAC,eAAe,EAAE,uDAA0B,CAAC;IAC7C,CAAC,cAAc,EAAE,6CAAqB,CAAC;IACvC,CAAC,aAAa,EAAE,uDAA0B,CAAC;CAC9C,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC1B,KAAuB,EACvB,wBAAiC;IAEzB,IAAA,cAAc,GAA8B,KAAK,eAAnC,EAAE,aAAa,GAAe,KAAK,cAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IAE1D,IAAI,MAAM,GAAgC,IAAI,CAAC;IAC/C,IAAM,KAAK,GAAyB;QAChC,cAAc,gBAAA;QACd,QAAQ,UAAA;QACR,wBAAwB,0BAAA;QACxB,aAAa,eAAA;KAChB,CAAC;IAEF,kBAAkB,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,GAAG;QACjC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE;YACxB,MAAM,GAAG,GAAG,CAAC;SAChB;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;AAC/B,CAAC;AArBD,wCAqBC","sourcesContent":["import { documentContainWacElements } from './documentContainWacElements';\nimport { isExcelDesktopDocument } from './isExcelDesktopDocument';\nimport { isExcelOnlineDocument } from './isExcelOnlineDocument';\nimport { isGoogleSheetDocument } from './isGoogleSheetDocument';\nimport { isPowerPointDesktopDocument } from './isPowerPointDesktopDocument';\nimport { isWordDesktopDocument } from './isWordDesktopDocument';\nimport { shouldConvertToSingleImage } from './shouldConvertToSingleImage';\nimport type { ClipboardData } from 'roosterjs-content-model-types';\nimport type { BeforePasteEvent } from 'roosterjs-editor-types';\n\n/**\n * @internal\n */\nexport type GetSourceInputParams = {\n htmlAttributes: Record<string, string>;\n fragment: DocumentFragment;\n shouldConvertSingleImage: boolean;\n clipboardData: ClipboardData;\n};\n\n/**\n * @internal\n * Represent the types of sources to handle in the Paste Plugin\n */\nexport type KnownPasteSourceType =\n | 'wordDesktop'\n | 'excelDesktop'\n | 'excelOnline'\n | 'powerPointDesktop'\n | 'googleSheets'\n | 'wacComponents'\n | 'default'\n | 'singleImage';\n\n/**\n * @internal\n */\nexport type GetSourceFunction = (props: GetSourceInputParams) => boolean;\n\nconst getSourceFunctions = new Map<KnownPasteSourceType, GetSourceFunction>([\n ['wordDesktop', isWordDesktopDocument],\n ['excelDesktop', isExcelDesktopDocument],\n ['excelOnline', isExcelOnlineDocument],\n ['powerPointDesktop', isPowerPointDesktopDocument],\n ['wacComponents', documentContainWacElements],\n ['googleSheets', isGoogleSheetDocument],\n ['singleImage', shouldConvertToSingleImage],\n]);\n\n/**\n * @internal\n * This function tries to get the source of the Pasted content\n * @param event the before paste event\n * @param shouldConvertSingleImage Whether convert single image is enabled.\n * @returns The Type of pasted content, if no type found will return {KnownSourceType.Default}\n */\nexport function getPasteSource(\n event: BeforePasteEvent,\n shouldConvertSingleImage: boolean\n): KnownPasteSourceType {\n const { htmlAttributes, clipboardData, fragment } = event;\n\n let result: KnownPasteSourceType | null = null;\n const param: GetSourceInputParams = {\n htmlAttributes,\n fragment,\n shouldConvertSingleImage,\n clipboardData,\n };\n\n getSourceFunctions.forEach((func, key) => {\n if (!result && func(param)) {\n result = key;\n }\n });\n\n return result ?? 'default';\n}\n"]}
@@ -6,6 +6,9 @@ define(["require", "exports", "roosterjs-content-model-core"], function (require
6
6
  * @internal
7
7
  */
8
8
  var deleteAllSegmentBefore = function (context) {
9
+ if (context.deleteResult != 'notDeleted') {
10
+ return;
11
+ }
9
12
  var _a = context.insertPoint, paragraph = _a.paragraph, marker = _a.marker;
10
13
  var index = paragraph.segments.indexOf(marker);
11
14
  for (var i = index - 1; i >= 0; i--) {
@@ -1 +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"]}
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;QAC9D,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,SAAS,eAAA,EAAE,MAAM,YAAwB,CAAC;QAClD,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEjD,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YACjC,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;YAE1B,IAAI,IAAA,4CAAa,EAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE;gBAC1D,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;aAClC;SACJ;IACL,CAAC,CAAC;IAjBW,QAAA,sBAAsB,0BAiBjC","sourcesContent":["import { deleteSegment } from 'roosterjs-content-model-core';\nimport type { DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport const deleteAllSegmentBefore: DeleteSelectionStep = context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const { paragraph, marker } = context.insertPoint;\n const index = paragraph.segments.indexOf(marker);\n\n for (let i = index - 1; i >= 0; i--) {\n const segment = paragraph.segments[i];\n\n segment.isSelected = true;\n\n if (deleteSegment(paragraph, segment, context.formatContext)) {\n context.deleteResult = 'range';\n }\n }\n};\n"]}
@@ -5,6 +5,9 @@ define(["require", "exports", "roosterjs-content-model-core", "../utils/getLeafS
5
5
  function getDeleteCollapsedSelection(direction) {
6
6
  return function (context) {
7
7
  var _a;
8
+ if (context.deleteResult != 'notDeleted') {
9
+ return;
10
+ }
8
11
  var isForward = direction == 'forward';
9
12
  var _b = context.insertPoint, paragraph = _b.paragraph, marker = _b.marker, path = _b.path, tableContext = _b.tableContext;
10
13
  var segments = paragraph.segments;
@@ -1 +1 @@
1
- {"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;;IAMA,SAAS,2BAA2B,CAAC,SAAiC;QAClE,OAAO,UAAA,OAAO;;YACV,IAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;YACnC,IAAA,KAA4C,OAAO,CAAC,WAAW,EAA7D,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,YAAY,kBAAwB,CAAC;YACtE,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;YAEpC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAElB,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,C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Aa,GAAG,SAAS,CAAC;4BAClC,OAAO,KAAK,CAAC,aAAa,CAAC;yBAC9B;wBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;oBAED,qHAAqH;oBACrH,OAAO,CAAC,gBAAgB,GAAG,YAAY,CAAC;iBAC3C;qBAAM;oBACH,IACI,IAAA,0CAAW,EACP,MAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EACd,KAAK,EACL,SAAS,CAAC,eAAe,EACzB,OAAO,CAAC,aAAa,EACrB,SAAS,CACZ,EACH;wBACE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;iBACJ;aACJ;iBAAM;gBACH,mFAAmF;gBACnF,yGAAyG;gBACzG,uFAAuF;gBACvF,OAAO,CAAC,YAAY,GAAG,iBAAiB,CAAC;aAC5C;QACL,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,SAAS,OAAO,CAAC,QAA+B;;QAC5C,IAAI,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,WAAW,KAAI,IAAI,EAAE;YACpD,IAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC;YAEnF,IAAI,CAAA,MAAA,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,WAAW,KAAI,IAAI,EAAE;gBACtE,QAAQ,CAAC,GAAG,EAAE,CAAC;aAClB;SACJ;IACL,CAAC;IAED;;OAEG;IACU,QAAA,+BAA+B,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAEtF;;OAEG;IACU,QAAA,gCAAgC,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { deleteBlock, deleteSegment } from 'roosterjs-content-model-core';\nimport { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type { ContentModelSegment, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n const isForward = direction == 'forward';\n const { paragraph, marker, path, tableContext } = context.insertPoint;\n const segments = paragraph.segments;\n\n fixupBr(segments);\n\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\n const segmentToDelete = segments[index];\n let blockToDelete: BlockAndPath | null;\n\n if (segmentToDelete) {\n if (deleteSegment(paragraph, segmentToDelete, context.formatContext, direction)) {\n context.deleteResult = 'singleChar';\n\n // It is possible that we have deleted everything from this paragraph, so we need to mark it as not implicit\n // to avoid losing its format. See https://github.com/microsoft/roosterjs/issues/1953\n setParagraphNotImplicit(paragraph);\n }\n } else if ((blockToDelete = getLeafSiblingBlock(path, paragraph, isForward))) {\n const { block, path, siblingSegment } = blockToDelete;\n\n if (block.blockType == 'Paragraph') {\n if (siblingSegment) {\n // When selection is under general segment, need to check if it has a sibling sibling, and delete from it\n if (deleteSegment(block, siblingSegment, context.formatContext, direction)) {\n context.deleteResult = 'range';\n }\n } else {\n if (isForward) {\n context.lastParagraph = block;\n } else {\n if (block.segments[block.segments.length - 1]?.segmentType == 'Br') {\n block.segments.pop();\n }\n\n context.insertPoint = {\n marker,\n paragraph: block,\n path,\n tableContext,\n };\n context.lastParagraph = paragraph;\n delete block.cachedElement;\n }\n\n context.deleteResult = 'range';\n }\n\n // When go across table, getLeafSiblingBlock will return null, when we are here, we must be in the same table context\n context.lastTableContext = tableContext;\n } else {\n if (\n deleteBlock(\n path[0].blocks,\n block,\n undefined /*replacement*/,\n context.formatContext,\n direction\n )\n ) {\n context.deleteResult = 'range';\n }\n }\n } else {\n // We have nothing to delete, in this case we don't want browser handle it as well.\n // Because when Backspace on an empty document, it will also delete the only DIV and SPAN element, causes\n // editor is really empty. We don't want that happen. So the handling should stop here.\n context.deleteResult = 'nothingToDelete';\n }\n };\n}\n\n/**\n * If the last segment is BR, remove it for now. We may add it back later when normalize model.\n * So that if this is an empty paragraph, it will start to delete next block\n */\nfunction fixupBr(segments: ContentModelSegment[]) {\n if (segments[segments.length - 1]?.segmentType == 'Br') {\n const segmentsWithoutBr = segments.filter(x => x.segmentType != 'SelectionMarker');\n\n if (segmentsWithoutBr[segmentsWithoutBr.length - 2]?.segmentType != 'Br') {\n segments.pop();\n }\n }\n}\n\n/**\n * @internal if we didn't delete anything, and we want to delete forward, now perform it\n */\nexport const forwardDeleteCollapsedSelection = getDeleteCollapsedSelection('forward');\n\n/**\n * @internal if we didn't delete anything, and we want to delete backward, now perform it\n */\nexport const backwardDeleteCollapsedSelection = getDeleteCollapsedSelection('backward');\n"]}
1
+ {"version":3,"file":"deleteCollapsedSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteCollapsedSelection.ts"],"names":[],"mappings":";;;;IAMA,SAAS,2BAA2B,CAAC,SAAiC;QAClE,OAAO,UAAA,OAAO;;YACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;gBACtC,OAAO;aACV;YAED,IAAM,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;YACnC,IAAA,KAA4C,OAAO,CAAC,WAAW,EAA7D,SAAS,eAAA,EAAE,MAAM,YAAA,EAAE,IAAI,UAAA,EAAE,YAAY,kBAAwB,CAAC;YACtE,IAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;YAEpC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAElB,IAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,IAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,aAAkC,CAAC;Y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AG,OAAO,CAAC;qBAClC;oBAED,qHAAqH;oBACrH,OAAO,CAAC,gBAAgB,GAAG,YAAY,CAAC;iBAC3C;qBAAM;oBACH,IACI,IAAA,0CAAW,EACP,MAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EACd,KAAK,EACL,SAAS,CAAC,eAAe,EACzB,OAAO,CAAC,aAAa,EACrB,SAAS,CACZ,EACH;wBACE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;iBACJ;aACJ;iBAAM;gBACH,mFAAmF;gBACnF,yGAAyG;gBACzG,uFAAuF;gBACvF,OAAO,CAAC,YAAY,GAAG,iBAAiB,CAAC;aAC5C;QACL,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,SAAS,OAAO,CAAC,QAA+B;;QAC5C,IAAI,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,WAAW,KAAI,IAAI,EAAE;YACpD,IAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,IAAI,iBAAiB,EAAlC,CAAkC,CAAC,CAAC;YAEnF,IAAI,CAAA,MAAA,iBAAiB,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,0CAAE,WAAW,KAAI,IAAI,EAAE;gBACtE,QAAQ,CAAC,GAAG,EAAE,CAAC;aAClB;SACJ;IACL,CAAC;IAED;;OAEG;IACU,QAAA,+BAA+B,GAAG,2BAA2B,CAAC,SAAS,CAAC,CAAC;IAEtF;;OAEG;IACU,QAAA,gCAAgC,GAAG,2BAA2B,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { deleteBlock, deleteSegment } from 'roosterjs-content-model-core';\nimport { getLeafSiblingBlock } from '../utils/getLeafSiblingBlock';\nimport { setParagraphNotImplicit } from 'roosterjs-content-model-dom';\nimport type { BlockAndPath } from '../utils/getLeafSiblingBlock';\nimport type { ContentModelSegment, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\nfunction getDeleteCollapsedSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const isForward = direction == 'forward';\n const { paragraph, marker, path, tableContext } = context.insertPoint;\n const segments = paragraph.segments;\n\n fixupBr(segments);\n\n const index = segments.indexOf(marker) + (isForward ? 1 : -1);\n const segmentToDelete = segments[index];\n let blockToDelete: BlockAndPath | null;\n\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"]}
@@ -13,6 +13,9 @@ define(["require", "exports", "tslib", "roosterjs-content-model-core", "roosterj
13
13
  })(DeleteWordState || (DeleteWordState = {}));
14
14
  function getDeleteWordSelection(direction) {
15
15
  return function (context) {
16
+ if (context.deleteResult != 'notDeleted') {
17
+ return;
18
+ }
16
19
  var _a = context.insertPoint, marker = _a.marker, paragraph = _a.paragraph;
17
20
  var startIndex = paragraph.segments.indexOf(marker);
18
21
  var deleteNext = direction == 'forward';
@@ -1 +1 @@
1
- {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";;;;IAQA,IAAW,eAOV;IAPD,WAAW,eAAe;QACtB,uDAAK,CAAA;QACL,mEAAW,CAAA;QACX,qDAAI,CAAA;QACJ,2DAAO,CAAA;QACP,uDAAK,CAAA;QACL,mDAAG,CAAA;IACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;IAQD,SAAS,sBAAsB,CAAC,SAAiC;QAC7D,OAAO,UAAA,OAAO;YACJ,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;YAClD,IAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,C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J;;;oBAjCD,CAAC,IAAI,IAAI,CAAA;;wBAmCb,yBAAM;wBAIF,qBAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CAAC,gEAAgE;;oBAD3H,IACI,SAAsD,CAAC,gEAAgE;sBACzH;wBACE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;wBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;4BACV,CAAC,IAAI,IAAI,CAAC;yBACb;wBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;oBACD,yBAAM;wBAGN,yBAAM;yBAGN,sBAAO,IAAI,EAAC;;oBA/DwC,CAAC,IAAI,IAAI,CAAA;;yBAmEzE,sBAAO,IAAI,EAAC;;;KACf;IAED;;OAEG;IACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAE5E;;OAEG;IACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { isPunctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n DeleteSelectionContext,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\nconst enum DeleteWordState {\n Start,\n Punctuation,\n Text,\n NonText,\n Space,\n End,\n}\n\ninterface CharInfo {\n text: boolean;\n space: boolean;\n punctuation: boolean;\n}\n\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n const { marker, paragraph } = context.insertPoint;\n const startIndex = paragraph.segments.indexOf(marker);\n const deleteNext = direction == 'forward';\n\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\n let curr = iterator.next();\n\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\n const { punctuation, space, text } = curr.value;\n\n // This is a state machine of how to delete a whole word together with space and punctuations.\n // For a full state machine chart, see\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\n switch (state) {\n case DeleteWordState.Start:\n state = space\n ? DeleteWordState.Space\n : punctuation\n ? DeleteWordState.Punctuation\n : DeleteWordState.Text;\n curr = iterator.next(true /*delete*/);\n break;\n\n case DeleteWordState.Punctuation:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.Text:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (text) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.NonText:\n if (punctuation || !space) {\n state = DeleteWordState.End;\n } else {\n curr = iterator.next(true /*delete*/);\n }\n break;\n\n case DeleteWordState.Space:\n if (space) {\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\n curr = iterator.next(true /*delete*/);\n } else {\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\n }\n break;\n }\n }\n };\n}\n\nfunction* iterateSegments(\n paragraph: ContentModelParagraph,\n markerIndex: number,\n forward: boolean,\n context: DeleteSelectionContext\n): Generator<CharInfo, null, boolean> {\n const step = forward ? 1 : -1;\n const segments = paragraph.segments;\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph);\n\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\n const segment = segments[i];\n\n switch (segment.segmentType) {\n case 'Text':\n for (\n let j = forward ? 0 : segment.text.length - 1;\n j >= 0 && j < segment.text.length;\n j += step\n ) {\n const c = segment.text[j];\n const punctuation = isPunctuation(c);\n const space = isSpace(c);\n const text = !punctuation && !space;\n\n if (yield { punctuation, space, text }) {\n let newText = segment.text;\n\n newText = newText.substring(0, j) + newText.substring(j + 1);\n\n if (!preserveWhiteSpace) {\n newText = normalizeText(newText, forward);\n }\n\n context.deleteResult = 'range';\n\n if (newText) {\n segment.text = newText;\n\n if (step > 0) {\n j -= step;\n }\n } else {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n break;\n }\n }\n }\n break;\n\n case 'Image':\n if (\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\n ) {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n context.deleteResult = 'range';\n }\n break;\n\n case 'SelectionMarker':\n break;\n\n default:\n return null;\n }\n }\n\n return null;\n}\n\n/**\n * @internal\n */\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\n\n/**\n * @internal\n */\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\n"]}
1
+ {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";;;;IAQA,IAAW,eAOV;IAPD,WAAW,eAAe;QACtB,uDAAK,CAAA;QACL,mEAAW,CAAA;QACX,qDAAI,CAAA;QACJ,2DAAO,CAAA;QACP,uDAAK,CAAA;QACL,mDAAG,CAAA;IACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;IAQD,SAAS,sBAAsB,CAAC,SAAiC;QAC7D,OAAO,UAAA,OAAO;YACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;gBACtC,OAAO;aACV;YAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;YAClD,IAAM,UAAU,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtD,IAAM,UAAU,GAAG,SAAS,IAAI,SAAS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WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CAAC,gEAAgE;;oBAD3H,IACI,SAAsD,CAAC,gEAAgE;sBACzH;wBACE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;wBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;4BACV,CAAC,IAAI,IAAI,CAAC;yBACb;wBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;qBAClC;oBACD,yBAAM;wBAGN,yBAAM;yBAGN,sBAAO,IAAI,EAAC;;oBA/DwC,CAAC,IAAI,IAAI,CAAA;;yBAmEzE,sBAAO,IAAI,EAAC;;;KACf;IAED;;OAEG;IACU,QAAA,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAE5E;;OAEG;IACU,QAAA,2BAA2B,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { isPunctuation, isSpace, normalizeText } from 'roosterjs-content-model-core';\nimport { isWhiteSpacePreserved } from 'roosterjs-content-model-dom';\nimport type {\n ContentModelParagraph,\n DeleteSelectionContext,\n DeleteSelectionStep,\n} from 'roosterjs-content-model-types';\n\nconst enum DeleteWordState {\n Start,\n Punctuation,\n Text,\n NonText,\n Space,\n End,\n}\n\ninterface CharInfo {\n text: boolean;\n space: boolean;\n punctuation: boolean;\n}\n\nfunction getDeleteWordSelection(direction: 'forward' | 'backward'): DeleteSelectionStep {\n return context => {\n if (context.deleteResult != 'notDeleted') {\n return;\n }\n\n const { marker, paragraph } = context.insertPoint;\n const startIndex = paragraph.segments.indexOf(marker);\n const deleteNext = direction == 'forward';\n\n const iterator = iterateSegments(paragraph, startIndex, deleteNext, context);\n let curr = iterator.next();\n\n for (let state = DeleteWordState.Start; state != DeleteWordState.End && !curr.done; ) {\n const { punctuation, space, text } = curr.value;\n\n // This is a state machine of how to delete a whole word together with space and punctuations.\n // For a full state machine chart, see\n // Forward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/ForwardDeleteWord.png\n // Backward delete: https://github.com/microsoft/roosterjs/blob/master/assets/design-charts/BackwardDeleteWord.png\n switch (state) {\n case DeleteWordState.Start:\n state = space\n ? DeleteWordState.Space\n : punctuation\n ? DeleteWordState.Punctuation\n : DeleteWordState.Text;\n curr = iterator.next(true /*delete*/);\n break;\n\n case DeleteWordState.Punctuation:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.Text:\n if (deleteNext && space) {\n state = DeleteWordState.NonText;\n curr = iterator.next(true /*delete*/);\n } else if (text) {\n curr = iterator.next(true /*delete*/);\n } else {\n state = DeleteWordState.End;\n }\n break;\n\n case DeleteWordState.NonText:\n if (punctuation || !space) {\n state = DeleteWordState.End;\n } else {\n curr = iterator.next(true /*delete*/);\n }\n break;\n\n case DeleteWordState.Space:\n if (space) {\n curr = iterator.next(true /*delete*/);\n } else if (punctuation) {\n state = deleteNext ? DeleteWordState.NonText : DeleteWordState.Punctuation;\n curr = iterator.next(true /*delete*/);\n } else {\n state = deleteNext ? DeleteWordState.End : DeleteWordState.Text;\n }\n break;\n }\n }\n };\n}\n\nfunction* iterateSegments(\n paragraph: ContentModelParagraph,\n markerIndex: number,\n forward: boolean,\n context: DeleteSelectionContext\n): Generator<CharInfo, null, boolean> {\n const step = forward ? 1 : -1;\n const segments = paragraph.segments;\n const preserveWhiteSpace = isWhiteSpacePreserved(paragraph);\n\n for (let i = markerIndex + step; i >= 0 && i < segments.length; i += step) {\n const segment = segments[i];\n\n switch (segment.segmentType) {\n case 'Text':\n for (\n let j = forward ? 0 : segment.text.length - 1;\n j >= 0 && j < segment.text.length;\n j += step\n ) {\n const c = segment.text[j];\n const punctuation = isPunctuation(c);\n const space = isSpace(c);\n const text = !punctuation && !space;\n\n if (yield { punctuation, space, text }) {\n let newText = segment.text;\n\n newText = newText.substring(0, j) + newText.substring(j + 1);\n\n if (!preserveWhiteSpace) {\n newText = normalizeText(newText, forward);\n }\n\n context.deleteResult = 'range';\n\n if (newText) {\n segment.text = newText;\n\n if (step > 0) {\n j -= step;\n }\n } else {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n break;\n }\n }\n }\n break;\n\n case 'Image':\n if (\n yield { punctuation: true, space: false, text: false } // Treat image as punctuation since they have the same behavior.\n ) {\n segments.splice(i, 1);\n\n if (step > 0) {\n i -= step;\n }\n\n context.deleteResult = 'range';\n }\n break;\n\n case 'SelectionMarker':\n break;\n\n default:\n return null;\n }\n }\n\n return null;\n}\n\n/**\n * @internal\n */\nexport const forwardDeleteWordSelection = getDeleteWordSelection('forward');\n\n/**\n * @internal\n */\nexport const backwardDeleteWordSelection = getDeleteWordSelection('backward');\n"]}
@@ -8,7 +8,7 @@ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content
8
8
  function keyboardInput(editor, rawEvent) {
9
9
  var selection = editor.getDOMSelection();
10
10
  if (shouldInputWithContentModel(selection, rawEvent)) {
11
- editor.addUndoSnapshot();
11
+ editor.takeSnapshot();
12
12
  editor.formatContentModel(function (model, context) {
13
13
  var _a;
14
14
  var result = (0, roosterjs_content_model_core_1.deleteSelection)(model, [], context);
@@ -1 +1 @@
1
- {"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;QAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAClD,MAAM,CAAC,eAAe,EAAE,CAAC;YAEzB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;QACxF,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0DAA0D;SAC7H;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\n editor.addUndoSnapshot();\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(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\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 selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"keyboardInput.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardInput.ts"],"names":[],"mappings":";;;;IAKA;;OAEG;IACH,SAAgB,aAAa,CAAC,MAA2B,EAAE,QAAuB;QAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;QAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;YAClD,MAAM,CAAC,YAAY,EAAE,CAAC;YAEtB,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;;gBACX,IAAM,MAAM,GAAG,IAAA,8CAAe,EAAC,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;gBAEnD,0EAA0E;gBAC1E,qFAAqF;gBACrF,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;gBAE/B,oJAAoJ;gBACpJ,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAEhC,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,EAAE;oBAChC,2HAA2H;oBAC3H,OAAO,CAAC,gBAAgB,GAAG,MAAA,MAAM,CAAC,WAAW,0CAAE,MAAM,CAAC,MAAM,CAAC;oBAE7D,IAAA,mDAAqB,EAAC,KAAK,CAAC,CAAC;oBAE7B,sFAAsF;oBACtF,OAAO,IAAI,CAAC;iBACf;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC,EACD;gBACI,QAAQ,UAAA;aACX,CACJ,CAAC;YAEF,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IApCD,sCAoCC;IAED,SAAS,2BAA2B,CAAC,SAA8B,EAAE,QAAuB;QACxF,IAAI,CAAC,SAAS,EAAE;YACZ,OAAO,KAAK,CAAC,CAAC,oBAAoB;SACrC;aAAM,IACH,CAAC,IAAA,4CAAa,EAAC,QAAQ,CAAC;YACxB,CAAC,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,IAAI,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,EAClF;YACE,OAAO,SAAS,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,0DAA0D;SAC7H;aAAM;YACH,OAAO,KAAK,CAAC;SAChB;IACL,CAAC","sourcesContent":["import { deleteSelection, isModifierKey } from 'roosterjs-content-model-core';\nimport { normalizeContentModel } from 'roosterjs-content-model-dom';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldInputWithContentModel(selection, rawEvent)) {\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(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\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 selection.type != 'range' || !selection.range.collapsed; // TODO: Also handle Enter key even selection is collapsed\n } else {\n return false;\n }\n}\n"]}
@@ -9,12 +9,14 @@ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types'
9
9
  */
10
10
  export declare class ContentModelPastePlugin implements EditorPlugin {
11
11
  private unknownTagReplacement;
12
+ private allowExcelNoBorderTable?;
12
13
  private editor;
13
14
  /**
14
15
  * Construct a new instance of Paste class
15
16
  * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
17
+ * @param allowExcelNoBorderTable Allow table copied from Excel without border
16
18
  */
17
- constructor(unknownTagReplacement?: string);
19
+ constructor(unknownTagReplacement?: string, allowExcelNoBorderTable?: boolean | undefined);
18
20
  /**
19
21
  * Get name of this plugin
20
22
  */
@@ -23,10 +23,12 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
23
23
  /**
24
24
  * Construct a new instance of Paste class
25
25
  * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
26
+ * @param allowExcelNoBorderTable Allow table copied from Excel without border
26
27
  */
27
- function ContentModelPastePlugin(unknownTagReplacement) {
28
+ function ContentModelPastePlugin(unknownTagReplacement, allowExcelNoBorderTable) {
28
29
  if (unknownTagReplacement === void 0) { unknownTagReplacement = 'SPAN'; }
29
30
  this.unknownTagReplacement = unknownTagReplacement;
31
+ this.allowExcelNoBorderTable = allowExcelNoBorderTable;
30
32
  this.editor = null;
31
33
  }
32
34
  /**
@@ -71,7 +73,7 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
71
73
  var pasteType = PasteTypeMap[ev.pasteType];
72
74
  switch (pasteSource) {
73
75
  case 'wordDesktop':
74
- (0, processPastedContentFromWordDesktop_1.processPastedContentFromWordDesktop)(ev);
76
+ (0, processPastedContentFromWordDesktop_1.processPastedContentFromWordDesktop)(ev, this.editor.getTrustedHTMLHandler());
75
77
  break;
76
78
  case 'wacComponents':
77
79
  (0, processPastedContentWacComponents_1.processPastedContentWacComponents)(ev);
@@ -80,7 +82,7 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
80
82
  case 'excelDesktop':
81
83
  if (pasteType === 'normal' || pasteType === 'mergeFormat') {
82
84
  // Handle HTML copied from Excel
83
- (0, processPastedContentFromExcel_1.processPastedContentFromExcel)(ev, this.editor.getTrustedHTMLHandler());
85
+ (0, processPastedContentFromExcel_1.processPastedContentFromExcel)(ev, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
84
86
  }
85
87
  break;
86
88
  case 'googleSheets':
@@ -1 +1 @@
1
- {"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":";;;;;IA4BA,qCAAqC;IACrC,0DAA0D;IAC1D,IAAM,YAAY;QACd,sB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AAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { chainSanitizerCallback } from 'roosterjs-editor-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 {\n EditorPlugin,\n HtmlSanitizerOptions,\n IEditor,\n PluginEvent,\n} 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 */\n constructor(private unknownTagReplacement: string = 'SPAN') {}\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);\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(ev, this.editor.getTrustedHTMLHandler());\n }\n break;\n case 'googleSheets':\n ev.sanitizingOption.additionalTagReplacements[\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 sanitizeBlockStyles(ev.sanitizingOption);\n\n if (pasteType === 'mergeFormat') {\n addParser(ev.domToModelOption, 'block', blockElementParser);\n addParser(ev.domToModelOption, 'listLevel', blockElementParser);\n }\n\n ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;\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\nfunction sanitizeBlockStyles(sanitizingOption: Required<HtmlSanitizerOptions>) {\n chainSanitizerCallback(sanitizingOption.cssStyleCallbacks, 'display', (value: string) => {\n return value != 'flex'; // return whether we keep the style\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/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ACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { chainSanitizerCallback } from 'roosterjs-editor-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 {\n EditorPlugin,\n HtmlSanitizerOptions,\n IEditor,\n PluginEvent,\n} 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(\n private unknownTagReplacement: string = 'SPAN',\n private allowExcelNoBorderTable?: boolean\n ) {}\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.sanitizingOption.additionalTagReplacements[\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 sanitizeBlockStyles(ev.sanitizingOption);\n\n if (pasteType === 'mergeFormat') {\n addParser(ev.domToModelOption, 'block', blockElementParser);\n addParser(ev.domToModelOption, 'listLevel', blockElementParser);\n }\n\n ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;\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\nfunction sanitizeBlockStyles(sanitizingOption: Required<HtmlSanitizerOptions>) {\n chainSanitizerCallback(sanitizingOption.cssStyleCallbacks, 'display', (value: string) => {\n return value != 'flex'; // return whether we keep the style\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"]}
@@ -5,7 +5,7 @@ import type { ContentModelBeforePasteEvent } from 'roosterjs-content-model-types
5
5
  * Convert pasted content from Excel, add borders when source doc doesn't have a border
6
6
  * @param event The BeforePaste event
7
7
  */
8
- export declare function processPastedContentFromExcel(event: ContentModelBeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler): void;
8
+ export declare function processPastedContentFromExcel(event: ContentModelBeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
9
9
  /**
10
10
  * @internal Export for test only
11
11
  * @param html Source html
@@ -12,7 +12,7 @@ define(["require", "exports", "tslib", "../utils/addParser", "roosterjs-content-
12
12
  * Convert pasted content from Excel, add borders when source doc doesn't have a border
13
13
  * @param event The BeforePaste event
14
14
  */
15
- function processPastedContentFromExcel(event, trustedHTMLHandler) {
15
+ function processPastedContentFromExcel(event, trustedHTMLHandler, allowExcelNoBorderTable) {
16
16
  var fragment = event.fragment, htmlBefore = event.htmlBefore, clipboardData = event.clipboardData;
17
17
  var html = clipboardData.html ? excelHandler(clipboardData.html, htmlBefore) : undefined;
18
18
  if (html && clipboardData.html != html) {
@@ -39,7 +39,7 @@ define(["require", "exports", "tslib", "../utils/addParser", "roosterjs-content-
39
39
  }
40
40
  }
41
41
  (0, addParser_1.default)(event.domToModelOption, 'tableCell', function (format, element) {
42
- if (element.style.borderStyle === 'none') {
42
+ if (!allowExcelNoBorderTable && element.style.borderStyle === 'none') {
43
43
  format.borderBottom = DEFAULT_BORDER_STYLE;
44
44
  format.borderLeft = DEFAULT_BORDER_STYLE;
45
45
  format.borderRight = DEFAULT_BORDER_STYLE;
@@ -1 +1 @@
1
- {"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;IAMA,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;IACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;IACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;IAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;IAEjD;;;;OAIG;IAEH,SAAgB,6BAA6B,CACzC,KAAmC,EACnC,kBAAsC;QAE9B,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3F,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,IAAI,EAAE;YACpC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;YACnF,IAAA,4CAAc,EAAC,QAAQ,EAAE,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,IAAI,CAAC,CAAC;SACvC;QAED,mBAAmB;QACnB,IAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,IACI,IAAA,0CAAY,EAAC,UAAU,EAAE,cAAc,CAAC;YACxC,UAAU,CAAC,OAAO,IAAI,KAAK;YAC3B,UAAU,CAAC,UAAU,EACvB;YACE,IAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,UAAC,KAAW;gBACn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C;YAEhE,IAAI,KAAK,CAAC,cAAc,KAAK,WAAW,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;gBAChE,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;gBACtC,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC;aACjC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IA1DD,sEA0DC;IAED;;;OAGG;IAEH,SAAgB,YAAY,CAAC,IAAY,EAAE,UAAkB;QACzD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAC/B,IAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;YAChD,IAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACzC,IAAI,GAAG,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC;SAC9B;QACD,IAAI,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE;YAC/B,IAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtD,IAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACrD,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAbD,oCAaC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { TrustedHTMLHandler } from 'roosterjs-editor-types';\nimport type { ContentModelBeforePasteEvent } 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: ContentModelBeforePasteEvent,\n trustedHTMLHandler: TrustedHTMLHandler\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 (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
+ {"version":3,"file":"processPastedContentFromExcel.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/Excel/processPastedContentFromExcel.ts"],"names":[],"mappings":";;;;IAMA,IAAM,iBAAiB,GAAG,yCAAyC,CAAC;IACpE,IAAM,iBAAiB,GAAG,4CAA4C,CAAC;IACvE,IAAM,aAAa,GAAG,iBAAiB,CAAC;IACxC,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;IAC9C,IAAM,oBAAoB,GAAG,mBAAmB,CAAC;IAEjD;;;;OAIG;IAEH,SAAgB,6BAA6B,CACzC,KAAmC,EACnC,kBAAsC,EACtC,uBAAiC;QAEzB,IAAA,QAAQ,GAAgC,KAAK,SAArC,EAAE,UAAU,GAAoB,KAAK,WAAzB,EAAE,aAAa,GAAK,KAAK,cAAV,CAAW;QACtD,IAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE3F,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,IAAI,EAAE;YACpC,IAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC;Y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AG,KAAK,GAAG,IAAI,GAAG,UAAU,CAAC;SACpC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAbD,oCAaC","sourcesContent":["import addParser from '../utils/addParser';\nimport { isNodeOfType, moveChildNodes } from 'roosterjs-content-model-dom';\nimport { setProcessor } from '../utils/setProcessor';\nimport type { TrustedHTMLHandler } from 'roosterjs-editor-types';\nimport type { ContentModelBeforePasteEvent } 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: ContentModelBeforePasteEvent,\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"]}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @internal
3
+ **/
4
+ export declare const WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES: string[];
5
+ /**
6
+ * @internal
7
+ **/
8
+ export declare const BULLET_LIST_STYLE: string;
9
+ /**
10
+ * @internal
11
+ **/
12
+ export declare const NUMBER_LIST_STYLE: string;
13
+ /**
14
+ * @internal
15
+ **/
16
+ export declare const IMAGE_BORDER: string;
17
+ /**
18
+ * @internal
19
+ **/
20
+ export declare const IMAGE_CONTAINER: string;
21
+ /**
22
+ * @internal
23
+ **/
24
+ export declare const OUTLINE_ELEMENT: string;
25
+ /**
26
+ * @internal
27
+ **/
28
+ export declare const PARAGRAPH: string;
29
+ /**
30
+ * @internal
31
+ **/
32
+ export declare const LIST_CONTAINER_ELEMENT_CLASS_NAME: string;
33
+ /**
34
+ * @internal
35
+ **/
36
+ export declare const TABLE_CONTAINER: string;
37
+ /**
38
+ * @internal
39
+ **/
40
+ export declare const COMMENT_HIGHLIGHT_CLASS: string;
41
+ /**
42
+ * @internal
43
+ **/
44
+ export declare const COMMENT_HIGHLIGHT_CLICKED_CLASS: string;
45
+ /**
46
+ * @internal
47
+ **/
48
+ export declare const TEMP_ELEMENTS_CLASSES: string[];
49
+ /**
50
+ * @internal
51
+ **/
52
+ export declare const WAC_IDENTIFY_SELECTOR: string;
53
+ /**
54
+ * @internal
55
+ **/
56
+ export declare const CLASSES_TO_KEEP: string[];
@@ -0,0 +1,87 @@
1
+ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CLASSES_TO_KEEP = exports.WAC_IDENTIFY_SELECTOR = exports.TEMP_ELEMENTS_CLASSES = exports.COMMENT_HIGHLIGHT_CLICKED_CLASS = exports.COMMENT_HIGHLIGHT_CLASS = exports.TABLE_CONTAINER = exports.LIST_CONTAINER_ELEMENT_CLASS_NAME = exports.PARAGRAPH = exports.OUTLINE_ELEMENT = exports.IMAGE_CONTAINER = exports.IMAGE_BORDER = exports.NUMBER_LIST_STYLE = exports.BULLET_LIST_STYLE = exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = void 0;
5
+ /**
6
+ * @internal
7
+ **/
8
+ exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES = [
9
+ 'TableInsertRowGapBlank',
10
+ 'TableColumnResizeHandle',
11
+ 'TableCellTopBorderHandle',
12
+ 'TableCellLeftBorderHandle',
13
+ 'TableHoverColumnHandle',
14
+ 'TableHoverRowHandle',
15
+ ];
16
+ /**
17
+ * @internal
18
+ **/
19
+ exports.BULLET_LIST_STYLE = 'BulletListStyle';
20
+ /**
21
+ * @internal
22
+ **/
23
+ exports.NUMBER_LIST_STYLE = 'NumberListStyle';
24
+ /**
25
+ * @internal
26
+ **/
27
+ exports.IMAGE_BORDER = 'WACImageBorder';
28
+ /**
29
+ * @internal
30
+ **/
31
+ exports.IMAGE_CONTAINER = 'WACImageContainer';
32
+ /**
33
+ * @internal
34
+ **/
35
+ exports.OUTLINE_ELEMENT = 'OutlineElement';
36
+ /**
37
+ * @internal
38
+ **/
39
+ exports.PARAGRAPH = 'Paragraph';
40
+ /**
41
+ * @internal
42
+ **/
43
+ exports.LIST_CONTAINER_ELEMENT_CLASS_NAME = 'ListContainerWrapper';
44
+ /**
45
+ * @internal
46
+ **/
47
+ exports.TABLE_CONTAINER = 'TableContainer';
48
+ /**
49
+ * @internal
50
+ **/
51
+ exports.COMMENT_HIGHLIGHT_CLASS = 'CommentHighlightRest';
52
+ /**
53
+ * @internal
54
+ **/
55
+ exports.COMMENT_HIGHLIGHT_CLICKED_CLASS = 'CommentHighlightClicked';
56
+ /**
57
+ * @internal
58
+ **/
59
+ exports.TEMP_ELEMENTS_CLASSES = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES), false), [
60
+ 'ListMarkerWrappingSpan',
61
+ ], false);
62
+ /**
63
+ * @internal
64
+ **/
65
+ exports.WAC_IDENTIFY_SELECTOR = "ul[class^=\"" + exports.BULLET_LIST_STYLE + "\"]>." + exports.OUTLINE_ELEMENT + ",ol[class^=\"" + exports.NUMBER_LIST_STYLE + "\"]>." + exports.OUTLINE_ELEMENT + ",span." + exports.IMAGE_CONTAINER + ",span." + exports.IMAGE_BORDER + ",." + exports.COMMENT_HIGHLIGHT_CLASS + ",." + exports.COMMENT_HIGHLIGHT_CLICKED_CLASS + "," +
66
+ exports.WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(function (c) { return "table div[class^=\"" + c + "\"]"; }).join(',');
67
+ /**
68
+ * @internal
69
+ **/
70
+ exports.CLASSES_TO_KEEP = (0, tslib_1.__spreadArray)((0, tslib_1.__spreadArray)([
71
+ exports.OUTLINE_ELEMENT,
72
+ exports.IMAGE_CONTAINER
73
+ ], (0, tslib_1.__read)(exports.TEMP_ELEMENTS_CLASSES), false), [
74
+ exports.PARAGRAPH,
75
+ exports.IMAGE_BORDER,
76
+ exports.TABLE_CONTAINER,
77
+ exports.COMMENT_HIGHLIGHT_CLASS,
78
+ exports.COMMENT_HIGHLIGHT_CLICKED_CLASS,
79
+ 'NumberListStyle',
80
+ 'ListContainerWrapper',
81
+ 'BulletListStyle',
82
+ 'TableCellContent',
83
+ 'WACImageContainer',
84
+ 'LineBreakBlob',
85
+ ], false);
86
+ });
87
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/WacComponents/constants.ts"],"names":[],"mappings":";;;;IAAA;;QAEI;IACS,QAAA,sCAAsC,GAAa;QAC5D,wBAAwB;QACxB,yBAAyB;QACzB,0BAA0B;QAC1B,2BAA2B;QAC3B,wBAAwB;QACxB,qBAAqB;KACxB,CAAC;IACF;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,iBAAiB,GAAW,iBAAiB,CAAC;IAC3D;;QAEI;IACS,QAAA,YAAY,GAAW,gBAAgB,CAAC;IACrD;;QAEI;IACS,QAAA,eAAe,GAAW,mBAAmB,CAAC;IAC3D;;QAEI;IACS,QAAA,eAAe,GAAW,gBAAgB,CAAC;IACxD;;QAEI;IACS,QAAA,SAAS,GAAW,WAAW,CAAC;IAC7C;;QAEI;IACS,QAAA,iCAAiC,GAAW,sBAAsB,CAAC;IAChF;;QAEI;IACS,QAAA,eAAe,GAAW,gBAAgB,CAAC;IACxD;;QAEI;IACS,QAAA,uBAAuB,GAAW,sBAAsB,CAAC;IACtE;;QAEI;IACS,QAAA,+BAA+B,GAAW,yBAAyB,CAAC;IACjF;;QAEI;IACS,QAAA,qBAAqB,iFAC3B,8CAAsC;QACzC,wBAAwB;cAC1B;IACF;;QAEI;IACS,QAAA,qBAAqB,GAC9B,iBAAc,yBAAiB,aAAO,uBAAe,qBAAe,yBAAiB,aAAO,uBAAe,cAAS,uBAAe,cAAS,oBAAY,UAAK,+BAAuB,UAAK,uCAA+B,MAAG;QAC3N,8CAAsC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,wBAAqB,CAAC,QAAI,EAA1B,CAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F;;QAEI;IACS,QAAA,eAAe;QACxB,uBAAe;QACf,uBAAe;2BACZ,6BAAqB;QACxB,iBAAS;QACT,oBAAY;QACZ,uBAAe;QACf,+BAAuB;QACvB,uCAA+B;QAC/B,iBAAiB;QACjB,sBAAsB;QACtB,iBAAiB;QACjB,kBAAkB;QAClB,mBAAmB;QACnB,eAAe;cACjB","sourcesContent":["/**\n * @internal\n **/\nexport const WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES: string[] = [\n 'TableInsertRowGapBlank',\n 'TableColumnResizeHandle',\n 'TableCellTopBorderHandle',\n 'TableCellLeftBorderHandle',\n 'TableHoverColumnHandle',\n 'TableHoverRowHandle',\n];\n/**\n * @internal\n **/\nexport const BULLET_LIST_STYLE: string = 'BulletListStyle';\n/**\n * @internal\n **/\nexport const NUMBER_LIST_STYLE: string = 'NumberListStyle';\n/**\n * @internal\n **/\nexport const IMAGE_BORDER: string = 'WACImageBorder';\n/**\n * @internal\n **/\nexport const IMAGE_CONTAINER: string = 'WACImageContainer';\n/**\n * @internal\n **/\nexport const OUTLINE_ELEMENT: string = 'OutlineElement';\n/**\n * @internal\n **/\nexport const PARAGRAPH: string = 'Paragraph';\n/**\n * @internal\n **/\nexport const LIST_CONTAINER_ELEMENT_CLASS_NAME: string = 'ListContainerWrapper';\n/**\n * @internal\n **/\nexport const TABLE_CONTAINER: string = 'TableContainer';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLASS: string = 'CommentHighlightRest';\n/**\n * @internal\n **/\nexport const COMMENT_HIGHLIGHT_CLICKED_CLASS: string = 'CommentHighlightClicked';\n/**\n * @internal\n **/\nexport const TEMP_ELEMENTS_CLASSES: string[] = [\n ...WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES,\n 'ListMarkerWrappingSpan',\n];\n/**\n * @internal\n **/\nexport const WAC_IDENTIFY_SELECTOR: string =\n `ul[class^=\"${BULLET_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},ol[class^=\"${NUMBER_LIST_STYLE}\"]>.${OUTLINE_ELEMENT},span.${IMAGE_CONTAINER},span.${IMAGE_BORDER},.${COMMENT_HIGHLIGHT_CLASS},.${COMMENT_HIGHLIGHT_CLICKED_CLASS},` +\n WORD_ONLINE_TABLE_TEMP_ELEMENT_CLASSES.map(c => `table div[class^=\"${c}\"]`).join(',');\n/**\n * @internal\n **/\nexport const CLASSES_TO_KEEP: string[] = [\n OUTLINE_ELEMENT,\n IMAGE_CONTAINER,\n ...TEMP_ELEMENTS_CLASSES,\n PARAGRAPH,\n IMAGE_BORDER,\n TABLE_CONTAINER,\n COMMENT_HIGHLIGHT_CLASS,\n COMMENT_HIGHLIGHT_CLICKED_CLASS,\n 'NumberListStyle',\n 'ListContainerWrapper',\n 'BulletListStyle',\n 'TableCellContent',\n 'WACImageContainer',\n 'LineBreakBlob',\n];\n"]}