@atlaskit/editor-plugin-media 8.9.0 → 8.10.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 (32) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/mediaPlugin.js +44 -77
  3. package/dist/cjs/pm-plugins/commands.js +1 -23
  4. package/dist/cjs/pm-plugins/main.js +0 -16
  5. package/dist/cjs/ui/toolbar/index.js +3 -2
  6. package/dist/es2019/mediaPlugin.js +4 -39
  7. package/dist/es2019/pm-plugins/commands.js +0 -22
  8. package/dist/es2019/pm-plugins/main.js +0 -14
  9. package/dist/es2019/ui/toolbar/index.js +3 -2
  10. package/dist/esm/mediaPlugin.js +45 -78
  11. package/dist/esm/pm-plugins/commands.js +0 -22
  12. package/dist/esm/pm-plugins/main.js +0 -16
  13. package/dist/esm/ui/toolbar/index.js +3 -2
  14. package/dist/types/mediaPluginType.d.ts +3 -3
  15. package/dist/types/pm-plugins/commands.d.ts +0 -2
  16. package/dist/types/pm-plugins/main.d.ts +1 -4
  17. package/dist/types/pm-plugins/types.d.ts +0 -3
  18. package/dist/types-ts4.5/mediaPluginType.d.ts +3 -3
  19. package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -2
  20. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -4
  21. package/dist/types-ts4.5/pm-plugins/types.d.ts +0 -3
  22. package/package.json +3 -4
  23. package/dist/cjs/ui/ImageEditor/ModalWrapper.js +0 -69
  24. package/dist/cjs/ui/ImageEditor/index.js +0 -62
  25. package/dist/es2019/ui/ImageEditor/ModalWrapper.js +0 -58
  26. package/dist/es2019/ui/ImageEditor/index.js +0 -53
  27. package/dist/esm/ui/ImageEditor/ModalWrapper.js +0 -60
  28. package/dist/esm/ui/ImageEditor/index.js +0 -52
  29. package/dist/types/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  30. package/dist/types/ui/ImageEditor/index.d.ts +0 -12
  31. package/dist/types-ts4.5/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  32. package/dist/types-ts4.5/ui/ImageEditor/index.d.ts +0 -12
@@ -6,7 +6,6 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
6
6
  import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
7
7
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
8
8
  import { fg } from '@atlaskit/platform-feature-flags';
9
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
10
9
  import { lazyMediaView } from './nodeviews/lazy-media';
11
10
  import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
12
11
  import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
@@ -17,7 +16,7 @@ import { mediaInlineSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaInli
17
16
  import { mediaSingleSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaSingle';
18
17
  import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
19
18
  import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
20
- import { hideMediaViewer, showMediaViewer, trackMediaPaste, hideImageEditor, showImageEditor } from './pm-plugins/commands';
19
+ import { hideMediaViewer, showMediaViewer, trackMediaPaste } from './pm-plugins/commands';
21
20
  import keymapPlugin from './pm-plugins/keymap';
22
21
  import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
23
22
  import linkingPlugin from './pm-plugins/linking';
@@ -27,7 +26,6 @@ import { createPlugin as createMediaPixelResizingPlugin } from './pm-plugins/pix
27
26
  import { stateKey } from './pm-plugins/plugin-key';
28
27
  import { createMediaIdentifierArray, extractMediaNodes } from './pm-plugins/utils/media-common';
29
28
  import { insertMediaAsMediaSingle as _insertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
30
- import { RenderImageEditor } from './ui/ImageEditor/ModalWrapper';
31
29
  import { MediaPickerComponents } from './ui/MediaPicker';
32
30
  import { RenderMediaViewer } from './ui/MediaViewer/PortalWrapper';
33
31
  import { floatingToolbar as _floatingToolbar } from './ui/toolbar';
@@ -97,36 +95,10 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
97
95
  items: mediaItems
98
96
  });
99
97
  };
