@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,60 +0,0 @@
1
- import { getCommonListAnalyticsAttributes } from '@atlaskit/editor-common/lists';
2
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
3
- import { isInsideListItem, isInsideTableCell } from '../utils/selection';
4
- import { isBulletList } from '@atlaskit/editor-common/utils';
5
- import { findFirstParentListNode } from '../utils/find';
6
- import { getRestartListsAttributes } from '../utils/analytics';
7
- import { outdentListItemsSelected as outdentListAction } from '../actions/outdent-list-items-selected';
8
- import { closeHistory } from '@atlaskit/editor-prosemirror/history';
9
- export const outdentList = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD, featureFlags) => {
10
- return function (state, dispatch) {
11
- if (!isInsideListItem(state)) {
12
- return false;
13
- }
14
- const {
15
- $from
16
- } = state.selection;
17
- const parentListNode = findFirstParentListNode($from);
18
- if (!parentListNode) {
19
- // 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
20
- return true;
21
- }
22
-
23
- // Save the history, so it could undo/revert to the same state before the outdent, see https://product-fabric.atlassian.net/browse/ED-14753
24
- closeHistory(state.tr);
25
- const actionSubjectId = isBulletList(parentListNode.node) ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
26
- let customTr = state.tr;
27
- outdentListAction(customTr, state, featureFlags);
28
- if (!customTr || !customTr.docChanged) {
29
- // 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
30
- // If inside table cell and can't outdent list, then let it handle by table keymap
31
- return !isInsideTableCell(state);
32
- }
33
- const restartListsAttributes = {};
34
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
35
- const {
36
- outdentScenario,
37
- splitListStartNumber
38
- } = getRestartListsAttributes(customTr);
39
- if (outdentScenario === OUTDENT_SCENARIOS.SPLIT_LIST) {
40
- restartListsAttributes.outdentScenario = outdentScenario;
41
- restartListsAttributes.splitListStartNumber = splitListStartNumber;
42
- }
43
- }
44
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
45
- action: ACTION.OUTDENTED,
46
- actionSubject: ACTION_SUBJECT.LIST,
47
- actionSubjectId,
48
- eventType: EVENT_TYPE.TRACK,
49
- attributes: {
50
- ...getCommonListAnalyticsAttributes(state),
51
- ...restartListsAttributes,
52
- inputMethod
53
- }
54
- })(customTr);
55
- if (dispatch) {
56
- dispatch(customTr);
57
- }
58
- return true;
59
- };
60
- };
@@ -1,120 +0,0 @@
1
- import React from 'react';
2
- import { bulletList, listItem, orderedList, orderedListWithOrder } from '@atlaskit/adf-schema';
3
- import { createPlugin } from './pm-plugins/main';
4
- import inputRulePlugin from './pm-plugins/input-rules';
5
- import keymapPlugin from './pm-plugins/keymap';
6
- import { listMessages as messages } from '@atlaskit/editor-common/messages';
7
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../analytics';
8
- import { toggleBulletList, toggleOrderedList, tooltip } from '../../keymaps';
9
- import { IconList, IconListNumber } from '@atlaskit/editor-common/quick-insert';
10
- import { isInsideListItem } from './utils/selection';
11
- import { indentList, outdentList, toggleBulletList as toggleBulletListCommand, toggleOrderedList as toggleOrderedListCommand } from './commands';
12
- import { findRootParentListNode } from './utils/find';
13
- import { pluginKey as listPluginKey } from './pm-plugins/main';
14
-
15
- /*
16
- Toolbar buttons to bullet and ordered list can be found in
17
- packages/editor/editor-core/src/plugins/toolbar-lists-indentation/ui/Toolbar.tsx
18
- */
19
- const listPlugin = (options, api) => {
20
- var _api$dependencies$ana;
21
- const featureFlags = (api === null || api === void 0 ? void 0 : api.dependencies.featureFlags.sharedState.currentState()) || {};
22
- const 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;
23
- return {
24
- name: 'list',
25
- actions: {
26
- indentList: indentList(editorAnalyticsAPI),
27
- outdentList: outdentList(editorAnalyticsAPI),
28
- toggleOrderedList: toggleOrderedListCommand(editorAnalyticsAPI),
29
- toggleBulletList: toggleBulletListCommand(editorAnalyticsAPI),
30
- isInsideListItem,
31
- findRootParentListNode
32
- },
33
- getSharedState: editorState => {
34
- if (!editorState) {
35
- return undefined;
36
- }
37
- return listPluginKey.getState(editorState);
38
- },
39
- nodes() {
40
- return [{
41
- name: 'bulletList',
42
- node: bulletList
43
- }, {
44
- name: 'orderedList',
45
- node: options !== null && options !== void 0 && options.restartNumberedLists ? orderedListWithOrder : orderedList
46
- }, {
47
- name: 'listItem',
48
- node: listItem
49
- }];
50
- },
51
- pmPlugins() {
52
- return [{
53
- name: 'list',
54
- plugin: ({
55
- dispatch
56
- }) => createPlugin(dispatch, featureFlags)
57
- }, {
58
- name: 'listInputRule',
59
- plugin: ({
60
- schema,
61
- featureFlags
62
- }) => inputRulePlugin(schema, featureFlags)
63
- }, {
64
- name: 'listKeymap',
65
- plugin: () => {
66
- var _api$dependencies$ana2;
67
- return keymapPlugin(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);
68
- }
69
- }];
70
- },
71
- pluginsOptions: {
72
- quickInsert: ({
73
- formatMessage
74
- }) => [{
75
- id: 'unorderedList',
76
- title: formatMessage(messages.unorderedList),
77
- description: formatMessage(messages.unorderedListDescription),
78
- keywords: ['ul', 'unordered'],
79
- priority: 1100,
80
- keyshortcut: tooltip(toggleBulletList),
81
- icon: () => /*#__PURE__*/React.createElement(IconList, null),
82
- action(insert, state) {
83
- const tr = insert(state.schema.nodes.bulletList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
84
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
85
- action: ACTION.INSERTED,
86
- actionSubject: ACTION_SUBJECT.LIST,
87
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_BULLET,
88
- eventType: EVENT_TYPE.TRACK,
89
- attributes: {
90
- inputMethod: INPUT_METHOD.QUICK_INSERT
91
- }
92
- })(tr);
93
- return tr;
94
- }
95
- }, {
96
- id: 'orderedList',
97
- title: formatMessage(messages.orderedList),
98
- description: formatMessage(messages.orderedListDescription),
99
- keywords: ['ol', 'ordered'],
100
- priority: 1200,
101
- keyshortcut: tooltip(toggleOrderedList),
102
- icon: () => /*#__PURE__*/React.createElement(IconListNumber, null),
103
- action(insert, state) {
104
- const tr = insert(state.schema.nodes.orderedList.createChecked({}, state.schema.nodes.listItem.createChecked({}, state.schema.nodes.paragraph.createChecked())));
105
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
106
- action: ACTION.INSERTED,
107
- actionSubject: ACTION_SUBJECT.LIST,
108
- actionSubjectId: ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER,
109
- eventType: EVENT_TYPE.TRACK,
110
- attributes: {
111
- inputMethod: INPUT_METHOD.QUICK_INSERT
112
- }
113
- })(tr);
114
- return tr;
115
- }
116
- }]
117
- }
118
- };
119
- };
120
- export default listPlugin;
@@ -1,29 +0,0 @@
1
- // Common Translations will live here
2
- import { defineMessages } from 'react-intl-next';
3
- export const messages = defineMessages({
4
- unorderedList: {
5
- id: 'fabric.editor.unorderedList',
6
- defaultMessage: 'Bullet list',
7
- description: 'A list with bullets. Also known as an “unordered” list'
8
- },
9
- unorderedListDescription: {
10
- id: 'fabric.editor.unorderedList.description',
11
- defaultMessage: 'Create an unordered list',
12
- description: ''
13
- },
14
- orderedList: {
15
- id: 'fabric.editor.orderedList',
16
- defaultMessage: 'Numbered list',
17
- description: 'A list with ordered items 1… 2… 3…'
18
- },
19
- orderedListDescription: {
20
- id: 'fabric.editor.orderedList.description',
21
- defaultMessage: 'Create an ordered list',
22
- description: ''
23
- },
24
- lists: {
25
- id: 'fabric.editor.lists',
26
- defaultMessage: 'Lists',
27
- description: 'Menu shows ordered/bullet list and unordered/numbered lists'
28
- }
29
- });
@@ -1,55 +0,0 @@
1
- import { ruleWithAnalytics } from '../../../../utils/input-rules';
2
- import { createWrappingJoinRule } from './wrapping-join-rule';
3
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
5
- const getOrder = matchResult => Number(matchResult[1]);
6
- export function createRuleForListType({
7
- listType,
8
- expression,
9
- featureFlags
10
- }) {
11
- let joinScenario = JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.NO_JOIN;
12
- const isBulletList = listType.name === 'bulletList';
13
- const actionSubjectId = isBulletList ? ACTION_SUBJECT_ID.FORMAT_LIST_BULLET : ACTION_SUBJECT_ID.FORMAT_LIST_NUMBER;
14
- const getAnalyticsPayload = (state, matchResult) => {
15
- const analyticsPayload = {
16
- action: ACTION.INSERTED,
17
- actionSubject: ACTION_SUBJECT.LIST,
18
- actionSubjectId,
19
- eventType: EVENT_TYPE.TRACK,
20
- attributes: {
21
- inputMethod: INPUT_METHOD.FORMATTING
22
- }
23
- };
24
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && listType === state.schema.nodes.orderedList && analyticsPayload.attributes) {
25
- analyticsPayload.attributes.listStartNumber = getOrder(matchResult);
26
- analyticsPayload.attributes.joinScenario = joinScenario;
27
- // we reset the tracked joinScenario after storing it in the event payload
28
- joinScenario = JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.NO_JOIN;
29
- }
30
- return analyticsPayload;
31
- };
32
- const joinToNeighbourIfSameListType = (_, node, scenario) => {
33
- const shouldJoin = node.type === listType;
34
- if (shouldJoin) {
35
- joinScenario = scenario;
36
- }
37
- return shouldJoin;
38
- };
39
- let getAttrs = {};
40
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
41
- getAttrs = matchResult => {
42
- return {
43
- order: getOrder(matchResult)
44
- };
45
- };
46
- }
47
- const inputRule = createWrappingJoinRule({
48
- featureFlags,
49
- match: expression,
50
- nodeType: listType,
51
- getAttrs,
52
- joinPredicate: joinToNeighbourIfSameListType
53
- });
54
- return ruleWithAnalytics(getAnalyticsPayload)(inputRule);
55
- }
@@ -1,33 +0,0 @@
1
- import { createPlugin } from '@atlaskit/prosemirror-input-rules';
2
- import { createRuleForListType } from './create-list-input-rule';
3
- export default function inputRulePlugin(schema, featureFlags) {
4
- const {
5
- nodes: {
6
- bulletList,
7
- orderedList
8
- }
9
- } = schema;
10
- const rules = [];
11
- if (bulletList) {
12
- rules.push(createRuleForListType({
13
- // Using UTF instead of • character
14
- // because of issue where product converted the
15
- // character into an escaped version.
16
- expression: /^\s*([\*\-\u2022]) $/,
17
- listType: bulletList,
18
- featureFlags
19
- }));
20
- }
21
- const expression = featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists ? /((^[1-9]{1}[0-9]{0,2})|^(0))[\.\)] $/ : /^(1)[\.\)] $/;
22
- if (orderedList) {
23
- rules.push(createRuleForListType({
24
- expression,
25
- listType: orderedList,
26
- featureFlags
27
- }));
28
- }
29
- if (rules.length !== 0) {
30
- return createPlugin('lists', rules);
31
- }
32
- return;
33
- }
@@ -1,52 +0,0 @@
1
- import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
- import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
3
- import { JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST } from '@atlaskit/editor-common/analytics';
4
- import { createRule } from '@atlaskit/prosemirror-input-rules';
5
- export const createWrappingJoinRule = ({
6
- match,
7
- nodeType,
8
- getAttrs,
9
- joinPredicate,
10
- featureFlags
11
- }) => {
12
- const handler = (state, match, start, end) => {
13
- const attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
14
- const tr = state.tr;
15
- const fixedStart = Math.max(start, 1);
16
- tr.delete(fixedStart, end);
17
- const $start = tr.doc.resolve(fixedStart);
18
- const range = $start.blockRange();
19
- const wrapping = range && findWrapping(range, nodeType, attrs);
20
- if (!wrapping || !range) {
21
- return null;
22
- }
23
- const parentNodePosMapped = tr.mapping.map(range.start);
24
- const parentNode = tr.doc.nodeAt(parentNodePosMapped);
25
- const lastWrap = wrapping[wrapping.length - 1];
26
- if (parentNode && lastWrap) {
27
- const allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
28
- tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
29
- }
30
- tr.wrap(range, wrapping);
31
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && nodeType === state.schema.nodes.orderedList) {
32
- // if an orderedList node would be inserted by the input rule match, and
33
- // that orderedList node is being added directly before another orderedList
34
- // node, then join those nodes
35
- const $end = tr.doc.resolve(tr.mapping.map(end));
36
- const node = findParentNodeOfTypeClosestToPos($end, nodeType);
37
- if (node) {
38
- const nodeEnd = node.pos + node.node.nodeSize;
39
- const after = tr.doc.resolve(nodeEnd).nodeAfter;
40
- if (after && after.type === nodeType && canJoin(tr.doc, nodeEnd) && (!joinPredicate || joinPredicate(match, after, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_BELOW))) {
41
- tr.join(nodeEnd);
42
- }
43
- }
44
- }
45
- const before = tr.doc.resolve(fixedStart - 1).nodeBefore;
46
- if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
47
- tr.join(fixedStart - 1);
48
- }
49
- return tr;
50
- };
51
- return createRule(match, handler);
52
- };
@@ -1,19 +0,0 @@
1
- import { keymap } from '@atlaskit/editor-prosemirror/keymap';
2
- import { bindKeymapWithCommand, findShortcutByKeymap, toggleOrderedList, toggleBulletList, indentList, outdentList, enter, backspace, deleteKey, findKeyMapForBrowser, forwardDelete } from '@atlaskit/editor-common/keymaps';
3
- import { indentList as indentListCommand, outdentList as outdentListCommand, enterKeyCommand, toggleList, backspaceKeyCommand, deleteKeyCommand } from '../commands';
4
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- export function keymapPlugin(featureFlags, editorAnalyticsAPI) {
6
- const list = {};
7
- bindKeymapWithCommand(findShortcutByKeymap(toggleOrderedList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'orderedList'), list);
8
- bindKeymapWithCommand(findShortcutByKeymap(toggleBulletList), toggleList(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, 'bulletList'), list);
9
- bindKeymapWithCommand(indentList.common, indentListCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD), list);
10
- bindKeymapWithCommand(outdentList.common, outdentListCommand(editorAnalyticsAPI)(INPUT_METHOD.KEYBOARD, featureFlags), list);
11
- bindKeymapWithCommand(enter.common, enterKeyCommand(editorAnalyticsAPI)(featureFlags), list);
12
- bindKeymapWithCommand(backspace.common, backspaceKeyCommand(editorAnalyticsAPI)(featureFlags), list);
13
- bindKeymapWithCommand(deleteKey.common, deleteKeyCommand(editorAnalyticsAPI), list);
14
-
15
- // This shortcut is Mac only
16
- bindKeymapWithCommand(findKeyMapForBrowser(forwardDelete), deleteKeyCommand(editorAnalyticsAPI), list);
17
- return keymap(list);
18
- }
19
- export default keymapPlugin;
@@ -1,159 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
4
- import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { isWrappingPossible } from '../utils/selection';
6
- import { isListNode } from '@atlaskit/editor-common/utils';
7
- import { pluginFactory } from '../../../utils/plugin-state-factory';
8
- import { setGapCursorSelection } from '../../../utils';
9
- import { Side } from '@atlaskit/editor-common/selection';
10
- import { listItemCounterPadding, CodeBlockSharedCssClassName, getOrderedListInlineStyles } from '@atlaskit/editor-common/styles';
11
- import { getItemCounterDigitsSize } from '@atlaskit/editor-common/utils';
12
- const listPluginKey = new PluginKey('listPlugin');
13
- export const pluginKey = listPluginKey;
14
- const initialState = {
15
- bulletListActive: false,
16
- bulletListDisabled: false,
17
- orderedListActive: false,
18
- orderedListDisabled: false,
19
- decorationSet: DecorationSet.empty
20
- };
21
- export const getDecorations = (doc, state, featureFlags) => {
22
- const decorations = [];
23
-
24
- // this stack keeps track of each (nested) list to calculate the indentation level
25
- const processedListsStack = [];
26
- doc.nodesBetween(0, doc.content.size, (node, currentNodeStartPos) => {
27
- if (processedListsStack.length > 0) {
28
- let isOutsideLastList = true;
29
- while (isOutsideLastList && processedListsStack.length > 0) {
30
- const lastList = processedListsStack[processedListsStack.length - 1];
31
- const lastListEndPos = lastList.startPos + lastList.node.nodeSize;
32
- isOutsideLastList = currentNodeStartPos >= lastListEndPos;
33
- // once we finish iterating over each innermost list, pop the stack to
34
- // decrease the indent level attribute accordingly
35
- if (isOutsideLastList) {
36
- processedListsStack.pop();
37
- }
38
- }
39
- }
40
- if (isListNode(node)) {
41
- processedListsStack.push({
42
- node,
43
- startPos: currentNodeStartPos
44
- });
45
- const from = currentNodeStartPos;
46
- const to = currentNodeStartPos + node.nodeSize;
47
- const depth = processedListsStack.length;
48
- decorations.push(Decoration.node(from, to, {
49
- 'data-indent-level': `${depth}`
50
- }));
51
- if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists) {
52
- var _node$attrs;
53
- // If a numbered list has item counters numbering >= 100, we'll need to add special
54
- // spacing to account for the extra digit chars
55
- const digitsSize = getItemCounterDigitsSize({
56
- itemsCount: node === null || node === void 0 ? void 0 : node.childCount,
57
- order: node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.order
58
- });
59
- if (digitsSize) {
60
- decorations.push(Decoration.node(from, to, {
61
- style: getOrderedListInlineStyles(digitsSize, 'string')
62
- }));
63
- }
64
- } else {
65
- if (node.childCount >= 100) {
66
- decorations.push(Decoration.node(from, to, {
67
- 'data-child-count': '100+'
68
- }));
69
- }
70
- }
71
- }
72
- });
73
- return DecorationSet.empty.add(doc, decorations);
74
- };
75
- const handleDocChanged = featureFlags => (tr, pluginState, editorState) => {
76
- const nextPluginState = handleSelectionChanged(tr, pluginState);
77
- const decorationSet = getDecorations(tr.doc, editorState, featureFlags);
78
- return {
79
- ...nextPluginState,
80
- decorationSet
81
- };
82
- };
83
- const handleSelectionChanged = (tr, pluginState) => {
84
- const {
85
- bulletList,
86
- orderedList
87
- } = tr.doc.type.schema.nodes;
88
- const listParent = findParentNodeOfType([bulletList, orderedList])(tr.selection);
89
- const bulletListActive = !!listParent && listParent.node.type === bulletList;
90
- const orderedListActive = !!listParent && listParent.node.type === orderedList;
91
- const bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, tr.selection));
92
- const orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, tr.selection));
93
- if (bulletListActive !== pluginState.bulletListActive || orderedListActive !== pluginState.orderedListActive || bulletListDisabled !== pluginState.bulletListDisabled || orderedListDisabled !== pluginState.orderedListDisabled) {
94
- const nextPluginState = {
95
- ...pluginState,
96
- bulletListActive,
97
- orderedListActive,
98
- bulletListDisabled,
99
- orderedListDisabled
100
- };
101
- return nextPluginState;
102
- }
103
- return pluginState;
104
- };
105
- const reducer = () => state => {
106
- return state;
107
- };
108
- const createInitialState = featureFlags => state => {
109
- return {
110
- ...initialState,
111
- decorationSet: getDecorations(state.doc, state, featureFlags)
112
- };
113
- };
114
- export const createPlugin = (eventDispatch, featureFlags) => {
115
- const {
116
- getPluginState,
117
- createPluginState
118
- } = pluginFactory(listPluginKey, reducer(), {
119
- onDocChanged: handleDocChanged(featureFlags),
120
- onSelectionChanged: handleSelectionChanged
121
- });
122
- return new SafePlugin({
123
- state: createPluginState(eventDispatch, createInitialState(featureFlags)),
124
- key: listPluginKey,
125
- props: {
126
- decorations(state) {
127
- const {
128
- decorationSet
129
- } = getPluginState(state);
130
- return decorationSet;
131
- },
132
- handleClick: (view, pos, event) => {
133
- const {
134
- state
135
- } = view;
136
- if (['LI', 'UL'].includes((event === null || event === void 0 ? void 0 : event.target).tagName)) {
137
- var _nodeAtPos$firstChild;
138
- const nodeAtPos = state.tr.doc.nodeAt(pos);
139
- const {
140
- listItem,
141
- codeBlock
142
- } = view.state.schema.nodes;
143
- if ((nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.type) === listItem && (nodeAtPos === null || nodeAtPos === void 0 ? void 0 : (_nodeAtPos$firstChild = nodeAtPos.firstChild) === null || _nodeAtPos$firstChild === void 0 ? void 0 : _nodeAtPos$firstChild.type) === codeBlock) {
144
- var _document, _document$elementFrom;
145
- const bufferPx = 50;
146
- const isCodeBlockNextToListMarker = Boolean((_document = document) === null || _document === void 0 ? void 0 : (_document$elementFrom = _document.elementFromPoint(event.clientX + (listItemCounterPadding + bufferPx), event.clientY)) === null || _document$elementFrom === void 0 ? void 0 : _document$elementFrom.closest(`.${CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER}`));
147
- if (isCodeBlockNextToListMarker) {
148
- // +1 needed to put cursor inside li
149
- // otherwise gap cursor markup will be injected as immediate child of ul resulting in invalid html
150
- setGapCursorSelection(view, pos + 1, Side.LEFT);
151
- return true;
152
- }
153
- }
154
- }
155
- return false;
156
- }
157
- }
158
- });
159
- };
@@ -1,102 +0,0 @@
1
- import { Fragment, NodeRange, Slice } from '@atlaskit/editor-prosemirror/model';
2
- import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { liftTarget, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
4
- import { getListLiftTarget } from './utils/indentation';
5
- function liftListItem(selection, tr) {
6
- let {
7
- $from,
8
- $to
9
- } = selection;
10
- const nodeType = tr.doc.type.schema.nodes.listItem;
11
- let range = $from.blockRange($to, node => !!node.childCount && !!node.firstChild && node.firstChild.type === nodeType);
12
- if (!range || range.depth < 2 || $from.node(range.depth - 1).type !== nodeType) {
13
- return tr;
14
- }
15
- let end = range.end;
16
- let endOfList = $to.end(range.depth);
17
- if (end < endOfList) {
18
- tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(nodeType.create(undefined, range.parent.copy())), 1, 0), 1, true));
19
- range = new NodeRange(tr.doc.resolve($from.pos), tr.doc.resolve(endOfList), range.depth);
20
- }
21
- return tr.lift(range, liftTarget(range)).scrollIntoView();
22
- }
23
-
24
- // Function will lift list item following selection to level-1.
25
- export function liftFollowingList(from, to, rootListDepth, tr) {
26
- const {
27
- listItem
28
- } = tr.doc.type.schema.nodes;
29
- let lifted = false;
30
- tr.doc.nodesBetween(from, to, (node, pos) => {
31
- if (!lifted && node.type === listItem && pos > from) {
32
- lifted = true;
33
- let listDepth = rootListDepth + 3;
34
- while (listDepth > rootListDepth + 2) {
35
- const start = tr.doc.resolve(tr.mapping.map(pos));
36
- listDepth = start.depth;
37
- const end = tr.doc.resolve(tr.mapping.map(pos + node.textContent.length));
38
- const sel = new TextSelection(start, end);
39
- tr = liftListItem(sel, tr);
40
- }
41
- }
42
- });
43
- return tr;
44
- }
45
- export function liftNodeSelectionList(selection, tr) {
46
- const {
47
- from
48
- } = selection;
49
- const {
50
- listItem
51
- } = tr.doc.type.schema.nodes;
52
- const mappedPosition = tr.mapping.map(from);
53
- const nodeAtPos = tr.doc.nodeAt(mappedPosition);
54
- const start = tr.doc.resolve(mappedPosition);
55
- if ((start === null || start === void 0 ? void 0 : start.parent.type) !== listItem) {
56
- return tr;
57
- }
58
- const end = tr.doc.resolve(mappedPosition + ((nodeAtPos === null || nodeAtPos === void 0 ? void 0 : nodeAtPos.nodeSize) || 1));
59
- const range = start.blockRange(end);
60
- if (range) {
61
- const liftTarget = getListLiftTarget(start);
62
- tr.lift(range, liftTarget);
63
- }
64
- return tr;
65
- }
66
-
67
- // The function will list paragraphs in selection out to level 1 below root list.
68
- export function liftTextSelectionList(selection, tr) {
69
- const {
70
- from,
71
- to
72
- } = selection;
73
- const {
74
- paragraph
75
- } = tr.doc.type.schema.nodes;
76
- const listCol = [];
77
- tr.doc.nodesBetween(from, to, (node, pos) => {
78
- if (node.type === paragraph) {
79
- listCol.push({
80
- node,
81
- pos
82
- });
83
- }
84
- });
85
- for (let i = listCol.length - 1; i >= 0; i--) {
86
- const paragraph = listCol[i];
87
- const start = tr.doc.resolve(tr.mapping.map(paragraph.pos));
88
- if (start.depth > 0) {
89
- let end;
90
- if (paragraph.node.textContent && paragraph.node.textContent.length > 0) {
91
- end = tr.doc.resolve(tr.mapping.map(paragraph.pos + paragraph.node.textContent.length));
92
- } else {
93
- end = tr.doc.resolve(tr.mapping.map(paragraph.pos + 1));
94
- }
95
- const range = start.blockRange(end);
96
- if (range) {
97
- tr.lift(range, getListLiftTarget(start));
98
- }
99
- }
100
- }
101
- return tr;
102
- }
@@ -1 +0,0 @@
1
- export const MAX_NESTED_LIST_INDENTATION = 6;
@@ -1,12 +0,0 @@
1
- export const RESTART_LISTS_ANALYTICS_KEY = 'restartListsAnalytics';
2
- export const getRestartListsAttributes = tr => {
3
- var _tr$getMeta;
4
- return (_tr$getMeta = tr.getMeta(RESTART_LISTS_ANALYTICS_KEY)) !== null && _tr$getMeta !== void 0 ? _tr$getMeta : {};
5
- };
6
- export const storeRestartListsAttributes = (tr, attributes) => {
7
- const meta = getRestartListsAttributes(tr);
8
- tr.setMeta(RESTART_LISTS_ANALYTICS_KEY, {
9
- ...meta,
10
- ...attributes
11
- });
12
- };