@atlaskit/editor-plugin-paste 2.1.0 → 2.1.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 2.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#103729](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/103729)
8
+ [`3188f307d178a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3188f307d178a) -
9
+ ED-25321: fixes issue where pasting action/task item into the middle of a list item will paste in
10
+ the wrong location and create an extra empty task item
11
+
3
12
  ## 2.1.0
4
13
 
5
14
  ### Minor Changes
@@ -12,6 +12,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
12
12
  var _state = require("@atlaskit/editor-prosemirror/state");
13
13
  var _transform = require("@atlaskit/editor-prosemirror/transform");
14
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
15
16
  var _index = require("../index");
16
17
  var _lists = require("./lists");
17
18
  function insertSliceForLists(_ref) {
@@ -105,9 +106,15 @@ function insertSliceForTaskInsideList(_ref5) {
105
106
  slice = _ref5.slice;
106
107
  var schema = tr.doc.type.schema;
107
108
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
109
+ var selectionBeforeReplace = tr.selection.from;
108
110
  tr.replaceSelection(new _model.Slice(_model.Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
109
- updateSelectionAfterReplace({
110
- tr: tr
111
- });
111
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
112
+ var nextSelection = _state.Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
113
+ tr.setSelection(nextSelection);
114
+ } else {
115
+ updateSelectionAfterReplace({
116
+ tr: tr
117
+ });
118
+ }
112
119
  tr.replaceSelection(slice);
113
120
  }
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.checkIfSelectionInNestedList = checkIfSelectionInNestedList;
7
8
  exports.checkTaskListInList = checkTaskListInList;
8
9
  exports.doesSelectionWhichStartsOrEndsInListContainEntireList = void 0;
9
10
  exports.flattenNestedListInSlice = flattenNestedListInSlice;
@@ -40,6 +41,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
40
41
  var _state = require("@atlaskit/editor-prosemirror/state");
41
42
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
42
43
  var _utils3 = require("@atlaskit/editor-tables/utils");
44
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
43
45
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
44
46
  var _commands = require("../../editor-commands/commands");
45
47
  var _main = require("../main");
@@ -265,16 +267,22 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
265
267
  var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
266
268
 
267
269
  // Anything to do with nested lists should safeInsert and not be handled here
268
- var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
269
- var selectionIsInNestedList = !!grandParentListNode;
270
- var selectedListItemHasNestedList = false;
271
- selectionParentListItemNode.node.content.forEach(function (child) {
272
- if ((0, _utils.isListNode)(child)) {
273
- selectedListItemHasNestedList = true;
270
+ if ((0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
271
+ if (checkIfSelectionInNestedList(state)) {
272
+ return false;
273
+ }
274
+ } else {
275
+ var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
276
+ var selectionIsInNestedList = !!grandParentListNode;
277
+ var selectedListItemHasNestedList = false;
278
+ selectionParentListItemNode.node.content.forEach(function (child) {
279
+ if ((0, _utils.isListNode)(child)) {
280
+ selectedListItemHasNestedList = true;
281
+ }
282
+ });
283
+ if (selectedListItemHasNestedList || selectionIsInNestedList) {
284
+ return false;
274
285
  }
275
- });
276
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
277
- return false;
278
286
  }
279
287
 
280
288
  // Node after the insert position
@@ -1057,7 +1065,7 @@ function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodebloc
1057
1065
  });
1058
1066
  if ((0, _utils.insideTableCell)(state) && (0, _utils.isInListItem)(state) && (0, _utils2.canInsert)(selection.$from, slice.content) && (0, _utils2.canInsert)(selection.$to, slice.content) || sliceHasList) {
1059
1067
  tr.replaceSelection(slice);
1060
- } else if (checkTaskListInList(state, slice)) {
1068
+ } else if (checkTaskListInList(state, slice) && (!(0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1061
1069
  (0, _edgeCases.insertSliceForTaskInsideList)({
1062
1070
  tr: tr,
1063
1071
  slice: slice
@@ -1066,6 +1074,11 @@ function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodebloc
1066
1074
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1067
1075
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1068
1076
  tr = (0, _utils2.safeInsert)(slice.content, tr.selection.$to.pos)(tr);
1077
+ if (checkTaskListInList(state, slice) && (0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
1078
+ (0, _edgeCases.updateSelectionAfterReplace)({
1079
+ tr: tr
1080
+ });
1081
+ }
1069
1082
  }
1070
1083
  }
1071
1084
  tr.setStoredMarks([]);
@@ -1119,4 +1132,26 @@ var handleSelectedTable = exports.handleSelectedTable = function handleSelectedT
1119
1132
  function checkTaskListInList(state, slice) {
1120
1133
  var _slice$content$firstC4;
1121
1134
  return Boolean((0, _utils.isInListItem)(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 || (_slice$content$firstC4 = _slice$content$firstC4.type) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.name) || ''));
1135
+ }
1136
+ function checkIfSelectionInNestedList(state) {
1137
+ var selection = state.selection,
1138
+ tr = state.tr;
1139
+ var _state$schema$nodes5 = state.schema.nodes,
1140
+ orderedList = _state$schema$nodes5.orderedList,
1141
+ bulletList = _state$schema$nodes5.bulletList,
1142
+ listItem = _state$schema$nodes5.listItem;
1143
+ var selectionParentListItemNode = (0, _utils2.findParentNodeOfType)(listItem)(selection);
1144
+ var selectionParentListNodeWithPos = (0, _utils2.findParentNodeOfType)([bulletList, orderedList])(selection);
1145
+ if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
1146
+ return false;
1147
+ }
1148
+ var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
1149
+ var selectionIsInNestedList = !!grandParentListNode;
1150
+ var selectedListItemHasNestedList = false;
1151
+ selectionParentListItemNode.node.content.forEach(function (child) {
1152
+ if ((0, _utils.isListNode)(child)) {
1153
+ selectedListItemHasNestedList = true;
1154
+ }
1155
+ });
1156
+ return selectedListItemHasNestedList || selectionIsInNestedList;
1122
1157
  }
@@ -3,6 +3,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
7
8
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
8
9
  export function insertSliceForLists({
@@ -108,9 +109,15 @@ export function insertSliceForTaskInsideList({
108
109
  schema
109
110
  } = tr.doc.type;
110
111
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
112
+ const selectionBeforeReplace = tr.selection.from;
111
113
  tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
112
- updateSelectionAfterReplace({
113
- tr
114
- });
114
+ if (fg('platform_editor_fix_paste_action_item_in_list')) {
115
+ const nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
116
+ tr.setSelection(nextSelection);
117
+ } else {
118
+ updateSelectionAfterReplace({
119
+ tr
120
+ });
121
+ }
115
122
  tr.replaceSelection(slice);
116
123
  }
@@ -10,13 +10,14 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
10
10
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
11
11
  import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
12
12
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
13
14
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
14
15
  // TODO: ED-20519 Needs Macro extraction
15
16
 
16
17
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
17
18
  import { isInsideBlockQuote } from '../main';
18
19
  import { getPluginState as getPastePluginState } from '../plugin-factory';
19
- import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
20
+ import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
20
21
  import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
21
22
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './index';
22
23
  const insideExpand = state => {
@@ -243,16 +244,22 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
243
244
  const listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
244
245
 
245
246
  // Anything to do with nested lists should safeInsert and not be handled here
246
- const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
247
- const selectionIsInNestedList = !!grandParentListNode;
248
- let selectedListItemHasNestedList = false;
249
- selectionParentListItemNode.node.content.forEach(child => {
250
- if (isListNode(child)) {
251
- selectedListItemHasNestedList = true;
247
+ if (fg('platform_editor_fix_paste_action_item_in_list')) {
248
+ if (checkIfSelectionInNestedList(state)) {
249
+ return false;
250
+ }
251
+ } else {
252
+ const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
253
+ const selectionIsInNestedList = !!grandParentListNode;
254
+ let selectedListItemHasNestedList = false;
255
+ selectionParentListItemNode.node.content.forEach(child => {
256
+ if (isListNode(child)) {
257
+ selectedListItemHasNestedList = true;
258
+ }
259
+ });
260
+ if (selectedListItemHasNestedList || selectionIsInNestedList) {
261
+ return false;
252
262
  }
253
- });
254
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
255
- return false;
256
263
  }
257
264
 
258
265
  // Node after the insert position
@@ -1041,7 +1048,7 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
1041
1048
  });
1042
1049
  if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
1043
1050
  tr.replaceSelection(slice);
1044
- } else if (checkTaskListInList(state, slice)) {
1051
+ } else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1045
1052
  insertSliceForTaskInsideList({
1046
1053
  tr,
1047
1054
  slice
@@ -1050,6 +1057,11 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
1050
1057
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1051
1058
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1052
1059
  tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
1060
+ if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
1061
+ updateSelectionAfterReplace({
1062
+ tr
1063
+ });
1064
+ }
1053
1065
  }
1054
1066
  }
1055
1067
  tr.setStoredMarks([]);
@@ -1101,4 +1113,29 @@ export const handleSelectedTable = editorAnalyticsAPI => slice => (state, dispat
1101
1113
  export function checkTaskListInList(state, slice) {
1102
1114
  var _slice$content$firstC4, _slice$content$firstC5;
1103
1115
  return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 ? void 0 : (_slice$content$firstC5 = _slice$content$firstC4.type) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.name) || ''));
1116
+ }
1117
+ export function checkIfSelectionInNestedList(state) {
1118
+ const {
1119
+ selection,
1120
+ tr
1121
+ } = state;
1122
+ const {
1123
+ orderedList,
1124
+ bulletList,
1125
+ listItem
1126
+ } = state.schema.nodes;
1127
+ const selectionParentListItemNode = findParentNodeOfType(listItem)(selection);
1128
+ const selectionParentListNodeWithPos = findParentNodeOfType([bulletList, orderedList])(selection);
1129
+ if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
1130
+ return false;
1131
+ }
1132
+ const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
1133
+ const selectionIsInNestedList = !!grandParentListNode;
1134
+ let selectedListItemHasNestedList = false;
1135
+ selectionParentListItemNode.node.content.forEach(child => {
1136
+ if (isListNode(child)) {
1137
+ selectedListItemHasNestedList = true;
1138
+ }
1139
+ });
1140
+ return selectedListItemHasNestedList || selectionIsInNestedList;
1104
1141
  }
@@ -3,6 +3,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
5
5
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
6
+ import { fg } from '@atlaskit/platform-feature-flags';
6
7
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
7
8
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
8
9
  export function insertSliceForLists(_ref) {
@@ -96,9 +97,15 @@ export function insertSliceForTaskInsideList(_ref5) {
96
97
  slice = _ref5.slice;
97
98
  var schema = tr.doc.type.schema;
98
99
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
100
+ var selectionBeforeReplace = tr.selection.from;
99
101
  tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
100
- updateSelectionAfterReplace({
101
- tr: tr
102
- });
102
+ if (fg('platform_editor_fix_paste_action_item_in_list')) {
103
+ var nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
104
+ tr.setSelection(nextSelection);
105
+ } else {
106
+ updateSelectionAfterReplace({
107
+ tr: tr
108
+ });
109
+ }
103
110
  tr.replaceSelection(slice);
104
111
  }
@@ -18,13 +18,14 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
18
18
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
19
19
  import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
20
20
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
21
+ import { fg } from '@atlaskit/platform-feature-flags';
21
22
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
23
  // TODO: ED-20519 Needs Macro extraction
23
24
 
24
25
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
25
26
  import { isInsideBlockQuote } from '../main';
26
27
  import { getPluginState as getPastePluginState } from '../plugin-factory';
27
- import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
28
+ import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
28
29
  import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
29
30
  import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './index';
30
31
  var insideExpand = function insideExpand(state) {
@@ -240,16 +241,22 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
240
241
  var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
241
242
 
242
243
  // Anything to do with nested lists should safeInsert and not be handled here
243
- var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
244
- var selectionIsInNestedList = !!grandParentListNode;
245
- var selectedListItemHasNestedList = false;
246
- selectionParentListItemNode.node.content.forEach(function (child) {
247
- if (isListNode(child)) {
248
- selectedListItemHasNestedList = true;
244
+ if (fg('platform_editor_fix_paste_action_item_in_list')) {
245
+ if (checkIfSelectionInNestedList(state)) {
246
+ return false;
247
+ }
248
+ } else {
249
+ var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
250
+ var selectionIsInNestedList = !!grandParentListNode;
251
+ var selectedListItemHasNestedList = false;
252
+ selectionParentListItemNode.node.content.forEach(function (child) {
253
+ if (isListNode(child)) {
254
+ selectedListItemHasNestedList = true;
255
+ }
256
+ });
257
+ if (selectedListItemHasNestedList || selectionIsInNestedList) {
258
+ return false;
249
259
  }
250
- });
251
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
252
- return false;
253
260
  }
254
261
 
255
262
  // Node after the insert position
@@ -1032,7 +1039,7 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
1032
1039
  });
1033
1040
  if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
1034
1041
  tr.replaceSelection(slice);
1035
- } else if (checkTaskListInList(state, slice)) {
1042
+ } else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1036
1043
  insertSliceForTaskInsideList({
1037
1044
  tr: tr,
1038
1045
  slice: slice
@@ -1041,6 +1048,11 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
1041
1048
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1042
1049
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1043
1050
  tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
1051
+ if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
1052
+ updateSelectionAfterReplace({
1053
+ tr: tr
1054
+ });
1055
+ }
1044
1056
  }
1045
1057
  }
1046
1058
  tr.setStoredMarks([]);
@@ -1094,4 +1106,26 @@ export var handleSelectedTable = function handleSelectedTable(editorAnalyticsAPI
1094
1106
  export function checkTaskListInList(state, slice) {
1095
1107
  var _slice$content$firstC4;
1096
1108
  return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 || (_slice$content$firstC4 = _slice$content$firstC4.type) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.name) || ''));
1109
+ }
1110
+ export function checkIfSelectionInNestedList(state) {
1111
+ var selection = state.selection,
1112
+ tr = state.tr;
1113
+ var _state$schema$nodes5 = state.schema.nodes,
1114
+ orderedList = _state$schema$nodes5.orderedList,
1115
+ bulletList = _state$schema$nodes5.bulletList,
1116
+ listItem = _state$schema$nodes5.listItem;
1117
+ var selectionParentListItemNode = findParentNodeOfType(listItem)(selection);
1118
+ var selectionParentListNodeWithPos = findParentNodeOfType([bulletList, orderedList])(selection);
1119
+ if (!selectionParentListItemNode || !selectionParentListNodeWithPos) {
1120
+ return false;
1121
+ }
1122
+ var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
1123
+ var selectionIsInNestedList = !!grandParentListNode;
1124
+ var selectedListItemHasNestedList = false;
1125
+ selectionParentListItemNode.node.content.forEach(function (child) {
1126
+ if (isListNode(child)) {
1127
+ selectedListItemHasNestedList = true;
1128
+ }
1129
+ });
1130
+ return selectedListItemHasNestedList || selectionIsInNestedList;
1097
1131
  }
@@ -56,3 +56,4 @@ export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: Qu
56
56
  export declare function handlePasteIntoCaption(slice: Slice): Command;
57
57
  export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
58
58
  export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
59
+ export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
@@ -56,3 +56,4 @@ export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: Qu
56
56
  export declare function handlePasteIntoCaption(slice: Slice): Command;
57
57
  export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
58
58
  export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
59
+ export declare function checkIfSelectionInNestedList(state: EditorState): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -124,6 +124,9 @@
124
124
  },
125
125
  "platform_editor_fix_captions_on_copy": {
126
126
  "type": "boolean"
127
+ },
128
+ "platform_editor_fix_paste_action_item_in_list": {
129
+ "type": "boolean"
127
130
  }
128
131
  }
129
132
  }