roosterjs-content-model-plugins 9.1.0 → 9.2.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 (235) hide show
  1. package/lib/autoFormat/AutoFormatPlugin.d.ts +15 -5
  2. package/lib/autoFormat/AutoFormatPlugin.js +41 -4
  3. package/lib/autoFormat/AutoFormatPlugin.js.map +1 -1
  4. package/lib/autoFormat/link/createLink.js +2 -0
  5. package/lib/autoFormat/link/createLink.js.map +1 -1
  6. package/lib/autoFormat/list/keyboardListTrigger.js +7 -9
  7. package/lib/autoFormat/list/keyboardListTrigger.js.map +1 -1
  8. package/lib/autoFormat/numbers/transformFraction.d.ts +5 -0
  9. package/lib/autoFormat/numbers/transformFraction.js +27 -0
  10. package/lib/autoFormat/numbers/transformFraction.js.map +1 -0
  11. package/lib/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  12. package/lib/autoFormat/numbers/transformOrdinals.js +32 -0
  13. package/lib/autoFormat/numbers/transformOrdinals.js.map +1 -0
  14. package/lib/customReplace/CustomReplacePlugin.d.ts +61 -0
  15. package/lib/customReplace/CustomReplacePlugin.js +87 -0
  16. package/lib/customReplace/CustomReplacePlugin.js.map +1 -0
  17. package/lib/edit/EditPlugin.js +19 -1
  18. package/lib/edit/EditPlugin.js.map +1 -1
  19. package/lib/edit/inputSteps/handleEnterOnList.js +8 -1
  20. package/lib/edit/inputSteps/handleEnterOnList.js.map +1 -1
  21. package/lib/edit/keyboardTab.js +5 -5
  22. package/lib/edit/keyboardTab.js.map +1 -1
  23. package/lib/edit/tabUtils/handleTabOnList.d.ts +2 -2
  24. package/lib/edit/tabUtils/handleTabOnList.js +3 -3
  25. package/lib/edit/tabUtils/handleTabOnList.js.map +1 -1
  26. package/lib/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  27. package/lib/edit/tabUtils/handleTabOnParagraph.js +2 -2
  28. package/lib/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  29. package/lib/index.d.ts +7 -1
  30. package/lib/index.js +8 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/markdown/utils/setFormat.js +11 -9
  33. package/lib/markdown/utils/setFormat.js.map +1 -1
  34. package/lib/picker/PickerHandler.d.ts +112 -0
  35. package/lib/picker/PickerHandler.js +3 -0
  36. package/lib/picker/PickerHandler.js.map +1 -0
  37. package/lib/picker/PickerHelper.d.ts +22 -0
  38. package/lib/picker/PickerHelper.js +3 -0
  39. package/lib/picker/PickerHelper.js.map +1 -0
  40. package/lib/picker/PickerHelperImpl.d.ts +25 -0
  41. package/lib/picker/PickerHelperImpl.js +54 -0
  42. package/lib/picker/PickerHelperImpl.js.map +1 -0
  43. package/lib/picker/PickerPlugin.d.ts +54 -0
  44. package/lib/picker/PickerPlugin.js +217 -0
  45. package/lib/picker/PickerPlugin.js.map +1 -0
  46. package/lib/picker/getQueryString.d.ts +5 -0
  47. package/lib/picker/getQueryString.js +36 -0
  48. package/lib/picker/getQueryString.js.map +1 -0
  49. package/lib/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  50. package/lib/pluginUtils/Rect/getDOMInsertPointRect.js +57 -0
  51. package/lib/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  52. package/lib/shortcut/ShortcutPlugin.js +1 -0
  53. package/lib/shortcut/ShortcutPlugin.js.map +1 -1
  54. package/lib/shortcut/shortcuts.d.ts +7 -0
  55. package/lib/shortcut/shortcuts.js +15 -1
  56. package/lib/shortcut/shortcuts.js.map +1 -1
  57. package/lib/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  58. package/lib/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  59. package/lib/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  60. package/lib/tableEdit/OnTableEditorCreatedCallback.js +3 -0
  61. package/lib/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  62. package/lib/tableEdit/TableEditPlugin.d.ts +4 -1
  63. package/lib/tableEdit/TableEditPlugin.js +5 -2
  64. package/lib/tableEdit/TableEditPlugin.js.map +1 -1
  65. package/lib/tableEdit/editors/TableEditor.d.ts +4 -1
  66. package/lib/tableEdit/editors/TableEditor.js +23 -7
  67. package/lib/tableEdit/editors/TableEditor.js.map +1 -1
  68. package/lib/tableEdit/editors/features/TableEditFeature.js +3 -3
  69. package/lib/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  70. package/lib/tableEdit/editors/features/TableInserter.d.ts +2 -1
  71. package/lib/tableEdit/editors/features/TableInserter.js +7 -9
  72. package/lib/tableEdit/editors/features/TableInserter.js.map +1 -1
  73. package/lib/tableEdit/editors/features/TableMover.d.ts +2 -1
  74. package/lib/tableEdit/editors/features/TableMover.js +8 -11
  75. package/lib/tableEdit/editors/features/TableMover.js.map +1 -1
  76. package/lib/tableEdit/editors/features/TableResizer.d.ts +2 -1
  77. package/lib/tableEdit/editors/features/TableResizer.js +19 -3
  78. package/lib/tableEdit/editors/features/TableResizer.js.map +1 -1
  79. package/lib-amd/autoFormat/AutoFormatPlugin.d.ts +15 -5
  80. package/lib-amd/autoFormat/AutoFormatPlugin.js +39 -5
  81. package/lib-amd/autoFormat/AutoFormatPlugin.js.map +1 -1
  82. package/lib-amd/autoFormat/link/createLink.js +2 -0
  83. package/lib-amd/autoFormat/link/createLink.js.map +1 -1
  84. package/lib-amd/autoFormat/list/keyboardListTrigger.js +7 -9
  85. package/lib-amd/autoFormat/list/keyboardListTrigger.js.map +1 -1
  86. package/lib-amd/autoFormat/numbers/transformFraction.d.ts +5 -0
  87. package/lib-amd/autoFormat/numbers/transformFraction.js +28 -0
  88. package/lib-amd/autoFormat/numbers/transformFraction.js.map +1 -0
  89. package/lib-amd/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  90. package/lib-amd/autoFormat/numbers/transformOrdinals.js +33 -0
  91. package/lib-amd/autoFormat/numbers/transformOrdinals.js.map +1 -0
  92. package/lib-amd/customReplace/CustomReplacePlugin.d.ts +61 -0
  93. package/lib-amd/customReplace/CustomReplacePlugin.js +88 -0
  94. package/lib-amd/customReplace/CustomReplacePlugin.js.map +1 -0
  95. package/lib-amd/edit/EditPlugin.js +19 -1
  96. package/lib-amd/edit/EditPlugin.js.map +1 -1
  97. package/lib-amd/edit/inputSteps/handleEnterOnList.js +8 -2
  98. package/lib-amd/edit/inputSteps/handleEnterOnList.js.map +1 -1
  99. package/lib-amd/edit/keyboardTab.js +5 -5
  100. package/lib-amd/edit/keyboardTab.js.map +1 -1
  101. package/lib-amd/edit/tabUtils/handleTabOnList.d.ts +2 -2
  102. package/lib-amd/edit/tabUtils/handleTabOnList.js +3 -3
  103. package/lib-amd/edit/tabUtils/handleTabOnList.js.map +1 -1
  104. package/lib-amd/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  105. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js +2 -2
  106. package/lib-amd/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  107. package/lib-amd/index.d.ts +7 -1
  108. package/lib-amd/index.js +6 -2
  109. package/lib-amd/index.js.map +1 -1
  110. package/lib-amd/markdown/utils/setFormat.js +11 -9
  111. package/lib-amd/markdown/utils/setFormat.js.map +1 -1
  112. package/lib-amd/picker/PickerHandler.d.ts +112 -0
  113. package/lib-amd/picker/PickerHandler.js +5 -0
  114. package/lib-amd/picker/PickerHandler.js.map +1 -0
  115. package/lib-amd/picker/PickerHelper.d.ts +22 -0
  116. package/lib-amd/picker/PickerHelper.js +5 -0
  117. package/lib-amd/picker/PickerHelper.js.map +1 -0
  118. package/lib-amd/picker/PickerHelperImpl.d.ts +25 -0
  119. package/lib-amd/picker/PickerHelperImpl.js +53 -0
  120. package/lib-amd/picker/PickerHelperImpl.js.map +1 -0
  121. package/lib-amd/picker/PickerPlugin.d.ts +54 -0
  122. package/lib-amd/picker/PickerPlugin.js +215 -0
  123. package/lib-amd/picker/PickerPlugin.js.map +1 -0
  124. package/lib-amd/picker/getQueryString.d.ts +5 -0
  125. package/lib-amd/picker/getQueryString.js +37 -0
  126. package/lib-amd/picker/getQueryString.js.map +1 -0
  127. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  128. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js +58 -0
  129. package/lib-amd/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  130. package/lib-amd/shortcut/ShortcutPlugin.js +1 -0
  131. package/lib-amd/shortcut/ShortcutPlugin.js.map +1 -1
  132. package/lib-amd/shortcut/shortcuts.d.ts +7 -0
  133. package/lib-amd/shortcut/shortcuts.js +15 -1
  134. package/lib-amd/shortcut/shortcuts.js.map +1 -1
  135. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  136. package/lib-amd/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  137. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  138. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js +5 -0
  139. package/lib-amd/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  140. package/lib-amd/tableEdit/TableEditPlugin.d.ts +4 -1
  141. package/lib-amd/tableEdit/TableEditPlugin.js +5 -2
  142. package/lib-amd/tableEdit/TableEditPlugin.js.map +1 -1
  143. package/lib-amd/tableEdit/editors/TableEditor.d.ts +4 -1
  144. package/lib-amd/tableEdit/editors/TableEditor.js +23 -7
  145. package/lib-amd/tableEdit/editors/TableEditor.js.map +1 -1
  146. package/lib-amd/tableEdit/editors/features/TableEditFeature.js +3 -3
  147. package/lib-amd/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  148. package/lib-amd/tableEdit/editors/features/TableInserter.d.ts +2 -1
  149. package/lib-amd/tableEdit/editors/features/TableInserter.js +7 -9
  150. package/lib-amd/tableEdit/editors/features/TableInserter.js.map +1 -1
  151. package/lib-amd/tableEdit/editors/features/TableMover.d.ts +2 -1
  152. package/lib-amd/tableEdit/editors/features/TableMover.js +8 -11
  153. package/lib-amd/tableEdit/editors/features/TableMover.js.map +1 -1
  154. package/lib-amd/tableEdit/editors/features/TableResizer.d.ts +2 -1
  155. package/lib-amd/tableEdit/editors/features/TableResizer.js +19 -4
  156. package/lib-amd/tableEdit/editors/features/TableResizer.js.map +1 -1
  157. package/lib-mjs/autoFormat/AutoFormatPlugin.d.ts +15 -5
  158. package/lib-mjs/autoFormat/AutoFormatPlugin.js +41 -4
  159. package/lib-mjs/autoFormat/AutoFormatPlugin.js.map +1 -1
  160. package/lib-mjs/autoFormat/link/createLink.js +3 -1
  161. package/lib-mjs/autoFormat/link/createLink.js.map +1 -1
  162. package/lib-mjs/autoFormat/list/keyboardListTrigger.js +7 -9
  163. package/lib-mjs/autoFormat/list/keyboardListTrigger.js.map +1 -1
  164. package/lib-mjs/autoFormat/numbers/transformFraction.d.ts +5 -0
  165. package/lib-mjs/autoFormat/numbers/transformFraction.js +23 -0
  166. package/lib-mjs/autoFormat/numbers/transformFraction.js.map +1 -0
  167. package/lib-mjs/autoFormat/numbers/transformOrdinals.d.ts +5 -0
  168. package/lib-mjs/autoFormat/numbers/transformOrdinals.js +28 -0
  169. package/lib-mjs/autoFormat/numbers/transformOrdinals.js.map +1 -0
  170. package/lib-mjs/customReplace/CustomReplacePlugin.d.ts +61 -0
  171. package/lib-mjs/customReplace/CustomReplacePlugin.js +84 -0
  172. package/lib-mjs/customReplace/CustomReplacePlugin.js.map +1 -0
  173. package/lib-mjs/edit/EditPlugin.js +19 -1
  174. package/lib-mjs/edit/EditPlugin.js.map +1 -1
  175. package/lib-mjs/edit/inputSteps/handleEnterOnList.js +8 -1
  176. package/lib-mjs/edit/inputSteps/handleEnterOnList.js.map +1 -1
  177. package/lib-mjs/edit/keyboardTab.js +5 -5
  178. package/lib-mjs/edit/keyboardTab.js.map +1 -1
  179. package/lib-mjs/edit/tabUtils/handleTabOnList.d.ts +2 -2
  180. package/lib-mjs/edit/tabUtils/handleTabOnList.js +3 -3
  181. package/lib-mjs/edit/tabUtils/handleTabOnList.js.map +1 -1
  182. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.d.ts +2 -2
  183. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js +2 -2
  184. package/lib-mjs/edit/tabUtils/handleTabOnParagraph.js.map +1 -1
  185. package/lib-mjs/index.d.ts +7 -1
  186. package/lib-mjs/index.js +4 -1
  187. package/lib-mjs/index.js.map +1 -1
  188. package/lib-mjs/markdown/utils/setFormat.js +11 -9
  189. package/lib-mjs/markdown/utils/setFormat.js.map +1 -1
  190. package/lib-mjs/picker/PickerHandler.d.ts +112 -0
  191. package/lib-mjs/picker/PickerHandler.js +2 -0
  192. package/lib-mjs/picker/PickerHandler.js.map +1 -0
  193. package/lib-mjs/picker/PickerHelper.d.ts +22 -0
  194. package/lib-mjs/picker/PickerHelper.js +2 -0
  195. package/lib-mjs/picker/PickerHelper.js.map +1 -0
  196. package/lib-mjs/picker/PickerHelperImpl.d.ts +25 -0
  197. package/lib-mjs/picker/PickerHelperImpl.js +51 -0
  198. package/lib-mjs/picker/PickerHelperImpl.js.map +1 -0
  199. package/lib-mjs/picker/PickerPlugin.d.ts +54 -0
  200. package/lib-mjs/picker/PickerPlugin.js +214 -0
  201. package/lib-mjs/picker/PickerPlugin.js.map +1 -0
  202. package/lib-mjs/picker/getQueryString.d.ts +5 -0
  203. package/lib-mjs/picker/getQueryString.js +32 -0
  204. package/lib-mjs/picker/getQueryString.js.map +1 -0
  205. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.d.ts +7 -0
  206. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js +53 -0
  207. package/lib-mjs/pluginUtils/Rect/getDOMInsertPointRect.js.map +1 -0
  208. package/lib-mjs/shortcut/ShortcutPlugin.js +2 -1
  209. package/lib-mjs/shortcut/ShortcutPlugin.js.map +1 -1
  210. package/lib-mjs/shortcut/shortcuts.d.ts +7 -0
  211. package/lib-mjs/shortcut/shortcuts.js +14 -0
  212. package/lib-mjs/shortcut/shortcuts.js.map +1 -1
  213. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js +2 -2
  214. package/lib-mjs/shortcut/utils/setShortcutIndentationCommand.js.map +1 -1
  215. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.d.ts +4 -0
  216. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js +2 -0
  217. package/lib-mjs/tableEdit/OnTableEditorCreatedCallback.js.map +1 -0
  218. package/lib-mjs/tableEdit/TableEditPlugin.d.ts +4 -1
  219. package/lib-mjs/tableEdit/TableEditPlugin.js +5 -2
  220. package/lib-mjs/tableEdit/TableEditPlugin.js.map +1 -1
  221. package/lib-mjs/tableEdit/editors/TableEditor.d.ts +4 -1
  222. package/lib-mjs/tableEdit/editors/TableEditor.js +24 -8
  223. package/lib-mjs/tableEdit/editors/TableEditor.js.map +1 -1
  224. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js +3 -3
  225. package/lib-mjs/tableEdit/editors/features/TableEditFeature.js.map +1 -1
  226. package/lib-mjs/tableEdit/editors/features/TableInserter.d.ts +2 -1
  227. package/lib-mjs/tableEdit/editors/features/TableInserter.js +7 -9
  228. package/lib-mjs/tableEdit/editors/features/TableInserter.js.map +1 -1
  229. package/lib-mjs/tableEdit/editors/features/TableMover.d.ts +2 -1
  230. package/lib-mjs/tableEdit/editors/features/TableMover.js +8 -11
  231. package/lib-mjs/tableEdit/editors/features/TableMover.js.map +1 -1
  232. package/lib-mjs/tableEdit/editors/features/TableResizer.d.ts +2 -1
  233. package/lib-mjs/tableEdit/editors/features/TableResizer.js +19 -3
  234. package/lib-mjs/tableEdit/editors/features/TableResizer.js.map +1 -1
  235. package/package.json +5 -5
