@atlaskit/editor-core 187.28.5 → 187.29.2

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 (220) 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/utils/commands.js +1 -33
  9. package/dist/cjs/utils/index.js +0 -13
  10. package/dist/cjs/utils/mark.js +2 -46
  11. package/dist/cjs/utils/selection.js +0 -5
  12. package/dist/cjs/version-wrapper.js +1 -1
  13. package/dist/es2019/index.js +0 -1
  14. package/dist/es2019/labs/next/presets/universal.js +2 -1
  15. package/dist/es2019/plugins/analytics/index.js +1 -1
  16. package/dist/es2019/plugins/analytics/types/index.js +1 -1
  17. package/dist/es2019/plugins/index.js +0 -1
  18. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/commands.js +1 -1
  19. package/dist/es2019/utils/commands.js +1 -33
  20. package/dist/es2019/utils/index.js +1 -2
  21. package/dist/es2019/utils/mark.js +0 -41
  22. package/dist/es2019/utils/selection.js +0 -6
  23. package/dist/es2019/version-wrapper.js +1 -1
  24. package/dist/esm/index.js +0 -1
  25. package/dist/esm/labs/next/presets/universal.js +2 -1
  26. package/dist/esm/plugins/analytics/index.js +1 -1
  27. package/dist/esm/plugins/analytics/types/index.js +1 -1
  28. package/dist/esm/plugins/index.js +0 -1
  29. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/commands.js +1 -1
  30. package/dist/esm/utils/commands.js +1 -31
  31. package/dist/esm/utils/index.js +1 -2
  32. package/dist/esm/utils/mark.js +0 -42
  33. package/dist/esm/utils/selection.js +0 -4
  34. package/dist/esm/version-wrapper.js +1 -1
  35. package/dist/types/index.d.ts +0 -3
  36. package/dist/types/plugins/analytics/index.d.ts +1 -1
  37. package/dist/types/plugins/analytics/types/index.d.ts +1 -1
  38. package/dist/types/plugins/index.d.ts +0 -1
  39. package/dist/types/plugins/paste/index.d.ts +1 -1
  40. package/dist/types/utils/commands.d.ts +1 -4
  41. package/dist/types/utils/index.d.ts +1 -2
  42. package/dist/types/utils/mark.d.ts +2 -12
  43. package/dist/types/utils/selection.d.ts +0 -2
  44. package/dist/types-ts4.5/index.d.ts +0 -3
  45. package/dist/types-ts4.5/plugins/analytics/index.d.ts +1 -1
  46. package/dist/types-ts4.5/plugins/analytics/types/index.d.ts +1 -1
  47. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  48. package/dist/types-ts4.5/plugins/paste/index.d.ts +1 -1
  49. package/dist/types-ts4.5/utils/commands.d.ts +1 -4
  50. package/dist/types-ts4.5/utils/index.d.ts +1 -2
  51. package/dist/types-ts4.5/utils/mark.d.ts +2 -12
  52. package/dist/types-ts4.5/utils/selection.d.ts +0 -2
  53. package/package.json +7 -3
  54. package/report.api.md +0 -9
  55. package/tmp/api-report-tmp.d.ts +0 -9
  56. package/dist/cjs/plugins/list/actions/conversions.js +0 -153
  57. package/dist/cjs/plugins/list/actions/indent-list-items-selected.js +0 -125
  58. package/dist/cjs/plugins/list/actions/indent-list.js +0 -49
  59. package/dist/cjs/plugins/list/actions/join-list-items-forward.js +0 -59
  60. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/index.js +0 -40
  61. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -88
  62. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -85
  63. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -79
  64. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -45
  65. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -56
  66. package/dist/cjs/plugins/list/actions/merge-lists.js +0 -27
  67. package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +0 -291
  68. package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +0 -98
  69. package/dist/cjs/plugins/list/commands/indent-list.js +0 -71
  70. package/dist/cjs/plugins/list/commands/index.js +0 -348
  71. package/dist/cjs/plugins/list/commands/join-list-item-forward.js +0 -61
  72. package/dist/cjs/plugins/list/commands/listBackspace.js +0 -284
  73. package/dist/cjs/plugins/list/commands/outdent-list.js +0 -70
  74. package/dist/cjs/plugins/list/index.js +0 -133
  75. package/dist/cjs/plugins/list/messages.js +0 -37
  76. package/dist/cjs/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -61
  77. package/dist/cjs/plugins/list/pm-plugins/input-rules/index.js +0 -36
  78. package/dist/cjs/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -58
  79. package/dist/cjs/plugins/list/pm-plugins/keymap.js +0 -27
  80. package/dist/cjs/plugins/list/pm-plugins/main.js +0 -168
  81. package/dist/cjs/plugins/list/transforms.js +0 -100
  82. package/dist/cjs/plugins/list/types.js +0 -8
  83. package/dist/cjs/plugins/list/utils/analytics.js +0 -22
  84. package/dist/cjs/plugins/list/utils/find.js +0 -68
  85. package/dist/cjs/plugins/list/utils/indentation.js +0 -22
  86. package/dist/cjs/plugins/list/utils/node.js +0 -16
  87. package/dist/cjs/plugins/list/utils/selection.js +0 -95
  88. package/dist/cjs/utils/input-rules.js +0 -30
  89. package/dist/es2019/plugins/list/actions/conversions.js +0 -160
  90. package/dist/es2019/plugins/list/actions/indent-list-items-selected.js +0 -124
  91. package/dist/es2019/plugins/list/actions/indent-list.js +0 -44
  92. package/dist/es2019/plugins/list/actions/join-list-items-forward.js +0 -54
  93. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/index.js +0 -5
  94. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -74
  95. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -78
  96. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -72
  97. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -37
  98. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -48
  99. package/dist/es2019/plugins/list/actions/merge-lists.js +0 -24
  100. package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +0 -295
  101. package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +0 -91
  102. package/dist/es2019/plugins/list/commands/indent-list.js +0 -62
  103. package/dist/es2019/plugins/list/commands/index.js +0 -322
  104. package/dist/es2019/plugins/list/commands/join-list-item-forward.js +0 -53
  105. package/dist/es2019/plugins/list/commands/listBackspace.js +0 -276
  106. package/dist/es2019/plugins/list/commands/outdent-list.js +0 -60
  107. package/dist/es2019/plugins/list/index.js +0 -120
  108. package/dist/es2019/plugins/list/messages.js +0 -29
  109. package/dist/es2019/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -55
  110. package/dist/es2019/plugins/list/pm-plugins/input-rules/index.js +0 -33
  111. package/dist/es2019/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -52
  112. package/dist/es2019/plugins/list/pm-plugins/keymap.js +0 -19
  113. package/dist/es2019/plugins/list/pm-plugins/main.js +0 -159
  114. package/dist/es2019/plugins/list/transforms.js +0 -102
  115. package/dist/es2019/plugins/list/types.js +0 -1
  116. package/dist/es2019/plugins/list/utils/analytics.js +0 -12
  117. package/dist/es2019/plugins/list/utils/find.js +0 -61
  118. package/dist/es2019/plugins/list/utils/indentation.js +0 -16
  119. package/dist/es2019/plugins/list/utils/node.js +0 -12
  120. package/dist/es2019/plugins/list/utils/selection.js +0 -96
  121. package/dist/es2019/utils/input-rules.js +0 -20
  122. package/dist/esm/plugins/list/actions/conversions.js +0 -147
  123. package/dist/esm/plugins/list/actions/indent-list-items-selected.js +0 -117
  124. package/dist/esm/plugins/list/actions/indent-list.js +0 -43
  125. package/dist/esm/plugins/list/actions/join-list-items-forward.js +0 -52
  126. package/dist/esm/plugins/list/actions/join-list-items-scenarios/index.js +0 -5
  127. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -81
  128. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -79
  129. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -73
  130. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -38
  131. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -49
  132. package/dist/esm/plugins/list/actions/merge-lists.js +0 -21
  133. package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +0 -283
  134. package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +0 -92
  135. package/dist/esm/plugins/list/commands/indent-list.js +0 -63
  136. package/dist/esm/plugins/list/commands/index.js +0 -320
  137. package/dist/esm/plugins/list/commands/join-list-item-forward.js +0 -53
  138. package/dist/esm/plugins/list/commands/listBackspace.js +0 -275
  139. package/dist/esm/plugins/list/commands/outdent-list.js +0 -62
  140. package/dist/esm/plugins/list/index.js +0 -127
  141. package/dist/esm/plugins/list/messages.js +0 -29
  142. package/dist/esm/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -56
  143. package/dist/esm/plugins/list/pm-plugins/input-rules/index.js +0 -30
  144. package/dist/esm/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -51
  145. package/dist/esm/plugins/list/pm-plugins/keymap.js +0 -19
  146. package/dist/esm/plugins/list/pm-plugins/main.js +0 -159
  147. package/dist/esm/plugins/list/transforms.js +0 -92
  148. package/dist/esm/plugins/list/types.js +0 -1
  149. package/dist/esm/plugins/list/utils/analytics.js +0 -12
  150. package/dist/esm/plugins/list/utils/find.js +0 -59
  151. package/dist/esm/plugins/list/utils/indentation.js +0 -16
  152. package/dist/esm/plugins/list/utils/node.js +0 -10
  153. package/dist/esm/plugins/list/utils/selection.js +0 -81
  154. package/dist/esm/utils/input-rules.js +0 -22
  155. package/dist/types/plugins/list/actions/conversions.d.ts +0 -6
  156. package/dist/types/plugins/list/actions/indent-list-items-selected.d.ts +0 -2
  157. package/dist/types/plugins/list/actions/indent-list.d.ts +0 -2
  158. package/dist/types/plugins/list/actions/join-list-items-forward.d.ts +0 -13
  159. package/dist/types/plugins/list/actions/join-list-items-scenarios/index.d.ts +0 -5
  160. package/dist/types/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +0 -9
  161. package/dist/types/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +0 -9
  162. package/dist/types/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +0 -9
  163. package/dist/types/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +0 -9
  164. package/dist/types/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +0 -9
  165. package/dist/types/plugins/list/actions/merge-lists.d.ts +0 -7
  166. package/dist/types/plugins/list/actions/outdent-list-items-selected.d.ts +0 -3
  167. package/dist/types/plugins/list/actions/wrap-and-join-lists.d.ts +0 -15
  168. package/dist/types/plugins/list/commands/indent-list.d.ts +0 -6
  169. package/dist/types/plugins/list/commands/index.d.ts +0 -17
  170. package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +0 -3
  171. package/dist/types/plugins/list/commands/listBackspace.d.ts +0 -10
  172. package/dist/types/plugins/list/commands/outdent-list.d.ts +0 -7
  173. package/dist/types/plugins/list/index.d.ts +0 -3
  174. package/dist/types/plugins/list/messages.d.ts +0 -27
  175. package/dist/types/plugins/list/pm-plugins/input-rules/create-list-input-rule.d.ts +0 -9
  176. package/dist/types/plugins/list/pm-plugins/input-rules/index.d.ts +0 -4
  177. package/dist/types/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +0 -12
  178. package/dist/types/plugins/list/pm-plugins/keymap.d.ts +0 -5
  179. package/dist/types/plugins/list/pm-plugins/main.d.ts +0 -11
  180. package/dist/types/plugins/list/transforms.d.ts +0 -4
  181. package/dist/types/plugins/list/types.d.ts +0 -4
  182. package/dist/types/plugins/list/utils/analytics.d.ts +0 -5
  183. package/dist/types/plugins/list/utils/find.d.ts +0 -10
  184. package/dist/types/plugins/list/utils/indentation.d.ts +0 -2
  185. package/dist/types/plugins/list/utils/node.d.ts +0 -2
  186. package/dist/types/plugins/list/utils/selection.d.ts +0 -14
  187. package/dist/types/utils/input-rules.d.ts +0 -10
  188. package/dist/types-ts4.5/plugins/list/actions/conversions.d.ts +0 -6
  189. package/dist/types-ts4.5/plugins/list/actions/indent-list-items-selected.d.ts +0 -2
  190. package/dist/types-ts4.5/plugins/list/actions/indent-list.d.ts +0 -2
  191. package/dist/types-ts4.5/plugins/list/actions/join-list-items-forward.d.ts +0 -16
  192. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/index.d.ts +0 -5
  193. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +0 -9
  194. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +0 -9
  195. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +0 -9
  196. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +0 -9
  197. package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +0 -9
  198. package/dist/types-ts4.5/plugins/list/actions/merge-lists.d.ts +0 -7
  199. package/dist/types-ts4.5/plugins/list/actions/outdent-list-items-selected.d.ts +0 -3
  200. package/dist/types-ts4.5/plugins/list/actions/wrap-and-join-lists.d.ts +0 -15
  201. package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +0 -6
  202. package/dist/types-ts4.5/plugins/list/commands/index.d.ts +0 -17
  203. package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +0 -3
  204. package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +0 -13
  205. package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +0 -7
  206. package/dist/types-ts4.5/plugins/list/index.d.ts +0 -3
  207. package/dist/types-ts4.5/plugins/list/messages.d.ts +0 -27
  208. package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/create-list-input-rule.d.ts +0 -9
  209. package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/index.d.ts +0 -4
  210. package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +0 -12
  211. package/dist/types-ts4.5/plugins/list/pm-plugins/keymap.d.ts +0 -5
  212. package/dist/types-ts4.5/plugins/list/pm-plugins/main.d.ts +0 -11
  213. package/dist/types-ts4.5/plugins/list/transforms.d.ts +0 -4
  214. package/dist/types-ts4.5/plugins/list/types.d.ts +0 -4
  215. package/dist/types-ts4.5/plugins/list/utils/analytics.d.ts +0 -5
  216. package/dist/types-ts4.5/plugins/list/utils/find.d.ts +0 -10
  217. package/dist/types-ts4.5/plugins/list/utils/indentation.d.ts +0 -2
  218. package/dist/types-ts4.5/plugins/list/utils/node.d.ts +0 -2
  219. package/dist/types-ts4.5/plugins/list/utils/selection.d.ts +0 -14
  220. package/dist/types-ts4.5/utils/input-rules.d.ts +0 -10
