roosterjs-content-model-plugins 0.26.3 → 0.27.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 (190) hide show
  1. package/lib/autoFormat/AutoFormatPlugin.d.ts +2 -2
  2. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  3. package/lib/autoFormat/keyboardListTrigger.d.ts +2 -2
  4. package/lib/autoFormat/keyboardListTrigger.js.map +1 -1
  5. package/lib/edit/EditPlugin.d.ts +3 -3
  6. package/lib/edit/EditPlugin.js +1 -1
  7. package/lib/edit/EditPlugin.js.map +1 -1
  8. package/lib/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
  9. package/lib/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  10. package/lib/edit/handleKeyboardEventCommon.d.ts +2 -2
  11. package/lib/edit/handleKeyboardEventCommon.js.map +1 -1
  12. package/lib/edit/inputSteps/handleEnterOnList.js +40 -10
  13. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
  14. package/lib/edit/keyboardDelete.d.ts +3 -3
  15. package/lib/edit/keyboardDelete.js +1 -1
  16. package/lib/edit/keyboardDelete.js.map +1 -1
  17. package/lib/edit/keyboardInput.d.ts +2 -2
  18. package/lib/edit/keyboardInput.js.map +1 -1
  19. package/lib/edit/keyboardTab.d.ts +2 -2
  20. package/lib/edit/keyboardTab.js +19 -11
  21. package/lib/edit/keyboardTab.js.map +1 -1
  22. package/lib/edit/tabUtils/handleTabOnList.d.ts +7 -0
  23. package/lib/edit/tabUtils/handleTabOnList.js +34 -0
  24. package/lib/edit/tabUtils/handleTabOnList.js.map +1 -0
  25. package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  26. package/lib/edit/tabUtils/handleTabOnParagraph.js +81 -0
  27. package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  28. package/lib/index.d.ts +4 -0
  29. package/lib/index.js +18 -1
  30. package/lib/index.js.map +1 -1
  31. package/lib/paste/PastePlugin.d.ts +2 -3
  32. package/lib/paste/PastePlugin.js +0 -1
  33. package/lib/paste/PastePlugin.js.map +1 -1
  34. package/lib/shortcut/ShortcutCommand.d.ts +44 -0
  35. package/lib/shortcut/ShortcutCommand.js +3 -0
  36. package/lib/shortcut/ShortcutCommand.js.map +1 -0
  37. package/lib/shortcut/ShortcutPlugin.d.ts +51 -0
  38. package/lib/shortcut/ShortcutPlugin.js +118 -0
  39. package/lib/shortcut/ShortcutPlugin.js.map +1 -0
  40. package/lib/shortcut/shortcuts.d.ts +73 -0
  41. package/lib/shortcut/shortcuts.js +178 -0
  42. package/lib/shortcut/shortcuts.js.map +1 -0
  43. package/lib/tableEdit/TableEditPlugin.d.ts +47 -0
  44. package/lib/tableEdit/TableEditPlugin.js +156 -0
  45. package/lib/tableEdit/TableEditPlugin.js.map +1 -0
  46. package/lib/tableEdit/editors/TableEditor.d.ts +73 -0
  47. package/lib/tableEdit/editors/TableEditor.js +294 -0
  48. package/lib/tableEdit/editors/TableEditor.js.map +1 -0
  49. package/lib/tableEdit/editors/features/CellResizer.d.ts +6 -0
  50. package/lib/tableEdit/editors/features/CellResizer.js +169 -0
  51. package/lib/tableEdit/editors/features/CellResizer.js.map +1 -0
  52. package/lib/tableEdit/editors/features/TableEditorFeature.d.ts +13 -0
  53. package/lib/tableEdit/editors/features/TableEditorFeature.js +17 -0
  54. package/lib/tableEdit/editors/features/TableEditorFeature.js.map +1 -0
  55. package/lib/tableEdit/editors/features/TableInserter.d.ts +6 -0
  56. package/lib/tableEdit/editors/features/TableInserter.js +113 -0
  57. package/lib/tableEdit/editors/features/TableInserter.js.map +1 -0
  58. package/lib/tableEdit/editors/features/TableMover.d.ts +8 -0
  59. package/lib/tableEdit/editors/features/TableMover.js +83 -0
  60. package/lib/tableEdit/editors/features/TableMover.js.map +1 -0
  61. package/lib/tableEdit/editors/features/TableResizer.d.ts +6 -0
  62. package/lib/tableEdit/editors/features/TableResizer.js +163 -0
  63. package/lib/tableEdit/editors/features/TableResizer.js.map +1 -0
  64. package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +2 -2
  65. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  66. package/lib-amd/autoFormat/keyboardListTrigger.d.ts +2 -2
  67. package/lib-amd/autoFormat/keyboardListTrigger.js.map +1 -1
  68. package/lib-amd/edit/EditPlugin.d.ts +3 -3
  69. package/lib-amd/edit/EditPlugin.js +1 -1
  70. package/lib-amd/edit/EditPlugin.js.map +1 -1
  71. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js +19 -1
  72. package/lib-amd/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  73. package/lib-amd/edit/handleKeyboardEventCommon.d.ts +2 -2
  74. package/lib-amd/edit/handleKeyboardEventCommon.js.map +1 -1
  75. package/lib-amd/edit/inputSteps/handleEnterOnList.js +40 -10
  76. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
  77. package/lib-amd/edit/keyboardDelete.d.ts +3 -3
  78. package/lib-amd/edit/keyboardDelete.js +1 -1
  79. package/lib-amd/edit/keyboardDelete.js.map +1 -1
  80. package/lib-amd/edit/keyboardInput.d.ts +2 -2
  81. package/lib-amd/edit/keyboardInput.js.map +1 -1
  82. package/lib-amd/edit/keyboardTab.d.ts +2 -2
  83. package/lib-amd/edit/keyboardTab.js +18 -12
  84. package/lib-amd/edit/keyboardTab.js.map +1 -1
  85. package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +7 -0
  86. package/lib-amd/edit/tabUtils/handleTabOnList.js +34 -0
  87. package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -0
  88. package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  89. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +81 -0
  90. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  91. package/lib-amd/index.d.ts +4 -0
  92. package/lib-amd/index.js +16 -2
  93. package/lib-amd/index.js.map +1 -1
  94. package/lib-amd/paste/PastePlugin.d.ts +2 -3
  95. package/lib-amd/paste/PastePlugin.js +0 -1
  96. package/lib-amd/paste/PastePlugin.js.map +1 -1
  97. package/lib-amd/shortcut/ShortcutCommand.d.ts +44 -0
  98. package/lib-amd/shortcut/ShortcutCommand.js +5 -0
  99. package/lib-amd/shortcut/ShortcutCommand.js.map +1 -0
  100. package/lib-amd/shortcut/ShortcutPlugin.d.ts +51 -0
  101. package/lib-amd/shortcut/ShortcutPlugin.js +118 -0
  102. package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -0
  103. package/lib-amd/shortcut/shortcuts.d.ts +73 -0
  104. package/lib-amd/shortcut/shortcuts.js +178 -0
  105. package/lib-amd/shortcut/shortcuts.js.map +1 -0
  106. package/lib-amd/tableEdit/TableEditPlugin.d.ts +47 -0
  107. package/lib-amd/tableEdit/TableEditPlugin.js +155 -0
  108. package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -0
  109. package/lib-amd/tableEdit/editors/TableEditor.d.ts +73 -0
  110. package/lib-amd/tableEdit/editors/TableEditor.js +289 -0
  111. package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -0
  112. package/lib-amd/tableEdit/editors/features/CellResizer.d.ts +6 -0
  113. package/lib-amd/tableEdit/editors/features/CellResizer.js +165 -0
  114. package/lib-amd/tableEdit/editors/features/CellResizer.js.map +1 -0
  115. package/lib-amd/tableEdit/editors/features/TableEditorFeature.d.ts +13 -0
  116. package/lib-amd/tableEdit/editors/features/TableEditorFeature.js +19 -0
  117. package/lib-amd/tableEdit/editors/features/TableEditorFeature.js.map +1 -0
  118. package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +6 -0
  119. package/lib-amd/tableEdit/editors/features/TableInserter.js +110 -0
  120. package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -0
  121. package/lib-amd/tableEdit/editors/features/TableMover.d.ts +8 -0
  122. package/lib-amd/tableEdit/editors/features/TableMover.js +80 -0
  123. package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -0
  124. package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +6 -0
  125. package/lib-amd/tableEdit/editors/features/TableResizer.js +160 -0
  126. package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -0
  127. package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +2 -2
  128. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  129. package/lib-mjs/autoFormat/keyboardListTrigger.d.ts +2 -2
  130. package/lib-mjs/autoFormat/keyboardListTrigger.js.map +1 -1
  131. package/lib-mjs/edit/EditPlugin.d.ts +3 -3
  132. package/lib-mjs/edit/EditPlugin.js +1 -1
  133. package/lib-mjs/edit/EditPlugin.js.map +1 -1
  134. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js +20 -1
  135. package/lib-mjs/edit/deleteSteps/deleteCollapsedSelection.js.map +1 -1
  136. package/lib-mjs/edit/handleKeyboardEventCommon.d.ts +2 -2
  137. package/lib-mjs/edit/handleKeyboardEventCommon.js.map +1 -1
  138. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +42 -12
  139. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
  140. package/lib-mjs/edit/keyboardDelete.d.ts +3 -3
  141. package/lib-mjs/edit/keyboardDelete.js +1 -1
  142. package/lib-mjs/edit/keyboardDelete.js.map +1 -1
  143. package/lib-mjs/edit/keyboardInput.d.ts +2 -2
  144. package/lib-mjs/edit/keyboardInput.js.map +1 -1
  145. package/lib-mjs/edit/keyboardTab.d.ts +2 -2
  146. package/lib-mjs/edit/keyboardTab.js +19 -11
  147. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  148. package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +7 -0
  149. package/lib-mjs/edit/tabUtils/handleTabOnList.js +30 -0
  150. package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -0
  151. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +17 -0
  152. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +77 -0
  153. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -0
  154. package/lib-mjs/index.d.ts +4 -0
  155. package/lib-mjs/index.js +3 -0
  156. package/lib-mjs/index.js.map +1 -1
  157. package/lib-mjs/paste/PastePlugin.d.ts +2 -3
  158. package/lib-mjs/paste/PastePlugin.js +0 -1
  159. package/lib-mjs/paste/PastePlugin.js.map +1 -1
  160. package/lib-mjs/shortcut/ShortcutCommand.d.ts +44 -0
  161. package/lib-mjs/shortcut/ShortcutCommand.js +2 -0
  162. package/lib-mjs/shortcut/ShortcutCommand.js.map +1 -0
  163. package/lib-mjs/shortcut/ShortcutPlugin.d.ts +51 -0
  164. package/lib-mjs/shortcut/ShortcutPlugin.js +115 -0
  165. package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -0
  166. package/lib-mjs/shortcut/shortcuts.d.ts +73 -0
  167. package/lib-mjs/shortcut/shortcuts.js +175 -0
  168. package/lib-mjs/shortcut/shortcuts.js.map +1 -0
  169. package/lib-mjs/tableEdit/TableEditPlugin.d.ts +47 -0
  170. package/lib-mjs/tableEdit/TableEditPlugin.js +153 -0
  171. package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -0
  172. package/lib-mjs/tableEdit/editors/TableEditor.d.ts +73 -0
  173. package/lib-mjs/tableEdit/editors/TableEditor.js +292 -0
  174. package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -0
  175. package/lib-mjs/tableEdit/editors/features/CellResizer.d.ts +6 -0
  176. package/lib-mjs/tableEdit/editors/features/CellResizer.js +166 -0
  177. package/lib-mjs/tableEdit/editors/features/CellResizer.js.map +1 -0
  178. package/lib-mjs/tableEdit/editors/features/TableEditorFeature.d.ts +13 -0
  179. package/lib-mjs/tableEdit/editors/features/TableEditorFeature.js +13 -0
  180. package/lib-mjs/tableEdit/editors/features/TableEditorFeature.js.map +1 -0
  181. package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +6 -0
  182. package/lib-mjs/tableEdit/editors/features/TableInserter.js +110 -0
  183. package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -0
  184. package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +8 -0
  185. package/lib-mjs/tableEdit/editors/features/TableMover.js +80 -0
  186. package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -0
  187. package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +6 -0
  188. package/lib-mjs/tableEdit/editors/features/TableResizer.js +160 -0
  189. package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -0
  190. package/package.json +5 -5