@@ -0,0 +1,214 @@
1
+ import { ChangeSource, isCursorMovingKey, isPunctuation } from 'roosterjs-content-model-dom';
2
+ import { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';
3
+ import { getQueryString } from './getQueryString';
4
+ import { PickerHelperImpl } from './PickerHelperImpl';
5
+ /**
6
+ * PickerPlugin represents a plugin of editor which can handle picker related behaviors, including
7
+ * - Show picker when special trigger key is pressed
8
+ * - Hide picker
9
+ * - Change selection in picker by Up/Down/Left/Right
10
+ * - Apply selected item in picker
11
+ *
12
+ * PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.
13
+ */
14
+ var PickerPlugin = /** @class */ (function () {
15
+ /**
16
+ * Construct a new instance of PickerPlugin class
17
+ * @param triggerCharacter The character to trigger a picker to be shown
18
+ * @param handler Picker handler for receiving picker state change events
19
+ */
20
+ function PickerPlugin(triggerCharacter, handler) {
21
+ this.triggerCharacter = triggerCharacter;
22
+ this.handler = handler;
23
+ this.isMac = false;
24
+ this.lastQueryString = '';
25
+ this.helper = null;
26
+ }
27
+ /**
28
+ * Get a friendly name
29
+ */
30
+ PickerPlugin.prototype.getName = function () {
31
+ return 'Picker';
32
+ };
33
+ /**
34
+ * Initialize this plugin. This should only be called from Editor
35
+ * @param editor Editor instance
36
+ */
37
+ PickerPlugin.prototype.initialize = function (editor) {
38
+ this.isMac = !!editor.getEnvironment().isMac;
39
+ this.helper = new PickerHelperImpl(editor, this.handler, this.triggerCharacter);
40
+ this.handler.onInitialize(this.helper);
41
+ };
42
+ /**
43
+ * Dispose this plugin
44
+ */
45
+ PickerPlugin.prototype.dispose = function () {
46
+ this.handler.onDispose();
47
+ this.helper = null;
48
+ };
49
+ /**
50
+ * Check if the plugin should handle the given event exclusively.
51
+ * Handle an event exclusively means other plugin will not receive this event in
52
+ * onPluginEvent method.
53
+ * If two plugins will return true in willHandleEventExclusively() for the same event,
54
+ * the final result depends on the order of the plugins are added into editor
55
+ * @param event The event to check
56
+ */
57
+ PickerPlugin.prototype.willHandleEventExclusively = function (event) {
58
+ var _a;
59
+ return (!!((_a = this.helper) === null || _a === void 0 ? void 0 : _a.direction) &&
60
+ event.eventType == 'keyDown' &&
61
+ (isCursorMovingKey(event.rawEvent) ||
62
+ event.rawEvent.key == 'Enter' ||
63
+ event.rawEvent.key == 'Tab' ||
64
+ event.rawEvent.key == 'Escape'));
65
+ };
66
+ /**
67
+ * Handle events triggered from editor
68
+ * @param event PluginEvent object
69
+ */
70
+ PickerPlugin.prototype.onPluginEvent = function (event) {
71
+ if (!this.helper) {
72
+ return;
73
+ }
74
+ switch (event.eventType) {
75
+ case 'contentChanged':
76
+ if (this.helper.direction) {
77
+ if (event.source == ChangeSource.SetContent) {
78
+ this.helper.closePicker();
79
+ }
80
+ else {
81
+ this.onSuggestingInput(this.helper);
82
+ }
83
+ }
84
+ break;
85
+ case 'keyDown':
86
+ if (this.helper.direction) {
87
+ this.onSuggestingKeyDown(this.helper, event.rawEvent);
88
+ }
89
+ break;
90
+ case 'input':
91
+ if (this.helper.direction) {
92
+ this.onSuggestingInput(this.helper);
93
+ }
94
+ else {
95
+ this.onInput(this.helper, event.rawEvent);
96
+ }
97
+ break;
98
+ case 'mouseUp':
99
+ if (this.helper.direction) {
100
+ this.helper.closePicker();
101
+ }
102
+ break;
103
+ }
104
+ };
105
+ PickerPlugin.prototype.onSuggestingKeyDown = function (helper, event) {
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
107
+ switch (event.key) {
108
+ case 'ArrowLeft':
109
+ case 'ArrowRight':
110
+ if (helper.direction == 'horizontal' || helper.direction == 'both') {
111
+ var isIncrement = event.key == 'ArrowRight';
112
+ if (helper.editor.getDOMHelper().isRightToLeft()) {
113
+ isIncrement = !isIncrement;
114
+ }
115
+ (_b = (_a = this.handler).onSelectionChanged) === null || _b === void 0 ? void 0 : _b.call(_a, isIncrement ? 'next' : 'previous');
116
+ }
117
+ event.preventDefault();
118
+ break;
119
+ case 'ArrowUp':
120
+ case 'ArrowDown':
121
+ {
122
+ var isIncrement = event.key == 'ArrowDown';
123
+ if (helper.direction != 'horizontal') {
124
+ (_d = (_c = this.handler).onSelectionChanged) === null || _d === void 0 ? void 0 : _d.call(_c, helper.direction == 'both'
125
+ ? isIncrement
126
+ ? 'nextRow'
127
+ : 'previousRow'
128
+ : isIncrement
129
+ ? 'next'
130
+ : 'previous');
131
+ }
132
+ }
133
+ event.preventDefault();
134
+ break;
135
+ case 'PageUp':
136
+ case 'PageDown':
137
+ (_f = (_e = this.handler).onSelectionChanged) === null || _f === void 0 ? void 0 : _f.call(_e, event.key == 'PageDown' ? 'nextPage' : 'previousPage');
138
+ event.preventDefault();
139
+ break;
140
+ case 'Home':
141
+ case 'End':
142
+ var hasCtrl = this.isMac ? event.metaKey : event.ctrlKey;
143
+ (_h = (_g = this.handler).onSelectionChanged) === null || _h === void 0 ? void 0 : _h.call(_g, event.key == 'Home'
144
+ ? hasCtrl
145
+ ? 'first'
146
+ : 'firstInRow'
147
+ : hasCtrl
148
+ ? 'last'
149
+ : 'lastInRow');
150
+ event.preventDefault();
151
+ break;
152
+ case 'Escape':
153
+ helper.closePicker();
154
+ event.preventDefault();
155
+ break;
156
+ case 'Enter':
157
+ case 'Tab':
158
+ (_k = (_j = this.handler).onSelect) === null || _k === void 0 ? void 0 : _k.call(_j);
159
+ event.preventDefault();
160
+ break;
161
+ }
162
+ };
163
+ PickerPlugin.prototype.onSuggestingInput = function (helper) {
164
+ var _this = this;
165
+ if (!formatTextSegmentBeforeSelectionMarker(helper.editor, function (_, segment, paragraph) {
166
+ var _a, _b;
167
+ var newQueryString = getQueryString(_this.triggerCharacter, paragraph, segment).replace(/[\u0020\u00A0]/g, ' ');
168
+ var oldQueryString = _this.lastQueryString;
169
+ if (newQueryString &&
170
+ ((newQueryString.length >= oldQueryString.length &&
171
+ newQueryString.indexOf(oldQueryString) == 0) ||
172
+ (newQueryString.length < oldQueryString.length &&
173
+ oldQueryString.indexOf(newQueryString) == 0))) {
174
+ _this.lastQueryString = newQueryString;
175
+ (_b = (_a = _this.handler).onQueryStringChanged) === null || _b === void 0 ? void 0 : _b.call(_a, newQueryString);
176
+ }
177
+ else {
178
+ helper.closePicker();
179
+ }
180
+ return false;
181
+ })) {
182
+ helper.closePicker();
183
+ }
184
+ };
185
+ PickerPlugin.prototype.onInput = function (helper, event) {
186
+ var _this = this;
187
+ if (event.inputType == 'insertText' && event.data == this.triggerCharacter) {
188
+ formatTextSegmentBeforeSelectionMarker(helper.editor, function (_, segment) {
189
+ if (segment.text.endsWith(_this.triggerCharacter)) {
190
+ var charBeforeTrigger = segment.text[segment.text.length - 2];
191
+ if (!charBeforeTrigger ||
192
+ !charBeforeTrigger.trim() ||
193
+ isPunctuation(charBeforeTrigger)) {
194
+ var selection = helper.editor.getDOMSelection();
195
+ var pos = (selection === null || selection === void 0 ? void 0 : selection.type) == 'range' && selection.range.collapsed
196
+ ? {
197
+ node: selection.range.startContainer,
198
+ offset: selection.range.startOffset,
199
+ }
200
+ : null;
201
+ if (pos) {
202
+ _this.lastQueryString = _this.triggerCharacter;
203
+ helper.direction = _this.handler.onTrigger(_this.lastQueryString, pos);
204
+ }
205
+ }
206
+ }
207
+ return false;
208
+ });
209
+ }
210
+ };
211
+ return PickerPlugin;
212
+ }());
213
+ export { PickerPlugin };
214
+ //# sourceMappingURL=PickerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/picker/PickerPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC7F,OAAO,EAAE,sCAAsC,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD;;;;;;;;GAQG;AACH;IAKI;;;;OAIG;IACH,sBAAoB,gBAAwB,EAAmB,OAAsB;QAAjE,qBAAgB,GAAhB,gBAAgB,CAAQ;QAAmB,YAAO,GAAP,OAAO,CAAe;QAT7E,UAAK,GAAY,KAAK,CAAC;QACvB,oBAAe,GAAG,EAAE,CAAC;QACrB,WAAM,GAA4B,IAAI,CAAC;IAOyC,CAAC;IAEzF;;OAEG;IACH,8BAAO,GA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AC,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACxE,sCAAsC,CAAC,MAAM,CAAC,MAAM,EAAE,UAAC,CAAC,EAAE,OAAO;gBAC7D,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAI,CAAC,gBAAgB,CAAC,EAAE;oBAC9C,IAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oBAEhE,IACI,CAAC,iBAAiB;wBAClB,CAAC,iBAAiB,CAAC,IAAI,EAAE;wBACzB,aAAa,CAAC,iBAAiB,CAAC,EAClC;wBACE,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;wBAClD,IAAM,GAAG,GACL,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS;4BACnD,CAAC,CAAC;gCACI,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,cAAc;gCACpC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,WAAW;6BACtC;4BACH,CAAC,CAAC,IAAI,CAAC;wBAEf,IAAI,GAAG,EAAE;4BACL,KAAI,CAAC,eAAe,GAAG,KAAI,CAAC,gBAAgB,CAAC;4BAC7C,MAAM,CAAC,SAAS,GAAG,KAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;yBACxE;qBACJ;iBACJ;gBAED,OAAO,KAAK,CAAC;YACjB,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACL,mBAAC;AAAD,CAAC,AAvOD,IAuOC","sourcesContent":["import { ChangeSource, isCursorMovingKey, isPunctuation } from 'roosterjs-content-model-dom';\nimport { formatTextSegmentBeforeSelectionMarker } from 'roosterjs-content-model-api';\nimport { getQueryString } from './getQueryString';\nimport { PickerHelperImpl } from './PickerHelperImpl';\nimport type { PickerHandler } from './PickerHandler';\nimport type {\n DOMInsertPoint,\n EditorPlugin,\n IEditor,\n PluginEvent,\n} from 'roosterjs-content-model-types';\n\n/**\n * PickerPlugin represents a plugin of editor which can handle picker related behaviors, including\n * - Show picker when special trigger key is pressed\n * - Hide picker\n * - Change selection in picker by Up/Down/Left/Right\n * - Apply selected item in picker\n *\n * PickerPlugin doesn't provide any UI, it just wraps related DOM events and invoke callback functions.\n */\nexport class PickerPlugin implements EditorPlugin {\n private isMac: boolean = false;\n private lastQueryString = '';\n private helper: PickerHelperImpl | null = null;\n\n /**\n * Construct a new instance of PickerPlugin class\n * @param triggerCharacter The character to trigger a picker to be shown\n * @param handler Picker handler for receiving picker state change events\n */\n constructor(private triggerCharacter: string, private readonly handler: PickerHandler) {}\n\n /**\n * Get a friendly name\n */\n getName() {\n return 'Picker';\n }\n\n /**\n * Initialize this plugin. This should only be called from Editor\n * @param editor Editor instance\n */\n initialize(editor: IEditor) {\n this.isMac = !!editor.getEnvironment().isMac;\n this.helper = new PickerHelperImpl(editor, this.handler, this.triggerCharacter);\n this.handler.onInitialize(this.helper);\n }\n\n /**\n * Dispose this plugin\n */\n dispose() {\n this.handler.onDispose();\n this.helper = 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 !!this.helper?.direction &&\n event.eventType == 'keyDown' &&\n (isCursorMovingKey(event.rawEvent) ||\n event.rawEvent.key == 'Enter' ||\n event.rawEvent.key == 'Tab' ||\n event.rawEvent.key == 'Escape')\n );\n }\n\n /**\n * Handle events triggered from editor\n * @param event PluginEvent object\n */\n onPluginEvent(event: PluginEvent) {\n if (!this.helper) {\n return;\n }\n\n switch (event.eventType) {\n case 'contentChanged':\n if (this.helper.direction) {\n if (event.source == ChangeSource.SetContent) {\n this.helper.closePicker();\n } else {\n this.onSuggestingInput(this.helper);\n }\n }\n break;\n\n case 'keyDown':\n if (this.helper.direction) {\n this.onSuggestingKeyDown(this.helper, event.rawEvent);\n }\n break;\n\n case 'input':\n if (this.helper.direction) {\n this.onSuggestingInput(this.helper);\n } else {\n this.onInput(this.helper, event.rawEvent);\n }\n break;\n\n case 'mouseUp':\n if (this.helper.direction) {\n this.helper.closePicker();\n }\n break;\n }\n }\n\n private onSuggestingKeyDown(helper: PickerHelperImpl, event: KeyboardEvent) {\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowRight':\n if (helper.direction == 'horizontal' || helper.direction == 'both') {\n let isIncrement = event.key == 'ArrowRight';\n\n if (helper.editor.getDOMHelper().isRightToLeft()) {\n isIncrement = !isIncrement;\n }\n\n this.handler.onSelectionChanged?.(isIncrement ? 'next' : 'previous');\n }\n\n event.preventDefault();\n break;\n case 'ArrowUp':\n case 'ArrowDown':\n {\n const isIncrement = event.key == 'ArrowDown';\n\n if (helper.direction != 'horizontal') {\n this.handler.onSelectionChanged?.(\n helper.direction == 'both'\n ? isIncrement\n ? 'nextRow'\n : 'previousRow'\n : isIncrement\n ? 'next'\n : 'previous'\n );\n }\n }\n\n event.preventDefault();\n break;\n case 'PageUp':\n case 'PageDown':\n this.handler.onSelectionChanged?.(\n event.key == 'PageDown' ? 'nextPage' : 'previousPage'\n );\n\n event.preventDefault();\n break;\n case 'Home':\n case 'End':\n const hasCtrl = this.isMac ? event.metaKey : event.ctrlKey;\n this.handler.onSelectionChanged?.(\n event.key == 'Home'\n ? hasCtrl\n ? 'first'\n : 'firstInRow'\n : hasCtrl\n ? 'last'\n : 'lastInRow'\n );\n\n event.preventDefault();\n break;\n case 'Escape':\n helper.closePicker();\n event.preventDefault();\n break;\n\n case 'Enter':\n case 'Tab':\n this.handler.onSelect?.();\n event.preventDefault();\n break;\n }\n }\n\n private onSuggestingInput(helper: PickerHelperImpl) {\n if (\n !formatTextSegmentBeforeSelectionMarker(helper.editor, (_, segment, paragraph) => {\n const newQueryString = getQueryString(\n this.triggerCharacter,\n paragraph,\n segment\n ).replace(/[\\u0020\\u00A0]/g, ' ');\n const oldQueryString = this.lastQueryString;\n\n if (\n newQueryString &&\n ((newQueryString.length >= oldQueryString.length &&\n newQueryString.indexOf(oldQueryString) == 0) ||\n (newQueryString.length < oldQueryString.length &&\n oldQueryString.indexOf(newQueryString) == 0))\n ) {\n this.lastQueryString = newQueryString;\n this.handler.onQueryStringChanged?.(newQueryString);\n } else {\n helper.closePicker();\n }\n\n return false;\n })\n ) {\n helper.closePicker();\n }\n }\n\n private onInput(helper: PickerHelperImpl, event: InputEvent) {\n if (event.inputType == 'insertText' && event.data == this.triggerCharacter) {\n formatTextSegmentBeforeSelectionMarker(helper.editor, (_, segment) => {\n if (segment.text.endsWith(this.triggerCharacter)) {\n const charBeforeTrigger = segment.text[segment.text.length - 2];\n\n if (\n !charBeforeTrigger ||\n !charBeforeTrigger.trim() ||\n isPunctuation(charBeforeTrigger)\n ) {\n const selection = helper.editor.getDOMSelection();\n const pos: DOMInsertPoint | null =\n selection?.type == 'range' && selection.range.collapsed\n ? {\n node: selection.range.startContainer,\n offset: selection.range.startOffset,\n }\n : null;\n\n if (pos) {\n this.lastQueryString = this.triggerCharacter;\n helper.direction = this.handler.onTrigger(this.lastQueryString, pos);\n }\n }\n }\n\n return false;\n });\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ContentModelParagraph, ContentModelText } from 'roosterjs-content-model-types';
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare function getQueryString(triggerCharacter: string, paragraph: ContentModelParagraph, previousSegment: ContentModelText, splittedSegmentResult?: ContentModelText[]): string;
@@ -0,0 +1,32 @@
1
+ import { splitTextSegment } from '../pluginUtils/splitTextSegment';
2
+ /**
3
+ * @internal
4
+ */
5
+ export function getQueryString(triggerCharacter, paragraph, previousSegment, splittedSegmentResult) {
6
+ var result = '';
7
+ var i = paragraph.segments.indexOf(previousSegment);
8
+ for (; i >= 0; i--) {
9
+ var segment = paragraph.segments[i];
10
+ if (segment.segmentType != 'Text') {
11
+ result = '';
12
+ break;
13
+ }
14
+ var index = segment.text.lastIndexOf(triggerCharacter);
15
+ if (index >= 0) {
16
+ result = segment.text.substring(index) + result;
17
+ splittedSegmentResult === null || splittedSegmentResult === void 0 ? void 0 : splittedSegmentResult.unshift(index > 0
18
+ ? splitTextSegment(segment, paragraph, index, segment.text.length)
19
+ : segment);
20
+ break;
21
+ }
22
+ else {
23
+ result = segment.text + result;
24
+ splittedSegmentResult === null || splittedSegmentResult === void 0 ? void 0 : splittedSegmentResult.unshift(segment);
25
+ }
26
+ }
27
+ if (i < 0) {
28
+ result = '';
29
+ }
30
+ return result;
31
+ }
32
+ //# sourceMappingURL=getQueryString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getQueryString.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/picker/getQueryString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGnE;;GAEG;AACH,MAAM,UAAU,cAAc,CAC1B,gBAAwB,EACxB,SAAgC,EAChC,eAAiC,EACjC,qBAA0C;IAE1C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAEpD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAChB,IAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAEtC,IAAI,OAAO,CAAC,WAAW,IAAI,MAAM,EAAE;YAC/B,MAAM,GAAG,EAAE,CAAC;YACZ,MAAM;SACT;QAED,IAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAEzD,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;YAEhD,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,OAAO,CAC1B,KAAK,GAAG,CAAC;gBACL,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;gBAClE,CAAC,CAAC,OAAO,CAChB,CAAC;YAEF,MAAM;SACT;aAAM;YACH,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC;YAE/B,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,OAAO,CAAC,OAAO,CAAC,CAAC;SAC3C;KACJ;IAED,IAAI,CAAC,GAAG,CAAC,EAAE;QACP,MAAM,GAAG,EAAE,CAAC;KACf;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { splitTextSegment } from '../pluginUtils/splitTextSegment';\nimport type { ContentModelParagraph, ContentModelText } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function getQueryString(\n triggerCharacter: string,\n paragraph: ContentModelParagraph,\n previousSegment: ContentModelText,\n splittedSegmentResult?: ContentModelText[]\n): string {\n let result = '';\n let i = paragraph.segments.indexOf(previousSegment);\n\n for (; i >= 0; i--) {\n const segment = paragraph.segments[i];\n\n if (segment.segmentType != 'Text') {\n result = '';\n break;\n }\n\n const index = segment.text.lastIndexOf(triggerCharacter);\n\n if (index >= 0) {\n result = segment.text.substring(index) + result;\n\n splittedSegmentResult?.unshift(\n index > 0\n ? splitTextSegment(segment, paragraph, index, segment.text.length)\n : segment\n );\n\n break;\n } else {\n result = segment.text + result;\n\n splittedSegmentResult?.unshift(segment);\n }\n }\n\n if (i < 0) {\n result = '';\n }\n\n return result;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { DOMInsertPoint, Rect } from 'roosterjs-content-model-types';
2
+ /**
3
+ * Get bounding rect of the given DOM insert point
4
+ * @param doc The document object
5
+ * @param pos The input DOM insert point
6
+ */
7
+ export declare function getDOMInsertPointRect(doc: Document, pos: DOMInsertPoint): Rect | null;
@@ -0,0 +1,53 @@
1
+ import { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';
2
+ /**
3
+ * Get bounding rect of the given DOM insert point
4
+ * @param doc The document object
5
+ * @param pos The input DOM insert point
6
+ */
7
+ export function getDOMInsertPointRect(doc, pos) {
8
+ var _a;
9
+ var node = pos.node, offset = pos.offset;
10
+ var range = doc.createRange();
11
+ range.setStart(node, offset);
12
+ // 1) try to get rect using range.getBoundingClientRect()
13
+ var rect = normalizeRect(range.getBoundingClientRect());
14
+ if (rect) {
15
+ return rect;
16
+ }
17
+ // 2) try to get rect using range.getClientRects
18
+ while (node.lastChild) {
19
+ if (offset == node.childNodes.length) {
20
+ node = node.lastChild;
21
+ offset = node.childNodes.length;
22
+ }
23
+ else {
24
+ node = node.childNodes[offset];
25
+ offset = 0;
26
+ }
27
+ }
28
+ var rects = range.getClientRects && range.getClientRects();
29
+ rect = rects && rects.length == 1 ? normalizeRect(rects[0]) : null;
30
+ if (rect) {
31
+ return rect;
32
+ }
33
+ // 3) if node is text node, try inserting a SPAN and get the rect of SPAN for others
34
+ if (isNodeOfType(node, 'TEXT_NODE')) {
35
+ var span = node.ownerDocument.createElement('span');
36
+ span.textContent = '\u200b';
37
+ range.insertNode(span);
38
+ rect = normalizeRect(span.getBoundingClientRect());
39
+ (_a = span.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(span);
40
+ if (rect) {
41
+ return rect;
42
+ }
43
+ }
44
+ // 4) try getBoundingClientRect on element
45
+ if (isNodeOfType(node, 'ELEMENT_NODE') && node.getBoundingClientRect) {
46
+ rect = normalizeRect(node.getBoundingClientRect());
47
+ if (rect) {
48
+ return rect;
49
+ }
50
+ }
51
+ return null;
52
+ }
53
+ //# sourceMappingURL=getDOMInsertPointRect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDOMInsertPointRect.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/pluginUtils/Rect/getDOMInsertPointRect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG1E;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAa,EAAE,GAAmB;;IAC9D,IAAA,IAAI,GAAa,GAAG,KAAhB,EAAE,MAAM,GAAK,GAAG,OAAR,CAAS;IAC3B,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IAEhC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAE7B,yDAAyD;IACzD,IAAI,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAExD,IAAI,IAAI,EAAE;QACN,OAAO,IAAI,CAAC;KACf;IAED,gDAAgD;IAChD,OAAO,IAAI,CAAC,SAAS,EAAE;QACnB,IAAI,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YAClC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YACtB,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SACnC;aAAM;YACH,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAC/B,MAAM,GAAG,CAAC,CAAC;SACd;KACJ;IAED,IAAM,KAAK,GAAG,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;IAC7D,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,IAAI,IAAI,EAAE;QACN,OAAO,IAAI,CAAC;KACf;IAED,oFAAoF;IACpF,IAAI,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE;QACjC,IAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAEtD,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;QAC5B,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QACnD,MAAA,IAAI,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,IAAI,EAAE;YACN,OAAO,IAAI,CAAC;SACf;KACJ;IAED,0CAA0C;IAC1C,IAAI,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,IAAI,CAAC,qBAAqB,EAAE;QAClE,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAEnD,IAAI,IAAI,EAAE;YACN,OAAO,IAAI,CAAC;SACf;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { isNodeOfType, normalizeRect } from 'roosterjs-content-model-dom';\nimport type { DOMInsertPoint, Rect } from 'roosterjs-content-model-types';\n\n/**\n * Get bounding rect of the given DOM insert point\n * @param doc The document object\n * @param pos The input DOM insert point\n */\nexport function getDOMInsertPointRect(doc: Document, pos: DOMInsertPoint): Rect | null {\n let { node, offset } = pos;\n const range = doc.createRange();\n\n range.setStart(node, offset);\n\n // 1) try to get rect using range.getBoundingClientRect()\n let rect = normalizeRect(range.getBoundingClientRect());\n\n if (rect) {\n return rect;\n }\n\n // 2) try to get rect using range.getClientRects\n while (node.lastChild) {\n if (offset == node.childNodes.length) {\n node = node.lastChild;\n offset = node.childNodes.length;\n } else {\n node = node.childNodes[offset];\n offset = 0;\n }\n }\n\n const rects = range.getClientRects && range.getClientRects();\n rect = rects && rects.length == 1 ? normalizeRect(rects[0]) : null;\n if (rect) {\n return rect;\n }\n\n // 3) if node is text node, try inserting a SPAN and get the rect of SPAN for others\n if (isNodeOfType(node, 'TEXT_NODE')) {\n const span = node.ownerDocument.createElement('span');\n\n span.textContent = '\\u200b';\n range.insertNode(span);\n rect = normalizeRect(span.getBoundingClientRect());\n span.parentNode?.removeChild(span);\n\n if (rect) {\n return rect;\n }\n }\n\n // 4) try getBoundingClientRect on element\n if (isNodeOfType(node, 'ELEMENT_NODE') && node.getBoundingClientRect) {\n rect = normalizeRect(node.getBoundingClientRect());\n\n if (rect) {\n return rect;\n }\n }\n\n return null;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { cacheGetEventData } from 'roosterjs-content-model-dom';
2
- import { ShortcutBold, ShortcutBullet, ShortcutClearFormat, ShortcutDecreaseFont, ShortcutIncreaseFont, ShortcutIndentList, ShortcutItalic, ShortcutNumbering, ShortcutOutdentList, ShortcutRedo, ShortcutRedoMacOS, ShortcutUnderline, ShortcutUndo, ShortcutUndo2, } from './shortcuts';
2
+ import { ShortcutBold, ShortcutBullet, ShortcutClearFormat, ShortcutDecreaseFont, ShortcutIncreaseFont, ShortcutIndentList, ShortcutItalic, ShortcutNumbering, ShortcutOutdentList, ShortcutRedo, ShortcutRedoAlt, ShortcutRedoMacOS, ShortcutUnderline, ShortcutUndo, ShortcutUndo2, } from './shortcuts';
3
3
  var defaultShortcuts = [
4
4
  ShortcutBold,
5
5
  ShortcutItalic,
@@ -8,6 +8,7 @@ var defaultShortcuts = [
8
8
  ShortcutUndo,
9
9
  ShortcutUndo2,
10
10
  ShortcutRedo,
11
+ ShortcutRedoAlt,
11
12
  ShortcutRedoMacOS,
12
13
  ShortcutBullet,
13
14
  ShortcutNumbering,
@@ -1 +1 @@
1
- {"version":3,"file":"ShortcutPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/ShortcutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EACH,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB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AAK,GAAc,KAAK,MAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;QAC5D,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QAClD,IAAM,aAAa,GACf,CAAC,WAAW,CAAC,WAAW,IAAI,MAAM,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,WAAW,CAAC,WAAW,IAAI,KAAK,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhE,OAAO,aAAa,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC;IAC3F,CAAC;IACL,qBAAC;AAAD,CAAC,AA3GD,IA2GC","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-dom';\nimport type { ShortcutCommand, ShortcutKeyDefinition } from './ShortcutCommand';\nimport {\n ShortcutBold,\n ShortcutBullet,\n ShortcutClearFormat,\n ShortcutDecreaseFont,\n ShortcutIncreaseFont,\n ShortcutIndentList,\n ShortcutItalic,\n ShortcutNumbering,\n ShortcutOutdentList,\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 ShortcutIndentList,\n ShortcutOutdentList,\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"]}
1
+ {"version":3,"file":"ShortcutPlugin.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/ShortcutPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EACH,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,aAAa,GAChB,MAAM,aAAa,CAAC;AAQrB,IAAM,gBAAgB,GAAsB;IACxC,YAAY;IACZ,cAAc;IACd,iBAAiB;IACjB,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;IAClB,mBAAmB;CACtB,CAAC;AACF,IAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD;;GAEG;AACH;IAII;;;OAGG;IACH,wBAAoB,SAA+C;QAA/C,0BAAA,EAAA,4BAA+C;QAA/C,cAAS,GAAT,SAAS,CAAsC;QAP3D,WAAM,GAAmB,IAAI,CAAC;QAC9B,UAAK,GAAG,KAAK,CAAC;IAMgD,CAAC;IAEvE;;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ACH,OAAA,KAAI,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;wBACjC,KAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC;gBADvD,CACuD,CAC9D,CAAC,CAAC,CAAC,CACP,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,gCAAO,GAAf,UAAgB,WAAsC;QAClD,QAAQ,WAAW,EAAE;YACjB,KAAK,KAAK;gBACN,OAAO,IAAI,CAAC,KAAK,CAAC;YAEtB,KAAK,QAAQ;gBACT,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YAEvB;gBACI,OAAO,IAAI,CAAC;SACnB;IACL,CAAC;IAEO,sCAAa,GAArB,UAAsB,WAAkC,EAAE,KAAoB;QAClE,IAAA,OAAO,GAAuC,KAAK,QAA5C,EAAE,MAAM,GAA+B,KAAK,OAApC,EAAE,QAAQ,GAAqB,KAAK,SAA1B,EAAE,KAAK,GAAc,KAAK,MAAnB,EAAE,OAAO,GAAK,KAAK,QAAV,CAAW;QAC5D,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QAClD,IAAM,aAAa,GACf,CAAC,WAAW,CAAC,WAAW,IAAI,MAAM,IAAI,UAAU,IAAI,CAAC,MAAM,CAAC;YAC5D,CAAC,WAAW,CAAC,WAAW,IAAI,KAAK,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhE,OAAO,aAAa,IAAI,QAAQ,IAAI,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC;IAC3F,CAAC;IACL,qBAAC;AAAD,CAAC,AA3GD,IA2GC","sourcesContent":["import { cacheGetEventData } from 'roosterjs-content-model-dom';\nimport type { ShortcutCommand, ShortcutKeyDefinition } from './ShortcutCommand';\nimport {\n ShortcutBold,\n ShortcutBullet,\n ShortcutClearFormat,\n ShortcutDecreaseFont,\n ShortcutIncreaseFont,\n ShortcutIndentList,\n ShortcutItalic,\n ShortcutNumbering,\n ShortcutOutdentList,\n ShortcutRedo,\n ShortcutRedoAlt,\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 ShortcutRedoAlt,\n ShortcutRedoMacOS,\n ShortcutBullet,\n ShortcutNumbering,\n ShortcutIncreaseFont,\n ShortcutDecreaseFont,\n ShortcutIndentList,\n ShortcutOutdentList,\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"]}
@@ -42,11 +42,18 @@ export declare const ShortcutUndo2: ShortcutCommand;
42
42
  */
43
43
  export declare const ShortcutRedo: ShortcutCommand;
44
44
  /**
45
+ * @deprecated
45
46
  * Shortcut command for Redo 2
46
47
  * Windows: N/A
47
48
  * MacOS: Meta + Shift + Z
48
49
  */
49
50
  export declare const ShortcutRedoMacOS: ShortcutCommand;
51
+ /**
52
+ * Shortcut command for Redo 3
53
+ * Windows: Ctrl + Shift + Z
54
+ * MacOS: Meta + Shift + Z
55
+ */
56
+ export declare const ShortcutRedoAlt: ShortcutCommand;
50
57
  /**
51
58
  * Shortcut command for Bullet List
52
59
  * Windows: Ctrl + . (Period)
@@ -111,6 +111,7 @@ export var ShortcutRedo = {
111
111
  environment: 'nonMac',
112
112
  };
113
113
  /**
114
+ * @deprecated
114
115
  * Shortcut command for Redo 2
115
116
  * Windows: N/A
116
117
  * MacOS: Meta + Shift + Z
@@ -124,6 +125,19 @@ export var ShortcutRedoMacOS = {
124
125
  onClick: function (editor) { return redo(editor); },
125
126
  environment: 'mac',
126
127
  };
128
+ /**
129
+ * Shortcut command for Redo 3
130
+ * Windows: Ctrl + Shift + Z
131
+ * MacOS: Meta + Shift + Z
132
+ */
133
+ export var ShortcutRedoAlt = {
134
+ shortcutKey: {
135
+ modifierKey: 'ctrl',
136
+ shiftKey: true,
137
+ which: 90 /* Z */,
138
+ },
139
+ onClick: function (editor) { return redo(editor); },
140
+ };
127
141
  /**
128
142
  * Shortcut command for Bullet List
129
143
  * Windows: Ctrl + . (Period)
@@ -1 +1 @@
1
- {"version":3,"file":"shortcuts.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACH,cAAc,EACd,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,GAClB,MAAM,6BAA6B,CAAC;AAGrC,IAAW,IAaV;AAbD,WAAW,IAAI;IACX,yCAAa,CAAA;IACb,kCAAU,CAAA;IACV,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,mCAAW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,KAAK,yBAAoB;KAC5B;IACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,eAAe,CAAC,MAAM,CAAC,EAAvB,CAAuB;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAoB;IACjD,WAAW,EAAE;QACT,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,IAAI;QACd,KAAK,kBAAa;KACrB;IACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,EAAlC,CAAkC;CACxD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAoB;IACjD,WAAW,EAAE;QACT,WAAW,EAAE,MAAM;QACnB,QAAQ,EAAE,IAAI;QACd,KAAK,iBAAY;KACpB;IACD,OAAO,EAAE,UAAA,MAAM,IAAI,OAAA,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,EAAlC,CAAkC;CACxD,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAAoB;IAC/C,WAAW,EAAE;QACT,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,IAAI;QACd,KAAK,qBAAiB;KACzB;IACD,OAAO,EAAE,UAAA,MAAM;QACX,6BAA6B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IACD,WAAW,EAAE,QAAQ;CACxB,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,IAAM,mBAAmB,GAAoB;IAChD,WAAW,EAAE;QACT,WAAW,EAAE,KAAK;QAClB,QAAQ,EAAE,IAAI;QACd,KAAK,oBAAgB;KACxB;IACD,OAAO,EAAE,UAAA,MAAM;QACX,6BAA6B,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,WAAW,EAAE,QAAQ;CACxB,CAAC","sourcesContent":["import { redo, undo } from 'roosterjs-content-model-core';\nimport { setShortcutIndentationCommand } from './utils/setShortcutIndentationCommand';\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 ArrowRight = 39,\n ArrowLeft = 37,\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: N/A\n */\nexport const ShortcutClearFormat: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.SPACE,\n },\n onClick: editor => clearFormat(editor),\n environment: 'nonMac',\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\n/**\n * Shortcut command for Intent list\n * Windows: Alt + Shift + Arrow Right\n * MacOS: N/A\n */\nexport const ShortcutIndentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowRight,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'indent');\n },\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Outdent list\n * Windows: Alt + Shift + Arrow Left\n * MacOS: N/A\n */\nexport const ShortcutOutdentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowLeft,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'outdent');\n },\n environment: 'nonMac',\n};\n"]}
1
+ {"version":3,"file":"shortcuts.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/shortcut/shortcuts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EACH,cAAc,EACd,WAAW,EACX,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,GAClB,MAAM,6BAA6B,CAAC;AAGrC,IAAW,IAaV;AAbD,WAAW,IAAI;IACX,yCAAa,CAAA;IACb,kCAAU,CAAA;IACV,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,0BAAM,CAAA;IACN,mCAAW,CAAA;IACX,qCAAY,CAAA;IACZ,mDAAmB,CAAA;IACnB,4CAAe,CAAA;IACf,0CAAc,CAAA;AAClB,CAAC,EAbU,IAAI,KAAJ,IAAI,QAad;AAED;;;;GAIG;AACH,MAAM,CAAC,IAAM,YAAY,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["import { redo, undo } from 'roosterjs-content-model-core';\nimport { setShortcutIndentationCommand } from './utils/setShortcutIndentationCommand';\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 ArrowRight = 39,\n ArrowLeft = 37,\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: N/A\n */\nexport const ShortcutClearFormat: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: false,\n which: Keys.SPACE,\n },\n onClick: editor => clearFormat(editor),\n environment: 'nonMac',\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 * @deprecated\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 Redo 3\n * Windows: Ctrl + Shift + Z\n * MacOS: Meta + Shift + Z\n */\nexport const ShortcutRedoAlt: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'ctrl',\n shiftKey: true,\n which: Keys.Z,\n },\n onClick: editor => redo(editor),\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\n/**\n * Shortcut command for Intent list\n * Windows: Alt + Shift + Arrow Right\n * MacOS: N/A\n */\nexport const ShortcutIndentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowRight,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'indent');\n },\n environment: 'nonMac',\n};\n\n/**\n * Shortcut command for Outdent list\n * Windows: Alt + Shift + Arrow Left\n * MacOS: N/A\n */\nexport const ShortcutOutdentList: ShortcutCommand = {\n shortcutKey: {\n modifierKey: 'alt',\n shiftKey: true,\n which: Keys.ArrowLeft,\n },\n onClick: editor => {\n setShortcutIndentationCommand(editor, 'outdent');\n },\n environment: 'nonMac',\n};\n"]}
@@ -4,12 +4,12 @@ import { setModelIndentation } from 'roosterjs-content-model-api';
4
4
  * @internal
