@atlaskit/editor-plugin-media 2.4.0 → 2.5.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cjs/mediaPlugin.js +8 -8
  3. package/dist/cjs/nodeviews/mediaSingle.js +16 -16
  4. package/dist/cjs/nodeviews/mediaSingleNext.js +2 -2
  5. package/dist/cjs/nodeviews/toDOM-fixes/mediaSingle.js +53 -51
  6. package/dist/cjs/pm-plugins/keymap.js +1 -2
  7. package/dist/cjs/pm-plugins/main.js +1 -1
  8. package/dist/cjs/pm-plugins/utils/media-single.js +10 -11
  9. package/dist/cjs/ui/toolbar/commands.js +2 -2
  10. package/dist/cjs/ui/toolbar/index.js +11 -9
  11. package/dist/cjs/ui/toolbar/mediaInline.js +1 -1
  12. package/dist/cjs/ui/toolbar/pixel-resizing.js +3 -3
  13. package/dist/es2019/mediaPlugin.js +7 -8
  14. package/dist/es2019/nodeviews/mediaSingle.js +8 -8
  15. package/dist/es2019/nodeviews/mediaSingleNext.js +2 -2
  16. package/dist/es2019/nodeviews/toDOM-fixes/mediaSingle.js +5 -5
  17. package/dist/es2019/pm-plugins/keymap.js +1 -2
  18. package/dist/es2019/pm-plugins/main.js +1 -1
  19. package/dist/es2019/pm-plugins/utils/media-single.js +10 -11
  20. package/dist/es2019/ui/toolbar/commands.js +2 -2
  21. package/dist/es2019/ui/toolbar/index.js +11 -9
  22. package/dist/es2019/ui/toolbar/mediaInline.js +1 -1
  23. package/dist/es2019/ui/toolbar/pixel-resizing.js +3 -3
  24. package/dist/esm/mediaPlugin.js +8 -8
  25. package/dist/esm/nodeviews/mediaSingle.js +16 -16
  26. package/dist/esm/nodeviews/mediaSingleNext.js +2 -2
  27. package/dist/esm/nodeviews/toDOM-fixes/mediaSingle.js +52 -50
  28. package/dist/esm/pm-plugins/keymap.js +1 -2
  29. package/dist/esm/pm-plugins/main.js +1 -1
  30. package/dist/esm/pm-plugins/utils/media-single.js +10 -11
  31. package/dist/esm/ui/toolbar/commands.js +2 -2
  32. package/dist/esm/ui/toolbar/index.js +11 -9
  33. package/dist/esm/ui/toolbar/mediaInline.js +1 -1
  34. package/dist/esm/ui/toolbar/pixel-resizing.js +3 -3
  35. package/dist/types/nodeviews/toDOM-fixes/mediaSingle.d.ts +1 -1
  36. package/dist/types/pm-plugins/utils/media-single.d.ts +4 -4
  37. package/dist/types/types/index.d.ts +2 -0
  38. package/dist/types/ui/toolbar/commands.d.ts +1 -1
  39. package/dist/types-ts4.5/nodeviews/toDOM-fixes/mediaSingle.d.ts +1 -1
  40. package/dist/types-ts4.5/pm-plugins/utils/media-single.d.ts +4 -4
  41. package/dist/types-ts4.5/types/index.d.ts +2 -0
  42. package/dist/types-ts4.5/ui/toolbar/commands.d.ts +1 -1
  43. package/package.json +2 -8
@@ -3,7 +3,6 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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) { _defineProperty(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; }
4
4
  import { mediaSingleSpec } from '@atlaskit/adf-schema';
5
5
  import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
6
- import { fg } from '@atlaskit/platform-feature-flags';
7
6
  import { N20, N50 } from '@atlaskit/theme/colors';
8
7
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
9
8
  import { getAttrsFromNodeMediaSingle } from './toDOMAttrs';
@@ -150,55 +149,57 @@ export var prepareWrapperContentDOM = function prepareWrapperContentDOM(_ref5) {
150
149
  class: 'media-content-wrap'
151
150
  }, 0]]]]];
152
151
  };