package/lib-amd/index.js CHANGED
@@ -1,9 +1,23 @@
1
- define(["require", "exports", "./paste/PastePlugin", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin"], function (require, exports, PastePlugin_1, EditPlugin_1, AutoFormatPlugin_1) {
1
+ define(["require", "exports", "./tableEdit/TableEditPlugin", "./paste/PastePlugin", "./edit/EditPlugin", "./autoFormat/AutoFormatPlugin", "./shortcut/shortcuts", "./shortcut/ShortcutPlugin"], function (require, exports, TableEditPlugin_1, PastePlugin_1, EditPlugin_1, AutoFormatPlugin_1, shortcuts_1, ShortcutPlugin_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = void 0;
4
+ exports.ShortcutPlugin = exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = exports.AutoFormatPlugin = exports.EditPlugin = exports.PastePlugin = exports.TableEditPlugin = void 0;
5
+ Object.defineProperty(exports, "TableEditPlugin", { enumerable: true, get: function () { return TableEditPlugin_1.TableEditPlugin; } });
5
6
  Object.defineProperty(exports, "PastePlugin", { enumerable: true, get: function () { return PastePlugin_1.PastePlugin; } });
6
7
  Object.defineProperty(exports, "EditPlugin", { enumerable: true, get: function () { return EditPlugin_1.EditPlugin; } });
7
8
  Object.defineProperty(exports, "AutoFormatPlugin", { enumerable: true, get: function () { return AutoFormatPlugin_1.AutoFormatPlugin; } });
9
+ Object.defineProperty(exports, "ShortcutBold", { enumerable: true, get: function () { return shortcuts_1.ShortcutBold; } });
10
+ Object.defineProperty(exports, "ShortcutItalic", { enumerable: true, get: function () { return shortcuts_1.ShortcutItalic; } });
11
+ Object.defineProperty(exports, "ShortcutUnderline", { enumerable: true, get: function () { return shortcuts_1.ShortcutUnderline; } });
12
+ Object.defineProperty(exports, "ShortcutClearFormat", { enumerable: true, get: function () { return shortcuts_1.ShortcutClearFormat; } });
13
+ Object.defineProperty(exports, "ShortcutUndo", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo; } });
14
+ Object.defineProperty(exports, "ShortcutUndo2", { enumerable: true, get: function () { return shortcuts_1.ShortcutUndo2; } });
15
+ Object.defineProperty(exports, "ShortcutRedo", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedo; } });
16
+ Object.defineProperty(exports, "ShortcutRedoMacOS", { enumerable: true, get: function () { return shortcuts_1.ShortcutRedoMacOS; } });
17
+ Object.defineProperty(exports, "ShortcutBullet", { enumerable: true, get: function () { return shortcuts_1.ShortcutBullet; } });
18
+ Object.defineProperty(exports, "ShortcutNumbering", { enumerable: true, get: function () { return shortcuts_1.ShortcutNumbering; } });
19
+ Object.defineProperty(exports, "ShortcutIncreaseFont", { enumerable: true, get: function () { return shortcuts_1.ShortcutIncreaseFont; } });
20
+ Object.defineProperty(exports, "ShortcutDecreaseFont", { enumerable: true, get: function () { return shortcuts_1.ShortcutDecreaseFont; } });
21
+ Object.defineProperty(exports, "ShortcutPlugin", { enumerable: true, get: function () { return ShortcutPlugin_1.ShortcutPlugin; } });
8
22
  });
