roosterjs-content-model-plugins 0.22.1 → 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.
Files changed (172) hide show
  1. package/lib/edit/ContentModelEditPlugin.d.ts +2 -2
  2. package/lib/edit/ContentModelEditPlugin.js +1 -2
  3. package/lib/edit/ContentModelEditPlugin.js.map +1 -1
  4. package/lib/edit/deleteSteps/deleteList.d.ts +5 -0
  5. package/lib/edit/deleteSteps/deleteList.js +24 -0
  6. package/lib/edit/deleteSteps/deleteList.js.map +1 -0
  7. package/lib/edit/deleteSteps/deleteWordSelection.js +1 -1
  8. package/lib/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  9. package/lib/edit/handleKeyboardEventCommon.d.ts +2 -3
  10. package/lib/edit/handleKeyboardEventCommon.js +1 -1
  11. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  12. package/lib/edit/keyboardDelete.d.ts +2 -2
  13. package/lib/edit/keyboardDelete.js +8 -1
  14. package/lib/edit/keyboardDelete.js.map +1 -1
  15. package/lib/edit/keyboardInput.d.ts +2 -2
  16. package/lib/edit/keyboardInput.js.map +1 -1
  17. package/lib/paste/ContentModelPastePlugin.d.ts +3 -4
  18. package/lib/paste/ContentModelPastePlugin.js +17 -36
  19. package/lib/paste/ContentModelPastePlugin.js.map +1 -1
  20. package/lib/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
  21. package/lib/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  22. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
  23. package/lib/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  24. package/lib/paste/WacComponents/constants.d.ts +0 -8
  25. package/lib/paste/WacComponents/constants.js +1 -24
  26. package/lib/paste/WacComponents/constants.js.map +1 -1
  27. package/lib/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
  28. package/lib/paste/WacComponents/processPastedContentWacComponents.js +61 -65
  29. package/lib/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  30. package/lib/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
  31. package/lib/paste/WordDesktop/getStyleMetadata.js +1 -1
  32. package/lib/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  33. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
  34. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
  35. package/lib/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  36. package/lib/paste/WordDesktop/processWordLists.js +39 -12
  37. package/lib/paste/WordDesktop/processWordLists.js.map +1 -1
  38. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
  39. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js +14 -0
  40. package/lib/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
  41. package/lib/paste/pasteSourceValidations/constants.d.ts +5 -5
  42. package/lib/paste/pasteSourceValidations/constants.js +5 -6
  43. package/lib/paste/pasteSourceValidations/constants.js.map +1 -1
  44. package/lib/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
  45. package/lib/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  46. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
  47. package/lib/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  48. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
  49. package/lib/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  50. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
  51. package/lib/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  52. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
  53. package/lib/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  54. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
  55. package/lib/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  56. package/lib/paste/utils/addParser.d.ts +2 -2
  57. package/lib/paste/utils/addParser.js.map +1 -1
  58. package/lib-amd/edit/ContentModelEditPlugin.d.ts +2 -2
  59. package/lib-amd/edit/ContentModelEditPlugin.js +1 -2
  60. package/lib-amd/edit/ContentModelEditPlugin.js.map +1 -1
  61. package/lib-amd/edit/deleteSteps/deleteList.d.ts +5 -0
  62. package/lib-amd/edit/deleteSteps/deleteList.js +25 -0
  63. package/lib-amd/edit/deleteSteps/deleteList.js.map +1 -0
  64. package/lib-amd/edit/deleteSteps/deleteWordSelection.js +1 -1
  65. package/lib-amd/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  66. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -3
  67. package/lib-amd/edit/handleKeyboardEventCommon.js +1 -1
  68. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  69. package/lib-amd/edit/keyboardDelete.d.ts +2 -2
  70. package/lib-amd/edit/keyboardDelete.js +8 -2
  71. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  72. package/lib-amd/edit/keyboardInput.d.ts +2 -2
  73. package/lib-amd/edit/keyboardInput.js.map +1 -1
  74. package/lib-amd/paste/ContentModelPastePlugin.d.ts +3 -4
  75. package/lib-amd/paste/ContentModelPastePlugin.js +17 -36
  76. package/lib-amd/paste/ContentModelPastePlugin.js.map +1 -1
  77. package/lib-amd/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
  78. package/lib-amd/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  79. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
  80. package/lib-amd/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  81. package/lib-amd/paste/WacComponents/constants.d.ts +0 -8
  82. package/lib-amd/paste/WacComponents/constants.js +1 -24
  83. package/lib-amd/paste/WacComponents/constants.js.map +1 -1
  84. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
  85. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js +61 -66
  86. package/lib-amd/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  87. package/lib-amd/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
  88. package/lib-amd/paste/WordDesktop/getStyleMetadata.js +1 -1
  89. package/lib-amd/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  90. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
  91. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -18
  92. package/lib-amd/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  93. package/lib-amd/paste/WordDesktop/processWordLists.js +39 -13
  94. package/lib-amd/paste/WordDesktop/processWordLists.js.map +1 -1
  95. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
  96. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js +16 -0
  97. package/lib-amd/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
  98. package/lib-amd/paste/pasteSourceValidations/constants.d.ts +5 -5
  99. package/lib-amd/paste/pasteSourceValidations/constants.js +5 -6
  100. package/lib-amd/paste/pasteSourceValidations/constants.js.map +1 -1
  101. package/lib-amd/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
  102. package/lib-amd/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  103. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -2
  104. package/lib-amd/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  105. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -3
  106. package/lib-amd/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  107. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -2
  108. package/lib-amd/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  109. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -2
  110. package/lib-amd/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  111. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -2
  112. package/lib-amd/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  113. package/lib-amd/paste/utils/addParser.d.ts +2 -2
  114. package/lib-amd/paste/utils/addParser.js.map +1 -1
  115. package/lib-mjs/edit/ContentModelEditPlugin.d.ts +2 -2
  116. package/lib-mjs/edit/ContentModelEditPlugin.js +1 -2
  117. package/lib-mjs/edit/ContentModelEditPlugin.js.map +1 -1
  118. package/lib-mjs/edit/deleteSteps/deleteList.d.ts +5 -0
  119. package/lib-mjs/edit/deleteSteps/deleteList.js +20 -0
  120. package/lib-mjs/edit/deleteSteps/deleteList.js.map +1 -0
  121. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js +1 -1
  122. package/lib-mjs/edit/deleteSteps/deleteWordSelection.js.map +1 -1
  123. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -3
  124. package/lib-mjs/edit/handleKeyboardEventCommon.js +1 -1
  125. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  126. package/lib-mjs/edit/keyboardDelete.d.ts +2 -2
  127. package/lib-mjs/edit/keyboardDelete.js +8 -1
  128. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  129. package/lib-mjs/edit/keyboardInput.d.ts +2 -2
  130. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  131. package/lib-mjs/paste/ContentModelPastePlugin.d.ts +3 -4
  132. package/lib-mjs/paste/ContentModelPastePlugin.js +17 -36
  133. package/lib-mjs/paste/ContentModelPastePlugin.js.map +1 -1
  134. package/lib-mjs/paste/Excel/processPastedContentFromExcel.d.ts +2 -3
  135. package/lib-mjs/paste/Excel/processPastedContentFromExcel.js.map +1 -1
  136. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.d.ts +1 -1
  137. package/lib-mjs/paste/PowerPoint/processPastedContentFromPowerPoint.js.map +1 -1
  138. package/lib-mjs/paste/WacComponents/constants.d.ts +0 -8
  139. package/lib-mjs/paste/WacComponents/constants.js +0 -23
  140. package/lib-mjs/paste/WacComponents/constants.js.map +1 -1
  141. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.d.ts +2 -2
  142. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js +63 -67
  143. package/lib-mjs/paste/WacComponents/processPastedContentWacComponents.js.map +1 -1
  144. package/lib-mjs/paste/WordDesktop/getStyleMetadata.d.ts +2 -2
  145. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js +1 -1
  146. package/lib-mjs/paste/WordDesktop/getStyleMetadata.js.map +1 -1
  147. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.d.ts +2 -2
  148. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js +8 -19
  149. package/lib-mjs/paste/WordDesktop/processPastedContentFromWordDesktop.js.map +1 -1
  150. package/lib-mjs/paste/WordDesktop/processWordLists.js +40 -13
  151. package/lib-mjs/paste/WordDesktop/processWordLists.js.map +1 -1
  152. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.d.ts +5 -0
  153. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js +10 -0
  154. package/lib-mjs/paste/WordDesktop/removeNegativeTextIndentParser.js.map +1 -0
  155. package/lib-mjs/paste/pasteSourceValidations/constants.d.ts +5 -5
  156. package/lib-mjs/paste/pasteSourceValidations/constants.js +5 -6
  157. package/lib-mjs/paste/pasteSourceValidations/constants.js.map +1 -1
  158. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.d.ts +1 -2
  159. package/lib-mjs/paste/pasteSourceValidations/getPasteSource.js.map +1 -1
  160. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js +2 -1
  161. package/lib-mjs/paste/pasteSourceValidations/isExcelDesktopDocument.js.map +1 -1
  162. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js +3 -2
  163. package/lib-mjs/paste/pasteSourceValidations/isExcelOnlineDocument.js.map +1 -1
  164. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js +2 -1
  165. package/lib-mjs/paste/pasteSourceValidations/isGoogleSheetDocument.js.map +1 -1
  166. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js +2 -1
  167. package/lib-mjs/paste/pasteSourceValidations/isPowerPointDesktopDocument.js.map +1 -1
  168. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js +2 -1
  169. package/lib-mjs/paste/pasteSourceValidations/isWordDesktopDocument.js.map +1 -1
  170. package/lib-mjs/paste/utils/addParser.d.ts +2 -2
  171. package/lib-mjs/paste/utils/addParser.js.map +1 -1
  172. package/package.json +5 -5