5
5
  */
6
6
  export function setShortcutIndentationCommand(editor, operation) {
7
- editor.formatContentModel(function (model) {
7
+ editor.formatContentModel(function (model, context) {
8
8
  var listItem = getFirstSelectedListItem(model);
9
9
  if (listItem &&
10
10
  listItem.blocks[0].blockType == 'Paragraph' &&
11
11
  listItem.blocks[0].segments[0].segmentType == 'SelectionMarker') {
12
- setModelIndentation(model, operation);
12
+ setModelIndentation(model, operation, undefined /*length*/, context);
13
13
  return true;
14
14
  }
15
15
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"setShortcutIndentationCommand.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/shortcut/utils/setShortcutIndentationCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAe,EAAE,SAA+B;IAC1F,MAAM,CAAC,kBAAkB,CAAC,UAAA,KAAK;QAC3B,IAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAEjD,IACI,QAAQ;YACR,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;YAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EACjE;YACE,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACtC,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { getFirstSelectedListItem } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setShortcutIndentationCommand(editor: IEditor, operation: 'indent' | 'outdent') {\n editor.formatContentModel(model => {\n const listItem = getFirstSelectedListItem(model);\n\n if (\n listItem &&\n listItem.blocks[0].blockType == 'Paragraph' &&\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\n ) {\n setModelIndentation(model, operation);\n return true;\n }\n return false;\n });\n}\n"]}
1
+ {"version":3,"file":"setShortcutIndentationCommand.js","sourceRoot":"","sources":["../../../../../packages/roosterjs-content-model-plugins/lib/shortcut/utils/setShortcutIndentationCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,MAAe,EAAE,SAA+B;IAC1F,MAAM,CAAC,kBAAkB,CAAC,UAAC,KAAK,EAAE,OAAO;QACrC,IAAM,QAAQ,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAEjD,IACI,QAAQ;YACR,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,WAAW;YAC3C,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,iBAAiB,EACjE;YACE,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC;SACf;QACD,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { getFirstSelectedListItem } from 'roosterjs-content-model-dom';\nimport { setModelIndentation } from 'roosterjs-content-model-api';\nimport type { IEditor } from 'roosterjs-content-model-types';\n\n/**\n * @internal\n */\nexport function setShortcutIndentationCommand(editor: IEditor, operation: 'indent' | 'outdent') {\n editor.formatContentModel((model, context) => {\n const listItem = getFirstSelectedListItem(model);\n\n if (\n listItem &&\n listItem.blocks[0].blockType == 'Paragraph' &&\n listItem.blocks[0].segments[0].segmentType == 'SelectionMarker'\n ) {\n setModelIndentation(model, operation, undefined /*length*/, context);\n return true;\n }\n return false;\n });\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.
3
+ */
4
+ export declare type OnTableEditorCreatedCallback = (editorType: 'HorizontalTableInserter' | 'VerticalTableInserter' | 'TableMover' | 'TableResizer', element: HTMLElement) => () => void;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OnTableEditorCreatedCallback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OnTableEditorCreatedCallback.js","sourceRoot":"","sources":["../../../../packages/roosterjs-content-model-plugins/lib/tableEdit/OnTableEditorCreatedCallback.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Optional callback when creating a TableEditPlugin, allows to customize the Selectors element as required.\n */\nexport type OnTableEditorCreatedCallback = (\n editorType: 'HorizontalTableInserter' | 'VerticalTableInserter' | 'TableMover' | 'TableResizer',\n element: HTMLElement\n) => () => void;\n"]}
@@ -1,9 +1,11 @@
1
+ import type { OnTableEditorCreatedCallback } from './OnTableEditorCreatedCallback';
1
2
  import type { EditorPlugin, IEditor, PluginEvent } from 'roosterjs-content-model-types';
2
3
  /**
3
4
  * TableEdit plugin, provides the ability to resize a table by drag-and-drop
4
5
  */
5
6
  export declare class TableEditPlugin implements EditorPlugin {
6
7
  private anchorContainerSelector?;
8
+ private onTableEditorCreated?;
7
9
  private editor;
8
10
  private onMouseMoveDisposer;
9
11
  private tableRectMap;
@@ -13,8 +15,9 @@ export declare class TableEditPlugin implements EditorPlugin {
13
15
  * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
14
16
  * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
15
17
  * If not specified, the plugin will be inserted in document.body
18
+ * @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
16
19
  */
17
- constructor(anchorContainerSelector?: string | undefined);
20
+ constructor(anchorContainerSelector?: string | undefined, onTableEditorCreated?: OnTableEditorCreatedCallback | undefined);
18
21
  /**
19
22
  * Get a friendly name of this plugin
20
23
  */
@@ -10,10 +10,12 @@ var TableEditPlugin = /** @class */ (function () {
10
10
  * @param anchorContainerSelector An optional selector string to specify the container to host the plugin.
11
11
  * The container must not be affected by transform: scale(), otherwise the position calculation will be wrong.
12
12
  * If not specified, the plugin will be inserted in document.body
13
+ * @param onTableEditorCreated An optional callback to customize the Table Editors elements when created.
13
14
  */
14
- function TableEditPlugin(anchorContainerSelector) {
15
+ function TableEditPlugin(anchorContainerSelector, onTableEditorCreated) {
15
16
  var _this = this;
16
17
  this.anchorContainerSelector = anchorContainerSelector;
18
+ this.onTableEditorCreated = onTableEditorCreated;
17
19
  this.editor = null;
18
20
  this.onMouseMoveDisposer = null;
19
21
  this.tableRectMap = null;
@@ -91,6 +93,7 @@ var TableEditPlugin = /** @class */ (function () {
91
93
  this.disposeTableEditor();
92
94
  this.editor = null;
93
95
  this.onMouseMoveDisposer = null;
96
+ this.onTableEditorCreated = undefined;
94
97
  };
95
98
  /**
96
99
  * Handle events triggered from editor
@@ -121,7 +124,7 @@ var TableEditPlugin = /** @class */ (function () {
121
124
  var container = this.anchorContainerSelector
122
125
  ? this.editor.getDocument().querySelector(this.anchorContainerSelector)
123
126
  : undefined;
124
- this.tableEditor = new TableEditor(this.editor, table, this.invalidateTableRects, isNodeOfType(container, 'ELEMENT_NODE') ? container : undefined, event === null || event === void 0 ? void 0 : event.currentTarget);
127
+ this.tableEditor = new TableEditor(this.editor, table, this.invalidateTableRects, isNodeOfType(container, 'ELEMENT_NODE') ? container : undefined, event === null || event === void 0 ? void 0 : event.currentTarget, this.onTableEditorCreated);
125
128
  }
126
129
  };
127
130
  TableEditPlugin.prototype.disposeTableEditor = function () {