9
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;;IAAS,0GAAA,WAAW,OAAA;IACX,wGAAA,UAAU,OAAA;IACV,oHAAA,gBAAgB,OAAA","sourcesContent":["export { PastePlugin } from './paste/PastePlugin';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages-content-model/roosterjs-content-model-plugins/lib/index.ts"],"names":[],"mappings":";;;;IAAS,kHAAA,eAAe,OAAA;IACf,0GAAA,WAAW,OAAA;IACX,wGAAA,UAAU,OAAA;IACV,oHAAA,gBAAgB,OAAA;IAGrB,yGAAA,YAAY,OAAA;IACZ,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,gHAAA,mBAAmB,OAAA;IACnB,yGAAA,YAAY,OAAA;IACZ,0GAAA,aAAa,OAAA;IACb,yGAAA,YAAY,OAAA;IACZ,8GAAA,iBAAiB,OAAA;IACjB,2GAAA,cAAc,OAAA;IACd,8GAAA,iBAAiB,OAAA;IACjB,iHAAA,oBAAoB,OAAA;IACpB,iHAAA,oBAAoB,OAAA;IAEf,gHAAA,cAAc,OAAA","sourcesContent":["export { TableEditPlugin } from './tableEdit/TableEditPlugin';\nexport { PastePlugin } from './paste/PastePlugin';\nexport { EditPlugin } from './edit/EditPlugin';\nexport { AutoFormatPlugin, AutoFormatOptions } from './autoFormat/AutoFormatPlugin';\n\nexport {\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n} from './shortcut/shortcuts';\nexport { ShortcutPlugin } from './shortcut/ShortcutPlugin';\nexport { ShortcutKeyDefinition, ShortcutCommand } from './shortcut/ShortcutCommand';\n"]}
@@ -1,11 +1,10 @@
1
- import type { EditorPlugin, IStandaloneEditor, PluginEvent } from 'roosterjs-content-model-types';
1
+ import type { EditorPlugin, IEditor, 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
5
5
  * 2. Content copied from Excel
6
6
  * 3. Content copied from Word Online or OneNote Online
7
7
  * 4. Content copied from Power Point
8
- * (This class is still under development, and may still be changed in the future with some breaking changes)
9
8
  */
10
9
  export declare class PastePlugin implements EditorPlugin {
11
10
  private allowExcelNoBorderTable?;
@@ -26,7 +25,7 @@ export declare class PastePlugin implements EditorPlugin {
26
25
  * editor reference so that it can call to any editor method or format API later.
27
26
  * @param editor The editor object
28
27
  */
29
- initialize(editor: IStandaloneEditor): void;
28
+ initialize(editor: IEditor): void;
30
29
  /**
31
30
  * The last method that editor will call to a plugin before it is disposed.
32
31
  * Plugin can take this chance to clear the reference to editor. After this method is
@@ -8,7 +8,6 @@ define(["require", "exports", "./utils/addParser", "roosterjs-content-model-dom"
8
8
  * 2. Content copied from Excel
9
9
  * 3. Content copied from Word Online or OneNote Online
10
10
  * 4. Content copied from Power Point
11
- * (This class is still under development, and may still be changed in the future with some breaking changes)
12
11
  */
13
12
  var PastePlugin = /** @class */ (function () {
14
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;;OAOG;IACH;QAGI;;;;WAIG;QACH,qBAAoB,uBAAiC;YAAjC,4BAAuB,GAAvB,uBAAuB,CAAU;YAP7C,WAAM,GAA6B,IAAI,CAAC;QAOQ,CAAC;QAEzD;;WAEG;QACH,6BAAO,GAAP;YACI,OAAO,OAAO,CAAC;QACnB,CAAC;QAED;;;;;WAKG;QACH,gCAAU,GAAV,UAAW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,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;KACvF,CAAC,CAAC;IAEH,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;QAChF,wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { 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 PastePlugin 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 'Paste';\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 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
+ {"version":3,"file":"PastePlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/paste/PastePlugin.ts"],"names":[],"mappings":";;;;IAoBA;;;;;;OAMG;IACH;QAGI;;;;W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AC,EAAE,kBAAkB,EAAE,CAAC;QACxF,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,EAAE,CAAC;QAC5F,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC;KACvF,CAAC,CAAC;IAEH,SAAS,iBAAiB,CAAC,MAAmC,EAAE,OAAoB;QAChF,wCAAU,CAAC,OAAO,CAAC,UAAA,GAAG;YAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACd,IAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC5C,IACI,QAAQ;oBACR,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACzB,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5B;oBACE,MAAM,CAAC,GAAG,CAAC,GAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAG,CAAC;iBAC7E;aACJ;QACL,CAAC,CAAC,CAAC;IACP,CAAC","sourcesContent":["import addParser from './utils/addParser';\nimport { BorderKeys } from 'roosterjs-content-model-dom';\nimport { 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 IEditor,\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 */\nexport class PastePlugin implements EditorPlugin {\n private editor: IEditor | 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 'Paste';\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 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"]}
@@ -0,0 +1,44 @@
1
+ import type { IEditor } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Definition of the shortcut key
4
+ */
5
+ export interface ShortcutKeyDefinition {
6
+ /**
7
+ * Modifier key for this shortcut, allowed values are:
8
+ * ctrl: Ctrl key (or Meta key on MacOS)
9
+ * alt: Alt key
10
+ */
11
+ modifierKey: 'ctrl' | 'alt';
12
+ /**
13
+ * Whether ALT key is required for this shortcut
14
+ */
15
+ shiftKey: boolean;
16
+ /**
17
+ * Key code for this shortcut. The value should be the value of KeyboardEvent.which
18
+ * We are still using key code here rather than key name (event.key) although event.which is deprecated because of globalization.
19
+ * For example, on US keyboard, Shift+Comma="<" but on Spanish keyboard it is ":"
20
+ * And we still want the shortcut key to be registered on the same key, in that case key name is different but key code keeps the same.
21
+ */
22
+ which: number;
23
+ }
24
+ /**
25
+ * Represents a command for shortcut
26
+ */
27
+ export interface ShortcutCommand {
28
+ /**
29
+ * Definition of the shortcut key
30
+ */
31
+ shortcutKey: ShortcutKeyDefinition;
32
+ /**
33
+ * @optional Required environment for this command
34
+ * all: (Default) This feature is available for all environments
35
+ * mac: This feature is available on MacOS only
36
+ * nonMac: This feature is available on OS other than MacOS
37
+ */
38
+ environment?: 'all' | 'mac' | 'nonMac';
39
+ /**
40
+ * The callback function to invoke when this shortcut is triggered
41
+ * @param editor The editor object
42
+ */
43
+ onClick: (editor: IEditor) => void;
44
+ }
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=ShortcutCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShortcutCommand.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/shortcut/ShortcutCommand.ts"],"names":[],"mappings":"","sourcesContent":["import type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * Definition of the shortcut key\n */\nexport interface ShortcutKeyDefinition {\n /**\n * Modifier key for this shortcut, allowed values are:\n * ctrl: Ctrl key (or Meta key on MacOS)\n * alt: Alt key\n */\n modifierKey: 'ctrl' | 'alt';\n\n /**\n * Whether ALT key is required for this shortcut\n */\n shiftKey: boolean;\n\n /**\n * Key code for this shortcut. The value should be the value of KeyboardEvent.which\n * We are still using key code here rather than key name (event.key) although event.which is deprecated because of globalization.\n * For example, on US keyboard, Shift+Comma=\"<\" but on Spanish keyboard it is \":\"\n * And we still want the shortcut key to be registered on the same key, in that case key name is different but key code keeps the same.\n */\n which: number;\n}\n\n/**\n * Represents a command for shortcut\n */\nexport interface ShortcutCommand {\n /**\n * Definition of the shortcut key\n */\n shortcutKey: ShortcutKeyDefinition;\n\n /**\n * @optional Required environment for this command\n * all: (Default) This feature is available for all environments\n * mac: This feature is available on MacOS only\n * nonMac: This feature is available on OS other than MacOS\n */\n environment?: 'all' | 'mac' | 'nonMac';\n\n /**\n * The callback function to invoke when this shortcut is triggered\n * @param editor The editor object\n */\n onClick: (editor: IEditor) => void;\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import type { ShortcutCommand } from './ShortcutCommand';
2
+ import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
3
+ /**
4
+ * Shortcut plugin hook on the specified shortcut keys and trigger related format API
5
+ */
6
+ export declare class ShortcutPlugin implements EditorPlugin {
7
+ private shortcuts;
8
+ private editor;
9
+ private isMac;
10
+ /**
11
+ * Create a new instance of ShortcutPlugin
12
+ * @param [shortcuts=defaultShortcuts] Allowed commands
13
+ */
14
+ constructor(shortcuts?: ShortcutCommand[]);
15
+ /**
16
+ * Get name of this plugin
17
+ */
18
+ getName(): string;
19
+ /**
20
+ * The first method that editor will call to a plugin when editor is initializing.
21
+ * It will pass in the editor instance, plugin should take this chance to save the
22
+ * editor reference so that it can call to any editor method or format API later.
23
+ * @param editor The editor object
24
+ */
25
+ initialize(editor: IEditor): void;
26
+ /**
27
+ * The last method that editor will call to a plugin before it is disposed.
28
+ * Plugin can take this chance to clear the reference to editor. After this method is
29
+ * called, plugin should not call to any editor method since it will result in error.
30
+ */
31
+ dispose(): void;
32
+ /**
33
+ * Check if the plugin should handle the given event exclusively.
34
+ * Handle an event exclusively means other plugin will not receive this event in
35
+ * onPluginEvent method.
36
+ * If two plugins will return true in willHandleEventExclusively() for the same event,
37
+ * the final result depends on the order of the plugins are added into editor
38
+ * @param event The event to check:
39
+ */
40
+ willHandleEventExclusively(event: PluginEvent): boolean;
41
+ /**
42
+ * Core method for a plugin. Once an event happens in editor, editor will call this
43
+ * method of each plugin to handle the event as long as the event is not handled
44
+ * exclusively by another plugin.
45
+ * @param event The event to handle:
46
+ */
47
+ onPluginEvent(event: PluginEvent): void;
48
+ private cacheGetCommand;
49
+ private matchOS;
50
+ private matchShortcut;
51
+ }
@@ -0,0 +1,118 @@
1
+ define(["require", "exports", "roosterjs-content-model-core", "./shortcuts"], function (require, exports, roosterjs_content_model_core_1, shortcuts_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ShortcutPlugin = void 0;
5
+ var defaultShortcuts = [
6
+ shortcuts_1.ShortcutBold,
7
+ shortcuts_1.ShortcutItalic,
8
+ shortcuts_1.ShortcutUnderline,
9
+ shortcuts_1.ShortcutClearFormat,
10
+ shortcuts_1.ShortcutUndo,
11
+ shortcuts_1.ShortcutUndo2,
12
+ shortcuts_1.ShortcutRedo,
13
+ shortcuts_1.ShortcutRedoMacOS,
14
+ shortcuts_1.ShortcutBullet,
15
+ shortcuts_1.ShortcutNumbering,
16
+ shortcuts_1.ShortcutIncreaseFont,
17
+ shortcuts_1.ShortcutDecreaseFont,
18
+ ];
19
+ var CommandCacheKey = '__ShortcutCommandCache';
20
+ /**
21
+ * Shortcut plugin hook on the specified shortcut keys and trigger related format API
22
+ */
23
+ var ShortcutPlugin = /** @class */ (function () {
24
+ /**
25
+ * Create a new instance of ShortcutPlugin
26
+ * @param [shortcuts=defaultShortcuts] Allowed commands
27
+ */
28
+ function ShortcutPlugin(shortcuts) {
29
+ if (shortcuts === void 0) { shortcuts = defaultShortcuts; }
30
+ this.shortcuts = shortcuts;
31
+ this.editor = null;
32
+ this.isMac = false;
33
+ }
34
+ /**
35
+ * Get name of this plugin
36
+ */
37
+ ShortcutPlugin.prototype.getName = function () {
38
+ return 'Shortcut';
39
+ };
40
+ /**
41
+ * The first method that editor will call to a plugin when editor is initializing.
42
+ * It will pass in the editor instance, plugin should take this chance to save the
43
+ * editor reference so that it can call to any editor method or format API later.
44
+ * @param editor The editor object
45
+ */
46
+ ShortcutPlugin.prototype.initialize = function (editor) {
47
+ this.editor = editor;
48
+ this.isMac = !!this.editor.getEnvironment().isMac;
49
+ };
50
+ /**
51
+ * The last method that editor will call to a plugin before it is disposed.
52
+ * Plugin can take this chance to clear the reference to editor. After this method is
53
+ * called, plugin should not call to any editor method since it will result in error.
54
+ */
55
+ ShortcutPlugin.prototype.dispose = function () {
56
+ this.editor = null;
57
+ };
58
+ /**
59
+ * Check if the plugin should handle the given event exclusively.
60
+ * Handle an event exclusively means other plugin will not receive this event in
61
+ * onPluginEvent method.
62
+ * If two plugins will return true in willHandleEventExclusively() for the same event,
63
+ * the final result depends on the order of the plugins are added into editor
64
+ * @param event The event to check:
65
+ */
66
+ ShortcutPlugin.prototype.willHandleEventExclusively = function (event) {
67
+ return (event.eventType == 'keyDown' &&
68
+ (event.rawEvent.ctrlKey || event.rawEvent.altKey || event.rawEvent.metaKey) &&
69
+ !!this.cacheGetCommand(event));
70
+ };
71
+ /**
72
+ * Core method for a plugin. Once an event happens in editor, editor will call this
73
+ * method of each plugin to handle the event as long as the event is not handled
74
+ * exclusively by another plugin.
75
+ * @param event The event to handle:
76
+ */
77
+ ShortcutPlugin.prototype.onPluginEvent = function (event) {
78
+ if (this.editor && event.eventType == 'keyDown') {
79
+ var command = this.cacheGetCommand(event);
80
+ if (command) {
81
+ command.onClick(this.editor);
82
+ event.rawEvent.preventDefault();
83
+ }
84
+ }
85
+ };
86
+ ShortcutPlugin.prototype.cacheGetCommand = function (event) {
87
+ var _this = this;
88
+ return (0, roosterjs_content_model_core_1.cacheGetEventData)(event, CommandCacheKey, function (event) {
89
+ var editor = _this.editor;
90
+ return (editor &&
91
+ _this.shortcuts.filter(function (command) {
92
+ return _this.matchOS(command.environment) &&
93
+ _this.matchShortcut(command.shortcutKey, event.rawEvent);
94
+ })[0]);
95
+ });
96
+ };
97
+ ShortcutPlugin.prototype.matchOS = function (environment) {
98
+ switch (environment) {
99
+ case 'mac':
100
+ return this.isMac;
101
+ case 'nonMac':
102
+ return !this.isMac;
103
+ default:
104
+ return true;
105
+ }
106
+ };
107
+ ShortcutPlugin.prototype.matchShortcut = function (shortcutKey, event) {
108
+ var ctrlKey = event.ctrlKey, altKey = event.altKey, shiftKey = event.shiftKey, which = event.which, metaKey = event.metaKey;
109
+ var ctrlOrMeta = this.isMac ? metaKey : ctrlKey;
110
+ var matchModifier = (shortcutKey.modifierKey == 'ctrl' && ctrlOrMeta && !altKey) ||
111
+ (shortcutKey.modifierKey == 'alt' && altKey && !ctrlOrMeta);
112
+ return matchModifier && shiftKey == shortcutKey.shiftKey && shortcutKey.which == which;
113
+ };
114
+ return ShortcutPlugin;
115
+ }());
116
+ exports.ShortcutPlugin = ShortcutPlugin;
117
+ });
118
+ //# sourceMappingURL=ShortcutPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShortcutPlugin.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/shortcut/ShortcutPlugin.ts"],"names":[],"mappings":";;;;IAuBA,IAAM,gBAAgB,GAAsB;QACxC,wBAAY;QACZ,0BAAc;QACd,6BAAiB;QACjB,+BAAmB;QACnB,wBAAY;QACZ,yBAAa;QACb,wBAAY;QACZ,6BAAiB;QACjB,0BAAc;QACd,6BAAiB;QACjB,gCAAoB;QACpB,gCAAoB;KACvB,CAAC;IACF,IAAM,eAAe,GAAG,wBAAwB,CAAC;IAEjD;;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,IAAI,KAAK,CAAC;QAC3F,CAAC;QACL,qBAAC;IAAD,CAAC,AA3GD,IA2GC;IA3GY,wCAAc","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-core';\nimport type { ShortcutCommand, ShortcutKeyDefinition } from './ShortcutCommand';\nimport {\n ShortcutBold,\n ShortcutBullet,\n ShortcutClearFormat,\n ShortcutDecreaseFont,\n ShortcutIncreaseFont,\n ShortcutItalic,\n ShortcutNumbering,\n ShortcutRedo,\n ShortcutRedoMacOS,\n ShortcutUnderline,\n ShortcutUndo,\n ShortcutUndo2,\n} from './shortcuts';\nimport type {\n EditorPlugin,\n IEditor,\n KeyDownEvent,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\nconst defaultShortcuts: ShortcutCommand[] = [\n ShortcutBold,\n ShortcutItalic,\n ShortcutUnderline,\n ShortcutClearFormat,\n ShortcutUndo,\n ShortcutUndo2,\n ShortcutRedo,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n];\nconst CommandCacheKey = '__ShortcutCommandCache';\n\n/**\n * Shortcut plugin hook on the specified shortcut keys and trigger related format API\n */\nexport class ShortcutPlugin implements EditorPlugin {\n private editor: IEditor | null = null;\n private isMac = false;\n\n /**\n * Create a new instance of ShortcutPlugin\n * @param [shortcuts=defaultShortcuts] Allowed commands\n */\n constructor(private shortcuts: ShortcutCommand[] = defaultShortcuts) {}\n\n /**\n * Get name of this plugin\n */\n getName() {\n return 'Shortcut';\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 this.editor = editor;\n this.isMac = !!this.editor.getEnvironment().isMac;\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 * Check if the plugin should handle the given event exclusively.\n * Handle an event exclusively means other plugin will not receive this event in\n * onPluginEvent method.\n * If two plugins will return true in willHandleEventExclusively() for the same event,\n * the final result depends on the order of the plugins are added into editor\n * @param event The event to check:\n */\n willHandleEventExclusively(event: PluginEvent) {\n return (\n event.eventType == 'keyDown' &&\n (event.rawEvent.ctrlKey || event.rawEvent.altKey || event.rawEvent.metaKey) &&\n !!this.cacheGetCommand(event)\n );\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 == 'keyDown') {\n const command = this.cacheGetCommand(event);\n\n if (command) {\n command.onClick(this.editor);\n event.rawEvent.preventDefault();\n }\n }\n }\n\n private cacheGetCommand(event: KeyDownEvent) {\n return cacheGetEventData(event, CommandCacheKey, event => {\n const editor = this.editor;\n\n return (\n editor &&\n this.shortcuts.filter(\n command =>\n this.matchOS(command.environment) &&\n this.matchShortcut(command.shortcutKey, event.rawEvent)\n )[0]\n );\n });\n }\n\n private matchOS(environment?: 'all' | 'mac' | 'nonMac') {\n switch (environment) {\n case 'mac':\n return this.isMac;\n\n case 'nonMac':\n return !this.isMac;\n\n default:\n return true;\n }\n }\n\n private matchShortcut(shortcutKey: ShortcutKeyDefinition, event: KeyboardEvent) {\n const { ctrlKey, altKey, shiftKey, which, metaKey } = event;\n const ctrlOrMeta = this.isMac ? metaKey : ctrlKey;\n const matchModifier =\n (shortcutKey.modifierKey == 'ctrl' && ctrlOrMeta && !altKey) ||\n (shortcutKey.modifierKey == 'alt' && altKey && !ctrlOrMeta);\n\n return matchModifier && shiftKey == shortcutKey.shiftKey && shortcutKey.which == which;\n }\n}\n"]}
@@ -0,0 +1,73 @@
1
+ import type { ShortcutCommand } from './ShortcutCommand';
2
+ /**
3
+ * Shortcut command for Bold
4
+ * Windows: Ctrl + B
5
+ * MacOS: Meta + B
6
+ */
7
+ export declare const ShortcutBold: ShortcutCommand;
8
+ /**
9
+ * Shortcut command for Italic
10
+ * Windows: Ctrl + I
11
+ * MacOS: Meta + I
12
+ */
13
+ export declare const ShortcutItalic: ShortcutCommand;
14
+ /**
15
+ * Shortcut command for Underline
16
+ * Windows: Ctrl + U
17
+ * MacOS: Meta + U
18
+ */
19
+ export declare const ShortcutUnderline: ShortcutCommand;
20
+ /**
21
+ * Shortcut command for Clear Format
22
+ * Windows: Ctrl + Space
23
+ * MacOS: Meta + Space
24
+ */
25
+ export declare const ShortcutClearFormat: ShortcutCommand;
26
+ /**
27
+ * Shortcut command for Undo 1
28
+ * Windows: Ctrl + Z
29
+ * MacOS: Meta + Z
30
+ */
31
+ export declare const ShortcutUndo: ShortcutCommand;
32
+ /**
33
+ * Shortcut command for Undo 2
34
+ * Windows: Alt + Backspace
35
+ * MacOS: N/A
36
+ */
37
+ export declare const ShortcutUndo2: ShortcutCommand;
38
+ /**
39
+ * Shortcut command for Redo 1
40
+ * Windows: Ctrl + Y
41
+ * MacOS: N/A
42
+ */
43
+ export declare const ShortcutRedo: ShortcutCommand;
44
+ /**
45
+ * Shortcut command for Redo 2
46
+ * Windows: N/A
47
+ * MacOS: Meta + Shift + Z
48
+ */
49
+ export declare const ShortcutRedoMacOS: ShortcutCommand;
50
+ /**
51
+ * Shortcut command for Bullet List
52
+ * Windows: Ctrl + . (Period)
53
+ * MacOS: Meta + . (Period)
54
+ */
55
+ export declare const ShortcutBullet: ShortcutCommand;
56
+ /**
57
+ * Shortcut command for Numbering List
58
+ * Windows: Ctrl + / (Forward slash)
59
+ * MacOS: Meta + / (Forward slash)
60
+ */
61
+ export declare const ShortcutNumbering: ShortcutCommand;
62
+ /**
63
+ * Shortcut command for Increase Font
64
+ * Windows: Ctrl + Shift + . (Period)
65
+ * MacOS: Meta + Shift + . (Period)
66
+ */
67
+ export declare const ShortcutIncreaseFont: ShortcutCommand;
68
+ /**
69
+ * Shortcut command for Decrease Font
70
+ * Windows: Ctrl + Shift + , (Comma)
71
+ * MacOS: Meta + Shift + , (Comma)
72
+ */
73
+ export declare const ShortcutDecreaseFont: ShortcutCommand;
@@ -0,0 +1,178 @@
1
+ define(["require", "exports", "roosterjs-content-model-core", "roosterjs-content-model-api"], function (require, exports, roosterjs_content_model_core_1, roosterjs_content_model_api_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ShortcutDecreaseFont = exports.ShortcutIncreaseFont = exports.ShortcutNumbering = exports.ShortcutBullet = exports.ShortcutRedoMacOS = exports.ShortcutRedo = exports.ShortcutUndo2 = exports.ShortcutUndo = exports.ShortcutClearFormat = exports.ShortcutUnderline = exports.ShortcutItalic = exports.ShortcutBold = void 0;
5
+ var Keys;
6
+ (function (Keys) {
7
+ Keys[Keys["BACKSPACE"] = 8] = "BACKSPACE";
8
+ Keys[Keys["SPACE"] = 32] = "SPACE";
9
+ Keys[Keys["B"] = 66] = "B";
10
+ Keys[Keys["I"] = 73] = "I";
11
+ Keys[Keys["U"] = 85] = "U";
12
+ Keys[Keys["Y"] = 89] = "Y";
13
+ Keys[Keys["Z"] = 90] = "Z";
14
+ Keys[Keys["COMMA"] = 188] = "COMMA";
15
+ Keys[Keys["PERIOD"] = 190] = "PERIOD";
16
+ Keys[Keys["FORWARD_SLASH"] = 191] = "FORWARD_SLASH";
17
+ })(Keys || (Keys = {}));
18
+ /**
19
+ * Shortcut command for Bold
20
+ * Windows: Ctrl + B
21
+ * MacOS: Meta + B
22
+ */
23
+ exports.ShortcutBold = {
24
+ shortcutKey: {
25
+ modifierKey: 'ctrl',
26
+ shiftKey: false,
27
+ which: 66 /* B */,
28
+ },
29
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.toggleBold)(editor); },
30
+ };
31
+ /**
32
+ * Shortcut command for Italic
33
+ * Windows: Ctrl + I
34
+ * MacOS: Meta + I
35
+ */
36
+ exports.ShortcutItalic = {
37
+ shortcutKey: {
38
+ modifierKey: 'ctrl',
39
+ shiftKey: false,
40
+ which: 73 /* I */,
41
+ },
42
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.toggleItalic)(editor); },
43
+ };
44
+ /**
45
+ * Shortcut command for Underline
46
+ * Windows: Ctrl + U
47
+ * MacOS: Meta + U
48
+ */
49
+ exports.ShortcutUnderline = {
50
+ shortcutKey: {
51
+ modifierKey: 'ctrl',
52
+ shiftKey: false,
53
+ which: 85 /* U */,
54
+ },
55
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.toggleUnderline)(editor); },
56
+ };
57
+ /**
58
+ * Shortcut command for Clear Format
59
+ * Windows: Ctrl + Space
60
+ * MacOS: Meta + Space
61
+ */
62
+ exports.ShortcutClearFormat = {
63
+ shortcutKey: {
64
+ modifierKey: 'ctrl',
65
+ shiftKey: false,
66
+ which: 32 /* SPACE */,
67
+ },
68
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.clearFormat)(editor); },
69
+ };
70
+ /**
71
+ * Shortcut command for Undo 1
72
+ * Windows: Ctrl + Z
73
+ * MacOS: Meta + Z
74
+ */
75
+ exports.ShortcutUndo = {
76
+ shortcutKey: {
77
+ modifierKey: 'ctrl',
78
+ shiftKey: false,
79
+ which: 90 /* Z */,
80
+ },
81
+ onClick: function (editor) { return (0, roosterjs_content_model_core_1.undo)(editor); },
82
+ };
83
+ /**
84
+ * Shortcut command for Undo 2
85
+ * Windows: Alt + Backspace
86
+ * MacOS: N/A
87
+ */
88
+ exports.ShortcutUndo2 = {
89
+ shortcutKey: {
90
+ modifierKey: 'alt',
91
+ shiftKey: false,
92
+ which: 8 /* BACKSPACE */,
93
+ },
94
+ onClick: function (editor) { return (0, roosterjs_content_model_core_1.undo)(editor); },
95
+ environment: 'nonMac',
96
+ };
97
+ /**
98
+ * Shortcut command for Redo 1
99
+ * Windows: Ctrl + Y
100
+ * MacOS: N/A
101
+ */
102
+ exports.ShortcutRedo = {
103
+ shortcutKey: {
104
+ modifierKey: 'ctrl',
105
+ shiftKey: false,
106
+ which: 89 /* Y */,
107
+ },
108
+ onClick: function (editor) { return (0, roosterjs_content_model_core_1.redo)(editor); },
109
+ environment: 'nonMac',
110
+ };
111
+ /**
112
+ * Shortcut command for Redo 2
113
+ * Windows: N/A
114
+ * MacOS: Meta + Shift + Z
115
+ */
116
+ exports.ShortcutRedoMacOS = {
117
+ shortcutKey: {
118
+ modifierKey: 'ctrl',
119
+ shiftKey: true,
120
+ which: 90 /* Z */,
121
+ },
122
+ onClick: function (editor) { return (0, roosterjs_content_model_core_1.redo)(editor); },
123
+ environment: 'mac',
124
+ };
125
+ /**
126
+ * Shortcut command for Bullet List
127
+ * Windows: Ctrl + . (Period)
128
+ * MacOS: Meta + . (Period)
129
+ */
130
+ exports.ShortcutBullet = {
131
+ shortcutKey: {
132
+ modifierKey: 'ctrl',
133
+ shiftKey: false,
134
+ which: 190 /* PERIOD */,
135
+ },
136
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.toggleBullet)(editor); },
137
+ };
138
+ /**
139
+ * Shortcut command for Numbering List
140
+ * Windows: Ctrl + / (Forward slash)
141
+ * MacOS: Meta + / (Forward slash)
142
+ */
143
+ exports.ShortcutNumbering = {
144
+ shortcutKey: {
145
+ modifierKey: 'ctrl',
146
+ shiftKey: false,
147
+ which: 191 /* FORWARD_SLASH */,
148
+ },
149
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.toggleNumbering)(editor); },
150
+ };
151
+ /**
152
+ * Shortcut command for Increase Font
153
+ * Windows: Ctrl + Shift + . (Period)
154
+ * MacOS: Meta + Shift + . (Period)
155
+ */
156
+ exports.ShortcutIncreaseFont = {
157
+ shortcutKey: {
158
+ modifierKey: 'ctrl',
159
+ shiftKey: true,
160
+ which: 190 /* PERIOD */,
161
+ },
162
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.changeFontSize)(editor, 'increase'); },
163
+ };
164
+ /**
165
+ * Shortcut command for Decrease Font
166
+ * Windows: Ctrl + Shift + , (Comma)
167
+ * MacOS: Meta + Shift + , (Comma)
168
+ */
169
+ exports.ShortcutDecreaseFont = {
170
+ shortcutKey: {
171
+ modifierKey: 'ctrl',
172
+ shiftKey: true,
173
+ which: 188 /* COMMA */,
174
+ },
175
+ onClick: function (editor) { return (0, roosterjs_content_model_api_1.changeFontSize)(editor, 'decrease'); },
176
+ };
177
+ });
178
+ //# sourceMappingURL=shortcuts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcuts.js","sourceRoot":"","sources":["../../../../packages-content-model/roosterjs-content-model-plugins/lib/shortcut/shortcuts.ts"],"names":[],"mappings":";;;;IAYA,IAAW,IAWV;IAXD,WAAW,IAAI;QACX,yCAAa,CAAA;QACb,kCAAU,CAAA;QACV,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,0BAAM,CAAA;QACN,mCAAW,CAAA;QACX,qCAAY,CAAA;QACZ,mDAAmB,CAAA;IACvB,CAAC,EAXU,IAAI,KAAJ,IAAI,QAWd;IAED;;;;OAIG;IACU,QAAA,YAAY,GAAoB;QACzC,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,YAAQ;SAChB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,wCAAU,EAAC,MAAM,CAAC,EAAlB,CAAkB;KACxC,CAAC;IAEF;;;;OAIG;IACU,QAAA,cAAc,GAAoB;QAC3C,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,YAAQ;SAChB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,0CAAY,EAAC,MAAM,CAAC,EAApB,CAAoB;KAC1C,CAAC;IAEF;;;;OAIG;IACU,QAAA,iBAAiB,GAAoB;QAC9C,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,YAAQ;SAChB;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AAI,OAAA,IAAA,mCAAI,EAAC,MAAM,CAAC,EAAZ,CAAY;QAC/B,WAAW,EAAE,KAAK;KACrB,CAAC;IAEF;;;;OAIG;IACU,QAAA,cAAc,GAAoB;QAC3C,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,kBAAa;SACrB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,0CAAY,EAAC,MAAM,CAAC,EAApB,CAAoB;KAC1C,CAAC;IAEF;;;;OAIG;IACU,QAAA,iBAAiB,GAAoB;QAC9C,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,KAAK;YACf,KAAK,yBAAoB;SAC5B;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,6CAAe,EAAC,MAAM,CAAC,EAAvB,CAAuB;KAC7C,CAAC;IAEF;;;;OAIG;IACU,QAAA,oBAAoB,GAAoB;QACjD,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;YACd,KAAK,kBAAa;SACrB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,4CAAc,EAAC,MAAM,EAAE,UAAU,CAAC,EAAlC,CAAkC;KACxD,CAAC;IAEF;;;;OAIG;IACU,QAAA,oBAAoB,GAAoB;QACjD,WAAW,EAAE;YACT,WAAW,EAAE,MAAM;YACnB,QAAQ,EAAE,IAAI;YACd,KAAK,iBAAY;SACpB;QACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,IAAA,4CAAc,EAAC,MAAM,EAAE,UAAU,CAAC,EAAlC,CAAkC;KACxD,CAAC","sourcesContent":["import { redo, undo } from 'roosterjs-content-model-core';\nimport {\n changeFontSize,\n clearFormat,\n toggleBold,\n toggleBullet,\n toggleItalic,\n toggleNumbering,\n toggleUnderline,\n} from 'roosterjs-content-model-api';\nimport type { ShortcutCommand } from './ShortcutCommand';\n\nconst enum Keys {\n BACKSPACE = 8,\n SPACE = 32,\n B = 66,\n I = 73,\n U = 85,\n Y = 89,\n Z = 90,\n COMMA = 188,\n PERIOD = 190,\n FORWARD_SLASH = 191,\n}\n\n/**\n * Shortcut command for Bold\n * Windows: Ctrl + B\n * MacOS: Meta + B\n */\nexport const ShortcutBold: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.B,\n },\n onClick: editor => toggleBold(editor),\n};\n\n/**\n * Shortcut command for Italic\n * Windows: Ctrl + I\n * MacOS: Meta + I\n */\nexport const ShortcutItalic: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.I,\n },\n onClick: editor => toggleItalic(editor),\n};\n\n/**\n * Shortcut command for Underline\n * Windows: Ctrl + U\n * MacOS: Meta + U\n */\nexport const ShortcutUnderline: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.U,\n },\n onClick: editor => toggleUnderline(editor),\n};\n\n/**\n * Shortcut command for Clear Format\n * Windows: Ctrl + Space\n * MacOS: Meta + Space\n */\nexport const ShortcutClearFormat: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.SPACE,\n },\n onClick: editor => clearFormat(editor),\n};\n\n/**\n * Shortcut command for Undo 1\n * Windows: Ctrl + Z\n * MacOS: Meta + Z\n */\nexport const ShortcutUndo: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.Z,\n },\n onClick: editor => undo(editor),\n};\n\n/**\n * Shortcut command for Undo 2\n * Windows: Alt + Backspace\n * MacOS: N/A\n */\nexport const ShortcutUndo2: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: false,\n which: Keys.BACKSPACE,\n },\n onClick: editor => undo(editor),\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Redo 1\n * Windows: Ctrl + Y\n * MacOS: N/A\n */\nexport const ShortcutRedo: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.Y,\n },\n onClick: editor => redo(editor),\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Redo 2\n * Windows: N/A\n * MacOS: Meta + Shift + Z\n */\nexport const ShortcutRedoMacOS: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.Z,\n },\n onClick: editor => redo(editor),\n environment: 'mac',\n};\n\n/**\n * Shortcut command for Bullet List\n * Windows: Ctrl + . (Period)\n * MacOS: Meta + . (Period)\n */\nexport const ShortcutBullet: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.PERIOD,\n },\n onClick: editor => toggleBullet(editor),\n};\n\n/**\n * Shortcut command for Numbering List\n * Windows: Ctrl + / (Forward slash)\n * MacOS: Meta + / (Forward slash)\n */\nexport const ShortcutNumbering: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.FORWARD_SLASH,\n },\n onClick: editor => toggleNumbering(editor),\n};\n\n/**\n * Shortcut command for Increase Font\n * Windows: Ctrl + Shift + . (Period)\n * MacOS: Meta + Shift + . (Period)\n */\nexport const ShortcutIncreaseFont: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.PERIOD,\n },\n onClick: editor => changeFontSize(editor, 'increase'),\n};\n\n/**\n * Shortcut command for Decrease Font\n * Windows: Ctrl + Shift + , (Comma)\n * MacOS: Meta + Shift + , (Comma)\n */\nexport const ShortcutDecreaseFont: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.COMMA,\n },\n onClick: editor => changeFontSize(editor, 'decrease'),\n};\n"]}