@atlaskit/editor-plugin-paste 3.1.8 → 3.2.0

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,18 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#134613](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134613)
8
+ [`be20cc186939b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/be20cc186939b) -
9
+ ED-26247 Remove feature flag platform_media_extended_resize_experience and replace it with a new
10
+ media prop which defaults to false allowPixelResizing
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 3.1.8
4
17
 
5
18
  ### Patch Changes
@@ -307,7 +307,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
307
307
  }
308
308
 
309
309
  // transform slices based on destination
310
- slice = (0, _media.transformSliceForMedia)(slice, schema)(state.selection);
310
+ slice = (0, _media.transformSliceForMedia)(slice, schema, pluginInjectionApi)(state.selection);
311
311
  var markdownSlice;
312
312
  if (isPlainText) {
313
313
  var _markdownSlice;
@@ -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);
@@ -281,7 +281,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
281
281
  }
282
282
 
283
283
  // transform slices based on destination
284
- slice = transformSliceForMedia(slice, schema)(state.selection);
284
+ slice = transformSliceForMedia(slice, schema, pluginInjectionApi)(state.selection);
285
285
  let markdownSlice;
286
286
  if (isPlainText) {
287
287
  var _markdownSlice;
@@ -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
@@ -299,7 +299,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
299
299
  }
300
300
 
301
301
  // transform slices based on destination
302
- slice = transformSliceForMedia(slice, schema)(state.selection);
302
+ slice = transformSliceForMedia(slice, schema, pluginInjectionApi)(state.selection);
303
303
  var markdownSlice;
304
304
  if (isPlainText) {
305
305
  var _markdownSlice;
@@ -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);
@@ -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
  /**
@@ -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
  /**
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.0",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
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.6.0",
37
37
  "@atlaskit/editor-markdown-transformer": "^5.16.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
39
39
  "@atlaskit/editor-plugin-annotation": "^2.5.0",
@@ -41,7 +41,7 @@
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.5.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",
@@ -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.4.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,9 +105,6 @@
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
  },