153
- export var toDOM = function toDOM(node) {
154
- var _mediaSingleAttrs$lay;
155
- var mediaSingleAttrs = node.attrs;
156
- var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
157
- var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
158
- var childNode = node.firstChild;
159
- var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
160
- var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
161
- var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
162
- var dataAttrs = getAttrsFromNodeMediaSingle(fg('platform_editor_media_extended_resize_experience'), node);
163
- var content = prepareWrapperContentDOM({
164
- layout: layout,
165
- dataAttrs: dataAttrs,
166
- childMediaWidth: childMediaWidth,
167
- childMediaHeight: childMediaHeight,
168
- mediaSingleDimensionWidth: mediaSingleAttrs.width,
169
- isPixelWidth: isPixelWidth,
170
- isExtendedResizeExperience: fg('platform_editor_media_extended_resize_experience')
171
- });
172
- var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
173
- var proportionCalc = mediaProportionalWidthCSSCalc({
174
- isPixelWidth: isPixelWidth,
175
- isMediaWrapped: isMediaWrapped,
176
- mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
177
- isExtendedResizeExperience: fg('platform_editor_media_extended_resize_experience')
178
- });
179
- var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
180
- isMediaWrapped: isMediaWrapped,
181
- isExternalMedia: isExternalMedia,
182
- isPixelWidth: isPixelWidth,
183
- childMediaWidth: childMediaWidth,
184
- mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
185
- });
186
- return ['div', {
187
- class: 'mediaSingleView-content-wrap',
188
- layout: layout,
189
- style: convertToInlineCss({
190
- '--ak-editor-media-single--proportion': proportionCalc,
191
- '--ak-editor-media-card-display': 'block',
192
- '--ak-editor-media-single--gutter-size': GUTTER_SIZE,
193
- '--ak-editor-media-margin-right': '0',
194
- '--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(N20, ")"),
195
- marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
196
- marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
197
- marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
198
- marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
199
- width: contentWrapperWidth
200
- })
201
- }, content];
152
+ export var getToDom = function getToDom(allowPixelResizing) {
153
+ return function (node) {
154
+ var _mediaSingleAttrs$lay;
155
+ var mediaSingleAttrs = node.attrs;
156
+ var isPixelWidth = (mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.widthType) === 'pixel';
157
+ var layout = (_mediaSingleAttrs$lay = mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.layout) !== null && _mediaSingleAttrs$lay !== void 0 ? _mediaSingleAttrs$lay : 'center';
158
+ var childNode = node.firstChild;
159
+ var isExternalMedia = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.type) === 'external';
160
+ var childMediaWidth = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.width) || DEFAULT_IMAGE_WIDTH;
161
+ var childMediaHeight = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs.height) || DEFAULT_IMAGE_HEIGHT;
162
+ var dataAttrs = getAttrsFromNodeMediaSingle(true, node);
163
+ var content = prepareWrapperContentDOM({
164
+ layout: layout,
165
+ dataAttrs: dataAttrs,
166
+ childMediaWidth: childMediaWidth,
167
+ childMediaHeight: childMediaHeight,
168
+ mediaSingleDimensionWidth: mediaSingleAttrs.width,
169
+ isPixelWidth: isPixelWidth,
170
+ isExtendedResizeExperience: allowPixelResizing
171
+ });
172
+ var isMediaWrapped = WRAPPED_LAYOUTS.includes(layout);
173
+ var proportionCalc = mediaProportionalWidthCSSCalc({
174
+ isPixelWidth: isPixelWidth,
175
+ isMediaWrapped: isMediaWrapped,
176
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width,
177
+ isExtendedResizeExperience: allowPixelResizing
178
+ });
179
+ var contentWrapperWidth = mediaContentWrapperWidthCSSCalc({
180
+ isMediaWrapped: isMediaWrapped,
181
+ isExternalMedia: isExternalMedia,
182
+ isPixelWidth: isPixelWidth,
183
+ childMediaWidth: childMediaWidth,
184
+ mediaSingleDimensionWidth: mediaSingleAttrs === null || mediaSingleAttrs === void 0 ? void 0 : mediaSingleAttrs.width
185
+ });
186
+ return ['div', {
187
+ class: 'mediaSingleView-content-wrap',
188
+ layout: layout,
189
+ style: convertToInlineCss({
190
+ '--ak-editor-media-single--proportion': proportionCalc,
191
+ '--ak-editor-media-card-display': 'block',
192
+ '--ak-editor-media-single--gutter-size': GUTTER_SIZE,
193
+ '--ak-editor-media-margin-right': '0',
194
+ '--ak-editor-media-card-background-color': "var(--ds-background-neutral, ".concat(N20, ")"),
195
+ marginTop: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
196
+ marginBottom: isMediaWrapped ? HALF_GUTTER_SIZE : "var(--ds-space-300, 24px)",
197
+ marginRight: isMediaWrapped ? layout === 'wrap-right' ? 'auto' : HALF_GUTTER_SIZE : 0,
198
+ marginLeft: isMediaWrapped ? layout === 'wrap-left' ? 'auto' : HALF_GUTTER_SIZE : 0,
199
+ width: contentWrapperWidth
200
+ })
201
+ }, content];
202
+ };
202
203
  };
