@atlaskit/editor-core 187.8.7 → 187.8.10

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 (144) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/index.js +0 -6
  3. package/dist/cjs/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  4. package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +4 -4
  5. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +5 -5
  6. package/dist/cjs/plugins/layout/pm-plugins/main.js +1 -1
  7. package/dist/cjs/plugins/list/actions/conversions.js +5 -5
  8. package/dist/cjs/plugins/list/actions/indent-list-items-selected.js +11 -11
  9. package/dist/cjs/plugins/list/actions/join-list-items-forward.js +6 -6
  10. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +6 -7
  11. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +3 -4
  12. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +3 -4
  13. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +2 -2
  14. package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +2 -2
  15. package/dist/cjs/plugins/list/actions/merge-lists.js +3 -3
  16. package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +11 -11
  17. package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +2 -2
  18. package/dist/cjs/plugins/list/commands/indent-list.js +6 -7
  19. package/dist/cjs/plugins/list/commands/index.js +8 -10
  20. package/dist/cjs/plugins/list/commands/join-list-item-forward.js +5 -5
  21. package/dist/cjs/plugins/list/commands/listBackspace.js +13 -14
  22. package/dist/cjs/plugins/list/commands/outdent-list.js +4 -3
  23. package/dist/cjs/plugins/list/pm-plugins/main.js +5 -6
  24. package/dist/cjs/plugins/list/utils/analytics.js +1 -35
  25. package/dist/cjs/plugins/list/utils/indentation.js +2 -20
  26. package/dist/cjs/plugins/list/utils/node.js +2 -106
  27. package/dist/cjs/plugins/list/utils/selection.js +3 -54
  28. package/dist/cjs/plugins/tasks-and-decisions/commands.js +2 -2
  29. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +17 -18
  30. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  31. package/dist/cjs/utils/commands.js +3 -109
  32. package/dist/cjs/utils/document.js +1 -26
  33. package/dist/cjs/utils/index.js +0 -6
  34. package/dist/cjs/version-wrapper.js +1 -1
  35. package/dist/cjs/version.json +1 -1
  36. package/dist/es2019/index.js +1 -1
  37. package/dist/es2019/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  38. package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +1 -1
  39. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +1 -1
  40. package/dist/es2019/plugins/layout/pm-plugins/main.js +1 -1
  41. package/dist/es2019/plugins/list/actions/conversions.js +2 -2
  42. package/dist/es2019/plugins/list/actions/indent-list-items-selected.js +2 -2
  43. package/dist/es2019/plugins/list/actions/join-list-items-forward.js +1 -1
  44. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
  45. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
  46. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
  47. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
  48. package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
  49. package/dist/es2019/plugins/list/actions/merge-lists.js +1 -1
  50. package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +3 -3
  51. package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +1 -1
  52. package/dist/es2019/plugins/list/commands/indent-list.js +3 -4
  53. package/dist/es2019/plugins/list/commands/index.js +4 -5
  54. package/dist/es2019/plugins/list/commands/join-list-item-forward.js +1 -1
  55. package/dist/es2019/plugins/list/commands/listBackspace.js +1 -2
  56. package/dist/es2019/plugins/list/commands/outdent-list.js +3 -2
  57. package/dist/es2019/plugins/list/pm-plugins/main.js +1 -1
  58. package/dist/es2019/plugins/list/utils/analytics.js +0 -36
  59. package/dist/es2019/plugins/list/utils/indentation.js +0 -18
  60. package/dist/es2019/plugins/list/utils/node.js +3 -89
  61. package/dist/es2019/plugins/list/utils/selection.js +1 -52
  62. package/dist/es2019/plugins/tasks-and-decisions/commands.js +1 -1
  63. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
  64. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  65. package/dist/es2019/utils/commands.js +2 -102
  66. package/dist/es2019/utils/document.js +1 -26
  67. package/dist/es2019/utils/index.js +1 -1
  68. package/dist/es2019/version-wrapper.js +1 -1
  69. package/dist/es2019/version.json +1 -1
  70. package/dist/esm/index.js +1 -1
  71. package/dist/esm/plugins/base/pm-plugins/newline-preserve-marks.js +1 -1
  72. package/dist/esm/plugins/block-type/pm-plugins/keymap.js +1 -1
  73. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +1 -1
  74. package/dist/esm/plugins/layout/pm-plugins/main.js +1 -1
  75. package/dist/esm/plugins/list/actions/conversions.js +2 -2
  76. package/dist/esm/plugins/list/actions/indent-list-items-selected.js +2 -2
  77. package/dist/esm/plugins/list/actions/join-list-items-forward.js +1 -1
  78. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +1 -2
  79. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +2 -2
  80. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +2 -2
  81. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +1 -1
  82. package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +1 -1
  83. package/dist/esm/plugins/list/actions/merge-lists.js +1 -1
  84. package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +3 -3
  85. package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +1 -1
  86. package/dist/esm/plugins/list/commands/indent-list.js +3 -4
  87. package/dist/esm/plugins/list/commands/index.js +4 -5
  88. package/dist/esm/plugins/list/commands/join-list-item-forward.js +1 -1
  89. package/dist/esm/plugins/list/commands/listBackspace.js +1 -2
  90. package/dist/esm/plugins/list/commands/outdent-list.js +3 -2
  91. package/dist/esm/plugins/list/pm-plugins/main.js +1 -1
  92. package/dist/esm/plugins/list/utils/analytics.js +0 -32
  93. package/dist/esm/plugins/list/utils/indentation.js +0 -17
  94. package/dist/esm/plugins/list/utils/node.js +3 -81
  95. package/dist/esm/plugins/list/utils/selection.js +3 -51
  96. package/dist/esm/plugins/tasks-and-decisions/commands.js +1 -1
  97. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
  98. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +2 -1
  99. package/dist/esm/utils/commands.js +2 -100
  100. package/dist/esm/utils/document.js +1 -26
  101. package/dist/esm/utils/index.js +1 -1
  102. package/dist/esm/version-wrapper.js +1 -1
  103. package/dist/esm/version.json +1 -1
  104. package/dist/types/index.d.ts +1 -1
  105. package/dist/types/plugins/list/actions/join-list-items-forward.d.ts +1 -1
  106. package/dist/types/plugins/list/commands/indent-list.d.ts +2 -1
  107. package/dist/types/plugins/list/commands/index.d.ts +2 -1
  108. package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +1 -1
  109. package/dist/types/plugins/list/commands/listBackspace.d.ts +1 -1
  110. package/dist/types/plugins/list/commands/outdent-list.d.ts +2 -1
  111. package/dist/types/plugins/list/utils/analytics.d.ts +2 -4
  112. package/dist/types/plugins/list/utils/indentation.d.ts +0 -5
  113. package/dist/types/plugins/list/utils/node.d.ts +2 -17
  114. package/dist/types/plugins/list/utils/selection.d.ts +1 -12
  115. package/dist/types/utils/commands.d.ts +3 -32
  116. package/dist/types/utils/document.d.ts +0 -4
  117. package/dist/types/utils/index.d.ts +1 -1
  118. package/dist/types-ts4.5/index.d.ts +1 -1
  119. package/dist/types-ts4.5/plugins/list/actions/join-list-items-forward.d.ts +1 -1
  120. package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +2 -1
  121. package/dist/types-ts4.5/plugins/list/commands/index.d.ts +2 -1
  122. package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +1 -1
  123. package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +1 -1
  124. package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +2 -1
  125. package/dist/types-ts4.5/plugins/list/utils/analytics.d.ts +2 -4
  126. package/dist/types-ts4.5/plugins/list/utils/indentation.d.ts +0 -5
  127. package/dist/types-ts4.5/plugins/list/utils/node.d.ts +2 -17
  128. package/dist/types-ts4.5/plugins/list/utils/selection.d.ts +1 -12
  129. package/dist/types-ts4.5/utils/commands.d.ts +3 -38
  130. package/dist/types-ts4.5/utils/document.d.ts +0 -4
  131. package/dist/types-ts4.5/utils/index.d.ts +1 -1
  132. package/package.json +2 -2
  133. package/report.api.md +0 -3
  134. package/tmp/api-report-tmp.d.ts +0 -3
  135. package/dist/cjs/plugins/list/utils/replace-content.js +0 -24
  136. package/dist/cjs/utils/prosemirror/autojoin.js +0 -68
  137. package/dist/es2019/plugins/list/utils/replace-content.js +0 -18
  138. package/dist/es2019/utils/prosemirror/autojoin.js +0 -57
  139. package/dist/esm/plugins/list/utils/replace-content.js +0 -17
  140. package/dist/esm/utils/prosemirror/autojoin.js +0 -63
  141. package/dist/types/plugins/list/utils/replace-content.d.ts +0 -8
  142. package/dist/types/utils/prosemirror/autojoin.d.ts +0 -13
  143. package/dist/types-ts4.5/plugins/list/utils/replace-content.d.ts +0 -8
  144. package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +0 -13
