@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,291 +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.outdentListItemsSelected = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _state = require("@atlaskit/editor-prosemirror/state");
10
- var _model = require("@atlaskit/editor-prosemirror/model");
11
- var _transform = require("@atlaskit/editor-prosemirror/transform");
12
- var _utils = require("@atlaskit/editor-common/utils");
13
- var _lists = require("@atlaskit/editor-common/lists");
14
- var _find = require("../utils/find");
15
- var _selection = require("../utils/selection");
16
- var _gapCursorSelection = require("../../selection/gap-cursor-selection");
17
- var _analytics = require("../utils/analytics");
18
- var _analytics2 = require("@atlaskit/editor-common/analytics");
19
- 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; }
20
- 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; }
21
- var outdentListItemsSelected = function outdentListItemsSelected(tr, state, featureFlags) {
22
- var originalSelection = tr.selection;
23
- var normalizedSelection = (0, _lists.normalizeListItemsSelection)({
24
- selection: tr.selection,
25
- doc: tr.doc
26
- });
27
- var rootList = (0, _find.findRootParentListNode)(normalizedSelection.$from);
28
- if (!rootList) {
29
- return;
30
- }
31
- var commonList = normalizedSelection.$from.blockRange(rootList, _utils.isListNode);
32
- if (!commonList) {
33
- return;
34
- }
35
- var hasNormalizedToPositionLiftedOut = false;
36
- var hasNormalizedFromPositionLiftedOut = false;
37
- var oldFrom = normalizedSelection.from,
38
- oldTo = normalizedSelection.to;
39
- var nodeRanges = splitRangeSelection(normalizedSelection);
40
- nodeRanges.forEach(function (range) {
41
- var $from = tr.doc.resolve(tr.mapping.map(range.from));
42
- var $to = tr.doc.resolve(tr.mapping.map(range.to));
43
- var mappedRange = $from.blockRange($to, _utils.isListNode);
44
- if (!mappedRange) {
45
- return;
46
- }
47
- if ((0, _utils.isListItemNode)($from.node(mappedRange.depth - 1))) {
48
- outdentRangeToParentList({
49
- tr: tr,
50
- range: mappedRange
51
- });
52
- } else {
53
- extractListItemsRangeFromList({
54
- tr: tr,
55
- range: mappedRange,
56
- state: state,
57
- featureFlags: featureFlags
58
- });
59
- hasNormalizedToPositionLiftedOut = hasNormalizedToPositionLiftedOut || oldTo >= range.from && oldTo < range.to;
60
- hasNormalizedFromPositionLiftedOut = hasNormalizedFromPositionLiftedOut || oldFrom >= range.from && oldFrom < range.to;
61
- }
62
- });
63
- var hasCommonListMoved = commonList.start !== tr.mapping.map(commonList.start);
64
- var nextSelection = calculateNewSelection({
65
- originalSelection: originalSelection,
66
- normalizedSelection: normalizedSelection,
67
- tr: tr,
68
- hasCommonListMoved: hasCommonListMoved,
69
- hasNormalizedToPositionLiftedOut: hasNormalizedToPositionLiftedOut,
70
- hasNormalizedFromPositionLiftedOut: hasNormalizedFromPositionLiftedOut
71
- });
72
- tr.setSelection(nextSelection);
73
- (0, _lists.joinSiblingLists)({
74
- tr: tr,
75
- direction: _lists.JoinDirection.RIGHT
76
- });
77
- };
78
- exports.outdentListItemsSelected = outdentListItemsSelected;
79
- var calculateNewSelection = function calculateNewSelection(_ref) {
80
- var tr = _ref.tr,
81
- originalSelection = _ref.originalSelection,
82
- normalizedSelection = _ref.normalizedSelection,
83
- hasCommonListMoved = _ref.hasCommonListMoved,
84
- hasNormalizedToPositionLiftedOut = _ref.hasNormalizedToPositionLiftedOut,
85
- hasNormalizedFromPositionLiftedOut = _ref.hasNormalizedFromPositionLiftedOut;
86
- var $from = normalizedSelection.$from,
87
- $to = normalizedSelection.$to;
88
- var isCursorSelection = normalizedSelection.empty;
89
- var from = tr.mapping.map($from.pos);
90
- var to = tr.mapping.map($to.pos);
91
- var LIST_STRUCTURE_CHANGED_OFFSET = 2;
92
- var isToFromSameListItem = $from.sameParent($to);
93
- if (hasNormalizedFromPositionLiftedOut) {
94
- var fromMapped = isToFromSameListItem ? $from.pos : from;
95
- from = hasNormalizedFromPositionLiftedOut ? $from.pos : fromMapped;
96
- from = hasCommonListMoved ? from - LIST_STRUCTURE_CHANGED_OFFSET : from;
97
- from = Math.max(from, 0);
98
- }
99
- if (hasNormalizedToPositionLiftedOut) {
100
- var toMapped = isToFromSameListItem ? $to.pos : to;
101
- to = hasNormalizedToPositionLiftedOut ? $to.pos : toMapped;
102
- to = hasCommonListMoved ? to - LIST_STRUCTURE_CHANGED_OFFSET : to;
103
- to = Math.min(to, tr.doc.nodeSize - 2);
104
- }
105
- if (normalizedSelection instanceof _gapCursorSelection.GapCursorSelection) {
106
- var nextSelectionFrom = tr.doc.resolve(from);
107
- return new _gapCursorSelection.GapCursorSelection(nextSelectionFrom, normalizedSelection.side);
108
- }
109
- if (originalSelection instanceof _state.NodeSelection) {
110
- return _state.NodeSelection.create(tr.doc, from);
111
- }
112
- if (isCursorSelection) {
113
- return _state.TextSelection.between(tr.doc.resolve(to), tr.doc.resolve(to), -1);
114
- }
115
- return _state.TextSelection.between(tr.doc.resolve(from), tr.doc.resolve(to), -1);
116
- };
117
- var splitRangeSelection = function splitRangeSelection(selection) {
118
- var commonListRange = (0, _selection.createListNodeRange)({
119
- selection: selection
120
- });
121
- if (!commonListRange) {
122
- return [];
123
- }
124
- var $from = selection.$from,
125
- $to = selection.$to;
126
- if ($from.pos === $to.pos && $from.sameParent($to)) {
127
- return [{
128
- from: commonListRange.start,
129
- to: commonListRange.end,
130
- depth: commonListRange.depth
131
- }];
132
- }
133
- var lastListItem = findPreviousListItemSibling($from);
134
- if (!lastListItem) {
135
- return [];
136
- }
137
- var nodeRanges = [];
138
- var doc = $from.doc;
139
- var previousListItem = findPreviousListItemSibling($to);
140
- while (previousListItem && previousListItem.pos >= lastListItem.pos && previousListItem.pos >= commonListRange.start) {
141
- var node = doc.nodeAt(previousListItem.pos);
142
- if (!node || !(0, _utils.isListItemNode)(node)) {
143
- return [];
144
- }
145
- var offset = 0;
146
- if (node && node.lastChild && (0, _utils.isListNode)(node.lastChild)) {
147
- offset = node.lastChild.nodeSize;
148
- }
149
- var start = previousListItem.pos + 1;
150
- nodeRanges.push({
151
- from: start,
152
- to: doc.resolve(start).end() - offset,
153
- depth: previousListItem.depth
154
- });
155
- previousListItem = findPreviousListItemSibling(previousListItem);
156
- }
157
- return nodeRanges;
158
- };
159
- var outdentRangeToParentList = function outdentRangeToParentList(_ref2) {
160
- var tr = _ref2.tr,
161
- range = _ref2.range;
162
- var end = range.end;
163
- var endOfList = range.$to.end(range.depth);
164
- var listItem = tr.doc.type.schema.nodes.listItem;
165
- if (end < endOfList) {
166
- var slice = new _model.Slice(_model.Fragment.from(listItem.create(null, range.parent.copy())), 1, 0);
167
- var step = new _transform.ReplaceAroundStep(end - 1, endOfList, end, endOfList, slice, 1, true);
168
- tr.step(step);
169
- range = new _model.NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
170
- }
171
- var target = (0, _transform.liftTarget)(range);
172
- if (target) {
173
- tr.lift(range, target);
174
- }
175
- };
176
- var extractListItemsRangeFromList = function extractListItemsRangeFromList(_ref3) {
177
- var tr = _ref3.tr,
178
- range = _ref3.range,
179
- state = _ref3.state,
180
- featureFlags = _ref3.featureFlags;
181
- var list = range.parent;
182
- var $start = tr.doc.resolve(range.start);
183
- var listStart = $start.start(range.depth);
184
- var listEnd = $start.end(range.depth);
185
- var isAtTop = listStart === range.start;
186
- var isAtBottom = listEnd === range.end;
187
- var isTheEntireList = isAtTop && isAtBottom;
188
- var listItemContent = isAtTop ? _model.Fragment.empty : _model.Fragment.from(list.copy(_model.Fragment.empty));
189
- for (var i = range.startIndex; i < range.endIndex; i++) {
190
- listItemContent = listItemContent.append(list.child(i).content);
191
- }
192
- if (isAtTop) {
193
- for (var _i = 0; _i < listItemContent.childCount; _i++) {
194
- var child = listItemContent.child(_i);
195
- if (child && (0, _utils.isListNode)(child) && child.type !== list.type) {
196
- var newNestedList = list.type.create(null, child.content);
197
- listItemContent = listItemContent.replaceChild(_i, newNestedList);
198
- }
199
- }
200
- }
201
- var nextList = list.copy(_model.Fragment.empty);
202
- var nextListStartNumber;
203
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
204
- // if splitting a numbered list, keep the splitted item
205
- // counter as the start of the next (second half) list (instead
206
- // of reverting back to 1 as a starting number)
207
- var order = (0, _utils.getOrderFromOrderedListNode)(list);
208
- if (list.type.name === 'orderedList') {
209
- nextListStartNumber = range.endIndex - 1 + order;
210
- // @ts-ignore - [unblock prosemirror bump] assigning to readonly attrs
211
- nextList.attrs = _objectSpread(_objectSpread({}, nextList.attrs), {}, {
212
- order: nextListStartNumber
213
- });
214
- var _getRestartListsAttri = (0, _analytics.getRestartListsAttributes)(tr),
215
- splitListStartNumber = _getRestartListsAttri.splitListStartNumber;
216
- if (typeof splitListStartNumber !== 'number') {
217
- (0, _analytics.storeRestartListsAttributes)(tr, {
218
- splitListStartNumber: nextListStartNumber
219
- });
220
- }
221
- }
222
- }
223
- var nextListFragment = listItemContent.append(_model.Fragment.from(nextList));
224
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
225
- // if the split list with nextListStartNumber is below another list
226
- // with order (e.g due to multi-level indent items being lifted), track the
227
- // list above's order instead, as it will be the split list's order after sibling joins
228
- nextListFragment.forEach(function (node, _offset, index) {
229
- var _node$attrs;
230
- if (node.type.name === 'orderedList' && ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order) === nextListStartNumber) {
231
- var _prev$attrs;
232
- var prev = nextListFragment.child(index - 1);
233
- if ((prev === null || prev === void 0 ? void 0 : (_prev$attrs = prev.attrs) === null || _prev$attrs === void 0 ? void 0 : _prev$attrs.order) >= 0) {
234
- var _prev$attrs2;
235
- (0, _analytics.storeRestartListsAttributes)(tr, {
236
- splitListStartNumber: prev === null || prev === void 0 ? void 0 : (_prev$attrs2 = prev.attrs) === null || _prev$attrs2 === void 0 ? void 0 : _prev$attrs2.order
237
- });
238
- }
239
- }
240
- });
241
- }
242
- if (isTheEntireList) {
243
- var slice = new _model.Slice(listItemContent, 0, 0);
244
- var step = new _transform.ReplaceStep($start.pos - 1, range.end + 1, slice, false);
245
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
246
- (0, _analytics.storeRestartListsAttributes)(tr, {
247
- outdentScenario: undefined
248
- });
249
- }
250
- tr.step(step);
251
- } else if (isAtTop) {
252
- var _slice = new _model.Slice(nextListFragment, 0, 1);
253
- var _step = new _transform.ReplaceStep($start.pos - 1, range.end, _slice, false);
254
- tr.step(_step);
255
- } else if (isAtBottom) {
256
- var _slice2 = new _model.Slice(listItemContent, 1, 0);
257
- var _step2 = new _transform.ReplaceStep($start.pos, listEnd + 1, _slice2, false);
258
- tr.step(_step2);
259
- } else {
260
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
261
- (0, _analytics.storeRestartListsAttributes)(tr, {
262
- outdentScenario: _analytics2.OUTDENT_SCENARIOS.SPLIT_LIST
263
- });
264
- }
265
- var _slice3 = new _model.Slice(nextListFragment, 1, 1);
266
- var _step3 = new _transform.ReplaceAroundStep($start.pos, listEnd, range.end, listEnd, _slice3, _slice3.size, false);
267
- tr.step(_step3);
268
- }
269
- };
270
- var findPreviousListItemSibling = function findPreviousListItemSibling($pos) {
271
- var doc = $pos.doc;
272
- var isPositionListItem = (0, _utils.isListNode)($pos.node());
273
- var listItemPosition = $pos;
274
- if (!isPositionListItem) {
275
- var listItem = (0, _find.findFirstParentListItemNode)($pos);
276
- if (!listItem) {
277
- return null;
278
- }
279
- return doc.resolve(listItem.pos);
280
- }
281
- var resolved = doc.resolve(listItemPosition.pos);
282
- var foundPosition = _state.Selection.findFrom(resolved, -1);
283
- if (!foundPosition) {
284
- return null;
285
- }
286
- var parentListItemNode = (0, _find.findFirstParentListItemNode)(foundPosition.$from);
287
- if (!parentListItemNode) {
288
- return null;
289
- }
290
- return doc.resolve(parentListItemNode.pos);
291
- };
@@ -1,98 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.wrapInList = wrapInList;
7
- exports.wrapInListAndJoin = wrapInListAndJoin;
8
- var _model = require("@atlaskit/editor-prosemirror/model");
9
- var _transform = require("@atlaskit/editor-prosemirror/transform");
10
- var _utils = require("@atlaskit/editor-common/utils");
11
- var _gapCursorSelection = require("../../selection/gap-cursor-selection");
12
- var _selection = require("../utils/selection");
13
- /**
14
- * Wraps the selection in a list with the given type. If this results in
15
- * two adjacent lists of the same type, those will be joined together.
16
- */
17
- function wrapInListAndJoin(nodeType, tr) {
18
- wrapInList(nodeType)(tr);
19
- (0, _utils.autoJoinTr)(tr, function (before, after) {
20
- return before.type === after.type && before.type === nodeType;
21
- });
22
- }
23
-
24
- /**
25
- * Wraps the selection in a list with the given type and attributes.
26
- *
27
- * Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L64-L89
28
- */
29
- function wrapInList(listType, attrs) {
30
- return function (tr) {
31
- var _tr$selection = tr.selection,
32
- $from = _tr$selection.$from,
33
- $to = _tr$selection.$to;
34
- var range;
35
- if (tr.selection instanceof _gapCursorSelection.GapCursorSelection && $from.nodeAfter && (0, _selection.isWrappingPossible)(listType, tr.selection)) {
36
- var nodeSize = $from.nodeAfter.nodeSize || 1;
37
- range = $from.blockRange($from.doc.resolve($from.pos + nodeSize));
38
- } else {
39
- range = $from.blockRange($to);
40
- }
41
- var doJoin = false;
42
- var outerRange = range;
43
- if (!range) {
44
- return false;
45
- }
46
- // This is at the top of an existing list item
47
- if (range.depth >= 2 &&
48
- // @ts-ignore - missing type for compatibleContent
49
- $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
50
- // Don't do anything if this is the top of the list
51
- if ($from.index(range.depth - 1) === 0) {
52
- return false;
53
- }
54
- var $insert = tr.doc.resolve(range.start - 2);
55
- outerRange = new _model.NodeRange($insert, $insert, range.depth);
56
- if (range.endIndex < range.parent.childCount) {
57
- range = new _model.NodeRange($from, tr.doc.resolve($to.end(range.depth)), range.depth);
58
- }
59
- doJoin = true;
60
- }
61
- var wrap = (0, _transform.findWrapping)(outerRange, listType, attrs, range);
62
- if (!wrap) {
63
- return false;
64
- }
65
- tr = doWrapInList(tr, range, wrap, doJoin, listType);
66
- return true;
67
- };
68
- }
69
-
70
- /**
71
- * Internal function used by wrapInList
72
- *
73
- * Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L91-L112
74
- */
75
- function doWrapInList(tr, range, wrappers, joinBefore, listType) {
76
- var content = _model.Fragment.empty;
77
- for (var i = wrappers.length - 1; i >= 0; i--) {
78
- content = _model.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
79
- }
80
- tr.step(new _transform.ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new _model.Slice(content, 0, 0), wrappers.length, true));
81
- var found = 0;
82
- for (var _i = 0; _i < wrappers.length; _i++) {
83
- if (wrappers[_i].type === listType) {
84
- found = _i + 1;
85
- }
86
- }
87
- var splitDepth = wrappers.length - found;
88
- var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0);
89
- var parent = range.parent;
90
- for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {
91
- if (!first && (0, _transform.canSplit)(tr.doc, splitPos, splitDepth)) {
92
- tr.split(splitPos, splitDepth);
93
- splitPos += 2 * splitDepth;
94
- }
95
- splitPos += parent.child(_i2).nodeSize;
96
- }
97
- return tr;
98
- }
@@ -1,71 +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.indentList = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _analytics = require("@atlaskit/editor-common/analytics");
10
- var _lists = require("@atlaskit/editor-common/lists");
11
- var _indentListItemsSelected = require("../actions/indent-list-items-selected");
12
- var _utils = require("@atlaskit/editor-common/utils");
13
- var _find = require("../utils/find");
14
- var _types = require("../types");
15
- var _selection = require("../utils/selection");
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 indentList = function indentList(editorAnalyticsAPI) {
20
- return function () {
21
- var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
22
- return function (state, dispatch) {
23
- var tr = state.tr,
24
- $from = state.selection.$from;
25
-
26
- // don't indent if selection is not inside a list
27
- if (!(0, _selection.isInsideListItem)(state)) {
28
- return false;
29
- }
30
-
31
- // Save the history, so it could undo/revert to the same state before the indent, see https://product-fabric.atlassian.net/browse/ED-14753
32
- (0, _history.closeHistory)(tr);
33
- var firstListItemSelectedAttributes = (0, _lists.getListItemAttributes)($from);
34
- var parentListNode = (0, _find.findFirstParentListNode)($from);
35
- if (!parentListNode || firstListItemSelectedAttributes && firstListItemSelectedAttributes.indentLevel === 0 && firstListItemSelectedAttributes.itemIndex === 0) {
36
- if ((0, _selection.isInsideTableCell)(state)) {
37
- // dont consume tab, as table-keymap should move cursor to next cell
38
- return false;
39
- } else {
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
- return true;
42
- }
43
- }
44
- var currentListNode = parentListNode.node;
45
- var actionSubjectId = (0, _utils.isBulletList)(currentListNode) ? _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : _analytics.ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
46
- (0, _indentListItemsSelected.indentListItemsSelected)(tr);
47
- var maximimunNestedLevelReached = !(0, _lists.hasValidListIndentationLevel)({
48
- tr: tr,
49
- maxIndentation: _types.MAX_NESTED_LIST_INDENTATION
50
- });
51
- if (maximimunNestedLevelReached || !tr.docChanged) {
52
- // 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
53
- return true;
54
- }
55
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
56
- action: _analytics.ACTION.INDENTED,
57
- actionSubject: _analytics.ACTION_SUBJECT.LIST,
58
- actionSubjectId: actionSubjectId,
59
- eventType: _analytics.EVENT_TYPE.TRACK,
60
- attributes: _objectSpread(_objectSpread({}, (0, _lists.getCommonListAnalyticsAttributes)(state)), {}, {
61
- inputMethod: inputMethod
62
- })
63
- })(tr);
64
- if (dispatch) {
65
- dispatch(tr);
66
- }
67
- return true;
68
- };
69
- };
70
- };
71
- exports.indentList = indentList;