203
204
 
204
205
  // @nodeSpecException:toDOM patch
@@ -207,6 +208,7 @@ export var mediaSingleSpecWithFixedToDOM = function mediaSingleSpecWithFixedToDO
207
208
  if (editorExperiment('platform_editor_exp_lazy_node_views', false)) {
208
209
  return mediaSingleNode;
209
210
  }
211
+ var toDOM = getToDom(mediaSingleOption.withExtendedWidthTypes);
210
212
  return _objectSpread(_objectSpread({}, mediaSingleNode), {}, {
211
213
  toDOM: toDOM
212
214
  });
@@ -5,7 +5,6 @@ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
5
5
  import { keymap } from '@atlaskit/editor-prosemirror/keymap';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../pm-plugins/commands/captions';
10
9
  import { stateKey } from '../pm-plugins/plugin-key';
11
10
  import { updateMediaSingleWidth } from '../ui/toolbar/commands';
@@ -38,7 +37,7 @@ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlug
38
37
  // Ignored via go/ees005
39
38
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
39
  bindKeymapWithCommand(enter.common, splitMediaGroup, list);
41
- if (fg('platform_editor_media_extended_resize_experience')) {
40
+ if (options !== null && options !== void 0 && options.allowPixelResizing) {
42
41
  bindKeymapWithCommand(
43
42
  // Ignored via go/ees005
44
43
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -149,7 +149,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
149
149
  case 'block':
150
150
  // read width state right before inserting to get up-to-date and define values
151
151
  var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 || (_this$pluginInjection2 = _this$pluginInjection2.width) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.sharedState.currentState();
152
- insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia);
152
+ insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, _this.onNodeInserted, insertMediaVia, _this.mediaOptions && _this.mediaOptions.allowPixelResizing);
153
153
  break;
154
154
  case 'group':
155
155
  insertMediaGroupNode(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType), insertMediaVia);
