@atlaskit/editor-plugin-paste 7.4.7 → 7.4.9

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,22 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 7.4.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4d676bbdb3ce6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4d676bbdb3ce6) -
8
+ ts-ignore added temporarily to unblock local consumption for help-center, will be removed once
9
+ project refs are setup
10
+ - Updated dependencies
11
+
12
+ ## 7.4.8
13
+
14
+ ### Patch Changes
15
+
16
+ - [`c94c7bb357496`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c94c7bb357496) -
17
+ [ux] EDITOR-3317 Fix beahavior when pasting paragraph from panel into list inside panel
18
+ - Updated dependencies
19
+
3
20
  ## 7.4.7
4
21
 
5
22
  ### Patch Changes
@@ -128,8 +128,12 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
128
128
  props: {
129
129
  // For serialising to plain text
130
130
  clipboardTextSerializer: (0, _platformFeatureFlags.fg)('platform_editor_date_to_text') ? (0, _clipboardTextSerializer.createClipboardTextSerializer)(getIntl()) : _clipboardTextSerializer.clipboardTextSerializer,
131
+ // @ts-ignore - Workaround for help-center local consumption
132
+
131
133
  handleDOMEvents: {
132
134
  // note
135
+ // @ts-ignore - Workaround for help-center local consumption
136
+
133
137
  paste: function paste(view, event) {
134
138
  mostRecentPasteEvent = event;
135
139
  if ((0, _expValEquals.expValEquals)('cc_editor_interactivity_monitoring', 'isEnabled', true) && event.clipboardData) {
@@ -139,6 +143,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
139
143
  }
140
144
  },
141
145
  // note
146
+ // @ts-ignore - Workaround for help-center local consumption
142
147
  handlePaste: function handlePaste(view, rawEvent, slice) {
143
148
  var _text, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$m, _schema$nodes$table;
144
149
  var event = rawEvent;
@@ -264,10 +269,15 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
264
269
  // appendedTransactions to repair them (if they're partial or incomplete) and we don't want
265
270
  // to split those repairing transactions in prosemirror-history when they're being added to the
266
271
  // "done" stack
272
+ // @ts-ignore - Workaround for help-center local consumption
273
+
267
274
  var isPastingTable = tr.steps.some(function (step) {
268
275
  var _slice$content;
269
276
  var slice = (0, _utils.extractSliceFromStep)(step);
270
277
  var tableExists = false;
278
+
279
+ // @ts-ignore - Workaround for help-center local consumption
280
+
271
281
  slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 || _slice$content.forEach(function (node) {
272
282
  if (node.type === state.schema.nodes.table) {
273
283
  tableExists = true;
@@ -525,6 +535,9 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
525
535
  // breakout marks are only valid in the root document.
526
536
  if (selectionParentType !== state.schema.nodes.doc) {
527
537
  var sliceCopy = _model.Slice.fromJSON(state.schema, slice.toJSON() || {});
538
+
539
+ // @ts-ignore - Workaround for help-center local consumption
540
+
528
541
  sliceCopy.content.descendants(function (node) {
529
542
  // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
530
543
  node.marks = node.marks.filter(function (mark) {
@@ -560,6 +573,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
560
573
  }
561
574
  return false;
562
575
  },
576
+ // @ts-ignore - Workaround for help-center local consumption
563
577
  transformPasted: function transformPasted(slice) {
564
578
  if (sanitizePrivateContent) {
565
579
  slice = (0, _handlers.handleMention)(slice, schema);
@@ -590,6 +604,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
590
604
  slice = (0, _transforms.transformSliceToRemoveMacroId)(slice, schema);
591
605
  return slice;
592
606
  },
607
+ // @ts-ignore - Workaround for help-center local consumption
593
608
  transformPastedHTML: function transformPastedHTML(html) {
594
609
  // Fix for issue ED-4438
595
610
  // text from google docs should not be pasted as inline code
@@ -27,11 +27,17 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
27
27
  key: _pluginKey.pluginKey,
28
28
  state: (0, _pluginFactory.createPluginState)(dispatch, _types.defaultState),
29
29
  props: {
30
+ // @ts-ignore - Workaround for help-center local consumption
31
+
30
32
  handleDOMEvents: {
33
+ // @ts-ignore - Workaround for help-center local consumption
34
+
31
35
  cut: function cut() {
32
36
  isCutEvent = true;
33
37
  }
34
38
  },
39
+ // @ts-ignore - Workaround for help-center local consumption
40
+
35
41
  handlePaste: function handlePaste(_ref, event, slice) {
36
42
  var _content$firstChild;
37
43
  var state = _ref.state,
@@ -69,6 +75,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
69
75
  var updatedTr = (0, _commands.resetContentMovedTransform)()(tr);
70
76
  dispatch(updatedTr);
71
77
  },
78
+ // @ts-ignore - Workaround for help-center local consumption
79
+
72
80
  transformCopied: function transformCopied(slice, _ref2) {
73
81
  var _content$firstChild2;
74
82
  var state = _ref2.state,
@@ -42,6 +42,7 @@ var _utils2 = require("@atlaskit/editor-prosemirror/utils");
42
42
  var _utils3 = require("@atlaskit/editor-tables/utils");
43
43
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
44
44
  var _prosemirrorHistory = require("@atlaskit/prosemirror-history");
45
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
45
46
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
46
47
  var _commands = require("../../editor-commands/commands");
47
48
  var _pluginFactory = require("../plugin-factory");
@@ -101,7 +102,7 @@ function handleMention(slice, schema) {
101
102
  }
102
103
  function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
103
104
  return function (state, dispatch) {
104
- var _slice$content$firstC, _slice$content$firstC2, _transformedSlice$con;
105
+ var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _transformedSlice$con;
105
106
  var schema = state.schema,
106
107
  selection = state.tr.selection;
107
108
  var codeMark = schema.marks.code,
@@ -124,12 +125,16 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
124
125
  var selectionIsValidNode = state.selection instanceof _state.NodeSelection && ['decisionList', 'decisionItem', 'taskList', 'taskItem'].includes(state.selection.node.type.name);
125
126
  var selectionHasValidParentNode = (0, _utils2.hasParentNodeOfType)([decisionItem, taskItem, panel])(state.selection);
126
127
  var selectionIsCodeBlock = (0, _utils2.hasParentNodeOfType)([codeBlock])(state.selection);
128
+ var selectionIsListItem = (0, _utils2.hasParentNodeOfType)([listItem])(state.selection);
127
129
  var panelNode = (0, _index.isSelectionInsidePanel)(selection);
128
130
  var selectionIsPanel = Boolean(panelNode);
131
+ var isSliceWholePanel = ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === panel && slice.openStart === 0 && slice.openEnd === 0;
129
132
 
130
133
  // we avoid handling codeBlock-in-panel use case in this function
131
134
  // returning false will allow code to flow into `handleCodeBlock` function
132
- if (selectionIsPanel && selectionIsCodeBlock) {
135
+ // Partial content copied from panels will have panel in the slice
136
+ // Return false to avoid handling this situation when pasted into list in panel and let `handlePastePanelOrDecisionContentIntoList` handle it
137
+ if (selectionIsPanel && (selectionIsCodeBlock || selectionIsListItem && !isSliceWholePanel && (0, _expValEquals.expValEquals)('platform_editor_pasting_text_in_panel', 'isEnabled', true))) {
133
138
  return false;
134
139
  }
135
140
 
@@ -152,7 +157,7 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
152
157
  var selectionIsTaskOrDecision = (0, _utils2.hasParentNode)(function (node) {
153
158
  return node.type === taskItem || node.type === decisionItem;
154
159
  })(selection);
155
- var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
160
+ var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === paragraph && slice.openEnd < 2;
156
161
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
157
162
  return false;
158
163
  }
@@ -165,7 +170,7 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
165
170
  var transformedSlice = compose.apply(null, filters)(slice);
166
171
  var isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
167
172
  var tr = (0, _prosemirrorHistory.closeHistory)(state.tr);
168
- if (panelNode && sliceHasTask && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === panel && (0, _index.isEmptyNode)(panelNode) && selection.$from.node() === selection.$to.node()) {
173
+ if (panelNode && sliceHasTask && ((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type) === panel && (0, _index.isEmptyNode)(panelNode) && selection.$from.node() === selection.$to.node()) {
169
174
  return Boolean((0, _lists.insertSliceInsideOfPanelNodeSelected)(panelNode)({
170
175
  tr: tr,
171
176
  slice: slice
@@ -225,7 +230,7 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
225
230
  }
226
231
  function handlePasteNonNestableBlockNodesIntoList(slice) {
227
232
  return function (state, dispatch) {
228
- var _tr$doc$nodeAt, _slice$content$firstC3, _sliceContent$firstCh, _findParentNodeOfType;
233
+ var _tr$doc$nodeAt, _slice$content$firstC4, _sliceContent$firstCh, _findParentNodeOfType;
229
234
  var tr = state.tr;
230
235
  var selection = tr.selection;
231
236
  var $from = selection.$from,
@@ -292,7 +297,7 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
292
297
  }
293
298
 
294
299
  // handle the insertion of the slice
295
- if (((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type.name) === 'blockquote' && (0, _utils2.contains)(slice.content.firstChild, state.schema.nodes.listItem)) {
300
+ if (((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.type.name) === 'blockquote' && (0, _utils2.contains)(slice.content.firstChild, state.schema.nodes.listItem)) {
296
301
  (0, _edgeCases.insertSliceInsideBlockquote)({
297
302
  tr: tr,
298
303
  slice: slice
@@ -1193,8 +1198,8 @@ var handleSelectedTable = exports.handleSelectedTable = function handleSelectedT
1193
1198
  };
1194
1199
  };
1195
1200
  function checkTaskListInList(state, slice) {
1196
- var _slice$content$firstC4;
1197
- 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) || ''));
1201
+ var _slice$content$firstC5;
1202
+ return Boolean((0, _utils.isInListItem)(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC5 = slice.content.firstChild) === null || _slice$content$firstC5 === void 0 || (_slice$content$firstC5 = _slice$content$firstC5.type) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.name) || ''));
1198
1203
  }
1199
1204
  function checkIfSelectionInNestedList(state) {
1200
1205
  var selection = state.selection,
@@ -94,8 +94,12 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
94
94
  props: {
95
95
  // For serialising to plain text
96
96
  clipboardTextSerializer: fg('platform_editor_date_to_text') ? createClipboardTextSerializer(getIntl()) : clipboardTextSerializer,
97
+ // @ts-ignore - Workaround for help-center local consumption
98
+
97
99
  handleDOMEvents: {
98
100
  // note
101
+ // @ts-ignore - Workaround for help-center local consumption
102
+
99
103
  paste: (view, event) => {
100
104
  mostRecentPasteEvent = event;
101
105
  if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true) && event.clipboardData) {
@@ -105,6 +109,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
105
109
  }
106
110
  },
107
111
  // note
112
+ // @ts-ignore - Workaround for help-center local consumption
113
+
108
114
  handlePaste(view, rawEvent, slice) {
109
115
  var _text, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$m, _schema$nodes$table;
110
116
  const event = rawEvent;
@@ -226,10 +232,15 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
226
232
  // appendedTransactions to repair them (if they're partial or incomplete) and we don't want
227
233
  // to split those repairing transactions in prosemirror-history when they're being added to the
228
234
  // "done" stack
235
+ // @ts-ignore - Workaround for help-center local consumption
236
+
229
237
  const isPastingTable = tr.steps.some(step => {
230
238
  var _slice$content;
231
239
  const slice = extractSliceFromStep(step);
232
240
  let tableExists = false;
241
+
242
+ // @ts-ignore - Workaround for help-center local consumption
243
+
233
244
  slice === null || slice === void 0 ? void 0 : (_slice$content = slice.content) === null || _slice$content === void 0 ? void 0 : _slice$content.forEach(node => {
234
245
  if (node.type === state.schema.nodes.table) {
235
246
  tableExists = true;
@@ -489,6 +500,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
489
500
  // breakout marks are only valid in the root document.
490
501
  if (selectionParentType !== state.schema.nodes.doc) {
491
502
  const sliceCopy = Slice.fromJSON(state.schema, slice.toJSON() || {});
503
+
504
+ // @ts-ignore - Workaround for help-center local consumption
505
+
492
506
  sliceCopy.content.descendants(node => {
493
507
  // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
494
508
  node.marks = node.marks.filter(mark => mark.type.name !== 'breakout');
@@ -522,6 +536,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
522
536
  }
523
537
  return false;
524
538
  },
539
+ // @ts-ignore - Workaround for help-center local consumption
540
+
525
541
  transformPasted(slice) {
526
542
  if (sanitizePrivateContent) {
527
543
  slice = handleMention(slice, schema);
@@ -552,6 +568,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
552
568
  slice = transformSliceToRemoveMacroId(slice, schema);
553
569
  return slice;
554
570
  },
571
+ // @ts-ignore - Workaround for help-center local consumption
572
+
555
573
  transformPastedHTML(html) {
556
574
  // Fix for issue ED-4438
557
575
  // text from google docs should not be pasted as inline code
@@ -18,11 +18,17 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
18
18
  key: pluginKey,
19
19
  state: createPluginState(dispatch, defaultState),
20
20
  props: {
21
+ // @ts-ignore - Workaround for help-center local consumption
22
+
21
23
  handleDOMEvents: {
24
+ // @ts-ignore - Workaround for help-center local consumption
25
+
22
26
  cut: () => {
23
27
  isCutEvent = true;
24
28
  }
25
29
  },
30
+ // @ts-ignore - Workaround for help-center local consumption
31
+
26
32
  handlePaste: ({
27
33
  state,
28
34
  dispatch
@@ -66,6 +72,8 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
66
72
  const updatedTr = resetContentMovedTransform()(tr);
67
73
  dispatch(updatedTr);
68
74
  },
75
+ // @ts-ignore - Workaround for help-center local consumption
76
+
69
77
  transformCopied: (slice, {
70
78
  state,
71
79
  dispatch
@@ -12,6 +12,7 @@ import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestT
12
12
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
13
13
  import { fg } from '@atlaskit/platform-feature-flags';
14
14
  import { closeHistory } from '@atlaskit/prosemirror-history';
15
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
15
16
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  // TODO: ED-20519 - Needs Macro extraction
17
18
 
@@ -64,7 +65,7 @@ export function handleMention(slice, schema) {
64
65
  }
65
66
  export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
66
67
  return (state, dispatch) => {
67
- var _slice$content$firstC, _slice$content$firstC2, _transformedSlice$con;
68
+ var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _transformedSlice$con;
68
69
  const {
69
70
  schema,
70
71
  tr: {
@@ -96,12 +97,16 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
96
97
  const selectionIsValidNode = state.selection instanceof NodeSelection && ['decisionList', 'decisionItem', 'taskList', 'taskItem'].includes(state.selection.node.type.name);
97
98
  const selectionHasValidParentNode = hasParentNodeOfType([decisionItem, taskItem, panel])(state.selection);
98
99
  const selectionIsCodeBlock = hasParentNodeOfType([codeBlock])(state.selection);
100
+ const selectionIsListItem = hasParentNodeOfType([listItem])(state.selection);
99
101
  const panelNode = isSelectionInsidePanel(selection);
100
102
  const selectionIsPanel = Boolean(panelNode);
103
+ const isSliceWholePanel = ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === panel && slice.openStart === 0 && slice.openEnd === 0;
101
104
 
102
105
  // we avoid handling codeBlock-in-panel use case in this function
103
106
  // returning false will allow code to flow into `handleCodeBlock` function
104
- if (selectionIsPanel && selectionIsCodeBlock) {
107
+ // Partial content copied from panels will have panel in the slice
108
+ // Return false to avoid handling this situation when pasted into list in panel and let `handlePastePanelOrDecisionContentIntoList` handle it
109
+ if (selectionIsPanel && (selectionIsCodeBlock || selectionIsListItem && !isSliceWholePanel && expValEquals('platform_editor_pasting_text_in_panel', 'isEnabled', true))) {
105
110
  return false;
106
111
  }
107
112
 
@@ -122,7 +127,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
122
127
  // and it is not from a depth that would indicate it being from inside from another node (e.g. text from a decision)
123
128
  // then we can rely on the default behaviour.
124
129
  const selectionIsTaskOrDecision = hasParentNode(node => node.type === taskItem || node.type === decisionItem)(selection);
125
- const sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
130
+ const sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === paragraph && slice.openEnd < 2;
126
131
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
127
132
  return false;
128
133
  }
@@ -135,7 +140,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
135
140
  const transformedSlice = compose.apply(null, filters)(slice);
136
141
  const isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
137
142
  const tr = closeHistory(state.tr);
138
- if (panelNode && sliceHasTask && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === panel && isEmptyNode(panelNode) && selection.$from.node() === selection.$to.node()) {
143
+ if (panelNode && sliceHasTask && ((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type) === panel && isEmptyNode(panelNode) && selection.$from.node() === selection.$to.node()) {
139
144
  return Boolean(insertSliceInsideOfPanelNodeSelected(panelNode)({
140
145
  tr,
141
146
  slice
@@ -195,7 +200,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
195
200
  }
196
201
  export function handlePasteNonNestableBlockNodesIntoList(slice) {
197
202
  return (state, dispatch) => {
198
- var _tr$doc$nodeAt, _slice$content$firstC3, _sliceContent$firstCh, _findParentNodeOfType;
203
+ var _tr$doc$nodeAt, _slice$content$firstC4, _sliceContent$firstCh, _findParentNodeOfType;
199
204
  const {
200
205
  tr
201
206
  } = state;
@@ -269,7 +274,7 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
269
274
  }
270
275
 
271
276
  // handle the insertion of the slice
272
- if (((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type.name) === 'blockquote' && contains(slice.content.firstChild, state.schema.nodes.listItem)) {
277
+ if (((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.type.name) === 'blockquote' && contains(slice.content.firstChild, state.schema.nodes.listItem)) {
273
278
  insertSliceInsideBlockquote({
274
279
  tr,
275
280
  slice
@@ -1172,8 +1177,8 @@ export const handleSelectedTable = editorAnalyticsAPI => slice => (state, dispat
1172
1177
  return false;
1173
1178
  };
1174
1179
  export function checkTaskListInList(state, slice) {
1175
- var _slice$content$firstC4, _slice$content$firstC5;
1176
- 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) || ''));
1180
+ var _slice$content$firstC5, _slice$content$firstC6;
1181
+ return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC5 = slice.content.firstChild) === null || _slice$content$firstC5 === void 0 ? void 0 : (_slice$content$firstC6 = _slice$content$firstC5.type) === null || _slice$content$firstC6 === void 0 ? void 0 : _slice$content$firstC6.name) || ''));
1177
1182
  }
1178
1183
  export function checkIfSelectionInNestedList(state) {
1179
1184
  const {
@@ -120,8 +120,12 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
120
120
  props: {
121
121
  // For serialising to plain text
122
122
  clipboardTextSerializer: fg('platform_editor_date_to_text') ? createClipboardTextSerializer(getIntl()) : clipboardTextSerializer,
123
+ // @ts-ignore - Workaround for help-center local consumption
124
+
123
125
  handleDOMEvents: {
124
126
  // note
127
+ // @ts-ignore - Workaround for help-center local consumption
128
+
125
129
  paste: function paste(view, event) {
126
130
  mostRecentPasteEvent = event;
127
131
  if (expValEquals('cc_editor_interactivity_monitoring', 'isEnabled', true) && event.clipboardData) {
@@ -131,6 +135,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
131
135
  }
132
136
  },
133
137
  // note
138
+ // @ts-ignore - Workaround for help-center local consumption
134
139
  handlePaste: function handlePaste(view, rawEvent, slice) {
135
140
  var _text, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$m, _schema$nodes$table;
136
141
  var event = rawEvent;
@@ -256,10 +261,15 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
256
261
  // appendedTransactions to repair them (if they're partial or incomplete) and we don't want
257
262
  // to split those repairing transactions in prosemirror-history when they're being added to the
258
263
  // "done" stack
264
+ // @ts-ignore - Workaround for help-center local consumption
265
+
259
266
  var isPastingTable = tr.steps.some(function (step) {
260
267
  var _slice$content;
261
268
  var slice = extractSliceFromStep(step);
262
269
  var tableExists = false;
270
+
271
+ // @ts-ignore - Workaround for help-center local consumption
272
+
263
273
  slice === null || slice === void 0 || (_slice$content = slice.content) === null || _slice$content === void 0 || _slice$content.forEach(function (node) {
264
274
  if (node.type === state.schema.nodes.table) {
265
275
  tableExists = true;
@@ -517,6 +527,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
517
527
  // breakout marks are only valid in the root document.
518
528
  if (selectionParentType !== state.schema.nodes.doc) {
519
529
  var sliceCopy = Slice.fromJSON(state.schema, slice.toJSON() || {});
530
+
531
+ // @ts-ignore - Workaround for help-center local consumption
532
+
520
533
  sliceCopy.content.descendants(function (node) {
521
534
  // @ts-ignore - [unblock prosemirror bump] assigning to readonly prop
522
535
  node.marks = node.marks.filter(function (mark) {
@@ -552,6 +565,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
552
565
  }
553
566
  return false;
554
567
  },
568
+ // @ts-ignore - Workaround for help-center local consumption
555
569
  transformPasted: function transformPasted(slice) {
556
570
  if (sanitizePrivateContent) {
557
571
  slice = handleMention(slice, schema);
@@ -582,6 +596,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
582
596
  slice = transformSliceToRemoveMacroId(slice, schema);
583
597
  return slice;
584
598
  },
599
+ // @ts-ignore - Workaround for help-center local consumption
585
600
  transformPastedHTML: function transformPastedHTML(html) {
586
601
  // Fix for issue ED-4438
587
602
  // text from google docs should not be pasted as inline code
@@ -21,11 +21,17 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
21
21
  key: pluginKey,
22
22
  state: createPluginState(dispatch, defaultState),
23
23
  props: {
24
+ // @ts-ignore - Workaround for help-center local consumption
25
+
24
26
  handleDOMEvents: {
27
+ // @ts-ignore - Workaround for help-center local consumption
28
+
25
29
  cut: function cut() {
26
30
  isCutEvent = true;
27
31
  }
28
32
  },
33
+ // @ts-ignore - Workaround for help-center local consumption
34
+
29
35
  handlePaste: function handlePaste(_ref, event, slice) {
30
36
  var _content$firstChild;
31
37
  var state = _ref.state,
@@ -63,6 +69,8 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
63
69
  var updatedTr = resetContentMovedTransform()(tr);
64
70
  dispatch(updatedTr);
65
71
  },
72
+ // @ts-ignore - Workaround for help-center local consumption
73
+
66
74
  transformCopied: function transformCopied(slice, _ref2) {
67
75
  var _content$firstChild2;
68
76
  var state = _ref2.state,
@@ -20,6 +20,7 @@ import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestT
20
20
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import { closeHistory } from '@atlaskit/prosemirror-history';
23
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
23
24
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
24
25
  // TODO: ED-20519 - Needs Macro extraction
25
26
 
@@ -75,7 +76,7 @@ export function handleMention(slice, schema) {
75
76
  }
76
77
  export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
77
78
  return function (state, dispatch) {
78
- var _slice$content$firstC, _slice$content$firstC2, _transformedSlice$con;
79
+ var _slice$content$firstC, _slice$content$firstC2, _slice$content$firstC3, _transformedSlice$con;
79
80
  var schema = state.schema,
80
81
  selection = state.tr.selection;
81
82
  var codeMark = schema.marks.code,
@@ -98,12 +99,16 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
98
99
  var selectionIsValidNode = state.selection instanceof NodeSelection && ['decisionList', 'decisionItem', 'taskList', 'taskItem'].includes(state.selection.node.type.name);
99
100
  var selectionHasValidParentNode = hasParentNodeOfType([decisionItem, taskItem, panel])(state.selection);
100
101
  var selectionIsCodeBlock = hasParentNodeOfType([codeBlock])(state.selection);
102
+ var selectionIsListItem = hasParentNodeOfType([listItem])(state.selection);
101
103
  var panelNode = isSelectionInsidePanel(selection);
102
104
  var selectionIsPanel = Boolean(panelNode);
105
+ var isSliceWholePanel = ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === panel && slice.openStart === 0 && slice.openEnd === 0;
103
106
 
104
107
  // we avoid handling codeBlock-in-panel use case in this function
105
108
  // returning false will allow code to flow into `handleCodeBlock` function
106
- if (selectionIsPanel && selectionIsCodeBlock) {
109
+ // Partial content copied from panels will have panel in the slice
110
+ // Return false to avoid handling this situation when pasted into list in panel and let `handlePastePanelOrDecisionContentIntoList` handle it
111
+ if (selectionIsPanel && (selectionIsCodeBlock || selectionIsListItem && !isSliceWholePanel && expValEquals('platform_editor_pasting_text_in_panel', 'isEnabled', true))) {
107
112
  return false;
108
113
  }
109
114
 
@@ -126,7 +131,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
126
131
  var selectionIsTaskOrDecision = hasParentNode(function (node) {
127
132
  return node.type === taskItem || node.type === decisionItem;
128
133
  })(selection);
129
- var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
134
+ var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === paragraph && slice.openEnd < 2;
130
135
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
131
136
  return false;
132
137
  }
@@ -139,7 +144,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
139
144
  var transformedSlice = compose.apply(null, filters)(slice);
140
145
  var isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
141
146
  var tr = closeHistory(state.tr);
142
- if (panelNode && sliceHasTask && ((_slice$content$firstC2 = slice.content.firstChild) === null || _slice$content$firstC2 === void 0 ? void 0 : _slice$content$firstC2.type) === panel && isEmptyNode(panelNode) && selection.$from.node() === selection.$to.node()) {
147
+ if (panelNode && sliceHasTask && ((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type) === panel && isEmptyNode(panelNode) && selection.$from.node() === selection.$to.node()) {
143
148
  return Boolean(insertSliceInsideOfPanelNodeSelected(panelNode)({
144
149
  tr: tr,
145
150
  slice: slice
@@ -199,7 +204,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
199
204
  }
200
205
  export function handlePasteNonNestableBlockNodesIntoList(slice) {
201
206
  return function (state, dispatch) {
202
- var _tr$doc$nodeAt, _slice$content$firstC3, _sliceContent$firstCh, _findParentNodeOfType;
207
+ var _tr$doc$nodeAt, _slice$content$firstC4, _sliceContent$firstCh, _findParentNodeOfType;
203
208
  var tr = state.tr;
204
209
  var selection = tr.selection;
205
210
  var $from = selection.$from,
@@ -266,7 +271,7 @@ export function handlePasteNonNestableBlockNodesIntoList(slice) {
266
271
  }
267
272
 
268
273
  // handle the insertion of the slice
269
- if (((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.type.name) === 'blockquote' && contains(slice.content.firstChild, state.schema.nodes.listItem)) {
274
+ if (((_slice$content$firstC4 = slice.content.firstChild) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.type.name) === 'blockquote' && contains(slice.content.firstChild, state.schema.nodes.listItem)) {
270
275
  insertSliceInsideBlockquote({
271
276
  tr: tr,
272
277
  slice: slice
@@ -1167,8 +1172,8 @@ export var handleSelectedTable = function handleSelectedTable(editorAnalyticsAPI
1167
1172
  };
1168
1173
  };
1169
1174
  export function checkTaskListInList(state, slice) {
1170
- var _slice$content$firstC4;
1171
- 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) || ''));
1175
+ var _slice$content$firstC5;
1176
+ return Boolean(isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC5 = slice.content.firstChild) === null || _slice$content$firstC5 === void 0 || (_slice$content$firstC5 = _slice$content$firstC5.type) === null || _slice$content$firstC5 === void 0 ? void 0 : _slice$content$firstC5.name) || ''));
1172
1177
  }
1173
1178
  export function checkIfSelectionInNestedList(state) {
1174
1179
  var selection = state.selection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "7.4.7",
3
+ "version": "7.4.9",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -44,14 +44,14 @@
44
44
  "@atlaskit/media-client": "^35.6.0",
45
45
  "@atlaskit/media-common": "^12.3.0",
46
46
  "@atlaskit/platform-feature-flags": "^1.1.0",
47
- "@atlaskit/tmp-editor-statsig": "^13.38.0",
47
+ "@atlaskit/tmp-editor-statsig": "^13.42.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "lodash": "^4.17.21",
50
50
  "react-intl-next": "npm:react-intl@^5.18.1",
51
51
  "uuid": "^3.1.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@atlaskit/editor-common": "^110.32.0",
54
+ "@atlaskit/editor-common": "^110.34.0",
55
55
  "react": "^18.2.0",
56
56
  "react-dom": "^18.2.0"
57
57
  },