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