@@ -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["ProgId" /* PROG_ID_NAME */] == POWERPOINT_ATTRIBUTE_VALUE;
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,6BAAiC,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
+ {"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["ProgId" /* PROG_ID_NAME */] == WORD_PROG_ID);
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,6BAAiC,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
+ {"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, FormatParsersPerCategory } from 'roosterjs-content-model-types';
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 FormatParsersPerCategory>(domToModelOption: DomToModelOption, entry: TKey, additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>): void;
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 FormatParsersPerCategory,\n} from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport default function addParser<TKey extends keyof FormatParsersPerCategory>(\n domToModelOption: DomToModelOption,\n entry: TKey,\n additionalFormatParsers: FormatParser<ContentModelFormatMap[TKey]>\n) {\n if (!domToModelOption.additionalFormatParsers) {\n domToModelOption.additionalFormatParsers = {};\n }\n if (!domToModelOption.additionalFormatParsers[entry]) {\n domToModelOption.additionalFormatParsers[entry] = [];\n }\n\n domToModelOption.additionalFormatParsers[entry]?.push(additionalFormatParsers);\n}\n"]}
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, IEditor, PluginEvent } from 'roosterjs-editor-types';
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: IEditor): void;
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 0 /* KeyDown */:
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;AAUhD;;;;;GAKG;AACH;IAAA;QACY,WAAM,GAA+B,IAAI,CAAC;IAiEtD,CAAC;IA/DG;;OAEG;IACH,wCAAO,GAAP;QACI,OAAO,kBAAkB,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACH,2CAAU,GAAV,UAAW,MAAe;QACtB,gFAAgF;QAChF,IAAI,CAAC,MAAM,GAAG,MAA6B,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACH,wCAAO,GAAP;QACI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,8CAAa,GAAb,UAAc,KAAkB;QAC5B,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,QAAQ,KAAK,CAAC,SAAS,EAAE;gBACrB;oBACI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;oBAC5C,MAAM;aACb;SACJ;IACL,CAAC;IAEO,mDAAkB,GAA1B,UAA2B,MAA2B,EAAE,KAAyB;QAC7E,IAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEhC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE;YAC3D,qHAAqH;YACrH,QAAQ,QAAQ,CAAC,GAAG,EAAE;gBAClB,KAAK,WAAW,CAAC;gBACjB,KAAK,QAAQ;oBACT,8CAA8C;oBAC9C,qIAAqI;oBACrI,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,AAlED,IAkEC","sourcesContent":["import { keyboardDelete } from './keyboardDelete';\nimport { keyboardInput } from './keyboardInput';\nimport { PluginEventType } from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n EditorPlugin,\n IEditor,\n PluginEvent,\n PluginKeyDownEvent,\n} from 'roosterjs-editor-types';\n\n/**\n * ContentModel edit plugins helps editor to do editing operation on top of content model.\n * This includes:\n * 1. Delete Key\n * 2. Backspace Key\n */\nexport class ContentModelEditPlugin implements EditorPlugin {\n private editor: IContentModelEditor | null = null;\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'ContentModelEdit';\n }\n\n /**\n * The first method that editor will call to a plugin when editor is initializing.\n * It will pass in the editor instance, plugin should take this chance to save the\n * editor reference so that it can call to any editor method or format API later.\n * @param editor The editor object\n */\n initialize(editor: IEditor) {\n // TODO: Later we may need a different interface for Content Model editor plugin\n this.editor = editor as IContentModelEditor;\n }\n\n /**\n * The last method that editor will call to a plugin before it is disposed.\n * Plugin can take this chance to clear the reference to editor. After this method is\n * called, plugin should not call to any editor method since it will result in error.\n */\n dispose() {\n this.editor = null;\n }\n\n /**\n * Core method for a plugin. Once an event happens in editor, editor will call this\n * method of each plugin to handle the event as long as the event is not handled\n * exclusively by another plugin.\n * @param event The event to handle:\n */\n onPluginEvent(event: PluginEvent) {\n if (this.editor) {\n switch (event.eventType) {\n case PluginEventType.KeyDown:\n this.handleKeyDownEvent(this.editor, event);\n break;\n }\n }\n }\n\n private handleKeyDownEvent(editor: IContentModelEditor, event: PluginKeyDownEvent) {\n const rawEvent = event.rawEvent;\n\n if (!rawEvent.defaultPrevented && !event.handledByEditFeature) {\n // TODO: Consider use ContentEditFeature and need to hide other conflict features that are not based on Content Model\n switch (rawEvent.key) {\n case 'Backspace':\n case 'Delete':\n // Use our API to handle BACKSPACE/DELETE key.\n // No need to clear cache here since if we rely on browser's behavior, there will be Input event and its handler will reconcile cache\n keyboardDelete(editor, rawEvent);\n break;\n\n case 'Enter':\n default:\n keyboardInput(editor, rawEvent);\n break;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"ContentModelEditPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/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,5 @@
1
+ import type { DeleteSelectionStep } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare const deleteList: DeleteSelectionStep;
@@ -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"]}
@@ -90,7 +90,7 @@ function iterateSegments(paragraph, markerIndex, forward, context) {
90
90
  case 0:
91
91
  step = forward ? 1 : -1;
92
92
  segments = paragraph.segments;
93
- preserveWhiteSpace = isWhiteSpacePreserved(paragraph);
93
+ preserveWhiteSpace = isWhiteSpacePreserved(paragraph.format.whiteSpace);
94
94
  i = markerIndex + step;
95
95
  _b.label = 1;
96
96
  case 1:
@@ -1 +1 @@
1
- {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAOpE,IAAW,eAOV;AAPD,WAAW,eAAe;IACtB,uDAAK,CAAA;IACL,mEAAW,CAAA;IACX,qDAAI,CAAA;IACJ,2DAAO,CAAA;IACP,uDAAK,CAAA;IACL,mDAAG,CAAA;AACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;AAQD,SAAS,sBAAsB,CAAC,SAAiC;IAC7D,OAAO,UAAA,OAAO;QACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAEK,IAAA,KAAwB,OAAO,CAAC,WAAW,EAAzC,MAAM,YAAA,EAAE,SAAS,eAAwB,CAAC;QAClD,IAAM,UA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gBAjCD,CAAC,IAAI,IAAI,CAAA;;oBAmCb,yBAAM;oBAIF,qBAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CAAC,gEAAgE;;gBAD3H,IACI,SAAsD,CAAC,gEAAgE;kBACzH;oBACE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;wBACV,CAAC,IAAI,IAAI,CAAC;qBACb;oBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;iBAClC;gBACD,yBAAM;oBAGN,yBAAM;qBAGN,sBAAO,IAAI,EAAC;;gBA/DwC,CAAC,IAAI,IAAI,CAAA;;qBAmEzE,sBAAO,IAAI,EAAC;;;CACf;AAED;;GAEG;AACH,MAAM,CAAC,IAAM,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,IAAM,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"]}
1
+ {"version":3,"file":"deleteWordSelection.js","sourceRoot":"","sources":["../../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/deleteSteps/deleteWordSelection.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAOpE,IAAW,eAOV;AAPD,WAAW,eAAe;IACtB,uDAAK,CAAA;IACL,mEAAW,CAAA;IACX,qDAAI,CAAA;IACJ,2DAAO,CAAA;IACP,uDAAK,CAAA;IACL,mDAAG,CAAA;AACP,CAAC,EAPU,eAAe,KAAf,eAAe,QAOzB;AAQD,SAAS,sBAAsB,CAAC,SAAiC;IAC7D,OAAO,UAAA,OAAO;QACV,IAAI,OAAO,CAAC,YAAY,IAAI,YAAY,EAAE;YACtC,OAAO;SACV;QAEK,IAAA,KAAwB,OAAO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IAAI,IAAI,GAAG,CAAC,EAAE;4BACV,CAAC,IAAI,IAAI,CAAC;yBACb;wBAED,wBAAM;qBACT;iBACJ;;;gBAjCD,CAAC,IAAI,IAAI,CAAA;;oBAmCb,yBAAM;oBAIF,qBAAM,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAA,CAAC,gEAAgE;;gBAD3H,IACI,SAAsD,CAAC,gEAAgE;kBACzH;oBACE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAEtB,IAAI,IAAI,GAAG,CAAC,EAAE;wBACV,CAAC,IAAI,IAAI,CAAC;qBACb;oBAED,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC;iBAClC;gBACD,yBAAM;oBAGN,yBAAM;qBAGN,sBAAO,IAAI,EAAC;;gBA/DwC,CAAC,IAAI,IAAI,CAAA;;qBAmEzE,sBAAO,IAAI,EAAC;;;CACf;AAED;;GAEG;AACH,MAAM,CAAC,IAAM,0BAA0B,GAAG,sBAAsB,CAAC,SAAS,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,CAAC,IAAM,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.format.whiteSpace);\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,10 +1,9 @@
1
- import type { IContentModelEditor } from 'roosterjs-content-model-editor';
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: IContentModelEditor, model: ContentModelDocument, rawEvent: KeyboardEvent, result: DeleteResult, context: FormatWithContentModelContext): boolean;
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.triggerPluginEvent(23 /* BeforeKeyboardEditing */, {
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;AASpE;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACrC,MAA2B,EAC3B,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,kBAAkB,iCAAwC;gBAC7D,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 { PluginEventType } from 'roosterjs-editor-types';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type {\n ContentModelDocument,\n DeleteResult,\n FormatWithContentModelContext,\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: IContentModelEditor,\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.triggerPluginEvent(PluginEventType.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
+ {"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 { IContentModelEditor } from 'roosterjs-content-model-editor';
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: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
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
- return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];
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;AAIhD;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,MAA2B,EAAE,QAAuB;IAC/E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,4BAA4B,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QACnD,MAAM,CAAC,kBAAkB,CACrB,UAAC,KAAK,EAAE,OAAO;YACX,IAAM,MAAM,GAAG,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,MA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pG,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 { isNodeOfType } from 'roosterjs-content-model-dom';\nimport {\n handleKeyboardEventResult,\n shouldDeleteAllSegmentsBefore,\n shouldDeleteWord,\n} from './handleKeyboardEventCommon';\nimport {\n backwardDeleteWordSelection,\n forwardDeleteWordSelection,\n} from './deleteSteps/deleteWordSelection';\nimport {\n backwardDeleteCollapsedSelection,\n forwardDeleteCollapsedSelection,\n} from './deleteSteps/deleteCollapsedSelection';\nimport type { IContentModelEditor } from 'roosterjs-content-model-editor';\nimport type { DOMSelection, DeleteSelectionStep } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n * Do keyboard event handling for DELETE/BACKSPACE key\n * @param editor The Content Model Editor\n * @param rawEvent DOM keyboard event\n */\nexport function keyboardDelete(editor: IContentModelEditor, rawEvent: KeyboardEvent) {\n const selection = editor.getDOMSelection();\n\n if (shouldDeleteWithContentModel(selection, rawEvent)) {\n editor.formatContentModel(\n (model, context) => {\n const result = deleteSelection(\n model,\n getDeleteSteps(rawEvent, !!editor.getEnvironment().isMac),\n context\n ).deleteResult;\n\n return handleKeyboardEventResult(editor, model, rawEvent, result, context);\n },\n {\n rawEvent,\n changeSource: ChangeSource.Keyboard,\n getChangeData: () => rawEvent.which,\n apiName: rawEvent.key == 'Delete' ? 'handleDeleteKey' : 'handleBackspaceKey',\n }\n );\n\n return true;\n }\n}\n\nfunction getDeleteSteps(rawEvent: KeyboardEvent, isMac: boolean): (DeleteSelectionStep | null)[] {\n const isForward = rawEvent.key == 'Delete';\n const deleteAllSegmentBeforeStep =\n shouldDeleteAllSegmentsBefore(rawEvent) && !isForward ? deleteAllSegmentBefore : null;\n const deleteWordSelection = shouldDeleteWord(rawEvent, isMac)\n ? isForward\n ? forwardDeleteWordSelection\n : backwardDeleteWordSelection\n : null;\n const deleteCollapsedSelection = isForward\n ? forwardDeleteCollapsedSelection\n : backwardDeleteCollapsedSelection;\n return [deleteAllSegmentBeforeStep, deleteWordSelection, deleteCollapsedSelection];\n}\n\nfunction shouldDeleteWithContentModel(selection: DOMSelection | null, rawEvent: KeyboardEvent) {\n if (!selection) {\n return false; // Nothing to delete\n } else if (selection.type != 'range' || !selection.range.collapsed) {\n return true; // Selection is not collapsed, need to delete all selections\n } else {\n const range = selection.range;\n\n // When selection is collapsed and is in middle of text node, no need to use Content Model to delete\n return !(\n isNodeOfType(range.startContainer, 'TEXT_NODE') &&\n !isModifierKey(rawEvent) &&\n (canDeleteBefore(rawEvent, range) || canDeleteAfter(rawEvent, range))\n );\n }\n}\n\nfunction canDeleteBefore(rawEvent: KeyboardEvent, range: Range) {\n return rawEvent.key == 'Backspace' && range.startOffset > 1;\n}\n\nfunction canDeleteAfter(rawEvent: KeyboardEvent, range: Range) {\n return (\n rawEvent.key == 'Delete' &&\n range.startOffset < (range.startContainer.nodeValue?.length ?? 0) - 1\n );\n}\n"]}
1
+ {"version":3,"file":"keyboardDelete.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/edit/keyboardDelete.ts"],"names":[],"mappings":"AAAA,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,CAAC;QAC/E,CAAC,EACD;YACI,QAAQ,UAAA;YACR,YAAY,EAAE,YAAY,CAAC,QAAQ;YACnC,aAAa,EAAE,cAAM,OAAA,QAAQ,CAAC,KAAK,EAAd,CAAc;YACnC,OAAO,EAAE,QAAQ,CAAC,GAAG,IAAI,QAAQ,C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B,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 { IContentModelEditor } from 'roosterjs-content-model-editor';
1
+ import type { IStandaloneEditor } from 'roosterjs-content-model-types';
2
2
  /**
3
3
  * @internal
4
4
  */
5
- export declare function keyboardInput(editor: IContentModelEditor, rawEvent: KeyboardEvent): true | undefined;
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;AAIpE;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2B,EAAE,QAAuB;IAC9E,IAAM,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAE3C,IAAI,2BAA2B,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE;QACpE,MAAM,CAAC,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 { 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, 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
+ {"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, IEditor, PluginEvent } from 'roosterjs-editor-types';
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
@@ -8,7 +8,6 @@ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-editor-types'
8
8
  * (This class is still under development, and may still be changed in the future with some breaking changes)
9
9
  */
10
10
  export declare class ContentModelPastePlugin implements EditorPlugin {
11
- private unknownTagReplacement;
12
11
  private allowExcelNoBorderTable?;
13
12
  private editor;
14
13
  /**
@@ -16,7 +15,7 @@ export declare class ContentModelPastePlugin implements EditorPlugin {
16
15
  * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
17
16
  * @param allowExcelNoBorderTable Allow table copied from Excel without border
18
17
  */
19
- constructor(unknownTagReplacement?: string, allowExcelNoBorderTable?: boolean | undefined);
18
+ constructor(allowExcelNoBorderTable?: boolean | undefined);
20
19
  /**
21
20
  * Get name of this plugin
22
21
  */
@@ -27,7 +26,7 @@ export declare class ContentModelPastePlugin implements EditorPlugin {
27
26
  * editor reference so that it can call to any editor method or format API later.
28
27
  * @param editor The editor object
29
28
  */
30
- initialize(editor: IEditor): void;
29
+ initialize(editor: IStandaloneEditor): void;
31
30
  /**
32
31
  * The last method that editor will call to a plugin before it is disposed.
33
32
  * Plugin can take this chance to clear the reference to editor. After this method is
@@ -1,22 +1,13 @@
1
- var _a;
2
1
  import addParser from './utils/addParser';
3
2
  import { BorderKeys } from 'roosterjs-content-model-dom';
4
- import { chainSanitizerCallback } from 'roosterjs-editor-dom';
5
3
  import { deprecatedBorderColorParser } from './utils/deprecatedColorParser';
6
4
  import { getPasteSource } from './pasteSourceValidations/getPasteSource';
7
5
  import { parseLink } from './utils/linkParser';
6
+ import { PastePropertyNames } from './pasteSourceValidations/constants';
8
7
  import { processPastedContentFromExcel } from './Excel/processPastedContentFromExcel';
9
8
  import { processPastedContentFromPowerPoint } from './PowerPoint/processPastedContentFromPowerPoint';
10
9
  import { processPastedContentFromWordDesktop } from './WordDesktop/processPastedContentFromWordDesktop';
11
10
  import { processPastedContentWacComponents } from './WacComponents/processPastedContentWacComponents';
12
- // Map old PasteType to new PasteType
13
- // TODO: We can remove this once we have standalone editor
14
- var PasteTypeMap = (_a = {},
15
- _a[3 /* AsImage */] = 'asImage',
16
- _a[1 /* AsPlainText */] = 'asPlainText',
17
- _a[2 /* MergeFormat */] = 'mergeFormat',
18
- _a[0 /* Normal */] = 'normal',
19
- _a);
20
11
  /**
21
12
  * Paste plugin, handles BeforePaste event and reformat some special content, including:
22
13
  * 1. Content copied from Word
@@ -31,9 +22,7 @@ var ContentModelPastePlugin = /** @class */ (function () {
31
22
  * @param unknownTagReplacement Replace solution of unknown tags, default behavior is to replace with SPAN
32
23
  * @param allowExcelNoBorderTable Allow table copied from Excel without border
33
24
  */
34
- function ContentModelPastePlugin(unknownTagReplacement, allowExcelNoBorderTable) {
35
- if (unknownTagReplacement === void 0) { unknownTagReplacement = 'SPAN'; }
36
- this.unknownTagReplacement = unknownTagReplacement;
25
+ function ContentModelPastePlugin(allowExcelNoBorderTable) {
37
26
  this.allowExcelNoBorderTable = allowExcelNoBorderTable;
38
27
  this.editor = null;
39
28
  }
@@ -68,46 +57,43 @@ var ContentModelPastePlugin = /** @class */ (function () {
68
57
  * @param event The event to handle:
69
58
  */
70
59
  ContentModelPastePlugin.prototype.onPluginEvent = function (event) {
71
- if (!this.editor || event.eventType != 10 /* BeforePaste */) {
60
+ if (!this.editor || event.eventType != 'beforePaste') {
72
61
  return;
73
62
  }
74
- var ev = event;
75
- if (!ev.domToModelOption) {
63
+ if (!event.domToModelOption) {
76
64
  return;
77
65
  }
78
- var pasteSource = getPasteSource(ev, false);
79
- var pasteType = PasteTypeMap[ev.pasteType];
66
+ var pasteSource = getPasteSource(event, false);
67
+ var pasteType = event.pasteType;
80
68
  switch (pasteSource) {
81
69
  case 'wordDesktop':
82
- processPastedContentFromWordDesktop(ev, this.editor.getTrustedHTMLHandler());
70
+ processPastedContentFromWordDesktop(event, this.editor.getTrustedHTMLHandler());
83
71
  break;
84
72
  case 'wacComponents':
85
- processPastedContentWacComponents(ev);
73
+ processPastedContentWacComponents(event);
86
74
  break;
87
75
  case 'excelOnline':
88
76
  case 'excelDesktop':
89
77
  if (pasteType === 'normal' || pasteType === 'mergeFormat') {
90
78
  // Handle HTML copied from Excel
91
- processPastedContentFromExcel(ev, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
79
+ processPastedContentFromExcel(event, this.editor.getTrustedHTMLHandler(), this.allowExcelNoBorderTable);
92
80
  }
93
81
  break;
94
82
  case 'googleSheets':
95
- ev.sanitizingOption.additionalTagReplacements["google-sheets-html-origin" /* GOOGLE_SHEET_NODE_NAME */] = '*';
83
+ event.domToModelOption.additionalAllowedTags.push(PastePropertyNames.GOOGLE_SHEET_NODE_NAME);
96
84
  break;
97
85
  case 'powerPointDesktop':
98
- processPastedContentFromPowerPoint(ev, this.editor.getTrustedHTMLHandler());
86
+ processPastedContentFromPowerPoint(event, this.editor.getTrustedHTMLHandler());
99
87
  break;
100
88
  }
101
- addParser(ev.domToModelOption, 'link', parseLink);
102
- addParser(ev.domToModelOption, 'tableCell', deprecatedBorderColorParser);
103
- addParser(ev.domToModelOption, 'tableCell', tableBorderParser);
104
- addParser(ev.domToModelOption, 'table', deprecatedBorderColorParser);
105
- sanitizeBlockStyles(ev.sanitizingOption);
89
+ addParser(event.domToModelOption, 'link', parseLink);
90
+ addParser(event.domToModelOption, 'tableCell', deprecatedBorderColorParser);
91
+ addParser(event.domToModelOption, 'tableCell', tableBorderParser);
92
+ addParser(event.domToModelOption, 'table', deprecatedBorderColorParser);
106
93
  if (pasteType === 'mergeFormat') {
107
- addParser(ev.domToModelOption, 'block', blockElementParser);
108
- addParser(ev.domToModelOption, 'listLevel', blockElementParser);
94
+ addParser(event.domToModelOption, 'block', blockElementParser);
95
+ addParser(event.domToModelOption, 'listLevel', blockElementParser);
109
96
  }
110
- ev.sanitizingOption.unknownTagReplacement = this.unknownTagReplacement;
111
97
  };
112
98
  return ContentModelPastePlugin;
113
99
  }());
@@ -121,11 +107,6 @@ var blockElementParser = function (format, element) {
121
107
  delete format.backgroundColor;
122
108
  }
123
109
  };
124
- function sanitizeBlockStyles(sanitizingOption) {
125
- chainSanitizerCallback(sanitizingOption.cssStyleCallbacks, 'display', function (value) {
126
- return value != 'flex'; // return whether we keep the style
127
- });
128
- }
129
110
  var ElementBorderKeys = new Map([
130
111
  ['borderTop', { w: 'borderTopWidth', s: 'borderTopStyle', c: 'borderTopColor' }],
131
112
  ['borderRight', { w: 'borderRightWidth', s: 'borderRightStyle', c: 'borderRightColor' }],
@@ -1 +1 @@
1
- {"version":3,"file":"ContentModelPastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/ContentModelPastePlugin.ts"],"names":[],"mappings":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AE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACvF,CAAC,CAAC;AAEH,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 { 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"]}
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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EAAE,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC5F,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACvF,CAAC,CAAC;AAEH,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 { 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-editor-types';
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: ContentModelBeforePasteEvent, trustedHTMLHandler: TrustedHTMLHandler, allowExcelNoBorderTable?: boolean): void;
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