@atlaskit/editor-plugin-paste 3.1.8 → 3.2.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,27 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 3.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#139698](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/139698)
8
+ [`cf8ea53ed0264`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cf8ea53ed0264) -
9
+ Clean-up nested expand feature gate
10
+ - Updated dependencies
11
+
12
+ ## 3.2.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [#134613](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134613)
17
+ [`be20cc186939b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/be20cc186939b) -
18
+ ED-26247 Remove feature flag platform_media_extended_resize_experience and replace it with a new
19
+ media prop which defaults to false allowPixelResizing
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies
24
+
3
25
  ## 3.1.8
4
26
 
5
27
  ### Patch Changes
@@ -358,12 +358,12 @@ var handlePasteNonNestableBlockNodesIntoListWithAnalytics = exports.handlePasteN
358
358
  }))((0, _handlers.handlePasteNonNestableBlockNodesIntoList)(slice));
359
359
  };
360
360
  };
361
- var handleExpandWithAnalytics = exports.handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported) {
361
+ var handleExpandWithAnalytics = exports.handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI) {
362
362
  return function (view, event, slice) {
363
363
  return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
364
364
  type: _analytics.PasteTypes.richText,
365
365
  pasteSplitList: true
366
- }))((0, _handlers.handleExpandPaste)(slice, isNestingExpandsSupported));
366
+ }))((0, _handlers.handleExpandPaste)(slice));
367
367
  };
368
368
  };
369
369
  var handleNestedTablePasteWithAnalytics = exports.handleNestedTablePasteWithAnalytics = function handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, isNestingTablesSupported) {
@@ -23,6 +23,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
23
23
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
24
24
  var _utils3 = require("@atlaskit/editor-tables/utils");
25
25
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
26
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
26
27
  var _actions = require("../editor-actions/actions");
27
28
  var _commands = require("../editor-commands/commands");
28
29
  var _media = require("../pm-plugins/media");
@@ -307,7 +308,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
307
308
  }
308
309
 
309
310
  // transform slices based on destination
310
- slice = (0, _media.transformSliceForMedia)(slice, schema)(state.selection);
311
+ slice = (0, _media.transformSliceForMedia)(slice, schema, pluginInjectionApi)(state.selection);
311
312
  var markdownSlice;
312
313
  if (isPlainText) {
313
314
  var _markdownSlice;
@@ -415,7 +416,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
415
416
 
416
417
  // finally, handle rich-text copy-paste
417
418
  if (isRichText || isNestedMarkdownTable) {
418
- var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
419
+ var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$l;
419
420
  // linkify the text where possible
420
421
  slice = (0, _utils.linkifyContent)(state.schema)(slice);
421
422
  if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
@@ -461,8 +462,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
461
462
  });
462
463
  slice = sliceCopy;
463
464
  }
464
- var isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.nestedExpandInExpandEx) || (0, _platformFeatureFlags.fg)('platform_editor_nest_nested_expand_in_expand_jira');
465
- if ((0, _analytics2.handleExpandWithAnalytics)(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
465
+ if ((0, _analytics2.handleExpandWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
466
466
  return true;
467
467
  }
468
468
  if (!(0, _coreUtils.insideTable)(state)) {
@@ -510,7 +510,9 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
510
510
  if (slice.content.childCount && slice.content.lastChild.type === schema.nodes.codeBlock) {
511
511
  slice = new _model.Slice(slice.content, 0, 0);
512
512
  }
513
- slice = (0, _transforms.transformSingleColumnLayout)(slice, schema);
513
+ if (!(0, _experiments.editorExperiment)('single_column_layouts', true)) {
514
+ slice = (0, _transforms.transformSingleColumnLayout)(slice, schema);
515
+ }
514
516
  if ((0, _platformFeatureFlags.fg)('platform_editor_macroid_reset_for_ext_on_paste')) {
515
517
  slice = (0, _transforms.transformSliceToRemoveMacroId)(slice, schema);
516
518
  }
@@ -12,7 +12,6 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
14
  var _mediaCommon = require("@atlaskit/media-common");
15
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
17
  /**
@@ -20,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
20
19
  *
21
20
  * TODO: ED-26959 - this func is only used in handlePaste, so layout update won't work for drop event
22
21
  */
23
- function transformSliceForMedia(slice, schema) {
22
+ function transformSliceForMedia(slice, schema, api) {
24
23
  var _schema$nodes = schema.nodes,
25
24
  mediaSingle = _schema$nodes.mediaSingle,
26
25
  layoutSection = _schema$nodes.layoutSection,
@@ -33,7 +32,9 @@ function transformSliceForMedia(slice, schema) {
33
32
  var newSlice = slice;
34
33
  if ((0, _utils2.hasParentNodeOfType)([layoutSection, table, bulletList, orderedList, expand, nestedExpand])(selection)) {
35
34
  newSlice = (0, _utils.mapSlice)(newSlice, function (node) {
36
- var extendedOrLegacyAttrs = (0, _platformFeatureFlags.fg)('platform_editor_media_extended_resize_experience') ? {
35
+ var _api$media, _mediaState$mediaOpti;
36
+ var mediaState = api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
37
+ var extendedOrLegacyAttrs = mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti = mediaState.mediaOptions) !== null && _mediaState$mediaOpti !== void 0 && _mediaState$mediaOpti.allowPixelResizing ? {
37
38
  layout: node.attrs.layout,
38
39
  widthType: node.attrs.widthType,
39
40
  width: node.attrs.width
@@ -98,7 +99,9 @@ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMedia
98
99
  // The duplication is in the following file:
99
100
  // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
100
101
  if (node.type === mediaSingle) {
101
- return (0, _platformFeatureFlags.fg)('platform_editor_media_extended_resize_experience') ? mediaSingle.createChecked({
102
+ var _api$media2, _mediaState$mediaOpti2;
103
+ var mediaState = api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.sharedState.currentState();
104
+ return mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti2 = mediaState.mediaOptions) !== null && _mediaState$mediaOpti2 !== void 0 && _mediaState$mediaOpti2.allowPixelResizing ? mediaSingle.createChecked({
102
105
  width: node.attrs.width || _mediaSingle.DEFAULT_IMAGE_WIDTH,
103
106
  widthType: node.attrs.widthType || 'pixel',
104
107
  layout: node.attrs.layout
@@ -109,16 +112,16 @@ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMedia
109
112
  return (0, _utils.mapSlice)(newSlice, function (node) {
110
113
  var __mediaTraceId = (0, _mediaCommon.getRandomHex)(8);
111
114
  if (node.type === media) {
112
- var _api$media;
113
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
115
+ var _api$media3;
116
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media3 = api.media) === null || _api$media3 === void 0 ? void 0 : _api$media3.commands.trackMediaPaste(node.attrs));
114
117
  return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
115
118
  __external: node.attrs.type === 'external',
116
119
  __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
117
120
  }), node.content, node.marks);
118
121
  }
119
122
  if (node.type.name === 'mediaInline') {
120
- var _api$media2;
121
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
123
+ var _api$media4;
124
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media4 = api.media) === null || _api$media4 === void 0 ? void 0 : _api$media4.commands.trackMediaPaste(node.attrs));
122
125
  return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
123
126
  __mediaTraceId: __mediaTraceId
124
127
  }), node.content, node.marks);
@@ -744,9 +744,9 @@ function handleNestedTablePaste(slice, isNestingTablesSupported) {
744
744
  return false;
745
745
  };
746
746
  }
747
- function handleExpandPaste(slice, isNestingExpandsSupported) {
747
+ function handleExpandPaste(slice) {
748
748
  return function (state, dispatch) {
749
- var isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
749
+ var isInsideNestableExpand = !!insideExpand(state);
750
750
 
751
751
  // Do not handle expand if it's not being pasted into a table or expand
752
752
  // OR if it's nested within another node when being pasted into a table/expand
@@ -325,10 +325,10 @@ export const handlePasteNonNestableBlockNodesIntoListWithAnalytics = editorAnaly
325
325
  type: PasteTypes.richText,
326
326
  pasteSplitList: true
327
327
  }))(handlePasteNonNestableBlockNodesIntoList(slice));
328
- export const handleExpandWithAnalytics = (editorAnalyticsAPI, isNestingExpandsSupported) => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
328
+ export const handleExpandWithAnalytics = editorAnalyticsAPI => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
329
329
  type: PasteTypes.richText,
330
330
  pasteSplitList: true
331
- }))(handleExpandPaste(slice, isNestingExpandsSupported));
331
+ }))(handleExpandPaste(slice));
332
332
  export const handleNestedTablePasteWithAnalytics = (editorAnalyticsAPI, isNestingTablesSupported) => (view, event, slice) => injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
333
333
  type: PasteTypes.richText,
334
334
  pasteSplitList: true
@@ -13,6 +13,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
13
13
  import { contains, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
14
14
  import { handlePaste as handlePasteTable } from '@atlaskit/editor-tables/utils';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
16
17
  import { PastePluginActionTypes } from '../editor-actions/actions';
17
18
  import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
18
19
  import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
@@ -281,7 +282,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
281
282
  }
282
283
 
283
284
  // transform slices based on destination
284
- slice = transformSliceForMedia(slice, schema)(state.selection);
285
+ slice = transformSliceForMedia(slice, schema, pluginInjectionApi)(state.selection);
285
286
  let markdownSlice;
286
287
  if (isPlainText) {
287
288
  var _markdownSlice;
@@ -391,7 +392,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
391
392
 
392
393
  // finally, handle rich-text copy-paste
393
394
  if (isRichText || isNestedMarkdownTable) {
394
- var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l;
395
+ var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$l;
395
396
  // linkify the text where possible
396
397
  slice = linkifyContent(state.schema)(slice);
397
398
  if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
@@ -435,8 +436,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
435
436
  });
436
437
  slice = sliceCopy;
437
438
  }
438
- const isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : (_pluginInjectionApi$f2 = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
439
- if (handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
439
+ if (handleExpandWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
440
440
  return true;
441
441
  }
442
442
  if (!insideTable(state)) {
@@ -484,7 +484,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
484
484
  if (slice.content.childCount && slice.content.lastChild.type === schema.nodes.codeBlock) {
485
485
  slice = new Slice(slice.content, 0, 0);
486
486
  }
487
- slice = transformSingleColumnLayout(slice, schema);
487
+ if (!editorExperiment('single_column_layouts', true)) {
488
+ slice = transformSingleColumnLayout(slice, schema);
489
+ }
488
490
  if (fg('platform_editor_macroid_reset_for_ext_on_paste')) {
489
491
  slice = transformSliceToRemoveMacroId(slice, schema);
490
492
  }
@@ -2,13 +2,12 @@ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
2
2
  import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
3
3
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { getRandomHex } from '@atlaskit/media-common';
5
- import { fg } from '@atlaskit/platform-feature-flags';
6
5
  /**
7
6
  * Ensure correct layout in nested mode
8
7
  *
9
8
  * TODO: ED-26959 - this func is only used in handlePaste, so layout update won't work for drop event
10
9
  */
11
- export function transformSliceForMedia(slice, schema) {
10
+ export function transformSliceForMedia(slice, schema, api) {
12
11
  const {
13
12
  mediaSingle,
14
13
  layoutSection,
@@ -22,7 +21,9 @@ export function transformSliceForMedia(slice, schema) {
22
21
  let newSlice = slice;
23
22
  if (hasParentNodeOfType([layoutSection, table, bulletList, orderedList, expand, nestedExpand])(selection)) {
24
23
  newSlice = mapSlice(newSlice, node => {
25
- const extendedOrLegacyAttrs = fg('platform_editor_media_extended_resize_experience') ? {
24
+ var _api$media, _mediaState$mediaOpti;
25
+ const mediaState = api === null || api === void 0 ? void 0 : (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
26
+ const extendedOrLegacyAttrs = mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti = mediaState.mediaOptions) !== null && _mediaState$mediaOpti !== void 0 && _mediaState$mediaOpti.allowPixelResizing ? {
26
27
  layout: node.attrs.layout,
27
28
  widthType: node.attrs.widthType,
28
29
  width: node.attrs.width
@@ -92,7 +93,9 @@ export const transformSliceToMediaSingleWithNewExperience = (slice, schema, api)
92
93
  // The duplication is in the following file:
93
94
  // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
94
95
  if (node.type === mediaSingle) {
95
- return fg('platform_editor_media_extended_resize_experience') ? mediaSingle.createChecked({
96
+ var _api$media2, _mediaState$mediaOpti2;
97
+ const mediaState = api === null || api === void 0 ? void 0 : (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.sharedState.currentState();
98
+ return mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti2 = mediaState.mediaOptions) !== null && _mediaState$mediaOpti2 !== void 0 && _mediaState$mediaOpti2.allowPixelResizing ? mediaSingle.createChecked({
96
99
  width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
97
100
  widthType: node.attrs.widthType || 'pixel',
98
101
  layout: node.attrs.layout
@@ -103,8 +106,8 @@ export const transformSliceToMediaSingleWithNewExperience = (slice, schema, api)
103
106
  return mapSlice(newSlice, node => {
104
107
  const __mediaTraceId = getRandomHex(8);
105
108
  if (node.type === media) {
106
- var _api$media;
107
- api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
109
+ var _api$media3;
110
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media3 = api.media) === null || _api$media3 === void 0 ? void 0 : _api$media3.commands.trackMediaPaste(node.attrs));
108
111
  return media.createChecked({
109
112
  ...node.attrs,
110
113
  __external: node.attrs.type === 'external',
@@ -112,8 +115,8 @@ export const transformSliceToMediaSingleWithNewExperience = (slice, schema, api)
112
115
  }, node.content, node.marks);
113
116
  }
114
117
  if (node.type.name === 'mediaInline') {
115
- var _api$media2;
116
- api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
118
+ var _api$media4;
119
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$media4 = api.media) === null || _api$media4 === void 0 ? void 0 : _api$media4.commands.trackMediaPaste(node.attrs));
117
120
  return mediaInline.createChecked({
118
121
  ...node.attrs,
119
122
  __mediaTraceId
@@ -733,9 +733,9 @@ export function handleNestedTablePaste(slice, isNestingTablesSupported) {
733
733
  return false;
734
734
  };
735
735
  }
736
- export function handleExpandPaste(slice, isNestingExpandsSupported) {
736
+ export function handleExpandPaste(slice) {
737
737
  return (state, dispatch) => {
738
- const isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
738
+ const isInsideNestableExpand = !!insideExpand(state);
739
739
 
740
740
  // Do not handle expand if it's not being pasted into a table or expand
741
741
  // OR if it's nested within another node when being pasted into a table/expand
@@ -346,12 +346,12 @@ export var handlePasteNonNestableBlockNodesIntoListWithAnalytics = function hand
346
346
  }))(handlePasteNonNestableBlockNodesIntoList(slice));
347
347
  };
348
348
  };
349
- export var handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported) {
349
+ export var handleExpandWithAnalytics = function handleExpandWithAnalytics(editorAnalyticsAPI) {
350
350
  return function (view, event, slice) {
351
351
  return injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI)(createPasteAnalyticsPayloadBySelection(event, slice, {
352
352
  type: PasteTypes.richText,
353
353
  pasteSplitList: true
354
- }))(handleExpandPaste(slice, isNestingExpandsSupported));
354
+ }))(handleExpandPaste(slice));
355
355
  };
356
356
  };
357
357
  export var handleNestedTablePasteWithAnalytics = function handleNestedTablePasteWithAnalytics(editorAnalyticsAPI, isNestingTablesSupported) {
@@ -15,6 +15,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
15
15
  import { contains, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
16
16
  import { handlePaste as handlePasteTable } from '@atlaskit/editor-tables/utils';
17
17
  import { fg } from '@atlaskit/platform-feature-flags';
18
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
18
19
  import { PastePluginActionTypes } from '../editor-actions/actions';
19
20
  import { splitParagraphs, upgradeTextToLists } from '../editor-commands/commands';
20
21
  import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../pm-plugins/media';
@@ -299,7 +300,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
299
300
  }
300
301
 
301
302
  // transform slices based on destination
302
- slice = transformSliceForMedia(slice, schema)(state.selection);
303
+ slice = transformSliceForMedia(slice, schema, pluginInjectionApi)(state.selection);
303
304
  var markdownSlice;
304
305
  if (isPlainText) {
305
306
  var _markdownSlice;
@@ -407,7 +408,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
407
408
 
408
409
  // finally, handle rich-text copy-paste
409
410
  if (isRichText || isNestedMarkdownTable) {
410
- var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
411
+ var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$l;
411
412
  // linkify the text where possible
412
413
  slice = linkifyContent(state.schema)(slice);
413
414
  if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
@@ -453,8 +454,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
453
454
  });
454
455
  slice = sliceCopy;
455
456
  }
456
- var isNestingExpandsSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 || (_pluginInjectionApi$f = _pluginInjectionApi$f.sharedState.currentState()) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.nestedExpandInExpandEx) || fg('platform_editor_nest_nested_expand_in_expand_jira');
457
- if (handleExpandWithAnalytics(editorAnalyticsAPI, isNestingExpandsSupported)(view, event, slice)(state, dispatch)) {
457
+ if (handleExpandWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
458
458
  return true;
459
459
  }
460
460
  if (!insideTable(state)) {
@@ -502,7 +502,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
502
502
  if (slice.content.childCount && slice.content.lastChild.type === schema.nodes.codeBlock) {
503
503
  slice = new Slice(slice.content, 0, 0);
504
504
  }
505
- slice = transformSingleColumnLayout(slice, schema);
505
+ if (!editorExperiment('single_column_layouts', true)) {
506
+ slice = transformSingleColumnLayout(slice, schema);
507
+ }
506
508
  if (fg('platform_editor_macroid_reset_for_ext_on_paste')) {
507
509
  slice = transformSliceToRemoveMacroId(slice, schema);
508
510
  }
@@ -5,13 +5,12 @@ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
5
  import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
6
6
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { getRandomHex } from '@atlaskit/media-common';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  /**
10
9
  * Ensure correct layout in nested mode
11
10
  *
12
11
  * TODO: ED-26959 - this func is only used in handlePaste, so layout update won't work for drop event
13
12
  */
14
- export function transformSliceForMedia(slice, schema) {
13
+ export function transformSliceForMedia(slice, schema, api) {
15
14
  var _schema$nodes = schema.nodes,
16
15
  mediaSingle = _schema$nodes.mediaSingle,
17
16
  layoutSection = _schema$nodes.layoutSection,
@@ -24,7 +23,9 @@ export function transformSliceForMedia(slice, schema) {
24
23
  var newSlice = slice;
25
24
  if (hasParentNodeOfType([layoutSection, table, bulletList, orderedList, expand, nestedExpand])(selection)) {
26
25
  newSlice = mapSlice(newSlice, function (node) {
27
- var extendedOrLegacyAttrs = fg('platform_editor_media_extended_resize_experience') ? {
26
+ var _api$media, _mediaState$mediaOpti;
27
+ var mediaState = api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
28
+ var extendedOrLegacyAttrs = mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti = mediaState.mediaOptions) !== null && _mediaState$mediaOpti !== void 0 && _mediaState$mediaOpti.allowPixelResizing ? {
28
29
  layout: node.attrs.layout,
29
30
  widthType: node.attrs.widthType,
30
31
  width: node.attrs.width
@@ -89,7 +90,9 @@ export var transformSliceToMediaSingleWithNewExperience = function transformSlic
89
90
  // The duplication is in the following file:
90
91
  // packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
91
92
  if (node.type === mediaSingle) {
92
- return fg('platform_editor_media_extended_resize_experience') ? mediaSingle.createChecked({
93
+ var _api$media2, _mediaState$mediaOpti2;
94
+ var mediaState = api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.sharedState.currentState();
95
+ return mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti2 = mediaState.mediaOptions) !== null && _mediaState$mediaOpti2 !== void 0 && _mediaState$mediaOpti2.allowPixelResizing ? mediaSingle.createChecked({
93
96
  width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
94
97
  widthType: node.attrs.widthType || 'pixel',
95
98
  layout: node.attrs.layout
@@ -100,16 +103,16 @@ export var transformSliceToMediaSingleWithNewExperience = function transformSlic
100
103
  return mapSlice(newSlice, function (node) {
101
104
  var __mediaTraceId = getRandomHex(8);
102
105
  if (node.type === media) {
103
- var _api$media;
104
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.commands.trackMediaPaste(node.attrs));
106
+ var _api$media3;
107
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media3 = api.media) === null || _api$media3 === void 0 ? void 0 : _api$media3.commands.trackMediaPaste(node.attrs));
105
108
  return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
106
109
  __external: node.attrs.type === 'external',
107
110
  __mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
108
111
  }), node.content, node.marks);
109
112
  }
110
113
  if (node.type.name === 'mediaInline') {
111
- var _api$media2;
112
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.commands.trackMediaPaste(node.attrs));
114
+ var _api$media4;
115
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media4 = api.media) === null || _api$media4 === void 0 ? void 0 : _api$media4.commands.trackMediaPaste(node.attrs));
113
116
  return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
114
117
  __mediaTraceId: __mediaTraceId
115
118
  }), node.content, node.marks);
@@ -718,9 +718,9 @@ export function handleNestedTablePaste(slice, isNestingTablesSupported) {
718
718
  return false;
719
719
  };
720
720
  }
721
- export function handleExpandPaste(slice, isNestingExpandsSupported) {
721
+ export function handleExpandPaste(slice) {
722
722
  return function (state, dispatch) {
723
- var isInsideNestableExpand = isNestingExpandsSupported && !!insideExpand(state);
723
+ var isInsideNestableExpand = !!insideExpand(state);
724
724
 
725
725
  // Do not handle expand if it's not being pasted into a table or expand
726
726
  // OR if it's nested within another node when being pasted into a table/expand
@@ -31,7 +31,7 @@ export declare const handleMarkdownWithAnalytics: (view: EditorView, event: Clip
31
31
  export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
32
32
  export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
33
33
  export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
34
- export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
34
+ export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
35
35
  export declare const handleNestedTablePasteWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingTablesSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
36
36
  export declare const handleSelectedTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
37
37
  export declare const handlePasteLinkOnSelectedTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
@@ -7,7 +7,7 @@ import type { PastePlugin } from '../pastePluginType';
7
7
  *
8
8
  * TODO: ED-26959 - this func is only used in handlePaste, so layout update won't work for drop event
9
9
  */
10
- export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
10
+ export declare function transformSliceForMedia(slice: Slice, schema: Schema, api?: ExtractInjectionAPI<PastePlugin>): (selection: Selection) => Slice;
11
11
  export declare const isImage: (fileType?: string) => boolean;
12
12
  export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema: Schema) => Slice;
13
13
  /**
@@ -21,7 +21,7 @@ export declare function handleCodeBlock(text: string): Command;
21
21
  export declare function handleMediaSingle(inputMethod: InputMethodInsertMedia, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined): (slice: Slice) => Command;
22
22
  export declare function handleTableContentPasteInBodiedExtension(slice: Slice): Command;
23
23
  export declare function handleNestedTablePaste(slice: Slice, isNestingTablesSupported?: boolean): Command;
24
- export declare function handleExpandPaste(slice: Slice, isNestingExpandsSupported?: boolean): Command;
24
+ export declare function handleExpandPaste(slice: Slice): Command;
25
25
  export declare function handleMarkdown(markdownSlice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, from?: number, to?: number): Command;
26
26
  export declare function handleParagraphBlockMarks(state: EditorState, slice: Slice): Slice;
27
27
  /**
@@ -31,7 +31,7 @@ export declare const handleMarkdownWithAnalytics: (view: EditorView, event: Clip
31
31
  export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
32
32
  export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
33
33
  export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
34
- export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
34
+ export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
35
35
  export declare const handleNestedTablePasteWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingTablesSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
36
36
  export declare const handleSelectedTableWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
37
37
  export declare const handlePasteLinkOnSelectedTextWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType) => Command;
@@ -7,7 +7,7 @@ import type { PastePlugin } from '../pastePluginType';
7
7
  *
8
8
  * TODO: ED-26959 - this func is only used in handlePaste, so layout update won't work for drop event
9
9
  */
10
- export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
10
+ export declare function transformSliceForMedia(slice: Slice, schema: Schema, api?: ExtractInjectionAPI<PastePlugin>): (selection: Selection) => Slice;
11
11
  export declare const isImage: (fileType?: string) => boolean;
12
12
  export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema: Schema) => Slice;
13
13
  /**
@@ -21,7 +21,7 @@ export declare function handleCodeBlock(text: string): Command;
21
21
  export declare function handleMediaSingle(inputMethod: InputMethodInsertMedia, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined): (slice: Slice) => Command;
22
22
  export declare function handleTableContentPasteInBodiedExtension(slice: Slice): Command;
23
23
  export declare function handleNestedTablePaste(slice: Slice, isNestingTablesSupported?: boolean): Command;
24
- export declare function handleExpandPaste(slice: Slice, isNestingExpandsSupported?: boolean): Command;
24
+ export declare function handleExpandPaste(slice: Slice): Command;
25
25
  export declare function handleMarkdown(markdownSlice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, from?: number, to?: number): Command;
26
26
  export declare function handleParagraphBlockMarks(state: EditorState, slice: Slice): Slice;
27
27
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "3.1.8",
3
+ "version": "3.2.1",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,22 +33,22 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^47.6.0",
35
35
  "@atlaskit/code": "^17.0.0",
36
- "@atlaskit/editor-common": "^103.4.0",
36
+ "@atlaskit/editor-common": "^103.9.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.5.0",
39
+ "@atlaskit/editor-plugin-annotation": "^2.6.0",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^2.1.0",
41
41
  "@atlaskit/editor-plugin-card": "^5.4.0",
42
42
  "@atlaskit/editor-plugin-feature-flags": "^1.4.0",
43
43
  "@atlaskit/editor-plugin-list": "^4.2.0",
44
- "@atlaskit/editor-plugin-media": "^2.4.0",
44
+ "@atlaskit/editor-plugin-media": "^2.6.0",
45
45
  "@atlaskit/editor-plugin-mentions": "^4.4.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.6.0",
51
+ "@atlaskit/tmp-editor-statsig": "^4.12.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.3.0",
64
+ "@atlaskit/editor-plugin-type-ahead": "^2.5.0",
65
65
  "@atlaskit/ssr": "^0.4.0",
66
66
  "@atlaskit/visual-regression": "^0.10.0",
67
67
  "@testing-library/react": "^13.4.0",
@@ -105,15 +105,9 @@
105
105
  }
106
106
  },
107
107
  "platform-feature-flags": {
108
- "platform_editor_media_extended_resize_experience": {
109
- "type": "boolean"
110
- },
111
108
  "editor_inline_comments_paste_insert_nodes": {
112
109
  "type": "boolean"
113
110
  },
114
- "platform_editor_nest_nested_expand_in_expand_jira": {
115
- "type": "boolean"
116
- },
117
111
  "platform_editor_use_nested_table_pm_nodes": {
118
112
  "type": "boolean"
119
113
  },