@atlaskit/editor-plugin-list 0.2.0 → 1.0.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 (181) hide show
  1. package/.eslintrc.js +14 -0
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +1 -1
  4. package/dist/cjs/actions/conversions.js +153 -0
  5. package/dist/cjs/actions/indent-list-items-selected.js +125 -0
  6. package/dist/cjs/actions/indent-list.js +49 -0
  7. package/dist/cjs/actions/join-list-items-forward.js +59 -0
  8. package/dist/cjs/actions/join-list-items-scenarios/index.js +40 -0
  9. package/dist/cjs/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +88 -0
  10. package/dist/cjs/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +85 -0
  11. package/dist/cjs/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +79 -0
  12. package/dist/cjs/actions/join-list-items-scenarios/join-paragraph-with-list.js +45 -0
  13. package/dist/cjs/actions/join-list-items-scenarios/join-sibling-list-items.js +56 -0
  14. package/dist/cjs/actions/merge-lists.js +27 -0
  15. package/dist/cjs/actions/outdent-list-items-selected.js +291 -0
  16. package/dist/cjs/actions/wrap-and-join-lists.js +100 -0
  17. package/dist/cjs/commands/indent-list.js +71 -0
  18. package/dist/cjs/commands/index.js +350 -0
  19. package/dist/cjs/commands/isFirstChildOfParent.js +12 -0
  20. package/dist/cjs/commands/join-list-item-forward.js +61 -0
  21. package/dist/cjs/commands/listBackspace.js +284 -0
  22. package/dist/cjs/commands/outdent-list.js +70 -0
  23. package/dist/cjs/index.js +8 -1
  24. package/dist/cjs/messages.js +37 -0
  25. package/dist/cjs/plugin.js +133 -0
  26. package/dist/cjs/pm-plugins/input-rules/create-list-input-rule.js +63 -0
  27. package/dist/cjs/pm-plugins/input-rules/index.js +38 -0
  28. package/dist/cjs/pm-plugins/input-rules/wrapping-join-rule.js +60 -0
  29. package/dist/cjs/pm-plugins/keymap.js +27 -0
  30. package/dist/cjs/pm-plugins/main.js +166 -0
  31. package/dist/cjs/transforms.js +99 -0
  32. package/dist/cjs/types.js +4 -1
  33. package/dist/cjs/utils/analytics.js +22 -0
  34. package/dist/cjs/utils/find.js +68 -0
  35. package/dist/cjs/utils/indentation.js +22 -0
  36. package/dist/cjs/utils/mark.js +40 -0
  37. package/dist/cjs/utils/node.js +16 -0
  38. package/dist/cjs/utils/selection.js +95 -0
  39. package/dist/es2019/actions/conversions.js +160 -0
  40. package/dist/es2019/actions/indent-list-items-selected.js +124 -0
  41. package/dist/es2019/actions/indent-list.js +44 -0
  42. package/dist/es2019/actions/join-list-items-forward.js +54 -0
  43. package/dist/es2019/actions/join-list-items-scenarios/index.js +5 -0
  44. package/dist/es2019/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +74 -0
  45. package/dist/es2019/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +77 -0
  46. package/dist/es2019/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +71 -0
  47. package/dist/es2019/actions/join-list-items-scenarios/join-paragraph-with-list.js +37 -0
  48. package/dist/es2019/actions/join-list-items-scenarios/join-sibling-list-items.js +48 -0
  49. package/dist/es2019/actions/merge-lists.js +24 -0
  50. package/dist/es2019/actions/outdent-list-items-selected.js +295 -0
  51. package/dist/es2019/actions/wrap-and-join-lists.js +93 -0
  52. package/dist/es2019/commands/indent-list.js +62 -0
  53. package/dist/es2019/commands/index.js +326 -0
  54. package/dist/es2019/commands/isFirstChildOfParent.js +7 -0
  55. package/dist/es2019/commands/join-list-item-forward.js +53 -0
  56. package/dist/es2019/commands/listBackspace.js +276 -0
  57. package/dist/es2019/commands/outdent-list.js +60 -0
  58. package/dist/es2019/index.js +1 -1
  59. package/dist/es2019/messages.js +29 -0
  60. package/dist/es2019/plugin.js +121 -0
  61. package/dist/es2019/pm-plugins/input-rules/create-list-input-rule.js +56 -0
  62. package/dist/es2019/pm-plugins/input-rules/index.js +35 -0
  63. package/dist/es2019/pm-plugins/input-rules/wrapping-join-rule.js +55 -0
  64. package/dist/es2019/pm-plugins/keymap.js +19 -0
  65. package/dist/es2019/pm-plugins/main.js +156 -0
  66. package/dist/es2019/transforms.js +101 -0
  67. package/dist/es2019/types.js +1 -1
  68. package/dist/es2019/utils/analytics.js +12 -0
  69. package/dist/es2019/utils/find.js +61 -0
  70. package/dist/es2019/utils/indentation.js +15 -0
  71. package/dist/es2019/utils/mark.js +30 -0
  72. package/dist/es2019/utils/node.js +12 -0
  73. package/dist/es2019/utils/selection.js +96 -0
  74. package/dist/esm/actions/conversions.js +147 -0
  75. package/dist/esm/actions/indent-list-items-selected.js +117 -0
  76. package/dist/esm/actions/indent-list.js +43 -0
  77. package/dist/esm/actions/join-list-items-forward.js +52 -0
  78. package/dist/esm/actions/join-list-items-scenarios/index.js +5 -0
  79. package/dist/esm/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +81 -0
  80. package/dist/esm/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +78 -0
  81. package/dist/esm/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +72 -0
  82. package/dist/esm/actions/join-list-items-scenarios/join-paragraph-with-list.js +38 -0
  83. package/dist/esm/actions/join-list-items-scenarios/join-sibling-list-items.js +49 -0
  84. package/dist/esm/actions/merge-lists.js +21 -0
  85. package/dist/esm/actions/outdent-list-items-selected.js +283 -0
  86. package/dist/esm/actions/wrap-and-join-lists.js +94 -0
  87. package/dist/esm/commands/indent-list.js +63 -0
  88. package/dist/esm/commands/index.js +324 -0
  89. package/dist/esm/commands/isFirstChildOfParent.js +5 -0
  90. package/dist/esm/commands/join-list-item-forward.js +53 -0
  91. package/dist/esm/commands/listBackspace.js +275 -0
  92. package/dist/esm/commands/outdent-list.js +62 -0
  93. package/dist/esm/index.js +1 -1
  94. package/dist/esm/messages.js +29 -0
  95. package/dist/esm/plugin.js +126 -0
  96. package/dist/esm/pm-plugins/input-rules/create-list-input-rule.js +57 -0
  97. package/dist/esm/pm-plugins/input-rules/index.js +32 -0
  98. package/dist/esm/pm-plugins/input-rules/wrapping-join-rule.js +54 -0
  99. package/dist/esm/pm-plugins/keymap.js +19 -0
  100. package/dist/esm/pm-plugins/main.js +156 -0
  101. package/dist/esm/transforms.js +91 -0
  102. package/dist/esm/types.js +1 -1
  103. package/dist/esm/utils/analytics.js +12 -0
  104. package/dist/esm/utils/find.js +59 -0
  105. package/dist/esm/utils/indentation.js +15 -0
  106. package/dist/esm/utils/mark.js +33 -0
  107. package/dist/esm/utils/node.js +10 -0
  108. package/dist/esm/utils/selection.js +81 -0
  109. package/dist/types/actions/conversions.d.ts +6 -0
  110. package/dist/types/actions/indent-list-items-selected.d.ts +2 -0
  111. package/dist/types/actions/indent-list.d.ts +2 -0
  112. package/dist/types/actions/join-list-items-forward.d.ts +13 -0
  113. package/dist/types/actions/join-list-items-scenarios/index.d.ts +5 -0
  114. package/dist/types/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +9 -0
  115. package/dist/types/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +9 -0
  116. package/dist/types/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +9 -0
  117. package/dist/types/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +9 -0
  118. package/dist/types/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +9 -0
  119. package/dist/types/actions/merge-lists.d.ts +7 -0
  120. package/dist/types/actions/outdent-list-items-selected.d.ts +3 -0
  121. package/dist/types/actions/wrap-and-join-lists.d.ts +17 -0
  122. package/dist/types/commands/indent-list.d.ts +6 -0
  123. package/dist/types/commands/index.d.ts +16 -0
  124. package/dist/types/commands/isFirstChildOfParent.d.ts +2 -0
  125. package/dist/types/commands/join-list-item-forward.d.ts +3 -0
  126. package/dist/types/commands/listBackspace.d.ts +10 -0
  127. package/dist/types/commands/outdent-list.d.ts +6 -0
  128. package/dist/types/index.d.ts +2 -1
  129. package/dist/types/messages.d.ts +27 -0
  130. package/dist/types/plugin.d.ts +2 -0
  131. package/dist/types/pm-plugins/input-rules/create-list-input-rule.d.ts +11 -0
  132. package/dist/types/pm-plugins/input-rules/index.d.ts +5 -0
  133. package/dist/types/pm-plugins/input-rules/wrapping-join-rule.d.ts +13 -0
  134. package/dist/types/pm-plugins/keymap.d.ts +5 -0
  135. package/dist/types/pm-plugins/main.d.ts +11 -0
  136. package/dist/types/transforms.d.ts +4 -0
  137. package/dist/types/types.d.ts +4 -6
  138. package/dist/types/utils/analytics.d.ts +5 -0
  139. package/dist/types/utils/find.d.ts +10 -0
  140. package/dist/types/utils/indentation.d.ts +2 -0
  141. package/dist/types/utils/mark.d.ts +8 -0
  142. package/dist/types/utils/node.d.ts +2 -0
  143. package/dist/types/utils/selection.d.ts +14 -0
  144. package/dist/types-ts4.5/actions/conversions.d.ts +6 -0
  145. package/dist/types-ts4.5/actions/indent-list-items-selected.d.ts +2 -0
  146. package/dist/types-ts4.5/actions/indent-list.d.ts +2 -0
  147. package/dist/types-ts4.5/actions/join-list-items-forward.d.ts +16 -0
  148. package/dist/types-ts4.5/actions/join-list-items-scenarios/index.d.ts +5 -0
  149. package/dist/types-ts4.5/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +9 -0
  150. package/dist/types-ts4.5/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +9 -0
  151. package/dist/types-ts4.5/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +9 -0
  152. package/dist/types-ts4.5/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +9 -0
  153. package/dist/types-ts4.5/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +9 -0
  154. package/dist/types-ts4.5/actions/merge-lists.d.ts +7 -0
  155. package/dist/types-ts4.5/actions/outdent-list-items-selected.d.ts +3 -0
  156. package/dist/types-ts4.5/actions/wrap-and-join-lists.d.ts +17 -0
  157. package/dist/types-ts4.5/commands/indent-list.d.ts +6 -0
  158. package/dist/types-ts4.5/commands/index.d.ts +16 -0
  159. package/dist/types-ts4.5/commands/isFirstChildOfParent.d.ts +2 -0
  160. package/dist/types-ts4.5/commands/join-list-item-forward.d.ts +3 -0
  161. package/dist/types-ts4.5/commands/listBackspace.d.ts +13 -0
  162. package/dist/types-ts4.5/commands/outdent-list.d.ts +6 -0
  163. package/dist/types-ts4.5/index.d.ts +2 -1
  164. package/dist/types-ts4.5/messages.d.ts +27 -0
  165. package/dist/types-ts4.5/plugin.d.ts +2 -0
  166. package/dist/types-ts4.5/pm-plugins/input-rules/create-list-input-rule.d.ts +11 -0
  167. package/dist/types-ts4.5/pm-plugins/input-rules/index.d.ts +5 -0
  168. package/dist/types-ts4.5/pm-plugins/input-rules/wrapping-join-rule.d.ts +13 -0
  169. package/dist/types-ts4.5/pm-plugins/keymap.d.ts +5 -0
  170. package/dist/types-ts4.5/pm-plugins/main.d.ts +11 -0
  171. package/dist/types-ts4.5/transforms.d.ts +4 -0
  172. package/dist/types-ts4.5/types.d.ts +4 -6
  173. package/dist/types-ts4.5/utils/analytics.d.ts +5 -0
  174. package/dist/types-ts4.5/utils/find.d.ts +10 -0
  175. package/dist/types-ts4.5/utils/indentation.d.ts +2 -0
  176. package/dist/types-ts4.5/utils/mark.d.ts +8 -0
  177. package/dist/types-ts4.5/utils/node.d.ts +2 -0
  178. package/dist/types-ts4.5/utils/selection.d.ts +14 -0
  179. package/package.json +8 -5
  180. package/report.api.md +6 -2
  181. package/tmp/api-report-tmp.d.ts +4 -1
