@atlaskit/editor-plugin-paste 3.1.4 → 3.1.6

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,19 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 3.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.1.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#129464](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/129464)
14
+ [`d5aeeb5947ae5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d5aeeb5947ae5) -
15
+ Cleans up feature flag that fixes pasting action items in a list
16
+
3
17
  ## 3.1.4
4
18
 
5
19
  ### Patch Changes
@@ -371,7 +371,9 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
371
371
 
372
372
  // get editor-tables to handle pasting tables if it can
373
373
  // otherwise, just the replace the selection with the content
374
- if ((0, _utils3.handlePaste)(view, null, slice)) {
374
+ if ((0, _utils3.handlePaste)(view, event, slice, {
375
+ pasteSource: (0, _util.getPasteSource)(event)
376
+ })) {
375
377
  (0, _analytics2.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, slice, {
376
378
  type: _analytics.PasteTypes.richText
377
379
  });
@@ -135,9 +135,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
135
135
  nodeDepth: (0, _utils.getParentNodeDepth)(selection)
136
136
  };
137
137
  if (isMultiSelectTrackingEnabled) {
138
- var _nodeTypes;
139
138
  newState = _objectSpread(_objectSpread({}, newState), {}, {
140
- nodeTypes: (_nodeTypes = nodeTypes) !== null && _nodeTypes !== void 0 ? _nodeTypes : nodeName,
139
+ nodeTypes: nodeTypes !== null && nodeTypes !== void 0 ? nodeTypes : nodeName,
141
140
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
142
141
  });
143
142
  }
@@ -12,7 +12,6 @@ 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");
16
15
  var _index = require("../index");
17
16
  var _lists = require("./lists");
18
17
  function insertSliceForLists(_ref) {
@@ -108,13 +107,7 @@ function insertSliceForTaskInsideList(_ref5) {
108
107
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
109
108
  var selectionBeforeReplace = tr.selection.from;
110
109
  tr.replaceSelection(new _model.Slice(_model.Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
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
- }
110
+ var nextSelection = _state.Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
111
+ tr.setSelection(nextSelection);
119
112
  tr.replaceSelection(slice);
120
113
  }
@@ -41,7 +41,6 @@ var _model = require("@atlaskit/editor-prosemirror/model");
41
41
  var _state = require("@atlaskit/editor-prosemirror/state");
42
42
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
43
43
  var _utils3 = require("@atlaskit/editor-tables/utils");
44
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
45
44
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
46
45
  var _commands = require("../../editor-commands/commands");
47
46
  var _pluginFactory = require("../plugin-factory");
@@ -266,22 +265,8 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
266
265
  var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
267
266
 
268
267
  // Anything to do with nested lists should safeInsert and not be handled here
269
- if ((0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
270
- if (checkIfSelectionInNestedList(state)) {
271
- return false;
272
- }
273
- } else {
274
- var grandParentListNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
275
- var selectionIsInNestedList = !!grandParentListNode;
276
- var selectedListItemHasNestedList = false;
277
- selectionParentListItemNode.node.content.forEach(function (child) {
278
- if ((0, _utils.isListNode)(child)) {
279
- selectedListItemHasNestedList = true;
280
- }
281
- });
282
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
283
- return false;
284
- }
268
+ if (checkIfSelectionInNestedList(state)) {
269
+ return false;
285
270
  }
286
271
 
287
272
  // Node after the insert position
@@ -1050,7 +1035,7 @@ function handleRichText(slice, queueCardsFromChangedTr) {
1050
1035
  });
1051
1036
  if ((0, _utils.insideTableCell)(state) && (0, _utils.isInListItem)(state) && (0, _utils2.canInsert)(selection.$from, slice.content) && (0, _utils2.canInsert)(selection.$to, slice.content) || sliceHasList) {
1052
1037
  tr.replaceSelection(slice);
1053
- } else if (checkTaskListInList(state, slice) && (!(0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1038
+ } else if (checkTaskListInList(state, slice) && !checkIfSelectionInNestedList(state)) {
1054
1039
  (0, _edgeCases.insertSliceForTaskInsideList)({
1055
1040
  tr: tr,
1056
1041
  slice: slice
@@ -1059,7 +1044,7 @@ function handleRichText(slice, queueCardsFromChangedTr) {
1059
1044
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1060
1045
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1061
1046
  tr = (0, _utils2.safeInsert)(slice.content, tr.selection.$to.pos)(tr);
1062
- if (checkTaskListInList(state, slice) && (0, _platformFeatureFlags.fg)('platform_editor_fix_paste_action_item_in_list')) {
1047
+ if (checkTaskListInList(state, slice)) {
1063
1048
  (0, _edgeCases.updateSelectionAfterReplace)({
1064
1049
  tr: tr
1065
1050
  });
@@ -345,7 +345,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
345
345
 
346
346
  // get editor-tables to handle pasting tables if it can
347
347
  // otherwise, just the replace the selection with the content
348
- if (handlePasteTable(view, null, slice)) {
348
+ if (handlePasteTable(view, event, slice, {
349
+ pasteSource: getPasteSource(event)
350
+ })) {
349
351
  sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
350
352
  type: PasteTypes.richText
351
353
  });
@@ -3,7 +3,6 @@ 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';
7
6
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
8
7
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
9
8
  export function insertSliceForLists({
@@ -111,13 +110,7 @@ export function insertSliceForTaskInsideList({
111
110
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
112
111
  const selectionBeforeReplace = tr.selection.from;
113
112
  tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
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
- }
113
+ const nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
114
+ tr.setSelection(nextSelection);
122
115
  tr.replaceSelection(slice);
123
116
  }
@@ -10,7 +10,6 @@ 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';
14
13
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
15
14
  // TODO: ED-20519 - Needs Macro extraction
16
15
 
@@ -243,22 +242,8 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
243
242
  const listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
244
243
 
245
244
  // Anything to do with nested lists should safeInsert and not be handled here
246
- if (fg('platform_editor_fix_paste_action_item_in_list')) {
247
- if (checkIfSelectionInNestedList(state)) {
248
- return false;
249
- }
250
- } else {
251
- const grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
252
- const selectionIsInNestedList = !!grandParentListNode;
253
- let selectedListItemHasNestedList = false;
254
- selectionParentListItemNode.node.content.forEach(child => {
255
- if (isListNode(child)) {
256
- selectedListItemHasNestedList = true;
257
- }
258
- });
259
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
260
- return false;
261
- }
245
+ if (checkIfSelectionInNestedList(state)) {
246
+ return false;
262
247
  }
263
248
 
264
249
  // Node after the insert position
@@ -1033,7 +1018,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1033
1018
  });
1034
1019
  if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
1035
1020
  tr.replaceSelection(slice);
1036
- } else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1021
+ } else if (checkTaskListInList(state, slice) && !checkIfSelectionInNestedList(state)) {
1037
1022
  insertSliceForTaskInsideList({
1038
1023
  tr,
1039
1024
  slice
@@ -1042,7 +1027,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1042
1027
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1043
1028
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1044
1029
  tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
1045
- if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
1030
+ if (checkTaskListInList(state, slice)) {
1046
1031
  updateSelectionAfterReplace({
1047
1032
  tr
1048
1033
  });
@@ -363,7 +363,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
363
363
 
364
364
  // get editor-tables to handle pasting tables if it can
365
365
  // otherwise, just the replace the selection with the content
366
- if (handlePasteTable(view, null, slice)) {
366
+ if (handlePasteTable(view, event, slice, {
367
+ pasteSource: getPasteSource(event)
368
+ })) {
367
369
  sendPasteAnalyticsEvent(editorAnalyticsAPI)(view, event, slice, {
368
370
  type: PasteTypes.richText
369
371
  });
@@ -129,9 +129,8 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
129
129
  nodeDepth: getParentNodeDepth(selection)
130
130
  };
131
131
  if (isMultiSelectTrackingEnabled) {
132
- var _nodeTypes;
133
132
  newState = _objectSpread(_objectSpread({}, newState), {}, {
134
- nodeTypes: (_nodeTypes = nodeTypes) !== null && _nodeTypes !== void 0 ? _nodeTypes : nodeName,
133
+ nodeTypes: nodeTypes !== null && nodeTypes !== void 0 ? nodeTypes : nodeName,
135
134
  hasSelectedMultipleNodes: hasSelectedMultipleNodes
136
135
  });
137
136
  }
@@ -3,7 +3,6 @@ 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';
7
6
  import { isCursorSelectionAtTextStartOrEnd, isEmptyNode, isSelectionInsidePanel } from '../index';
8
7
  import { insertSliceAtNodeEdge, insertSliceInsideOfPanelNodeSelected, insertSliceIntoEmptyNode, insertSliceIntoRangeSelectionInsideList } from './lists';
9
8
  export function insertSliceForLists(_ref) {
@@ -99,13 +98,7 @@ export function insertSliceForTaskInsideList(_ref5) {
99
98
  //To avoid the list being replaced with the tasklist, enclose the slice within a taskItem.
100
99
  var selectionBeforeReplace = tr.selection.from;
101
100
  tr.replaceSelection(new Slice(Fragment.from(schema.nodes.taskItem.createAndFill()), 0, 0));
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
- }
101
+ var nextSelection = Selection.near(tr.doc.resolve(selectionBeforeReplace + 1));
102
+ tr.setSelection(nextSelection);
110
103
  tr.replaceSelection(slice);
111
104
  }
@@ -18,7 +18,6 @@ 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';
22
21
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
23
22
  // TODO: ED-20519 - Needs Macro extraction
24
23
 
@@ -240,22 +239,8 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
240
239
  var listItemWrappingOffset = $to.depth - selectionParentListNodeWithPos.depth; // difference in depth between to position and list item node
241
240
 
242
241
  // Anything to do with nested lists should safeInsert and not be handled here
243
- if (fg('platform_editor_fix_paste_action_item_in_list')) {
244
- if (checkIfSelectionInNestedList(state)) {
245
- return false;
246
- }
247
- } else {
248
- var grandParentListNode = findParentNodeOfTypeClosestToPos(tr.doc.resolve(selectionParentListNodeWithPos.pos), [bulletList, orderedList]);
249
- var selectionIsInNestedList = !!grandParentListNode;
250
- var selectedListItemHasNestedList = false;
251
- selectionParentListItemNode.node.content.forEach(function (child) {
252
- if (isListNode(child)) {
253
- selectedListItemHasNestedList = true;
254
- }
255
- });
256
- if (selectedListItemHasNestedList || selectionIsInNestedList) {
257
- return false;
258
- }
242
+ if (checkIfSelectionInNestedList(state)) {
243
+ return false;
259
244
  }
260
245
 
261
246
  // Node after the insert position
@@ -1024,7 +1009,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1024
1009
  });
1025
1010
  if (insideTableCell(state) && isInListItem(state) && canInsert(selection.$from, slice.content) && canInsert(selection.$to, slice.content) || sliceHasList) {
1026
1011
  tr.replaceSelection(slice);
1027
- } else if (checkTaskListInList(state, slice) && (!fg('platform_editor_fix_paste_action_item_in_list') || !checkIfSelectionInNestedList(state))) {
1012
+ } else if (checkTaskListInList(state, slice) && !checkIfSelectionInNestedList(state)) {
1028
1013
  insertSliceForTaskInsideList({
1029
1014
  tr: tr,
1030
1015
  slice: slice
@@ -1033,7 +1018,7 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
1033
1018
  // need safeInsert rather than replaceSelection, so that nodes aren't split in half
1034
1019
  // e.g. when pasting a layout into a table, replaceSelection splits the table in half and adds the layout in the middle
1035
1020
  tr = safeInsert(slice.content, tr.selection.$to.pos)(tr);
1036
- if (checkTaskListInList(state, slice) && fg('platform_editor_fix_paste_action_item_in_list')) {
1021
+ if (checkTaskListInList(state, slice)) {
1037
1022
  updateSelectionAfterReplace({
1038
1023
  tr: tr
1039
1024
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,23 +32,23 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
- "@atlaskit/code": "^16.0.0",
36
- "@atlaskit/editor-common": "^102.10.0",
35
+ "@atlaskit/code": "^17.0.0",
36
+ "@atlaskit/editor-common": "^102.18.0",
37
37
  "@atlaskit/editor-markdown-transformer": "^5.16.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
- "@atlaskit/editor-plugin-annotation": "^2.1.0",
39
+ "@atlaskit/editor-plugin-annotation": "^2.2.0",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^2.1.0",
41
- "@atlaskit/editor-plugin-card": "^5.3.0",
41
+ "@atlaskit/editor-plugin-card": "^5.4.0",
42
42
  "@atlaskit/editor-plugin-feature-flags": "^1.3.0",
43
- "@atlaskit/editor-plugin-list": "^4.1.0",
43
+ "@atlaskit/editor-plugin-list": "^4.2.0",
44
44
  "@atlaskit/editor-plugin-media": "^2.3.0",
45
- "@atlaskit/editor-plugin-mentions": "^4.1.0",
45
+ "@atlaskit/editor-plugin-mentions": "^4.3.0",
46
46
  "@atlaskit/editor-prosemirror": "7.0.0",
47
47
  "@atlaskit/editor-tables": "^2.9.0",
48
48
  "@atlaskit/media-client": "^32.0.0",
49
49
  "@atlaskit/media-common": "^12.0.0",
50
50
  "@atlaskit/platform-feature-flags": "^1.1.0",
51
- "@atlaskit/tmp-editor-statsig": "^4.1.0",
51
+ "@atlaskit/tmp-editor-statsig": "^4.6.0",
52
52
  "@babel/runtime": "^7.0.0",
53
53
  "lodash": "^4.17.21",
54
54
  "uuid": "^3.1.0"
@@ -61,7 +61,7 @@
61
61
  "@af/visual-regression": "^1.3.0",
62
62
  "@atlaskit/editor-plugin-block-type": "^5.1.0",
63
63
  "@atlaskit/editor-plugin-history": "^2.0.0",
64
- "@atlaskit/editor-plugin-type-ahead": "^2.1.0",
64
+ "@atlaskit/editor-plugin-type-ahead": "^2.3.0",
65
65
  "@atlaskit/ssr": "^0.4.0",
66
66
  "@atlaskit/visual-regression": "^0.10.0",
67
67
  "@testing-library/react": "^13.4.0",
@@ -123,9 +123,6 @@
123
123
  "platform_editor_fix_captions_on_copy": {
124
124
  "type": "boolean"
125
125
  },
126
- "platform_editor_fix_paste_action_item_in_list": {
127
- "type": "boolean"
128
- },
129
126
  "platform_editor_legacy_content_macro": {
130
127
  "type": "boolean"
131
128
  },