@@ -1,39 +1,3 @@
1
- import { isListItemNode, isListNode } from '@atlaskit/editor-common/utils';
2
- import { getListItemAttributes } from './selection';
3
- export const getCommonListAnalyticsAttributes = state => {
4
- const {
5
- selection: {
6
- $from,
7
- $to
8
- }
9
- } = state;
10
- const fromAttrs = getListItemAttributes($from);
11
- const toAttrs = getListItemAttributes($to);
12
- return {
13
- itemIndexAtSelectionStart: fromAttrs.itemIndex,
14
- itemIndexAtSelectionEnd: toAttrs.itemIndex,
15
- indentLevelAtSelectionStart: fromAttrs.indentLevel,
16
- indentLevelAtSelectionEnd: toAttrs.indentLevel,
17
- itemsInSelection: countListItemsInSelection(state)
18
- };
19
- };
20
- export const countListItemsInSelection = state => {
21
- const {
22
- from,
23
- to
24
- } = state.selection;
25
- if (from === to) {
26
- return 1;
27
- }
28
- let count = 0;
29
- const listSlice = state.doc.cut(from, to);
30
- listSlice.content.nodesBetween(0, listSlice.content.size, (node, pos, parent, index) => {
31
- if (parent && isListItemNode(parent) && !isListNode(node) && index === 0) {
32
- count++;
33
- }
34
- });
35
- return count;
36
- };
37
1
  export const RESTART_LISTS_ANALYTICS_KEY = 'restartListsAnalytics';