@@ -0,0 +1,275 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ var _BACKSPACE_COMMANDS;
3
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, DELETE_DIRECTION, EVENT_TYPE, INPUT_METHOD, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
4
+ import { insertContentDeleteRange, isEmptySelectionAtStart, isListNode, isParagraphNode, walkPrevNode } from '@atlaskit/editor-common/utils';
5
+ import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
+ import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
7
+ //Cases below refer to the cases found in this document: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1146954996/List+Backspace+and+Delete+Behaviour
8
+ //Case for two adjacent list items of the same indentation
9
+ var listBackspaceCase2 = function listBackspaceCase2(tr, dispatch, $prev, $head) {
10
+ /* CASE 2
11
+ * Initial Structure:
12
+ *
13
+ * List A {
14
+ * ListItem B {
15
+ * ...Children C
16
+ * Paragraph D { text1 |textInsertPos| } //Cant have children since that would be Case 4
17
+ * |$prev||childrenGInsertPos| }
18
+ * ListItem E {
19
+ * Paragraph F { |$head| text2 }
20
+ * ...Children G
21
+ * }
22
+ * }
23
+ *
24
+ * Converts to:
25
+ *
26
+ * List A {
27
+ * ListItem B {
28
+ * ...Children C
29
+ * Paragraph C { text1text2 }
30
+ * ...Children G
31
+ * }
32
+ * }
33
+ *
34
+ */
35
+
36
+ var listItemE = $head.node(-1); //Head is inside listItem E so it must have a first and last child
37
+ if (!listItemE.firstChild) {
38
+ return false;
39
+ }
40
+ var beforeListItemE = $head.before(-1);
41
+ var afterListItemE = $head.after(-1);
42
+ var textInsertPos = $prev.pos - 1; //Paragraph D must be directly behind $prev otherwise it would be case 4
43
+ var childrenGInsertPos = $prev.pos;
44
+ var textContent = $head.parent.content;
45
+ var childrenGContent = listItemE.content.cut(listItemE.firstChild.nodeSize);
46
+ insertContentDeleteRange(tr, function (tr) {
47
+ return tr.doc.resolve(textInsertPos);
48
+ }, [[textContent, textInsertPos], [childrenGContent, childrenGInsertPos]], [[beforeListItemE, afterListItemE]]);
49
+ if (dispatch) {
50
+ dispatch(tr);
51
+ }
52
+ return true;
53
+ };
54
+
55
+ //Case for two adjacent list items with the first being of lower indentation
56
+ var listBackspaceCase3 = function listBackspaceCase3(tr, dispatch, $prev, $head) {
57
+ /* CASE 3
58
+ * Initial Structure:
59
+ *
60
+ * List A {
61
+ * ListItem B {
62
+ * ...Children C
63
+ * Paragraph D { text1 |$prev||textInsertPos| } |childrenHInsertPos|
64
+ * List E { |childrenJInsertPos|
65
+ * ListItem F {
66
+ * Paragraph G { |$head| text2 }
67
+ * ...Children H
68
+ * List? I {
69
+ * ...Children J
70
+ * }
71
+ * }
72
+ * ...Children K
73
+ * }
74
+ * }
75
+ * }
76
+ *
77
+ * Converts to:
78
+ *
79
+ * List A {
80
+ * ListItem B {
81
+ * ...Children C
82
+ * Paragraph D { text1text2 }
83
+ * ...Children H
84
+ * List E {
85
+ * ...Children J
86
+ * ...Children K
87
+ * }
88
+ * }
89
+ * }
90
+ *
91
+ */
92
+
93
+ var listE = $head.node(-2);
94
+ var listItemF = $head.node(-1); //Head is inside listItem F so it must have a first and last child
95
+ if (!listItemF.firstChild || !listItemF.lastChild) {
96
+ return false;
97
+ }
98
+ var beforeListE = $head.before(-2);
99
+ var beforeListItemF = $head.before(-1);
100
+ var afterParagraphD = $prev.after();
101
+ var afterListE = $head.after(-2);
102
+ var afterListItemF = $head.after(-1);
103
+ var startListE = $head.start(-2);
104
+ var containsChildrenJ = isListNode(listItemF.lastChild);
105
+ var shouldRemoveListE = listE.childCount === 1 && !containsChildrenJ; //Assures no Children J and K
106
+ var textInsertPos = $prev.pos;
107
+ var childrenHInsertPos = afterParagraphD;
108
+ var childrenJInsertPos = startListE;
109
+ var textContent = $head.parent.content;
110
+ var childrenHContent = containsChildrenJ ? listItemF.content.cut(listItemF.firstChild.nodeSize, listItemF.nodeSize - listItemF.lastChild.nodeSize - 2) : listItemF.content.cut(listItemF.firstChild.nodeSize); //If Children J doesn't exist then Children H will include the last node
111
+ var childrenJContent = listItemF.lastChild.content; //Will be invalid if there are no Children J but it will be unused
112
+
113
+ insertContentDeleteRange(tr, function (tr) {
114
+ return tr.doc.resolve(textInsertPos);
115
+ }, containsChildrenJ ? [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos], [childrenJContent, childrenJInsertPos]] : [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos]], [shouldRemoveListE ? [beforeListE, afterListE] : [beforeListItemF, afterListItemF]]);
116
+ if (dispatch) {
117
+ dispatch(tr);
118
+ }
119
+ return true;
120
+ };
121
+
122
+ //Case for two adjacent list items with the first being of greater indentation
123
+ var listBackspaceCase4 = function listBackspaceCase4(tr, dispatch, $prev, $head, $last) {
124
+ /* CASE 4
125
+ * Initial Structure:
126
+ *
127
+ * List A {
128
+ * ListItem B {
129
+ * Paragraph C { text1 }
130
+ * ...Children D
131
+ * List E {
132
+ * ...
133
+ * List F { //May be multiple levels of lists
134
+ * ...Children G
135
+ * ListItem H { //Last node of the block
136
+ * ...Children I
137
+ * Paragraph J { text2 |$last||textInsertPos| } |childrenMInsertPos| //Cant have children since this ListItem is the last of the block
138
+ * }
139
+ * }
140
+ * ...
141
+ * |childrenOInsertPosition| }
142
+ * |$prev| }
143
+ * ListItem K {
144
+ * Paragraph L { |$head| text3 }
145
+ * ...Children M
146
+ * List? N {
147
+ * ...Children O
148
+ * }
149
+ * }
150
+ * }
151
+ *
152
+ * Converts to:
153
+ *
154
+ * List A {
155
+ * ListItem B {
156
+ * Paragraph C { text1 }
157
+ * ...Children D
158
+ * List E {
159
+ * ...
160
+ * List F {
161
+ * ...Children G
162
+ * ListItem H {
163
+ * ...Children I
164
+ * Paragraph J { text2text3 }
165
+ * ...Children M
166
+ * }
167
+ * }
168
+ * ...
169
+ * ...Children O
170
+ * }
171
+ * }
172
+ * }
173
+ *
174
+ */
175
+
176
+ if (!$last) {
177
+ //Exit if an invalid last was given as a parameter
178
+ return false;
179
+ }
180
+ var listItemK = $head.node(-1); //Head is inside listItem K so it must have a first and last child
181
+ if (!listItemK.firstChild || !listItemK.lastChild) {
182
+ return false;
183
+ }
184
+ var paragraphL = $head.parent;
185
+ var beforeListItemK = $head.before(-1);
186
+ var afterParagraphJ = $last.after();
187
+ var afterListItemK = $head.after(-1);
188
+ var containsChildrenO = isListNode(listItemK.lastChild);
189
+ var textInsertPos = $last.pos;
190
+ var childrenMInsertPos = afterParagraphJ;
191
+ var childrenOInsertPos = $prev.pos - 1; //Last item of listItem B must be a list therefore we can simply decrement $prev to get there
192
+
193
+ var textContent = paragraphL.content;
194
+ var childrenMContent = containsChildrenO ? listItemK.content.cut(listItemK.firstChild.nodeSize, listItemK.nodeSize - listItemK.lastChild.nodeSize - 2) : listItemK.content.cut(listItemK.firstChild.nodeSize);
195
+ var childrenOContent = listItemK.lastChild.content;
196
+ insertContentDeleteRange(tr, function (tr) {
197
+ return tr.doc.resolve(textInsertPos);
198
+ }, containsChildrenO ? [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos], [childrenOContent, childrenOInsertPos]] : [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos]], [[beforeListItemK, afterListItemK]]);
199
+ if (dispatch) {
200
+ dispatch(tr);
201
+ }
202
+ return true;
203
+ };
204
+ var BACKSPACE_COMMANDS = (_BACKSPACE_COMMANDS = {}, _defineProperty(_BACKSPACE_COMMANDS, LIST_TEXT_SCENARIOS.JOIN_SIBLINGS, listBackspaceCase2), _defineProperty(_BACKSPACE_COMMANDS, LIST_TEXT_SCENARIOS.JOIN_DESCENDANT_TO_PARENT, listBackspaceCase3), _defineProperty(_BACKSPACE_COMMANDS, LIST_TEXT_SCENARIOS.JOIN_TO_SIBLING_DESCENDANT, listBackspaceCase4), _BACKSPACE_COMMANDS);
205
+ export var calcJoinListScenario = function calcJoinListScenario(walkNode, $head, tr) {
206
+ var $prev = walkNode.$pos,
207
+ prevFoundNode = walkNode.foundNode;
208
+ var prevInList = isPosInsideList($prev);
209
+ var headInParagraph = isPosInsideParagraph($head);
210
+ var headInFirstChild = $head.index(-1) === 0;
211
+ var headInList = isPosInsideList($head);
212
+
213
+ //Must be at the start of the selection of the first child in the listItem
214
+
215
+ if (!prevFoundNode || !prevInList || !headInParagraph || !headInFirstChild || !headInList) {
216
+ return false;
217
+ }
218
+ var prevInParagraph = isPosInsideParagraph($prev);
219
+ if (prevInParagraph) {
220
+ return [LIST_TEXT_SCENARIOS.JOIN_DESCENDANT_TO_PARENT, null];
221
+ }
222
+ var prevParentLastChildIsList = $prev.parent.lastChild && isListNode($prev.parent.lastChild);
223
+ var prevParentLastChildIsParagraph = isParagraphNode($prev.parent.lastChild);
224
+
225
+ // Will search for the possible last node for case 4 (where the list could be indented multiple times)
226
+ // $last is required to determine whether we are in case 2 or 4
227
+ var $last = tr.doc.resolve($prev.pos);
228
+ var lastFoundNode;
229
+ do {
230
+ var _walkNode = walkPrevNode($last);
231
+ $last = _walkNode.$pos;
232
+ lastFoundNode = _walkNode.foundNode;
233
+ } while (lastFoundNode && !$last.parent.isTextblock);
234
+ var lastInParagraph = isPosInsideParagraph($last);
235
+ if (lastFoundNode && prevParentLastChildIsList && lastInParagraph) {
236
+ return [LIST_TEXT_SCENARIOS.JOIN_TO_SIBLING_DESCENDANT, $last];
237
+ } else if (prevParentLastChildIsParagraph) {
238
+ return [LIST_TEXT_SCENARIOS.JOIN_SIBLINGS, null];
239
+ }
240
+ return false;
241
+ };
242
+ export var listBackspace = function listBackspace(editorAnalyticsAPI) {
243
+ return function (state, dispatch) {
244
+ var tr = state.tr,
245
+ $head = state.selection.$head;
246
+ var walkNode = walkPrevNode($head);
247
+ if (!isEmptySelectionAtStart(state)) {
248
+ return false;
249
+ }
250
+ var scenario = calcJoinListScenario(walkNode, $head, tr);
251
+ if (!scenario) {
252
+ return false;
253
+ }
254
+ var _state$schema$nodes = state.schema.nodes,
255
+ bulletList = _state$schema$nodes.bulletList,
256
+ orderedList = _state$schema$nodes.orderedList;
257
+ var listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
258
+ var actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
259
+ if (listParent && listParent.node.type === orderedList) {
260
+ actionSubjectId = ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
261
+ }
262
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
263
+ action: ACTION.LIST_ITEM_JOINED,
264
+ actionSubject: ACTION_SUBJECT.LIST,
265
+ actionSubjectId: actionSubjectId,
266
+ eventType: EVENT_TYPE.TRACK,
267
+ attributes: {
268
+ inputMethod: INPUT_METHOD.KEYBOARD,
269
+ direction: DELETE_DIRECTION.BACKWARD,
270
+ scenario: scenario[0]
271
+ }
272
+ })(tr);
273
+ return BACKSPACE_COMMANDS[scenario[0]](tr, dispatch, walkNode.$pos, $head, scenario[1]);
274
+ };
275
+ };
@@ -0,0 +1,62 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
5
+ import { getCommonListAnalyticsAttributes } from '@atlaskit/editor-common/lists';
6
+ import { isBulletList } from '@atlaskit/editor-common/utils';
7
+ import { closeHistory } from '@atlaskit/editor-prosemirror/history';
8
+ import { outdentListItemsSelected as outdentListAction } from '../actions/outdent-list-items-selected';
9
+ import { getRestartListsAttributes } from '../utils/analytics';
10
+ import { findFirstParentListNode } from '../utils/find';
11
+ import { isInsideListItem, isInsideTableCell } from '../utils/selection';
12
+ export var outdentList = function outdentList(editorAnalyticsAPI) {
13
+ return function () {
14
+ var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
15
+ var featureFlags = arguments.length > 1 ? arguments[1] : undefined;
16
+ return function (state, dispatch) {
17
+ if (!isInsideListItem(state)) {
18
+ return false;
19
+ }
20
+ var $from = state.selection.$from;
21
+ var parentListNode = findFirstParentListNode($from);
22
+ if (!parentListNode) {
23
+ // Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
24
+ return true;
25
+ }
26
+
27
+ // Save the history, so it could undo/revert to the same state before the outdent, see https://product-fabric.atlassian.net/browse/ED-14753
28
+ closeHistory(state.tr);
29
+ var actionSubjectId = isBulletList(parentListNode.node) ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
30
+ var customTr = state.tr;
31
+ outdentListAction(customTr, state, featureFlags);
32
+ if (!customTr || !customTr.docChanged) {
33
+ // Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
34
+ // If inside table cell and can't outdent list, then let it handle by table keymap
35
+ return !isInsideTableCell(state);
36
+ }
37
+ var restartListsAttributes = {};
38
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
39
+ var _getRestartListsAttri = getRestartListsAttributes(customTr),
40
+ outdentScenario = _getRestartListsAttri.outdentScenario,
41
+ splitListStartNumber = _getRestartListsAttri.splitListStartNumber;
42
+ if (outdentScenario === OUTDENT_SCENARIOS.SPLIT_LIST) {
43
+ restartListsAttributes.outdentScenario = outdentScenario;
44
+ restartListsAttributes.splitListStartNumber = splitListStartNumber;
45
+ }
46
+ }
47
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
48
+ action: ACTION.OUTDENTED,
49
+ actionSubject: ACTION_SUBJECT.LIST,
50
+ actionSubjectId: actionSubjectId,
51
+ eventType: EVENT_TYPE.TRACK,
52
+ attributes: _objectSpread(_objectSpread(_objectSpread({}, getCommonListAnalyticsAttributes(state)), restartListsAttributes), {}, {
53
+ inputMethod: inputMethod
54
+ })
55
+ })(customTr);
56
+ if (dispatch) {
57
+ dispatch(customTr);
58
+ }
59
+ return true;
60
+ };
61
+ };
62
+ };
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { listPlugin } from './plugin';
@@ -0,0 +1,29 @@
1
+ // Common Translations will live here
2
+ import { defineMessages } from 'react-intl-next';
3
+ export var messages = defineMessages({
4
+ unorderedList: {
5
+ id: 'fabric.editor.unorderedList',
6
+ defaultMessage: 'Bullet list',
7
+ description: 'A list with bullets. Also known as an “unordered” list'
8
+ },
9
+ unorderedListDescription: {
10
+ id: 'fabric.editor.unorderedList.description',
11
+ defaultMessage: 'Create an unordered list',
12
+ description: ''
13
+ },
14
+ orderedList: {
15
+ id: 'fabric.editor.orderedList',
16
+ defaultMessage: 'Numbered list',
17
+ description: 'A list with ordered items 1… 2… 3…'
18
+ },
19
+ orderedListDescription: {
20
+ id: 'fabric.editor.orderedList.description',
21
+ defaultMessage: 'Create an ordered list',
22
+ description: ''
23
+ },
24
+ lists: {
25
+ id: 'fabric.editor.lists',
26
+ defaultMessage: 'Lists',
27
+ description: 'Menu shows ordered/bullet list and unordered/numbered lists'
28
+ }
29
+ });
@@ -0,0 +1,126 @@
1
+ import React from 'react';
2
+ import { bulletList, listItem, orderedList, orderedListWithOrder } from '@atlaskit/adf-schema';
3
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
+ import { toggleBulletList, toggleOrderedList, tooltip } from '@atlaskit/editor-common/keymaps';
5
+ import { listMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
7
+ import { indentList, outdentList, toggleBulletList as toggleBulletListCommand, toggleOrderedList as toggleOrderedListCommand } from './commands';
8
+ import inputRulePlugin from './pm-plugins/input-rules';
9
+ import keymapPlugin from './pm-plugins/keymap';
10
+ import { createPlugin, pluginKey as listPluginKey } from './pm-plugins/main';
11
+ import { findRootParentListNode } from './utils/find';
12
+ import { isInsideListItem } from './utils/selection';
13
+
14
+ /*
15
+ Toolbar buttons to bullet and ordered list can be found in
16
+ packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
17
+ */
18
+ export var listPlugin = function listPlugin(options, api) {
19
+ var _api$dependencies$ana;
20
+ var featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
21
+ var editorAnalyticsAPI = api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions;
22
+ return {
23
+ name: 'list',
24
+ actions: {
25
+ indentList: indentList(editorAnalyticsAPI),
26
+ outdentList: outdentList(editorAnalyticsAPI),
27
+ toggleOrderedList: toggleOrderedListCommand(editorAnalyticsAPI),
28
+ toggleBulletList: toggleBulletListCommand(editorAnalyticsAPI),
29
+ isInsideListItem: isInsideListItem,
30
+ findRootParentListNode: findRootParentListNode
31
+ },
32
+ getSharedState: function getSharedState(editorState) {
33
+ if (!editorState) {
34
+ return undefined;
35
+ }
36
+ return listPluginKey.getState(editorState);
37
+ },
38
+ nodes: function nodes() {
39
+ return [{
40
+ name: 'bulletList',
41
+ node: bulletList
42
+ }, {
43
+ name: 'orderedList',
44
+ node: options !== null && options !== void 0 && options.restartNumberedLists ? orderedListWithOrder : orderedList
45
+ }, {
46
+ name: 'listItem',
47
+ node: listItem
48
+ }];
49
+ },
50
+ pmPlugins: function pmPlugins() {
51
+ return [{
52
+ name: 'list',
53
+ plugin: function plugin(_ref) {
54
+ var dispatch = _ref.dispatch;
55
+ return createPlugin(dispatch, featureFlags);
56
+ }
57
+ }, {
58
+ name: 'listInputRule',
59
+ plugin: function plugin(_ref2) {
60
+ var _api$dependencies$ana2;
61
+ var schema = _ref2.schema,
62
+ featureFlags = _ref2.featureFlags;
63
+ return inputRulePlugin(schema, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
64
+ }
65
+ }, {
66
+ name: 'listKeymap',
67
+ plugin: function plugin() {
68
+ var _api$dependencies$ana3;
69
+ return keymapPlugin(featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions);
70
+ }
71
+ }];
72
+ },
73
+ pluginsOptions: {
74
+ quickInsert: function quickInsert(_ref3) {
75
+ var formatMessage = _ref3.formatMessage;
76
+ return [{
77
+ id: 'unorderedList',
78
+ title: formatMessage(messages.unorderedList),
79
+ description: formatMessage(messages.unorderedListDescription),
80
+ keywords: ['ul', 'unordered'],
81
+ priority: 1100,
82
+ keyshortcut: tooltip(toggleBulletList),
83
+ icon: function icon() {
84
+ return /*#__PURE__*/React.createElement(IconList, null);
85
+ },
86
+ action: function action(insert, state) {
87
+ var tr = insert(state.schema.nodes.bulletList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
88
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
89
+ action: ACTION.INSERTED,
90
+ actionSubject: ACTION_SUBJECT.LIST,
91
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
92
+ eventType: EVENT_TYPE.TRACK,
93
+ attributes: {
94
+ inputMethod: INPUT_METHOD.QUICK_INSERT
95
+ }
96
+ })(tr);
97
+ return tr;
98
+ }
99
+ }, {
100
+ id: 'orderedList',
101
+ title: formatMessage(messages.orderedList),
102
+ description: formatMessage(messages.orderedListDescription),
103
+ keywords: ['ol', 'ordered'],
104
+ priority: 1200,
105
+ keyshortcut: tooltip(toggleOrderedList),
106
+ icon: function icon() {
107
+ return /*#__PURE__*/React.createElement(IconListNumber, null);
108
+ },
109
+ action: function action(insert, state) {
110
+ var tr = insert(state.schema.nodes.orderedList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
111
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
112
+ action: ACTION.INSERTED,
113
+ actionSubject: ACTION_SUBJECT.LIST,
114
+ actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER,
115
+ eventType: EVENT_TYPE.TRACK,
116
+ attributes: {
117
+ inputMethod: INPUT_METHOD.QUICK_INSERT
118
+ }
119
+ })(tr);
120
+ return tr;
121
+ }
122
+ }];
123
+ }
124
+ }
125
+ };
126
+ };
@@ -0,0 +1,57 @@
1
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
2
+ import { inputRuleWithAnalytics as ruleWithAnalytics } from '@atlaskit/editor-common/utils';
3
+ import { createWrappingJoinRule } from './wrapping-join-rule';
4
+ var getOrder = function getOrder(matchResult) {
5
+ return Number(matchResult[1]);
6
+ };
7
+ export function createRuleForListType(_ref) {
8
+ var listType = _ref.listType,
9
+ expression = _ref.expression,
10
+ featureFlags = _ref.featureFlags,
11
+ editorAnalyticsApi = _ref.editorAnalyticsApi;
12
+ var joinScenario = JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.NO_JOIN;
13
+ var isBulletList = listType.name === 'bulletList';
14
+ var actionSubjectId = isBulletList ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
15
+ var getAnalyticsPayload = function getAnalyticsPayload(state, matchResult) {
16
+ var analyticsPayload = {
17
+ action: ACTION.INSERTED,
18
+ actionSubject: ACTION_SUBJECT.LIST,
19
+ actionSubjectId: actionSubjectId,
20
+ eventType: EVENT_TYPE.TRACK,
21
+ attributes: {
22
+ inputMethod: INPUT_METHOD.FORMATTING
23
+ }
24
+ };
25
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && listType === state.schema.nodes.orderedList && analyticsPayload.attributes) {
26
+ analyticsPayload.attributes.listStartNumber = getOrder(matchResult);
27
+ analyticsPayload.attributes.joinScenario = joinScenario;
28
+ // we reset the tracked joinScenario after storing it in the event payload
29
+ joinScenario = JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.NO_JOIN;
30
+ }
31
+ return analyticsPayload;
32
+ };
33
+ var joinToNeighbourIfSameListType = function joinToNeighbourIfSameListType(_, node, scenario) {
34
+ var shouldJoin = node.type === listType;
35
+ if (shouldJoin) {
36
+ joinScenario = scenario;
37
+ }
38
+ return shouldJoin;
39
+ };
40
+ var getAttrs = {};
41
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ getAttrs = function getAttrs(matchResult) {
44
+ return {
45
+ order: getOrder(matchResult)
46
+ };
47
+ };
48
+ }
49
+ var inputRule = createWrappingJoinRule({
50
+ featureFlags: featureFlags,
51
+ match: expression,
52
+ nodeType: listType,
53
+ getAttrs: getAttrs,
54
+ joinPredicate: joinToNeighbourIfSameListType
55
+ });
56
+ return ruleWithAnalytics(getAnalyticsPayload, editorAnalyticsApi)(inputRule);
57
+ }
@@ -0,0 +1,32 @@
1
+ import { createPlugin } from '@atlaskit/prosemirror-input-rules';
2
+ import { createRuleForListType } from './create-list-input-rule';
3
+ export default function inputRulePlugin(schema, featureFlags, editorAnalyticsApi) {
4
+ var _schema$nodes = schema.nodes,
5
+ bulletList = _schema$nodes.bulletList,
6
+ orderedList = _schema$nodes.orderedList;
7
+ var rules = [];
8
+ if (bulletList) {
9
+ rules.push(createRuleForListType({
10
+ // Using UTF instead of • character
11
+ // because of issue where product converted the
12
+ // character into an escaped version.
13
+ expression: /^\s*([\*\-\u2022]) $/,
14
+ listType: bulletList,
15
+ featureFlags: featureFlags,
16
+ editorAnalyticsApi: editorAnalyticsApi
17
+ }));
18
+ }
19
+ var expression = featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists ? /((^[1-9]{1}[0-9]{0,2})|^(0))[\.\)] $/ : /^(1)[\.\)] $/;
20
+ if (orderedList) {
21
+ rules.push(createRuleForListType({
22
+ expression: expression,
23
+ listType: orderedList,
24
+ featureFlags: featureFlags,
25
+ editorAnalyticsApi: editorAnalyticsApi
26
+ }));
27
+ }
28
+ if (rules.length !== 0) {
29
+ return createPlugin('lists', rules);
30
+ }
31
+ return;
32
+ }
@@ -0,0 +1,54 @@
1
+ import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
2
+ import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
3
+ import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
4
+ import { createRule } from '@atlaskit/prosemirror-input-rules';
5
+
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ export var createWrappingJoinRule = function createWrappingJoinRule(_ref) {
9
+ var match = _ref.match,
10
+ nodeType = _ref.nodeType,
11
+ getAttrs = _ref.getAttrs,
12
+ joinPredicate = _ref.joinPredicate,
13
+ featureFlags = _ref.featureFlags;
14
+ var handler = function handler(state, match, start, end) {
15
+ var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
16
+ var tr = state.tr;
17
+ var fixedStart = Math.max(start, 1);
18
+ tr.delete(fixedStart, end);
19
+ var $start = tr.doc.resolve(fixedStart);
20
+ var range = $start.blockRange();
21
+ var wrapping = range && findWrapping(range, nodeType, attrs);
22
+ if (!wrapping || !range) {
23
+ return null;
24
+ }
25
+ var parentNodePosMapped = tr.mapping.map(range.start);
26
+ var parentNode = tr.doc.nodeAt(parentNodePosMapped);
27
+ var lastWrap = wrapping[wrapping.length - 1];
28
+ if (parentNode && lastWrap) {
29
+ var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
30
+ tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
31
+ }
32
+ tr.wrap(range, wrapping);
33
+ if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && nodeType === state.schema.nodes.orderedList) {
34
+ // if an orderedList node would be inserted by the input rule match, and
35
+ // that orderedList node is being added directly before another orderedList
36
+ // node, then join those nodes
37
+ var $end = tr.doc.resolve(tr.mapping.map(end));
38
+ var _node = findParentNodeOfTypeClosestToPos($end, nodeType);
39
+ if (_node) {
40
+ var nodeEnd = _node.pos + _node.node.nodeSize;
41
+ var after = tr.doc.resolve(nodeEnd).nodeAfter;
42
+ if (after && after.type === nodeType && canJoin(tr.doc, nodeEnd) && (!joinPredicate || joinPredicate(match, after, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_BELOW))) {
43
+ tr.join(nodeEnd);
44
+ }
45
+ }
46
+ }
47
+ var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
48
+ if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
49
+ tr.join(fixedStart - 1);
50
+ }
51
+ return tr;
52
+ };
53
+ return createRule(match, handler);
54
+ };
@@ -0,0 +1,19 @@
1
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
+ import { backspace, bindKeymapWithCommand, deleteKey, enter, findKeyMapForBrowser, findShortcutByKeymap, forwardDelete, indentList, outdentList, toggleBulletList, toggleOrderedList } from '@atlaskit/editor-common/keymaps';
3
+ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
4
+ import { backspaceKeyCommand, deleteKeyCommand, enterKeyCommand, indentList as indentListCommand, outdentList as outdentListCommand, toggleList } from '../commands';
5
+ export function keymapPlugin(featureFlags, editorAnalyticsAPI) {
6
+ var list = {};
7
+ bindKeymapWithCommand(findShortcutByKeymap(toggleOrderedList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'orderedList'), list);
8
+ bindKeymapWithCommand(findShortcutByKeymap(toggleBulletList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'bulletList'), list);
9
+ bindKeymapWithCommand(indentList.common, indentListCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
10
+ bindKeymapWithCommand(outdentList.common, outdentListCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, featureFlags), list);
11
+ bindKeymapWithCommand(enter.common, enterKeyCommand(editorAnalyticsAPI)(featureFlags), list);
12
+ bindKeymapWithCommand(backspace.common, backspaceKeyCommand(editorAnalyticsAPI)(featureFlags), list);
13
+ bindKeymapWithCommand(deleteKey.common, deleteKeyCommand(editorAnalyticsAPI), list);
14
+
15
+ // This shortcut is Mac only
16
+ bindKeymapWithCommand(findKeyMapForBrowser(forwardDelete), deleteKeyCommand(editorAnalyticsAPI), list);
17
+ return keymap(list);
18
+ }
19
+ export default keymapPlugin;