@@ -94,7 +94,7 @@ function insertNodesWithOptionalParagraph(_ref) {
94
94
  export var isMediaSingle = function isMediaSingle(schema, fileMimeType) {
95
95
  return !!schema.nodes.mediaSingle && isImage(fileMimeType);
96
96
  };
97
- export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia) {
97
+ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI, insertMediaVia, allowPixelResizing) {
98
98
  var _node$attrs$width;
99
99
  var state = view.state,
100
100
  dispatch = view.dispatch;
@@ -109,9 +109,8 @@ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, no
109
109
  if (node.type !== media || !isImage(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
110
110
  return false;
111
111
  }
112
- var resizeExperience = fg('platform_editor_media_extended_resize_experience');
113
112
  var insertMediaPopup = fg('platform_editor_add_media_from_url_rollout');
114
- var mediaSingleAttrs = resizeExperience && insertMediaPopup ? {
113
+ var mediaSingleAttrs = allowPixelResizing && insertMediaPopup ? {
115
114
  widthType: 'pixel',
116
115
  width: getMediaSingleInitialWidth((_node$attrs$width = node.attrs.width) !== null && _node$attrs$width !== void 0 ? _node$attrs$width : DEFAULT_IMAGE_WIDTH),
117
116
  layout: 'center'
@@ -136,7 +135,7 @@ var getFileExtension = function getFileExtension(fileName) {
136
135
  }
137
136
  return undefined;
138
137
  };
139
- export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia) {
138
+ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, widthPluginState, editorAnalyticsAPI, onNodeInserted, insertMediaVia, allowPixelResizing) {
140
139
  var _state$selection$$fro;
141
140
  if (collection === undefined) {
142
141
  return false;
@@ -149,7 +148,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
149
148
  // add undefined as fallback as we don't want media single width to have upper limit as 0
150
149
  // if widthPluginState.width is 0, default 760 will be used
151
150
  var contentWidth = getMaxWidthForNestedNodeNext(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
152
- var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert)(mediaState);
151
+ var node = createMediaSingleNode(state.schema, collection, contentWidth, mediaState.status !== 'error' && isVideo(mediaState.fileMimeType) ? MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH : MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, alignLeftOnInsert, allowPixelResizing)(mediaState);
153
152
  var fileExtension;
154
153
  if (mediaState.fileName) {
155
154
  var extensionIdx = mediaState.fileName.lastIndexOf('.');
@@ -188,7 +187,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
188
187
  }
189
188
  return true;
190
189
  };
191
- export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI) {
190
+ export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInlineToMediaSingleNode(view, fromNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing) {
192
191
  var _state$selection$$fro2;
193
192
  var state = view.state,
194
193
  dispatch = view.dispatch;
@@ -202,7 +201,7 @@ export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInli
202
201
  // add undefined as fallback as we don't want media single width to have upper limit as 0
203
202
  // if widthPluginState.width is 0, default 760 will be used
204
203
  var contentWidth = getMaxWidthForNestedNodeNext(view, state.selection.$from.pos, true) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.lineLength) || (widthPluginState === null || widthPluginState === void 0 ? void 0 : widthPluginState.width) || undefined;
205
- var node = replaceWithMediaSingleNode(state.schema, contentWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH)(fromNode);
204
+ var node = replaceWithMediaSingleNode(state.schema, contentWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, allowPixelResizing)(fromNode);
206
205
  var fileExtension = getFileExtension(fromNode.attrs.__fileName);
207
206
  // should split if media is valid content for the grandparent of the selected node
208
207
  // and the parent node is a paragraph
@@ -234,7 +233,7 @@ export var changeFromMediaInlineToMediaSingleNode = function changeFromMediaInli
234
233
  }
235
234
  return true;
236
235
  };
237
- var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert) {
236
+ var createMediaSingleNode = function createMediaSingleNode(schema, collection, maxWidth, minWidth, alignLeftOnInsert, allowPixelResizing) {
238
237
  return function (mediaState) {
239
238
  var id = mediaState.id,
240
239
  dimensions = mediaState.dimensions,
@@ -265,7 +264,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
265
264
  var mediaSingleAttrs = alignLeftOnInsert ? {
266
265
  layout: 'align-start'
267
266
  } : {};
268
- var extendedMediaSingleAttrs = fg('platform_editor_media_extended_resize_experience') ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
267
+ var extendedMediaSingleAttrs = allowPixelResizing ? _objectSpread(_objectSpread({}, mediaSingleAttrs), {}, {
269
268
  width: getMediaSingleInitialWidth(scaledWidth, maxWidth, minWidth),
270
269
  // TODO: ED-26962 - change to use enum
271
270
  widthType: 'pixel'
@@ -274,7 +273,7 @@ var createMediaSingleNode = function createMediaSingleNode(schema, collection, m
274
273
  return mediaSingle.createChecked(extendedMediaSingleAttrs, mediaNode);
275
274
  };
276
275
  };
277
- var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth) {
276
+ var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, maxWidth, minWidth, allowPixelResizing) {
278
277
  return function (mediaNode) {
279
278
  var width = mediaNode.attrs.width;
280
279
  var _schema$nodes2 = schema.nodes,
@@ -283,7 +282,7 @@ var replaceWithMediaSingleNode = function replaceWithMediaSingleNode(schema, max
283
282
  var copiedMediaNode = media.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
284
283
  type: 'file'
285
284
  }), mediaNode.content, mediaNode.marks);
286
- var extendedMediaSingleAttrs = fg('platform_editor_media_extended_resize_experience') ? {
285
+ var extendedMediaSingleAttrs = allowPixelResizing ? {
287
286
  width: getMediaSingleInitialWidth(width, maxWidth, minWidth),
288
287
  widthType: 'pixel'
289
288
  } : {};
@@ -123,7 +123,7 @@ export var changeMediaCardToInline = function changeMediaCardToInline(editorAnal
123
123
  return true;
124
124
  };
125
125
  };
126
- export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState) {
126
+ export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState, allowPixelResizing) {
127
127
  return function (state, dispatch, view) {
128
128
  var mediaInline = state.schema.nodes.mediaInline;
129
129
  var selectedNode = state.selection instanceof NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
@@ -131,7 +131,7 @@ export var changeMediaInlineToMediaSingle = function changeMediaInlineToMediaSin
131
131
  return false;
132
132
  }
133
133
  if (view) {
134
- return changeFromMediaInlineToMediaSingleNode(view, selectedNode, widthPluginState, editorAnalyticsAPI);
134
+ return changeFromMediaInlineToMediaSingleNode(view, selectedNode, widthPluginState, editorAnalyticsAPI, allowPixelResizing);
135
135
  }
136
136
  return true;
137
137
  };
@@ -231,7 +231,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
231
231
  allowMediaInline = options.allowMediaInline,
232
232
  allowMediaInlineImages = options.allowMediaInlineImages,
233
233
  allowImagePreview = options.allowImagePreview,
234
- isViewOnly = options.isViewOnly;
234
+ isViewOnly = options.isViewOnly,
235
+ allowPixelResizing = options.allowPixelResizing;
235
236
  var toolbarButtons = [];
236
237
  var _ref2 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
237
238
  hoverDecoration = _ref2.hoverDecoration;
@@ -270,7 +271,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
270
271
  var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width;
271
272
  var isChangingLayoutDisabled = false;
272
273
  var selectedNode = getSelectedMediaSingle(state);
273
- if (fg('platform_editor_media_extended_resize_experience')) {
274
+ if (allowPixelResizing) {
274
275
  var _widthPlugin$sharedSt;
275
276
  var contentWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
276
277
  var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
@@ -278,7 +279,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
278
279
  isChangingLayoutDisabled = true;
279
280
  }
280
281
  }
281
- var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
282
+ var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled, allowPixelResizing);
282
283
  var addLayoutDropdownToToolbar = function addLayoutDropdownToToolbar() {
283
284
  var selectedLayoutIcon = getSelectedLayoutIcon([].concat(_toConsumableArray(alignmentIcons), _toConsumableArray(wrappingIcons)),
284
285
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -435,7 +436,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
435
436
  // Pixel Entry Toolbar Support
436
437
  var selection = state.selection;
437
438
  var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
438
- if (allowResizing && (!isWithinTable || allowResizingInTables === true) && fg('platform_editor_media_extended_resize_experience')) {
439
+ if (allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing) {
439
440
  var selectedMediaSingleNode = getSelectedMediaSingle(state);
440
441
  var sizeInput = {
441
442
  type: 'custom',
@@ -699,7 +700,8 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
699
700
  allowResizing = options.allowResizing,
700
701
  isViewOnly = options.isViewOnly,
701
702
  allowResizingInTables = options.allowResizingInTables,
702
- allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions;
703
+ allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions,
704
+ allowPixelResizing = options.allowPixelResizing;
703
705
  var allowMediaInline = options.allowMediaInline;
704
706
  allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
705
707
  var mediaPluginState = stateKey.getState(state);
@@ -738,7 +740,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
738
740
  }
739
741
  var selection = state.selection;
740
742
  var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
741
- if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_media_extended_resize_experience')) {
743
+ if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing && editorExperiment('platform_editor_controls', 'variant1')) {
742
744
  var mediaPixelResizingPluginState = getMediaPixelResizingPluginState(state);
743
745
  if (mediaPixelResizingPluginState !== null && mediaPixelResizingPluginState !== void 0 && mediaPixelResizingPluginState.isPixelEditorOpen) {
744
746
  return getPixelResizingToolbar(baseToolbar, {
@@ -789,12 +791,12 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
789
791
  });
790
792
  }
791
793
  var hoverDecorationProps = function hoverDecorationProps(nodeType, className) {
792
- return fg('platform_editor_controls_patch_1') ? {
794
+ return {
793
795
  onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
794
796
  onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
795
797
  onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
796
798
  onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
797
- } : undefined;
799
+ };
798
800
  };
799
801
  items.push({
800
802
  type: 'overflow-dropdown',
@@ -840,7 +842,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
840
842
  scrollable: true,
841
843
  mediaAssistiveMessage: assistiveMessage
842
844
  });
843
- if (allowResizing && fg('platform_editor_media_extended_resize_experience')) {
845
+ if (allowResizing && allowPixelResizing) {
844
846
  return _objectSpread(_objectSpread({}, toolbarConfig), {}, {
845
847
  width: mediaPluginState.isResizing ? undefined : getMaxToolbarWidth()
846
848
  });
@@ -262,7 +262,7 @@ var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl
262
262
  LEGACY_fallbackIcon: IconEmbed
263
263
  });
264
264
  },
265
- onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
265
+ onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState, options === null || options === void 0 ? void 0 : options.allowPixelResizing)
266
266
  }, {
267
267
  type: 'separator'
268
268
  }, {
@@ -5,7 +5,6 @@ import React from 'react';
5
5
  import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
6
6
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import GrowHorizontalIcon from '@atlaskit/icon/core/grow-horizontal';
8
- import { fg } from '@atlaskit/platform-feature-flags';
9
8
  import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
10
9
  import { PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
11
10
  import { PIXEL_RESIZING_TOOLBAR_WIDTH } from '../../pm-plugins/pixel-resizing/ui/constants';
@@ -49,9 +48,10 @@ export var getResizeDropdownOption = function getResizeDropdownOption(mediaOptio
49
48
  }
50
49
  var allowResizing = mediaOptions.allowResizing,
51
50
  allowResizingInTables = mediaOptions.allowResizingInTables,
52
- allowAdvancedToolBarOptions = mediaOptions.allowAdvancedToolBarOptions;
51
+ allowAdvancedToolBarOptions = mediaOptions.allowAdvancedToolBarOptions,
52
+ allowPixelResizing = mediaOptions.allowPixelResizing;
53
53
  var isWithinTable = hasParentNodeOfType(state.schema.nodes.table)(state.selection);
54
- if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && fg('platform_editor_media_extended_resize_experience')) {
54
+ if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && allowPixelResizing) {
55
55
  return [{
56
56
  title: formatMessage(messages.resizeOption),
57
57
  onClick: openPixelEditor(),
@@ -37,7 +37,7 @@ type PrepareWrapperContentDOMProps = {
37
37
  isExtendedResizeExperience: boolean;
38
38
  };
39
39
  export declare const prepareWrapperContentDOM: ({ layout, dataAttrs, childMediaWidth, childMediaHeight, mediaSingleDimensionWidth, isPixelWidth, isExtendedResizeExperience, }: PrepareWrapperContentDOMProps) => DOMOutputSpec;
40
- export declare const toDOM: (node: PMNode) => DOMOutputSpec;
40
+ export declare const getToDom: (allowPixelResizing: boolean) => (node: PMNode) => DOMOutputSpec;
41
41
  export declare const mediaSingleSpecWithFixedToDOM: (mediaSingleOption: {
42
42
  withCaption?: boolean;
43
43
  withExtendedWidthTypes: boolean;
@@ -5,8 +5,8 @@ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model'
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { MediaState } from '../../types';
7
7
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
8
- export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, insertMediaVia?: InsertMediaVia) => boolean;
9
- export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, insertMediaVia?: InsertMediaVia) => boolean;
10
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined, insertMediaVia?: InsertMediaVia) => boolean;
11
- export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
8
+ export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
9
+ export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
10
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
11
+ export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, allowPixelResizing?: boolean) => boolean;
12
12
  export declare const isVideo: import("memoize-one").MemoizedFn<(fileType?: string) => boolean>;
@@ -55,6 +55,7 @@ export interface MediaPluginOptions {
55
55
  editorAppearance?: EditorAppearance;
56
56
  forceHandlePositioning?: HandlePositioning;
57
57
  mediaShallowCopyScope?: MediaCopyScope;
58
+ allowPixelResizing?: boolean;
58
59
  }
59
60
  /**
60
61
  * @private
@@ -125,6 +126,7 @@ export type MediaFloatingToolbarOptions = {
125
126
  fullWidthEnabled?: boolean;
126
127
  allowCommentsOnMedia?: boolean;
127
128
  isViewOnly?: boolean;
129
+ allowPixelResizing?: boolean;
128
130
  };
129
131
  export type MediaDecorationSpec = {
130
132
  type: 'media';
@@ -10,7 +10,7 @@ export declare const DEFAULT_BORDER_SIZE = 2;
10
10
  export declare const getNodeType: (state: EditorState) => "mediaSingle" | "mediaInline";
11
11
  export declare const changeInlineToMediaCard: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
12
12
  export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
13
- export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined) => Command;
13
+ export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined, allowPixelResizing?: boolean) => Command;
14
14
  export declare const removeInlineCard: Command;
15
15
  export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
16
16
  export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
@@ -37,7 +37,7 @@ type PrepareWrapperContentDOMProps = {
37
37
  isExtendedResizeExperience: boolean;
38
38
  };
39
39
  export declare const prepareWrapperContentDOM: ({ layout, dataAttrs, childMediaWidth, childMediaHeight, mediaSingleDimensionWidth, isPixelWidth, isExtendedResizeExperience, }: PrepareWrapperContentDOMProps) => DOMOutputSpec;
40
- export declare const toDOM: (node: PMNode) => DOMOutputSpec;
40
+ export declare const getToDom: (allowPixelResizing: boolean) => (node: PMNode) => DOMOutputSpec;
41
41
  export declare const mediaSingleSpecWithFixedToDOM: (mediaSingleOption: {
42
42
  withCaption?: boolean;
43
43
  withExtendedWidthTypes: boolean;
@@ -5,8 +5,8 @@ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model'
5
5
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
6
  import type { MediaState } from '../../types';
7
7
  export declare const isMediaSingle: (schema: Schema, fileMimeType?: string) => boolean;
8
- export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, insertMediaVia?: InsertMediaVia) => boolean;
9
- export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, insertMediaVia?: InsertMediaVia) => boolean;
10
- export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined, insertMediaVia?: InsertMediaVia) => boolean;
11
- export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined) => boolean;
8
+ export type InsertMediaAsMediaSingle = (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
9
+ export declare const insertMediaAsMediaSingle: (view: EditorView, node: PMNode, inputMethod: InputMethodInsertMedia, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
10
+ export declare const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, onNodeInserted?: ((id: string, selectionPosition: number) => void) | undefined, insertMediaVia?: InsertMediaVia, allowPixelResizing?: boolean) => boolean;
11
+ export declare const changeFromMediaInlineToMediaSingleNode: (view: EditorView, fromNode: PMNode, widthPluginState?: WidthPluginState | undefined, editorAnalyticsAPI?: EditorAnalyticsAPI | undefined, allowPixelResizing?: boolean) => boolean;
12
12
  export declare const isVideo: import("memoize-one").MemoizedFn<(fileType?: string) => boolean>;
@@ -55,6 +55,7 @@ export interface MediaPluginOptions {
55
55
  editorAppearance?: EditorAppearance;
56
56
  forceHandlePositioning?: HandlePositioning;
57
57
  mediaShallowCopyScope?: MediaCopyScope;
58
+ allowPixelResizing?: boolean;
58
59
  }
59
60
  /**
60
61
  * @private
@@ -125,6 +126,7 @@ export type MediaFloatingToolbarOptions = {
125
126
  fullWidthEnabled?: boolean;
126
127
  allowCommentsOnMedia?: boolean;
127
128
  isViewOnly?: boolean;
129
+ allowPixelResizing?: boolean;
128
130
  };
129
131
  export type MediaDecorationSpec = {
130
132
  type: 'media';
@@ -10,7 +10,7 @@ export declare const DEFAULT_BORDER_SIZE = 2;
10
10
  export declare const getNodeType: (state: EditorState) => "mediaSingle" | "mediaInline";
11
11
  export declare const changeInlineToMediaCard: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
12
12
  export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, forceFocusSelector: ForceFocusSelector | undefined) => Command;
13
- export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined) => Command;
13
+ export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, widthPluginState: WidthPluginState | undefined, allowPixelResizing?: boolean) => Command;
14
14
  export declare const removeInlineCard: Command;
15
15
  export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
16
16
  export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/analytics-namespaced-context": "^7.0.0",
39
39
  "@atlaskit/analytics-next": "^11.0.0",
40
40
  "@atlaskit/button": "^23.0.0",
41
- "@atlaskit/editor-common": "^103.4.0",
41
+ "@atlaskit/editor-common": "^103.6.0",
42
42
  "@atlaskit/editor-palette": "^2.1.0",
43
43
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
44
44
  "@atlaskit/editor-plugin-annotation": "^2.5.0",
@@ -135,9 +135,6 @@
135
135
  "platform_media_cross_client_copy": {
136
136
  "type": "boolean"
137
137
  },
138
- "platform_editor_media_extended_resize_experience": {
139
- "type": "boolean"
140
- },
141
138
  "platform_editor_media_batch_updates": {
142
139
  "type": "boolean"
143
140
  },
@@ -174,9 +171,6 @@
174
171
  "platform_editor_multi_images_overridden_upload_fix": {
175
172
  "type": "boolean"
176
173
  },
177
- "platform_editor_controls_patch_1": {
178
- "type": "boolean"
179
- },
180
174
  "platform_editor_remove_media_inline_feature_flag": {
181
175
  "type": "boolean"
182
176
  },