100
- var imageEditorStateSelector = function imageEditorStateSelector(states) {
101
- var _states$mediaState6, _states$mediaState7, _states$mediaState8;
102
- return {
103
- isImageEditorVisible: (_states$mediaState6 = states.mediaState) === null || _states$mediaState6 === void 0 ? void 0 : _states$mediaState6.isImageEditorVisible,
104
- imageEditorSelectedMedia: (_states$mediaState7 = states.mediaState) === null || _states$mediaState7 === void 0 ? void 0 : _states$mediaState7.imageEditorSelectedMedia,
105
- mediaClientConfig: (_states$mediaState8 = states.mediaState) === null || _states$mediaState8 === void 0 ? void 0 : _states$mediaState8.mediaClientConfig
106
- };
107
- };
108
- var ImageEditorFunctionalComponent = function ImageEditorFunctionalComponent(_ref3) {
109
- var api = _ref3.api;
110
- var _useSharedPluginState3 = useSharedPluginStateWithSelector(api, ['media'], imageEditorStateSelector),
111
- isImageEditorVisible = _useSharedPluginState3.isImageEditorVisible,
112
- imageEditorSelectedMedia = _useSharedPluginState3.imageEditorSelectedMedia,
113
- mediaClientConfig = _useSharedPluginState3.mediaClientConfig;
114
- if (!isImageEditorVisible || !imageEditorSelectedMedia || !mediaClientConfig) {
115
- return null;
116
- }
117
- var handleOnClose = function handleOnClose() {
118
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.hideImageEditor);
119
- };
120
- return /*#__PURE__*/React.createElement(RenderImageEditor, {
121
- mediaClientConfig: mediaClientConfig,
122
- onClose: handleOnClose,
123
- selectedNodeAttrs: imageEditorSelectedMedia
124
- });
125
- };
126
- export var mediaPlugin = function mediaPlugin(_ref4) {
127
- var _ref4$config = _ref4.config,
128
- options = _ref4$config === void 0 ? {} : _ref4$config,
129
- api = _ref4.api;
98
+ export var mediaPlugin = function mediaPlugin(_ref3) {
99
+ var _ref3$config = _ref3.config,
100
+ options = _ref3$config === void 0 ? {} : _ref3$config,
101
+ api = _ref3.api;
130
102
  var previousMediaProvider;
131
103
  var mediaErrorLocalIds = new Set();
132
104
  return {
@@ -167,8 +139,8 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
167
139
  return false;
168
140
  }
169
141
  previousMediaProvider = provider;
170
- return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref5) {
171
- var tr = _ref5.tr;
142
+ return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref4) {
143
+ var tr = _ref4.tr;
172
144
  return tr.setMeta(stateKey, {
173
145
  mediaProvider: provider
174
146
  });
@@ -178,21 +150,19 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
178
150
  commands: {
179
151
  showMediaViewer: showMediaViewer,
180
152
  hideMediaViewer: hideMediaViewer,
181
- trackMediaPaste: trackMediaPaste,
182
- showImageEditor: showImageEditor,
183
- hideImageEditor: hideImageEditor
153
+ trackMediaPaste: trackMediaPaste
184
154
  },
185
155
  nodes: function nodes() {
186
- var _ref6 = options || {},
187
- _ref6$allowMediaGroup = _ref6.allowMediaGroup,
188
- allowMediaGroup = _ref6$allowMediaGroup === void 0 ? true : _ref6$allowMediaGroup,
189
- _ref6$allowMediaSingl = _ref6.allowMediaSingle,
190
- allowMediaSingle = _ref6$allowMediaSingl === void 0 ? false : _ref6$allowMediaSingl,
191
- _ref6$allowPixelResiz = _ref6.allowPixelResizing,
192
- allowPixelResizing = _ref6$allowPixelResiz === void 0 ? false : _ref6$allowPixelResiz,
193
- allowCaptions = _ref6.allowCaptions,
194
- allowMediaInlineImages = _ref6.allowMediaInlineImages,
195
- mediaFeatureFlags = _ref6.featureFlags;
156
+ var _ref5 = options || {},
157
+ _ref5$allowMediaGroup = _ref5.allowMediaGroup,
158
+ allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
159
+ _ref5$allowMediaSingl = _ref5.allowMediaSingle,
160
+ allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
161
+ _ref5$allowPixelResiz = _ref5.allowPixelResizing,
162
+ allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
163
+ allowCaptions = _ref5.allowCaptions,
164
+ allowMediaInlineImages = _ref5.allowMediaInlineImages,
165
+ mediaFeatureFlags = _ref5.featureFlags;
196
166
  var allowMediaInline = fg('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
197
167
  var mediaSingleOption = {
198
168
  withCaption: allowCaptions,
@@ -226,16 +196,16 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
226
196
  pmPlugins: function pmPlugins() {
227
197
  var pmPlugins = [{
228
198
  name: 'media',
229
- plugin: function plugin(_ref7) {
230
- var schema = _ref7.schema,
231
- dispatch = _ref7.dispatch,
232
- getIntl = _ref7.getIntl,
233
- eventDispatcher = _ref7.eventDispatcher,
234
- providerFactory = _ref7.providerFactory,
235
- errorReporter = _ref7.errorReporter,
236
- portalProviderAPI = _ref7.portalProviderAPI,
237
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent,
238
- nodeViewPortalProviderAPI = _ref7.nodeViewPortalProviderAPI;
199
+ plugin: function plugin(_ref6) {
200
+ var schema = _ref6.schema,
201
+ dispatch = _ref6.dispatch,
202
+ getIntl = _ref6.getIntl,
203
+ eventDispatcher = _ref6.eventDispatcher,
204
+ providerFactory = _ref6.providerFactory,
205
+ errorReporter = _ref6.errorReporter,
206
+ portalProviderAPI = _ref6.portalProviderAPI,
207
+ dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
208
+ nodeViewPortalProviderAPI = _ref6.nodeViewPortalProviderAPI;
239
209
  return createPlugin(schema, {
240
210
  providerFactory: providerFactory,
241
211
  nodeViews: {
@@ -254,17 +224,17 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
254
224
  }
255
225
  }, {
256
226
  name: 'mediaKeymap',
257
- plugin: function plugin(_ref8) {
227
+ plugin: function plugin(_ref7) {
258
228
  var _api$analytics3, _api$selection;
259
- var getIntl = _ref8.getIntl;
229
+ var getIntl = _ref7.getIntl;
260
230
  return keymapPlugin(options, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
261
231
  }
262
232
  }];
263
233
  if (options && options.allowMediaSingle) {
264
234
  pmPlugins.push({
265
235
  name: 'mediaSingleKeymap',
266
- plugin: function plugin(_ref9) {
267
- var schema = _ref9.schema;
236
+ plugin: function plugin(_ref8) {
237
+ var schema = _ref8.schema;
268
238
  return keymapMediaSinglePlugin(schema);
269
239
  }
270
240
  });
@@ -276,9 +246,9 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
276
246
  });
277
247
  pmPlugins.push({
278
248
  name: 'mediaAltTextKeymap',
279
- plugin: function plugin(_ref0) {
249
+ plugin: function plugin(_ref9) {
280
250
  var _api$analytics4;
281
- var schema = _ref0.schema;
251
+ var schema = _ref9.schema;
282
252
  return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
283
253
  }
284
254
  });
@@ -286,15 +256,15 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
286
256
  if (options && options.allowLinking) {
287
257
  pmPlugins.push({
288
258
  name: 'mediaLinking',
289
- plugin: function plugin(_ref1) {
290
- var dispatch = _ref1.dispatch;
259
+ plugin: function plugin(_ref0) {
260
+ var dispatch = _ref0.dispatch;
291
261
  return linkingPlugin(dispatch);
292
262
  }
293
263
  });
294
264
  pmPlugins.push({
295
265
  name: 'mediaLinkingKeymap',
296
- plugin: function plugin(_ref10) {
297
- var schema = _ref10.schema;
266
+ plugin: function plugin(_ref1) {
267
+ var schema = _ref1.schema;
298
268
  return keymapLinkingPlugin(schema);
299
269
  }
300
270
  });
@@ -336,16 +306,13 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
336
306
  });
337
307
  return pmPlugins;
338
308
  },
339
- contentComponent: function contentComponent(_ref11) {
340
- var editorView = _ref11.editorView,
341
- appearance = _ref11.appearance;
309
+ contentComponent: function contentComponent(_ref10) {
310
+ var editorView = _ref10.editorView,
311
+ appearance = _ref10.appearance;
342
312
  if (!editorView) {
343
313
  return null;
344
314
  }
345
- return /*#__PURE__*/React.createElement(React.Fragment, null, (options === null || options === void 0 ? void 0 : options.allowImageEditing) && expValEquals('platform_editor_add_image_editing', 'isEnabled', true) && /*#__PURE__*/React.createElement(ImageEditorFunctionalComponent, {
346
- api: api,
347
- editorView: editorView
348
- }), /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
315
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
349
316
  api: api,
350
317
  editorView: editorView
351
318
  }), /*#__PURE__*/React.createElement(MediaPickerFunctionalComponent, {
@@ -354,8 +321,8 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
354
321
  api: api
355
322
  }));
356
323
  },
357
- secondaryToolbarComponent: function secondaryToolbarComponent(_ref12) {
358
- var disabled = _ref12.disabled;
324
+ secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
325
+ var disabled = _ref11.disabled;
359
326
  return /*#__PURE__*/React.createElement(ToolbarMedia, {
360
327
  isDisabled: disabled,
361
328
  isReducedSpacing: true,
@@ -377,7 +344,7 @@ export var mediaPlugin = function mediaPlugin(_ref4) {
377
344
  allowLinking: options && options.allowLinking,
378
345
  allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
379
346
  allowAltTextOnImages: options && options.allowAltTextOnImages,
380
- allowImageEditing: options && options.allowImageEditing,
347
+ allowImageEditing: !!(api !== null && api !== void 0 && api.mediaEditing) && options && options.allowImageEditing,
381
348
  allowImagePreview: options && options.allowImagePreview,
382
349
  altTextValidator: options && options.altTextValidator,
383
350
  fullWidthEnabled: options && options.fullWidthEnabled,
@@ -31,26 +31,4 @@ export var trackMediaPaste = function trackMediaPaste(attrs) {
31
31
  });
32
32
  return tr;
33
33
  };
34
- };
35
- export var showImageEditor = function showImageEditor(media) {
36
- return function (_ref4) {
37
- var tr = _ref4.tr;
38
- tr.setMeta(stateKey, {
39
- type: ACTIONS.SHOW_IMAGE_EDITOR,
40
- imageEditorSelectedMedia: media,
41
- isImageEditorVisible: true
42
- });
43
- tr.setMeta('addToHistory', false);
44
- return tr;
45
- };
46
- };
47
- export var hideImageEditor = function hideImageEditor(_ref5) {
48
- var tr = _ref5.tr;
49
- tr.setMeta(stateKey, {
50
- type: ACTIONS.HIDE_IMAGE_EDITOR,
51
- imageEditorSelectedMedia: null,
52
- isImageEditorVisible: false
53
- });
54
- tr.setMeta('addToHistory', false);
55
- return tr;
56
34
  };
@@ -82,7 +82,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
82
82
  _defineProperty(this, "allowInlineImages", false);
83
83
  _defineProperty(this, "uploadInProgressSubscriptions", []);
84
84
  _defineProperty(this, "uploadInProgressSubscriptionsNotified", false);
85
- _defineProperty(this, "isImageEditorVisible", false);
86
85
  // this is only a temporary variable, which gets cleared after the last inserted node has been selected
87
86
  _defineProperty(this, "lastAddedMediaSingleFileIds", []);
88
87
  _defineProperty(this, "destroyed", false);
@@ -630,11 +629,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
630
629
  value: function setResizingWidth(width) {
631
630
  this.resizingWidth = width;
632
631
  }
633
- }, {
634
- key: "setImageEditorVisibility",
635
- value: function setImageEditorVisibility(isVisible) {
636
- this.isImageEditorVisible = isVisible;
637
- }
638
632
  }, {
639
633
  key: "updateElement",
640
634
  value: function updateElement() {
@@ -876,16 +870,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
876
870
  nextPluginState = pluginState.clone();
877
871
  }
878
872
  break;
879
- case ACTIONS.SHOW_IMAGE_EDITOR:
880
- pluginState.imageEditorSelectedMedia = meta.imageEditorSelectedMedia;
881
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
882
- nextPluginState = nextPluginState.clone();
883
- break;
884
- case ACTIONS.HIDE_IMAGE_EDITOR:
885
- pluginState.imageEditorSelectedMedia = undefined;
886
- pluginState.isImageEditorVisible = meta.isImageEditorVisible;
887
- nextPluginState = nextPluginState.clone();
888
- break;
889
873
  }
890
874
 
891
875
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
@@ -114,13 +114,14 @@ export var handleShowMediaViewer = function handleShowMediaViewer(_ref) {
114
114
  api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
115
115
  };
116
116
  export var handleShowImageEditor = function handleShowImageEditor(_ref2) {
117
+ var _api$mediaEditing;
117
118
  var api = _ref2.api,
118
119
  mediaPluginState = _ref2.mediaPluginState;
119
120
  var selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
120
121
  if (!selectedNodeAttrs) {
121
122
  return false;
122
123
  }
123
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showImageEditor(selectedNodeAttrs));
124
+ api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$mediaEditing = api.mediaEditing) === null || _api$mediaEditing === void 0 ? void 0 : _api$mediaEditing.commands.showImageEditor(selectedNodeAttrs));
124
125
  };
125
126
  var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
126
127
  var _pluginInjectionApi$c;
@@ -554,7 +555,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
554
555
  });
555
556
  }
556
557
  // Image Editing Support
557
- if (allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
558
+ if (!!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.mediaEditing) && allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
558
559
  var _mediaNode$attrs;
559
560
  var _selectedMediaSingleNode = getSelectedMediaSingle(state);
560
561
  var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
@@ -14,6 +14,7 @@ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
14
14
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
15
15
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
16
16
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
+ import type { MediaEditingPlugin } from '@atlaskit/editor-plugin-media-editing';
17
18
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
19
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
19
20
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -38,7 +39,8 @@ export type MediaPluginDependencies = [
38
39
  OptionalPlugin<FeatureFlagsPlugin>,
39
40
  OptionalPlugin<ConnectivityPlugin>,
40
41
  OptionalPlugin<InteractionPlugin>,
41
- OptionalPlugin<ToolbarPlugin>
42
+ OptionalPlugin<ToolbarPlugin>,
43
+ OptionalPlugin<MediaEditingPlugin>
42
44
  ];
43
45
  export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
44
46
  actions: {
@@ -59,9 +61,7 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
59
61
  setProvider: (provider: Promise<MediaProvider>) => boolean;
60
62
  };
61
63
  commands: {
62
- hideImageEditor: EditorCommand;
63
64
  hideMediaViewer: EditorCommand;
64
- showImageEditor: (media: MediaADFAttrs) => EditorCommand;
65
65
  showMediaViewer: (media: MediaADFAttrs) => EditorCommand;
66
66
  trackMediaPaste: (attrs: MediaADFAttrs) => EditorCommand;
67
67
  };
@@ -3,5 +3,3 @@ import type { EditorCommand } from '@atlaskit/editor-common/types';
3
3
  export declare const showMediaViewer: (media: MediaADFAttrs) => EditorCommand;
4
4
  export declare const hideMediaViewer: EditorCommand;
5
5
  export declare const trackMediaPaste: (attrs: MediaADFAttrs) => EditorCommand;
6
- export declare const showImageEditor: (media: MediaADFAttrs) => EditorCommand;
7
- export declare const hideImageEditor: EditorCommand;
@@ -1,5 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
- import type { MediaADFAttrs, RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
2
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
3
3
  import type { InsertMediaVia } from '@atlaskit/editor-common/analytics';
4
4
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
@@ -41,8 +41,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
41
41
  (isUploading: boolean): void;
42
42
  }[];
43
43
  uploadInProgressSubscriptionsNotified: boolean;
44
- isImageEditorVisible?: boolean;
45
- imageEditorSelectedMedia?: MediaADFAttrs;
46
44
  lastAddedMediaSingleFileIds: {
47
45
  id: string;
48
46
  selectionPosition: number;
@@ -74,7 +72,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
74
72
  getMediaOptions: () => MediaPluginOptions;
75
73
  setIsResizing(isResizing: boolean): void;
76
74
  setResizingWidth(width: number): void;
77
- setImageEditorVisibility(isVisible: boolean): void;
78
75
  updateElement(): void;
79
76
  private isMediaSchemaNode;
80
77
  private getDomElement;
@@ -32,11 +32,9 @@ export interface MediaPluginState {
32
32
  handleMediaNodeRemoval: (node: PMNode | undefined, getPos: ProsemirrorGetPosHandler) => void;
33
33
  handleMediaNodeUnmount: (oldNode: PMNode) => void;
34
34
  ignoreLinks: boolean;
35
- imageEditorSelectedMedia?: MediaADFAttrs;
36
35
  insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string, insertMediaVia?: InsertMediaVia) => void;
37
36
  isFullscreen: boolean;
38
37
  isIdentifierInEditorScope: (identifier: Identifier) => boolean;
39
- isImageEditorVisible?: boolean;
40
38
  isMediaViewerVisible?: boolean;
41
39
  isResizing: boolean;
42
40
  lastAddedMediaSingleFileIds: {
@@ -58,7 +56,6 @@ export interface MediaPluginState {
58
56
  resizingWidth: number;
59
57
  selectedMediaContainerNode: () => PMNode | undefined;
60
58
  setBrowseFn: (browseFn: () => void) => void;
61
- setImageEditorVisibility: (isVisible: boolean) => void;
62
59
  setIsResizing(isResizing: boolean): void;
63
60
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
64
61
  setResizingWidth(width: number): void;
@@ -14,6 +14,7 @@ import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
14
14
  import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
15
15
  import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
16
16
  import type { InteractionPlugin } from '@atlaskit/editor-plugin-interaction';
17
+ import type { MediaEditingPlugin } from '@atlaskit/editor-plugin-media-editing';
17
18
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
18
19
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
19
20
  import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
@@ -38,7 +39,8 @@ export type MediaPluginDependencies = [
38
39
  OptionalPlugin<FeatureFlagsPlugin>,
39
40
  OptionalPlugin<ConnectivityPlugin>,
40
41
  OptionalPlugin<InteractionPlugin>,
41
- OptionalPlugin<ToolbarPlugin>
42
+ OptionalPlugin<ToolbarPlugin>,
43
+ OptionalPlugin<MediaEditingPlugin>
42
44
  ];
43
45
  export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
44
46
  actions: {
@@ -59,9 +61,7 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
59
61
  setProvider: (provider: Promise<MediaProvider>) => boolean;
60
62
  };
61
63
  commands: {
62
- hideImageEditor: EditorCommand;
63
64
  hideMediaViewer: EditorCommand;
64
- showImageEditor: (media: MediaADFAttrs) => EditorCommand;
65
65
  showMediaViewer: (media: MediaADFAttrs) => EditorCommand;
66
66
  trackMediaPaste: (attrs: MediaADFAttrs) => EditorCommand;
67
67
  };
@@ -3,5 +3,3 @@ import type { EditorCommand } from '@atlaskit/editor-common/types';
3
3
  export declare const showMediaViewer: (media: MediaADFAttrs) => EditorCommand;
4
4
  export declare const hideMediaViewer: EditorCommand;
5
5
  export declare const trackMediaPaste: (attrs: MediaADFAttrs) => EditorCommand;
6
- export declare const showImageEditor: (media: MediaADFAttrs) => EditorCommand;
7
- export declare const hideImageEditor: EditorCommand;
@@ -1,5 +1,5 @@
1
1
  import type { IntlShape } from 'react-intl-next';
2
- import type { MediaADFAttrs, RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
2
+ import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
3
3
  import type { InsertMediaVia } from '@atlaskit/editor-common/analytics';
4
4
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
5
5
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
@@ -41,8 +41,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
41
41
  (isUploading: boolean): void;
42
42
  }[];
43
43
  uploadInProgressSubscriptionsNotified: boolean;
44
- isImageEditorVisible?: boolean;
45
- imageEditorSelectedMedia?: MediaADFAttrs;
46
44
  lastAddedMediaSingleFileIds: {
47
45
  id: string;
48
46
  selectionPosition: number;
@@ -74,7 +72,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
74
72
  getMediaOptions: () => MediaPluginOptions;
75
73
  setIsResizing(isResizing: boolean): void;
76
74
  setResizingWidth(width: number): void;
77
- setImageEditorVisibility(isVisible: boolean): void;
78
75
  updateElement(): void;
79
76
  private isMediaSchemaNode;
80
77
  private getDomElement;
@@ -32,11 +32,9 @@ export interface MediaPluginState {
32
32
  handleMediaNodeRemoval: (node: PMNode | undefined, getPos: ProsemirrorGetPosHandler) => void;
33
33
  handleMediaNodeUnmount: (oldNode: PMNode) => void;
34
34
  ignoreLinks: boolean;
35
- imageEditorSelectedMedia?: MediaADFAttrs;
36
35
  insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string, insertMediaVia?: InsertMediaVia) => void;
37
36
  isFullscreen: boolean;
38
37
  isIdentifierInEditorScope: (identifier: Identifier) => boolean;
39
- isImageEditorVisible?: boolean;
40
38
  isMediaViewerVisible?: boolean;
41
39
  isResizing: boolean;
42
40
  lastAddedMediaSingleFileIds: {
@@ -58,7 +56,6 @@ export interface MediaPluginState {
58
56
  resizingWidth: number;
59
57
  selectedMediaContainerNode: () => PMNode | undefined;
60
58
  setBrowseFn: (browseFn: () => void) => void;
61
- setImageEditorVisibility: (isVisible: boolean) => void;
62
59
  setIsResizing(isResizing: boolean): void;
63
60
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
64
61
  setResizingWidth(width: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.9.0",
3
+ "version": "8.10.0",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -62,12 +62,11 @@
62
62
  "@atlaskit/media-picker": "^70.1.0",
63
63
  "@atlaskit/media-ui": "^28.7.0",
64
64
  "@atlaskit/media-viewer": "^52.5.0",
65
- "@atlaskit/modal-dialog": "^14.9.0",
66
65
  "@atlaskit/platform-feature-flags": "^1.1.0",
67
66
  "@atlaskit/primitives": "^17.0.0",
68
67
  "@atlaskit/textfield": "^8.2.0",
69
68
  "@atlaskit/theme": "^21.0.0",
70
- "@atlaskit/tmp-editor-statsig": "^16.1.0",
69
+ "@atlaskit/tmp-editor-statsig": "^16.3.0",
71
70
  "@atlaskit/tokens": "^9.0.0",
72
71
  "@atlaskit/tooltip": "^20.11.0",
73
72
  "@babel/runtime": "^7.0.0",
@@ -79,7 +78,7 @@
79
78
  "uuid": "^3.1.0"
80
79
  },
81
80
  "peerDependencies": {
82
- "@atlaskit/editor-common": "^110.48.0",
81
+ "@atlaskit/editor-common": "^110.50.0",
83
82
  "@atlaskit/media-core": "^37.0.0",
84
83
  "react": "^18.2.0",
85
84
  "react-dom": "^18.2.0",
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RenderImageEditor = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _mediaClient = require("@atlaskit/media-client");
12
- var _utils = require("../toolbar/utils");
13
- var _index = require("./index");
14
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
15
- var RenderImageEditor = exports.RenderImageEditor = function RenderImageEditor(_ref) {
16
- var mediaClientConfig = _ref.mediaClientConfig,
17
- onClose = _ref.onClose,
18
- selectedNodeAttrs = _ref.selectedNodeAttrs,
19
- errorReporter = _ref.errorReporter,
20
- onSave = _ref.onSave;
21
- var _useState = (0, _react.useState)(''),
22
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
23
- imageUrl = _useState2[0],
24
- setImageUrl = _useState2[1];
25
- (0, _react.useEffect)(function () {
26
- var getImageUrl = function getImageUrl() {
27
- if ((0, _utils.isExternalMedia)(selectedNodeAttrs)) {
28
- // External image - use the URL directly
29
- setImageUrl(selectedNodeAttrs.url || '');
30
- } else {
31
- // File media - use MediaClient to get the image URL
32
- var id = selectedNodeAttrs.id,
33
- _selectedNodeAttrs$co = selectedNodeAttrs.collection,
34
- collection = _selectedNodeAttrs$co === void 0 ? '' : _selectedNodeAttrs$co;
35
- try {
36
- var mediaClient = new _mediaClient.MediaClient(mediaClientConfig);
37
-
38
- // Subscribe to file state to get file information
39
- var subscription = mediaClient.file.getFileState(id, {
40
- collectionName: collection
41
- }).subscribe(function (fileState) {
42
- if (fileState.status === 'processed' || fileState.status === 'processing') {
43
- // Get the image URL from the processed file
44
- mediaClient.file.getFileBinaryURL(id, collection).then(function (url) {
45
- setImageUrl(url);
46
- });
47
- }
48
- });
49
-
50
- // Cleanup subscription on unmount
51
- return function () {
52
- return subscription.unsubscribe();
53
- };
54
- } catch (error) {
55
- if (errorReporter) {
56
- errorReporter.captureException(error instanceof Error ? error : new Error(String(error)));
57
- }
58
- setImageUrl('');
59
- }
60
- }
61
- };
62
- getImageUrl();
63
- }, [selectedNodeAttrs, mediaClientConfig, errorReporter]);
64
- return /*#__PURE__*/_react.default.createElement(_index.ImageEditor, {
65
- isOpen: true,
66
- onClose: onClose,
67
- imageUrl: imageUrl
68
- });
69
- };
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ImageEditor = void 0;
9
- var _react = require("@emotion/react");
10
- var _reactIntlNext = require("react-intl-next");
11
- var _new = _interopRequireDefault(require("@atlaskit/button/new"));
12
- var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
- /**
15
- * @jsxRuntime classic
16
- * @jsx jsx
17
- */
18
-
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
20
-
21
- var imageWrapper = (0, _react.css)({
22
- maxHeight: 'calc(100vh - 250px)',
23
- width: '100%',
24
- overflow: 'hidden',
25
- display: 'flex',
26
- justifyContent: 'center',
27
- alignItems: 'center'
28
- });
29
- var imageStyle = (0, _react.css)({
30
- maxWidth: '100%',
31
- maxHeight: 'calc(100vh - 250px)',
32
- width: 'auto',
33
- height: 'auto',
34
- objectFit: 'contain'
35
- });
36
- var ImageEditor = exports.ImageEditor = function ImageEditor(_ref) {
37
- var isOpen = _ref.isOpen,
38
- onClose = _ref.onClose,
39
- imageUrl = _ref.imageUrl;
40
- return (0, _react.jsx)(_modalDialog.ModalTransition, null, isOpen && (0, _react.jsx)(_modalDialog.default, {
41
- onClose: onClose,
42
- width: 1800
43
- }, (0, _react.jsx)("br", null), (0, _react.jsx)(_modalDialog.ModalBody, null, (0, _react.jsx)("div", {
44
- css: imageWrapper
45
- }, imageUrl && (0, _react.jsx)("img", {
46
- src: imageUrl,
47
- alt: "Edit preview",
48
- css: imageStyle
49
- }))), (0, _react.jsx)(_modalDialog.ModalFooter, null, (0, _react.jsx)(_new.default, {
50
- appearance: "subtle",
51
- onClick: onClose
52
- }, (0, _react.jsx)(_reactIntlNext.FormattedMessage, {
53
- id: "editor.imageEditor.cancel",
54
- defaultMessage: "Cancel"
55
- })), (0, _react.jsx)(_new.default, {
56
- appearance: "primary",
57
- onClick: onClose
58
- }, (0, _react.jsx)(_reactIntlNext.FormattedMessage, {
59
- id: "editor.imageEditor.done",
60
- defaultMessage: "Done"
61
- })))));
62
- };