@@ -1,348 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.enterKeyCommand = exports.deleteKeyCommand = exports.backspaceKeyCommand = void 0;
9
- Object.defineProperty(exports, "indentList", {
10
- enumerable: true,
11
- get: function get() {
12
- return _indentList.indentList;
13
- }
14
- });
15
- Object.defineProperty(exports, "outdentList", {
16
- enumerable: true,
17
- get: function get() {
18
- return _outdentList.outdentList;
19
- }
20
- });
21
- exports.toggleOrderedList = exports.toggleList = exports.toggleBulletList = exports.rootListDepth = void 0;
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
- var _model = require("@atlaskit/editor-prosemirror/model");
24
- var _state = require("@atlaskit/editor-prosemirror/state");
25
- var baseCommand = _interopRequireWildcard(require("@atlaskit/editor-prosemirror/commands"));
26
- var _utils = require("@atlaskit/editor-prosemirror/utils");
27
- var _utils2 = require("@atlaskit/editor-common/utils");
28
- var _commands2 = require("../../../utils/commands");
29
- var _utils3 = require("../../../utils");
30
- var _lists = require("@atlaskit/editor-common/lists");
31
- var _transforms = require("../transforms");
32
- var _gapCursorSelection = require("../../selection/gap-cursor-selection");
33
- var _analytics = require("@atlaskit/editor-common/analytics");
34
- var _selection = require("../utils/selection");
35
- var _listBackspace = require("./listBackspace");
36
- var _joinListItemForward = require("./join-list-item-forward");
37
- var _conversions = require("../actions/conversions");
38
- var _wrapAndJoinLists = require("../actions/wrap-and-join-lists");
39
- var _outdentList = require("./outdent-list");
40
- var _indentList = require("./indent-list");
41
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
42
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
43
- 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; }
44
- 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; }
45
- var enterKeyCommand = function enterKeyCommand(editorAnalyticsAPI) {
46
- return function (featureFlags) {
47
- return function (state, dispatch) {
48
- var selection = state.selection;
49
- if (selection.empty) {
50
- var $from = selection.$from;
51
- var _state$schema$nodes = state.schema.nodes,
52
- listItem = _state$schema$nodes.listItem,
53
- codeBlock = _state$schema$nodes.codeBlock;
54
- var wrapper = $from.node($from.depth - 1);
55
- if (wrapper && wrapper.type === listItem) {
56
- /** Check if the wrapper has any visible content */
57
- var wrapperHasContent = (0, _utils2.hasVisibleContent)(wrapper);
58
- if (!wrapperHasContent) {
59
- return (0, _outdentList.outdentList)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD, featureFlags)(state, dispatch);
60
- } else if (!(0, _utils.hasParentNodeOfType)(codeBlock)(selection)) {
61
- return splitListItem(listItem)(state, dispatch);
62
- }
63
- }
64
- }
65
- return false;
66
- };
67
- };
68
- };
69
- exports.enterKeyCommand = enterKeyCommand;
70
- var backspaceKeyCommand = function backspaceKeyCommand(editorAnalyticsAPI) {
71
- return function (featureFlags) {
72
- return function (state, dispatch) {
73
- return baseCommand.chainCommands((0, _listBackspace.listBackspace)(editorAnalyticsAPI),
74
- // if we're at the start of a list item, we need to either backspace
75
- // directly to an empty list item above, or outdent this node
76
- (0, _utils2.filterCommand)([_utils2.isEmptySelectionAtStart,
77
- // list items might have multiple paragraphs; only do this at the first one
78
- _commands2.isFirstChildOfParent, _selection.isInsideListItem], baseCommand.chainCommands(deletePreviousEmptyListItem, (0, _outdentList.outdentList)(editorAnalyticsAPI)(_analytics.INPUT_METHOD.KEYBOARD, featureFlags))),
79
- // if we're just inside a paragraph node (or gapcursor is shown) and backspace, then try to join
80
- // the text to the previous list item, if one exists
81
- (0, _utils2.filterCommand)([_utils2.isEmptySelectionAtStart, _selection.canJoinToPreviousListItem], joinToPreviousListItem))(state, dispatch);
82
- };
83
- };
84
- };
85
- exports.backspaceKeyCommand = backspaceKeyCommand;
86
- var deleteKeyCommand = function deleteKeyCommand(editorAnalyticsAPI) {
87
- return (0, _joinListItemForward.joinListItemForward)(editorAnalyticsAPI);
88
- };
89
-
90
- // Get the depth of the nearest ancestor list
91
- exports.deleteKeyCommand = deleteKeyCommand;
92
- var rootListDepth = function rootListDepth(pos, nodes) {
93
- var bulletList = nodes.bulletList,
94
- orderedList = nodes.orderedList,
95
- listItem = nodes.listItem;
96
- var depth;
97
- for (var i = pos.depth - 1; i > 0; i--) {
98
- var node = pos.node(i);
99
- if (node.type === bulletList || node.type === orderedList) {
100
- depth = i;
101
- }
102
- if (node.type !== bulletList && node.type !== orderedList && node.type !== listItem) {
103
- break;
104
- }
105
- }
106
- return depth;
107
- };
108
- exports.rootListDepth = rootListDepth;
109
- function untoggleSelectedList(tr) {
110
- var _tr = tr,
111
- selection = _tr.selection;
112
- var depth = rootListDepth(selection.$to, tr.doc.type.schema.nodes);
113
- tr = (0, _transforms.liftFollowingList)(selection.$to.pos, selection.$to.end(depth), depth || 0, tr);
114
- if (selection instanceof _state.NodeSelection || selection instanceof _gapCursorSelection.GapCursorSelection) {
115
- return (0, _transforms.liftNodeSelectionList)(selection, tr);
116
- }
117
- return (0, _transforms.liftTextSelectionList)(selection, tr);
118
- }
119
- var toggleList = function toggleList(editorAnalyticsAPI) {
120
- return function (inputMethod, listType) {
121
- return function (state, dispatch) {
122
- var tr = state.tr;
123
- var listInsideSelection = (0, _selection.selectionContainsList)(tr);
124
- var listNodeType = state.schema.nodes[listType];
125
- var actionSubjectId = listType === 'bulletList' ? _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
126
- if (listInsideSelection) {
127
- var selection = state.selection;
128
-
129
- // for gap cursor or node selection - list is expected 1 level up (listItem -> list)
130
- // for text selection - list is expected 2 levels up (paragraph -> listItem -> list)
131
- var positionDiff = selection instanceof _gapCursorSelection.GapCursorSelection || selection instanceof _state.NodeSelection ? 1 : 2;
132
- var fromNode = selection.$from.node(selection.$from.depth - positionDiff);
133
- var toNode = selection.$to.node(selection.$to.depth - positionDiff);
134
- var transformedFrom = listInsideSelection.type.name === 'bulletList' ? _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
135
- if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type.name) === listType && (toNode === null || toNode === void 0 ? void 0 : toNode.type.name) === listType) {
136
- var _tr2 = state.tr;
137
- untoggleSelectedList(_tr2);
138
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
139
- action: _analytics.ACTION.CONVERTED,
140
- actionSubject: _analytics.ACTION_SUBJECT.LIST,
141
- actionSubjectId: _analytics.ACTION_SUBJECT_ID.TEXT,
142
- eventType: _analytics.EVENT_TYPE.TRACK,
143
- attributes: _objectSpread(_objectSpread({}, (0, _lists.getCommonListAnalyticsAttributes)(state)), {}, {
144
- transformedFrom: transformedFrom,
145
- inputMethod: inputMethod
146
- })
147
- })(_tr2);
148
- if (dispatch) {
149
- dispatch(_tr2);
150
- }
151
- return true;
152
- }
153
- (0, _conversions.convertListType)({
154
- tr: tr,
155
- nextListNodeType: listNodeType
156
- });
157
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
158
- action: _analytics.ACTION.CONVERTED,
159
- actionSubject: _analytics.ACTION_SUBJECT.LIST,
160
- actionSubjectId: actionSubjectId,
161
- eventType: _analytics.EVENT_TYPE.TRACK,
162
- attributes: _objectSpread(_objectSpread({}, (0, _lists.getCommonListAnalyticsAttributes)(state)), {}, {
163
- transformedFrom: transformedFrom,
164
- inputMethod: inputMethod
165
- })
166
- })(tr);
167
- } else {
168
- // Need to have this before wrapInList so the wrapping is done with valid content
169
- // For example, if trying to convert centre or right aligned paragraphs to lists
170
- (0, _utils3.sanitiseMarksInSelection)(tr, listNodeType);
171
- (0, _wrapAndJoinLists.wrapInListAndJoin)(listNodeType, tr);
172
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
173
- action: _analytics.ACTION.INSERTED,
174
- actionSubject: _analytics.ACTION_SUBJECT.LIST,
175
- actionSubjectId: actionSubjectId,
176
- eventType: _analytics.EVENT_TYPE.TRACK,
177
- attributes: {
178
- inputMethod: inputMethod
179
- }
180
- })(tr);
181
- }
182
-
183
- // If document wasn't changed, return false from the command to indicate that the
184
- // editing action failed
185
- if (!tr.docChanged) {
186
- return false;
187
- }
188
- if (dispatch) {
189
- dispatch(tr);
190
- }
191
- return true;
192
- };
193
- };
194
- };
195
- exports.toggleList = toggleList;
196
- var toggleBulletList = function toggleBulletList(editorAnalyticsAPI) {
197
- return function (view) {
198
- var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
199
- return toggleList(editorAnalyticsAPI)(inputMethod, 'bulletList')(view.state, view.dispatch);
200
- };
201
- };
202
- exports.toggleBulletList = toggleBulletList;
203
- var toggleOrderedList = function toggleOrderedList(editorAnalyticsAPI) {
204
- return function (view) {
205
- var inputMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _analytics.INPUT_METHOD.TOOLBAR;
206
- return toggleList(editorAnalyticsAPI)(inputMethod, 'orderedList')(view.state, view.dispatch);
207
- };
208
- };
209
-
210
- /**
211
- * Implementation taken and modified for our needs from PM
212
- * @param itemType Node
213
- * Splits the list items, specific implementation take from PM
214
- */
215
- exports.toggleOrderedList = toggleOrderedList;
216
- function splitListItem(itemType) {
217
- return function (state, dispatch) {
218
- var ref = state.selection;
219
- var $from = ref.$from;
220
- var $to = ref.$to;
221
- var node = ref.node;
222
- if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
223
- return false;
224
- }
225
- var grandParent = $from.node(-1);
226
- if (grandParent.type !== itemType) {
227
- return false;
228
- }
229
- /** --> The following line changed from the original PM implementation to allow list additions with multiple paragraphs */
230
- if (grandParent.content.content.length <= 1 && $from.parent.content.size === 0 && !(grandParent.content.size === 0)) {
231
- // In an empty block. If this is a nested list, the wrapping
232
- // list item should be split. Otherwise, bail out and let next
233
- // command handle lifting.
234
- if ($from.depth === 2 || $from.node(-3).type !== itemType || $from.index(-2) !== $from.node(-2).childCount - 1) {
235
- return false;
236
- }
237
- if (dispatch) {
238
- var wrap = _model.Fragment.empty;
239
- var keepItem = $from.index(-1) > 0;
240
- // Build a fragment containing empty versions of the structure
241
- // from the outer list item to the parent node of the cursor
242
- for (var d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) {
243
- wrap = _model.Fragment.from($from.node(d).copy(wrap));
244
- }
245
- // Add a second list item with an empty default start node
246
- wrap = wrap.append(_model.Fragment.from(itemType.createAndFill()));
247
- var tr$1 = state.tr.replace($from.before(keepItem ? undefined : -1), $from.after(-3), new _model.Slice(wrap, keepItem ? 3 : 2, 2));
248
- tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve($from.pos + (keepItem ? 3 : 2))));
249
- dispatch(tr$1.scrollIntoView());
250
- }
251
- return true;
252
- }
253
- var nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : undefined;
254
- var tr = state.tr.delete($from.pos, $to.pos);
255
- var types = nextType && [undefined, {
256
- type: nextType
257
- }];
258
- if (dispatch) {
259
- dispatch(tr.split($from.pos, 2, types).scrollIntoView());
260
- }
261
- return true;
262
- };
263
- }
264
- var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
265
- var $from = state.selection.$from;
266
- var listItem = state.schema.nodes.listItem;
267
- var $cut = (0, _commands2.findCutBefore)($from);
268
- if (!$cut || !$cut.nodeBefore || !($cut.nodeBefore.type === listItem)) {
269
- return false;
270
- }
271
- var previousListItemEmpty = $cut.nodeBefore.childCount === 1 && $cut.nodeBefore.firstChild.nodeSize <= 2;
272
- if (previousListItemEmpty) {
273
- var tr = state.tr;
274
- if (dispatch) {
275
- dispatch(tr.delete($cut.pos - $cut.nodeBefore.nodeSize, $from.pos).scrollIntoView());
276
- }
277
- return true;
278
- }
279
- return false;
280
- };
281
- var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
282
- var $from = state.selection.$from;
283
- var _state$schema$nodes2 = state.schema.nodes,
284
- paragraph = _state$schema$nodes2.paragraph,
285
- listItem = _state$schema$nodes2.listItem,
286
- codeBlock = _state$schema$nodes2.codeBlock,
287
- bulletList = _state$schema$nodes2.bulletList,
288
- orderedList = _state$schema$nodes2.orderedList;
289
- var isGapCursorShown = state.selection instanceof _gapCursorSelection.GapCursorSelection;
290
- var $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
291
- var $cut = (0, _commands2.findCutBefore)($cutPos);
292
- if (!$cut) {
293
- return false;
294
- }
295
-
296
- // see if the containing node is a list
297
- if ($cut.nodeBefore && [bulletList, orderedList].indexOf($cut.nodeBefore.type) > -1) {
298
- // and the node after this is a paragraph or a codeBlock
299
- if ($cut.nodeAfter && ($cut.nodeAfter.type === paragraph || $cut.nodeAfter.type === codeBlock)) {
300
- // find the nearest paragraph that precedes this node
301
- var $lastNode = $cut.doc.resolve($cut.pos - 1);
302
- while ($lastNode.parent.type !== paragraph) {
303
- $lastNode = state.doc.resolve($lastNode.pos - 1);
304
- }
305
- var tr = state.tr;
306
- if (isGapCursorShown) {
307
- var nodeBeforePos = (0, _utils.findPositionOfNodeBefore)(tr.selection);
308
- if (typeof nodeBeforePos !== 'number') {
309
- return false;
310
- }
311
- // append the codeblock to the list node
312
- var list = $cut.nodeBefore.copy($cut.nodeBefore.content.append(_model.Fragment.from(listItem.createChecked({}, $cut.nodeAfter))));
313
- tr.replaceWith(nodeBeforePos, $from.pos + $cut.nodeAfter.nodeSize, list);
314
- } else {
315
- var step = (0, _lists.moveTargetIntoList)({
316
- insertPosition: $lastNode.pos,
317
- $target: $cut
318
- });
319
-
320
- // ED-13966: check if the step will cause an ProseMirror error
321
- // if there's an error don't apply the step as it will might lead into a data loss.
322
- // It doesn't play well with media being a leaf node.
323
- var stepResult = state.tr.maybeStep(step);
324
- if (stepResult.failed) {
325
- return false;
326
- } else {
327
- tr = state.tr.step(step);
328
- }
329
- }
330
-
331
- // find out if there's now another list following and join them
332
- // as in, [list, p, list] => [list with p, list], and we want [joined list]
333
- var $postCut = tr.doc.resolve(tr.mapping.map($cut.pos + $cut.nodeAfter.nodeSize));
334
- if ($postCut.nodeBefore && $postCut.nodeAfter && $postCut.nodeBefore.type === $postCut.nodeAfter.type && [bulletList, orderedList].indexOf($postCut.nodeBefore.type) > -1) {
335
- tr = tr.join($postCut.pos);
336
- }
337
- if (dispatch) {
338
- var _tr$doc$resolve$nodeB;
339
- if (!((_tr$doc$resolve$nodeB = tr.doc.resolve($lastNode.pos).nodeBefore) !== null && _tr$doc$resolve$nodeB !== void 0 && _tr$doc$resolve$nodeB.isBlock) || tr.doc.resolve($lastNode.pos).nodeBefore === null) {
340
- tr = tr.setSelection(_state.TextSelection.near(tr.doc.resolve(tr.mapping.map($cut.pos)), -1));
341
- }
342
- dispatch(tr.scrollIntoView());
343
- }
344
- return true;
345
- }
346
- }
347
- return false;
348
- };
@@ -1,61 +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.joinListItemForward = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
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 _joinListItemsForward = require("../actions/join-list-items-forward");
13
- var joinListItemForward = function joinListItemForward(editorAnalyticsAPI) {
14
- return function (state, dispatch) {
15
- var tr = state.tr,
16
- $head = state.selection.$head;
17
- var walkNode = (0, _utils.walkNextNode)($head);
18
- if (!(0, _utils.isEmptySelectionAtEnd)(state)) {
19
- return false;
20
- }
21
- var scenarios = (0, _joinListItemsForward.calcJoinListScenario)(walkNode, $head);
22
- if (!scenarios) {
23
- return false;
24
- }
25
- var _scenarios = (0, _slicedToArray2.default)(scenarios, 2),
26
- scenario = _scenarios[0],
27
- action = _scenarios[1];
28
- var result = action({
29
- tr: tr,
30
- $next: walkNode.$pos,
31
- $head: $head
32
- });
33
- if (!result) {
34
- return false;
35
- }
36
- var _state$schema$nodes = state.schema.nodes,
37
- bulletList = _state$schema$nodes.bulletList,
38
- orderedList = _state$schema$nodes.orderedList;
39
- var listParent = (0, _utils2.findParentNodeOfType)([bulletList, orderedList])(tr.selection);
40
- var actionSubjectId = _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET;
41
- if (listParent && listParent.node.type === orderedList) {
42
- actionSubjectId = _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
43
- }
44
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
45
- action: _analytics.ACTION.LIST_ITEM_JOINED,
46
- actionSubject: _analytics.ACTION_SUBJECT.LIST,
47
- actionSubjectId: actionSubjectId,
48
- eventType: _analytics.EVENT_TYPE.TRACK,
49
- attributes: {
50
- inputMethod: _analytics.INPUT_METHOD.KEYBOARD,
51
- direction: _analytics.DELETE_DIRECTION.FORWARD,
52
- scenario: scenario
53
- }
54
- })(tr);
55
- if (dispatch) {
56
- dispatch(tr);
57
- }
58
- return true;
59
- };
60
- };
61
- exports.joinListItemForward = joinListItemForward;