38
2
  export const getRestartListsAttributes = tr => {
39
3
  var _tr$getMeta;
@@ -1,4 +1,3 @@
1
- import { numberNestedLists } from './selection';
2
1
  import { isListItemNode, isListNode } from '@atlaskit/editor-common/utils';
3
2
 
4
3
  // This will return (depth - 1) for root list parent of a list.
@@ -14,21 +13,4 @@ export const getListLiftTarget = resPos => {
14
13
  }
15
14
  }
16
15
  return target - 1;
17
- };
18
- export const hasValidListIndentationLevel = ({
19
- tr,
20
- maxIndentation
21
- }) => {
22
- const initialIndentationLevel = numberNestedLists(tr.selection.$from);
23
- let currentIndentationLevel;
24
- let currentPos = tr.selection.$to.pos;
25
- do {
26
- const resolvedPos = tr.doc.resolve(currentPos);
27
- currentIndentationLevel = numberNestedLists(resolvedPos);
28
- if (currentIndentationLevel > maxIndentation) {
29
- return false;
30
- }
31
- currentPos++;
32
- } while (currentIndentationLevel >= initialIndentationLevel);
33
- return true;
34
16
  };
@@ -1,7 +1,6 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '@atlaskit/editor-common/utils';
3
- import { isListNode, isListItemNode } from '@atlaskit/editor-common/utils';
4
- function isListNodeValidContent(node) {
2
+ import { isListItemNode } from '@atlaskit/editor-common/utils';
3
+ export function isListNodeValidContent(node) {
5
4
  const {
6
5
  bulletList
7
6
  } = node.type.schema.nodes;
@@ -10,89 +9,4 @@ function isListNodeValidContent(node) {
10
9
  }
11
10
  const listFragment = Fragment.from(bulletList.createAndFill());
12
11
  return !isListItemNode(node) && node.type.validContent(listFragment);
13
- }
14
- export let JoinDirection = /*#__PURE__*/function (JoinDirection) {
15
- JoinDirection[JoinDirection["LEFT"] = 1] = "LEFT";
16
- JoinDirection[JoinDirection["RIGHT"] = -1] = "RIGHT";
17
- return JoinDirection;
18
- }({});
19
- export const joinSiblingLists = ({
20
- tr,
21
- direction,
22
- forceListType
23
- }) => {
24
- const result = {
25
- orderedList: 0,
26
- bulletList: 0
27
- };
28
- const {
29
- doc,
30
- selection: {
31
- $from,
32
- $to
33
- },
34
- selection
35
- } = tr;
36
- const range = $from.blockRange($to, isListNodeValidContent);
37
- if (!range) {
38
- return result;
39
- }
40
- const rootListNode = doc.nodeAt(range.start);
41
- const from = isListNode(rootListNode) ? range.start : 0;
42
- const to = isListNode(rootListNode) ? range.end : tr.doc.content.size;
43
- const joins = [];
44
- doc.nodesBetween(from, to, (node, pos, parent) => {
45
- const resolvedPos = doc.resolve(pos);
46
- const {
47
- nodeBefore,
48
- nodeAfter
49
- } = resolvedPos;
50
- if (!nodeBefore || !nodeAfter || !isListNode(nodeBefore) || !isListNode(nodeAfter)) {
51
- return;
52
- }
53
- const isNestedList = isListItemNode(parent);
54
- if (!isNestedList && nodeBefore.type !== nodeAfter.type && !forceListType) {
55
- return;
56
- }
57
- const index = resolvedPos.index();
58
- const positionPreviousNode = resolvedPos.posAtIndex(index - 1);
59
- const positionCurrentNode = resolvedPos.posAtIndex(index);
60
-
61
- // If the previous node is part of the selection, OR
62
- // If the previous node is not part of the selection and the previous node has the same list type that we’re converting to
63
- const joinBefore = positionPreviousNode >= from || nodeBefore.type === forceListType;
64
- if (forceListType) {
65
- if (joinBefore) {
66
- tr.setNodeMarkup(positionPreviousNode, forceListType);
67
- }
68
- tr.setNodeMarkup(positionCurrentNode, forceListType);
69
- }
70
- if (isNestedList && nodeBefore.type !== nodeAfter.type) {
71
- const nodeType = direction === JoinDirection.RIGHT ? nodeAfter.type : nodeBefore.type;
72
- tr.setNodeMarkup(positionPreviousNode, nodeType);
73
- }
74
- if (joinBefore) {
75
- joins.push(pos);
76
- }
77
- });
78
- if (selection.empty && rootListNode && isListNode(rootListNode)) {
79
- const resolvedPos = doc.resolve(range.start + rootListNode.nodeSize);
80
- const {
81
- nodeBefore,
82
- nodeAfter
83
- } = resolvedPos;
84
- if (nodeBefore && nodeAfter && isListNode(nodeBefore) && isListNode(nodeAfter) && nodeAfter.type === nodeBefore.type) {
85
- joins.push(resolvedPos.pos);
86
- }
87
- }
88
- for (let i = joins.length - 1; i >= 0; i--) {
89
- const listNode = tr.doc.nodeAt(joins[i]);
90
- const listName = listNode === null || listNode === void 0 ? void 0 : listNode.type.name;
91
- if (listName && (listName === 'orderedList' || listName === 'bulletList')) {
92
- const amount = result[listName] || 0;
93
- result[listName] = amount + 1;
94
- }
95
- tr.join(joins[i]);
96
- }
97
- return result;
98
- };
12
+ }
@@ -1,6 +1,5 @@
1
1
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
2
- import { Selection, TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
- import { findParentNodeClosestToPos, findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
2
+ import { findParentNodeOfType, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
3
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
5
4
  import { isListItemNode, isListNode, isParagraphNode } from '@atlaskit/editor-common/utils';
6
5
  export const isPosInsideParagraph = $pos => {
@@ -82,56 +81,6 @@ export const selectionContainsList = tr => {
82
81
  });
83
82
  return foundListNode;
84
83
  };
85
- export const numberNestedLists = resolvedPos => {
86
- let count = 0;
87
- for (let i = resolvedPos.depth - 1; i > 0; i--) {
88
- const node = resolvedPos.node(i);
89
- if (isListNode(node)) {
90
- count += 1;
91
- }
92
- }
93
- return count;
94
- };
95
- export const getListItemAttributes = $pos => {
96
- const indentLevel = numberNestedLists($pos) - 1;
97
- const itemAtPos = findParentNodeClosestToPos($pos, isListItemNode);
98
-
99
- // Get the index of the current item relative to parent (parent is at item depth - 1)
100
- const itemIndex = $pos.index(itemAtPos ? itemAtPos.depth - 1 : undefined);
101
- return {
102
- indentLevel,
103
- itemIndex
104
- };
105
- };
106
- export const normalizeListItemsSelection = ({
107
- selection,
108
- doc
109
- }) => {
110
- if (selection.empty) {
111
- return selection;
112
- }
113
- const {
114
- $from,
115
- $to
116
- } = selection;
117
- if (selection instanceof NodeSelection) {
118
- const head = resolvePositionToStartOfListItem($from);
119
- return new TextSelection(head, head);
120
- }
121
- const head = resolvePositionToStartOfListItem($from);
122
- const anchor = resolvePositionToEndOfListItem($to);
123
- return new TextSelection(anchor, head);
124
- };
125
- const resolvePositionToStartOfListItem = $pos => {
126
- const fromRange = $pos.blockRange($pos, isListItemNode);
127
- const fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
128
- return fromPosition;
129
- };
130
- const resolvePositionToEndOfListItem = $pos => {
131
- const toRange = $pos.blockRange($pos, isListItemNode);
132
- const toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
133
- return toPosition;
134
- };
135
84
  export const createListNodeRange = ({
136
85
  selection
137
86
  }) => {
@@ -6,7 +6,7 @@ import { uuid } from '@atlaskit/adf-schema';
6
6
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE, INPUT_METHOD, USER_CONTEXT } from '../analytics';
7
7
  import { GapCursorSelection } from '../selection/gap-cursor-selection';
8
8
  import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
9
- import { autoJoinTr } from '../../utils/prosemirror/autojoin';
9
+ import { autoJoinTr } from '@atlaskit/editor-common/utils';
10
10
  const getContextData = (contextProvider = {}) => {
11
11
  const {
12
12
  objectId,
@@ -4,8 +4,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
6
6
  import { uuid } from '@atlaskit/adf-schema';
7
- import { isEmptySelectionAtStart, deleteEmptyParagraphAndMoveBlockUp, isEmptySelectionAtEnd } from '../../../utils/commands';
8
- import { filterCommands as filter } from '@atlaskit/editor-common/utils';
7
+ import { filterCommand as filter, isEmptySelectionAtStart, deleteEmptyParagraphAndMoveBlockUp, isEmptySelectionAtEnd } from '@atlaskit/editor-common/utils';
9
8
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, withAnalytics } from '../../analytics';
10
9
  import { insertTaskDecisionWithAnalytics } from '../commands';
11
10
  import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
@@ -2,9 +2,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
2
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
4
  import { shallowEqual } from '@atlaskit/editor-common/utils';
5
- import { getListItemAttributes, isInsideListItem } from '../../list/utils/selection';
5
+ import { isInsideListItem } from '../../list/utils/selection';
6
6
  import { getCurrentIndentLevel as getTaskListIndentLevel, getTaskItemIndex, isInsideTask } from '../../tasks-and-decisions/pm-plugins/helpers';
7
7
  import { isIndentationAllowed, MAX_INDENTATION_LEVEL } from '../../indentation/commands';
8
+ import { getListItemAttributes } from '@atlaskit/editor-common/lists';
8
9
  export const pluginKey = new PluginKey('indentationButtonsPlugin');
9
10
  function getIndentationButtonsState(editorState, allowHeadingAndParagraphIndentation) {
10
11
  const state = {
@@ -1,20 +1,5 @@
1
- import { TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
1
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
3
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
- const isEmptySelectionAtStart = state => {
5
- const {
6
- empty,
7
- $from
8
- } = state.selection;
9
- return empty && ($from.parentOffset === 0 || state.selection instanceof GapCursorSelection);
10
- };
11
- const isEmptySelectionAtEnd = state => {
12
- const {
13
- empty,
14
- $from
15
- } = state.selection;
16
- return empty && ($from.end() === $from.pos || state.selection instanceof GapCursorSelection);
17
- };
18
3
  const isFirstChildOfParent = state => {
19
4
  const {
20
5
  $from
@@ -69,44 +54,6 @@ const withScrollIntoView = command => (state, dispatch, view) => command(state,
69
54
  dispatch(tr);
70
55
  }
71
56
  }, view);
72
- /**
73
- * Walk forwards from a position until we encounter the (inside) start of
74
- * the next node, or reach the end of the document.
75
- *
76
- * @param $startPos Position to start walking from.
77
- */
78
- const walkNextNode = $startPos => {
79
- let $pos = $startPos;
80
-
81
- // invariant 1: don't walk past the end of the document
82
- // invariant 2: we are at the beginning or
83
- // we haven't walked to the start of *any* node
84
- // parentOffset includes textOffset.
85
- while ($pos.pos < $pos.doc.nodeSize - 2 && ($pos.pos === $startPos.pos || $pos.parentOffset > 0)) {
86
- $pos = $pos.doc.resolve($pos.pos + 1);
87
- }
88
- return {
89
- $pos: $pos,
90
- foundNode: $pos.pos < $pos.doc.nodeSize - 2
91
- };
92
- };
93
-
94
- /**
95
- * Walk backwards from a position until we encounter the (inside) end of
96
- * the previous node, or reach the start of the document.
97
- *
98
- * @param $startPos Position to start walking from.
99
- */
100
- const walkPrevNode = $startPos => {
101
- let $pos = $startPos;
102
- while ($pos.pos > 0 && ($pos.pos === $startPos.pos || $pos.parentOffset < $pos.parent.nodeSize - 2)) {
103
- $pos = $pos.doc.resolve($pos.pos - 1);
104
- }
105
- return {
106
- $pos: $pos,
107
- foundNode: $pos.pos > 0
108
- };
109
- };
110
57
 
111
58
  /**
112
59
  * Insert content, delete a range and create a new selection
@@ -118,57 +65,10 @@ const walkPrevNode = $startPos => {
118
65
  * @param deletions the ranges to delete
119
66
  */
120
67
 
121
- const insertContentDeleteRange = (tr, getSelectionResolvedPos, insertions, deletions) => {
122
- insertions.forEach(contentInsert => {
123
- let [content, pos] = contentInsert;
124
- tr.insert(tr.mapping.map(pos), content);
125
- });
126
- deletions.forEach(deleteRange => {
127
- let [firstPos, lastPos] = deleteRange;
128
- tr.delete(tr.mapping.map(firstPos), tr.mapping.map(lastPos));
129
- });
130
- tr.setSelection(new TextSelection(getSelectionResolvedPos(tr)));
131
- };
132
68
  const selectNode = pos => (state, dispatch) => {
133
69
  if (dispatch) {
134
70
  dispatch(state.tr.setSelection(new NodeSelection(state.doc.resolve(pos))));
135
71
  }
136
72
  return true;
137
73
  };
138
-
139
- /**
140
- * If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
141
- * and move the node below it up. The selection will be retained, to be placed in the moved node.
142
- *
143
- * @param canNextNodeMoveUp check if node directly after the selection is able to be brought up to selection
144
- * @returns PM Command
145
- */
146
- const deleteEmptyParagraphAndMoveBlockUp = canNextNodeMoveUp => {
147
- return (state, dispatch, view) => {
148
- const {
149
- selection: {
150
- $from: {
151
- pos,
152
- parent
153
- },
154
- $head,
155
- empty
156
- },
157
- tr,
158
- doc
159
- } = state;
160
- const {
161
- $pos
162
- } = walkNextNode($head);
163
- const nextPMNode = doc.nodeAt($pos.pos - 1);
164
- if (empty && nextPMNode && canNextNodeMoveUp(nextPMNode) && isEmptyParagraph(parent) && view !== null && view !== void 0 && view.endOfTextblock('right')) {
165
- tr.deleteRange(pos - 1, pos + 1);
166
- if (dispatch) {
167
- dispatch(tr);
168
- }
169
- return true;
170
- }
171
- return false;
172
- };
173
- };
174
- export { isEmptySelectionAtStart, isEmptySelectionAtEnd, isFirstChildOfParent, isNthParentOfType, findCutBefore, withScrollIntoView, walkNextNode, walkPrevNode, insertContentDeleteRange, selectNode, deleteEmptyParagraphAndMoveBlockUp };
74
+ export { isFirstChildOfParent, isNthParentOfType, findCutBefore, withScrollIntoView, selectNode };
@@ -1,31 +1,6 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
3
2
  import { getBreakoutMode } from './node-width';
4
- import { processRawValue, hasDocAsParent, getStepRange } from '@atlaskit/editor-common/utils';
5
-
6
- /**
7
- * Returns false if node contains only empty inline nodes and hardBreaks.
8
- */
9
- export function hasVisibleContent(node) {
10
- const isInlineNodeHasVisibleContent = inlineNode => {
11
- return inlineNode.isText ? !!inlineNode.textContent.trim() : inlineNode.type.name !== 'hardBreak';
12
- };
13
- if (node.isInline) {
14
- return isInlineNodeHasVisibleContent(node);
15
- } else if (node.isBlock && (node.isLeaf || node.isAtom)) {
16
- return true;
17
- } else if (!node.childCount) {
18
- return false;
19
- }
20
- for (let index = 0; index < node.childCount; index++) {
21
- const child = node.child(index);
22
- const invisibleNodeTypes = ['paragraph', 'text', 'hardBreak'];
23
- if (!invisibleNodeTypes.includes(child.type.name) || hasVisibleContent(child)) {
24
- return true;
25
- }
26
- }
27
- return false;
28
- }
3
+ import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
29
4
 
30
5
  /**
31
6
  * Checks if a node has any content. Ignores node that only contain empty block nodes.
@@ -7,7 +7,7 @@ import { isNodeEmpty } from './document';
7
7
  import { atTheBeginningOfDoc, atTheEndOfDoc } from './prosemirror/position';
8
8
  import { isMediaNode } from '@atlaskit/editor-common/utils';
9
9
  export { insideTable } from '@atlaskit/editor-common/core-utils';
10
- export { hasVisibleContent, isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
10
+ export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
11
11
  export { sanitiseMarksInSelection } from './mark';
12
12
  export { isParagraph, isText, isLinkMark } from './nodes';
13
13
  export { setNodeSelection, setGapCursorSelection, setTextSelection } from './selection';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.8.7";
2
+ export const version = "187.8.10";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.8.7",
3
+ "version": "187.8.10",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -42,7 +42,7 @@ export { INPUT_METHOD, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } f
42
42
  export { setKeyboardHeight, setMobilePaddingTop, setIsExpanded } from './plugins/mobile-dimensions/commands';
43
43
 
44
44
  // Used in editor-test-helpers and mobile bridge
45
- export { setTextSelection, dedupe, getNodesCount, measurements, hasVisibleContent } from './utils';
45
+ export { setTextSelection, dedupe, getNodesCount, measurements } from './utils';
46
46
  export { getListCommands } from './utils/list-commands';
47
47
  export { ReactEditorView, BaseReactEditorView } from './create-editor';
48
48
  export { getDefaultPresetOptionsFromEditorProps } from './create-editor';
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
4
- import { filterCommands as filter } from '@atlaskit/editor-common/utils';
4
+ import { filterCommand as filter } from '@atlaskit/editor-common/utils';
5
5
  import { isSelectionEndOfParagraph } from '../../../utils';
6
6
  export var newlinePreserveMarksKey = new PluginKey('newlinePreserveMarksPlugin');
7
7
  var isSelectionAligned = function isSelectionAligned(state) {
@@ -5,7 +5,7 @@ import * as commands from '../../../commands';
5
5
  import * as blockTypes from '../types';
6
6
  import { keymap } from '../../../utils/keymap';
7
7
  import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
8
- import { deleteEmptyParagraphAndMoveBlockUp } from '../../../utils/commands';
8
+ import { deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
9
9
  import { INPUT_METHOD } from '../../analytics';
10
10
  import { isNodeAWrappingBlockNode } from '../utils';
11
11
  var backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
@@ -3,7 +3,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
4
4
  import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { getCursor } from '../../../utils';
6
- import { filterCommands as filter } from '@atlaskit/editor-common/utils';
6
+ import { filterCommand as filter } from '@atlaskit/editor-common/utils';
7
7
  import { isCursorBeforeClosingCharacter, isClosingCharacter } from '../ide-ux/paired-character-handling';
8
8
  import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bracket-handling';
9
9
  import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
@@ -6,7 +6,7 @@ import { TextSelection, Selection } from '@atlaskit/editor-prosemirror/state';
6
6
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
7
7
  import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
8
8
  import { findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
9
- import { filterCommands as filter } from '@atlaskit/editor-common/utils';
9
+ import { filterCommand as filter } from '@atlaskit/editor-common/utils';
10
10
  import { createSelectionClickHandler } from '../../selection/utils';
11
11
  import { fixColumnSizes, fixColumnStructure, getSelectedLayout } from '../actions';
12
12
  import { pluginKey } from './plugin-key';
@@ -2,8 +2,8 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { NodeRange } from '@atlaskit/editor-prosemirror/model';
3
3
  import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
4
4
  import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
5
- import { isListNode, joinSiblingLists } from '../utils/node';
6
- import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
5
+ import { isEmptyParagraph, isListNode } from '@atlaskit/editor-common/utils';
6
+ import { joinSiblingLists } from '@atlaskit/editor-common/lists';
7
7
  import { findFirstParentListNode } from '../utils/find';
8
8
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
9
9
  export function convertListType(_ref) {
@@ -1,9 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import { Selection, TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
3
3
  import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
4
- import { isListItemNode, isListNode } from '../utils/node';
4
+ import { normalizeListItemsSelection } from '@atlaskit/editor-common/lists';
5
5
  import { findFirstParentListItemNode } from '../utils/find';
6
- import { normalizeListItemsSelection } from '../utils/selection';
6
+ import { isListItemNode, isListNode } from '@atlaskit/editor-common/utils';
7
7
  import { GapCursorSelection } from '@atlaskit/editor-common/selection';
8
8
  export var indentListItemsSelected = function indentListItemsSelected(tr) {
9
9
  var originalSelection = tr.selection;
@@ -1,5 +1,5 @@
1
1
  import { LIST_TEXT_SCENARIOS } from '../../analytics';
2
- import { isParagraphNode, isListNode, isListItemNode } from '../utils/node';
2
+ import { isParagraphNode, isListNode, isListItemNode } from '@atlaskit/editor-common/utils';
3
3
  import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
4
4
  import { joinParagrapWithList, joinSiblingListItems, joinNestedListWithParentListItem, joinListItemWithParentNestedList, joinListItemWithParagraph } from './join-list-items-scenarios';
5
5
  export var calcJoinListScenario = function calcJoinListScenario(walkNode, $head) {
@@ -1,6 +1,5 @@
1
- import { insertContentDeleteRange } from '../../../../utils/commands';
1
+ import { insertContentDeleteRange, isListNode } from '@atlaskit/editor-common/utils';
2
2
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
- import { isListNode } from '../../utils/node';
4
3
  // Case for when a users selection is at the end of a paragraph, the paragraph
5
4
  // is followed by a list, and they delete forward
6
5
  export var joinListItemWithParagraph = function joinListItemWithParagraph(_ref) {
@@ -1,5 +1,5 @@
1
- import { insertContentDeleteRange } from '../../../../utils/commands';
2
- import { isListNode } from '../../utils/node';
1
+ import { insertContentDeleteRange } from '@atlaskit/editor-common/utils';
2
+ import { isListNode } from '@atlaskit/editor-common/utils';
3
3
  //Case for two adjacent list items with the first being of greater indentation
4
4
  export var joinListItemWithParentNestedList = function joinListItemWithParentNestedList(_ref) {
5
5
  var tr = _ref.tr,
@@ -1,5 +1,5 @@
1
- import { insertContentDeleteRange } from '../../../../utils/commands';
2
- import { isListNode } from '../../utils/node';
1
+ import { insertContentDeleteRange } from '@atlaskit/editor-common/utils';
2
+ import { isListNode } from '@atlaskit/editor-common/utils';
3
3
  //Case for two adjacent list items with the first being of lower indentation
4
4
  export var joinNestedListWithParentListItem = function joinNestedListWithParentListItem(_ref) {
5
5
  var tr = _ref.tr,
@@ -1,4 +1,4 @@
1
- import { insertContentDeleteRange } from '../../../../utils/commands';
1
+ import { insertContentDeleteRange } from '@atlaskit/editor-common/utils';
2
2
  //Case for two adjacent nodes with the first being a list item and the last being a paragraph
3
3
  export var joinParagrapWithList = function joinParagrapWithList(_ref) {
4
4
  var tr = _ref.tr,
@@ -1,4 +1,4 @@
1
- import { insertContentDeleteRange } from '../../../../utils/commands';
1
+ import { insertContentDeleteRange } from '@atlaskit/editor-common/utils';
2
2
  //Case for two adjacent list items of the same indentation
3
3
  export var joinSiblingListItems = function joinSiblingListItems(_ref) {
4
4
  var tr = _ref.tr,
@@ -1,4 +1,4 @@
1
- import { isListNode } from '../utils/node';
1
+ import { isListNode } from '@atlaskit/editor-common/utils';
2
2
  export function mergeNextListAtPosition(_ref) {
3
3
  var tr = _ref.tr,
4
4
  listPosition = _ref.listPosition;
@@ -4,10 +4,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  import { Selection, TextSelection, NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { NodeRange, Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
6
6
  import { liftTarget, ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
7
- import { getOrderFromOrderedListNode } from '@atlaskit/editor-common/utils';
8
- import { isListNode, isListItemNode, joinSiblingLists, JoinDirection } from '../utils/node';
7
+ import { getOrderFromOrderedListNode, isListNode, isListItemNode } from '@atlaskit/editor-common/utils';
8
+ import { joinSiblingLists, JoinDirection, normalizeListItemsSelection } from '@atlaskit/editor-common/lists';
9
9
  import { findFirstParentListItemNode, findRootParentListNode } from '../utils/find';
10
- import { normalizeListItemsSelection, createListNodeRange } from '../utils/selection';
10
+ import { createListNodeRange } from '../utils/selection';
11
11
  import { GapCursorSelection } from '../../selection/gap-cursor-selection';
12
12
  import { storeRestartListsAttributes, getRestartListsAttributes } from '../utils/analytics';
13
13
  import { OUTDENT_SCENARIOS } from '@atlaskit/editor-common/analytics';
@@ -1,6 +1,6 @@
1
1
  import { Fragment, Slice, NodeRange } from '@atlaskit/editor-prosemirror/model';
2
2
  import { ReplaceAroundStep, findWrapping, canSplit } from '@atlaskit/editor-prosemirror/transform';
3
- import { autoJoinTr } from '../../../utils/prosemirror/autojoin';
3
+ import { autoJoinTr } from '@atlaskit/editor-common/utils';
4
4
  import { GapCursorSelection } from '../../selection/gap-cursor-selection';
5
5
  import { isWrappingPossible } from '../utils/selection';
6
6
 
@@ -2,13 +2,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { hasValidListIndentationLevel } from '../utils/indentation';
5
+ import { hasValidListIndentationLevel, getListItemAttributes, getCommonListAnalyticsAttributes } from '@atlaskit/editor-common/lists';
6
6
  import { indentListItemsSelected as indentListAction } from '../actions/indent-list-items-selected';
7
- import { isBulletList } from '../utils/node';
7
+ import { isBulletList } from '@atlaskit/editor-common/utils';
8
8
  import { findFirstParentListNode } from '../utils/find';
9
9
  import { MAX_NESTED_LIST_INDENTATION } from '../types';
10
- import { isInsideListItem, isInsideTableCell, getListItemAttributes } from '../utils/selection';
11
- import { getCommonListAnalyticsAttributes } from '../utils/analytics';
10
+ import { isInsideListItem, isInsideTableCell } from '../utils/selection';
12
11
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
13
12
  export var indentList = function indentList(editorAnalyticsAPI) {
14
13
  return function () {