@atlaskit/editor-plugin-media 8.8.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 (50) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/cjs/mediaPlugin.js +44 -77
  3. package/dist/cjs/nodeviews/mediaNodeView/index.js +92 -7
  4. package/dist/cjs/nodeviews/mediaSingle.js +8 -1
  5. package/dist/cjs/pm-plugins/commands.js +1 -23
  6. package/dist/cjs/pm-plugins/main.js +0 -16
  7. package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -2
  8. package/dist/cjs/ui/ResizableMediaSingle/index.js +11 -0
  9. package/dist/cjs/ui/toolbar/index.js +3 -2
  10. package/dist/es2019/mediaPlugin.js +4 -39
  11. package/dist/es2019/nodeviews/mediaNodeView/index.js +88 -8
  12. package/dist/es2019/nodeviews/mediaSingle.js +8 -1
  13. package/dist/es2019/pm-plugins/commands.js +0 -22
  14. package/dist/es2019/pm-plugins/main.js +0 -14
  15. package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +13 -2
  16. package/dist/es2019/ui/ResizableMediaSingle/index.js +11 -0
  17. package/dist/es2019/ui/toolbar/index.js +3 -2
  18. package/dist/esm/mediaPlugin.js +45 -78
  19. package/dist/esm/nodeviews/mediaNodeView/index.js +92 -7
  20. package/dist/esm/nodeviews/mediaSingle.js +8 -1
  21. package/dist/esm/pm-plugins/commands.js +0 -22
  22. package/dist/esm/pm-plugins/main.js +0 -16
  23. package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -2
  24. package/dist/esm/ui/ResizableMediaSingle/index.js +11 -0
  25. package/dist/esm/ui/toolbar/index.js +3 -2
  26. package/dist/types/mediaPluginType.d.ts +3 -3
  27. package/dist/types/nodeviews/mediaNodeView/index.d.ts +13 -4
  28. package/dist/types/nodeviews/mediaSingle.d.ts +1 -0
  29. package/dist/types/pm-plugins/commands.d.ts +0 -2
  30. package/dist/types/pm-plugins/main.d.ts +1 -4
  31. package/dist/types/pm-plugins/types.d.ts +0 -3
  32. package/dist/types/ui/ResizableMediaSingle/index.d.ts +1 -0
  33. package/dist/types-ts4.5/mediaPluginType.d.ts +3 -3
  34. package/dist/types-ts4.5/nodeviews/mediaNodeView/index.d.ts +13 -4
  35. package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +1 -0
  36. package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -2
  37. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -4
  38. package/dist/types-ts4.5/pm-plugins/types.d.ts +0 -3
  39. package/dist/types-ts4.5/ui/ResizableMediaSingle/index.d.ts +1 -0
  40. package/package.json +3 -4
  41. package/dist/cjs/ui/ImageEditor/ModalWrapper.js +0 -69
  42. package/dist/cjs/ui/ImageEditor/index.js +0 -62
  43. package/dist/es2019/ui/ImageEditor/ModalWrapper.js +0 -58
  44. package/dist/es2019/ui/ImageEditor/index.js +0 -53
  45. package/dist/esm/ui/ImageEditor/ModalWrapper.js +0 -60
  46. package/dist/esm/ui/ImageEditor/index.js +0 -52
  47. package/dist/types/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  48. package/dist/types/ui/ImageEditor/index.d.ts +0 -12
  49. package/dist/types-ts4.5/ui/ImageEditor/ModalWrapper.d.ts +0 -13
  50. package/dist/types-ts4.5/ui/ImageEditor/index.d.ts +0 -12
@@ -4,20 +4,24 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import type { ContextIdentifierProvider, MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
6
6
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
- import type { ExtractInjectionAPI, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
8
  import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import type { MediaNextEditorPluginType } from '../../mediaPluginType';
12
- import type { getPosHandler, MediaOptions } from '../../types';
12
+ import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
13
13
  import type { MediaNodeViewProps } from '../types';
14
14
  interface MediaNodeWithPluginStateComponentProps {
15
15
  interactionState?: SharedInteractionState['interactionState'];
16
16
  mediaProvider?: Promise<MediaProvider>;
17
- width?: WidthPluginState;
18
17
  }
19
18
  declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
20
19
  private isSelected;
20
+ private hasBeenResized;
21
+ private resizeListenerBinding?;
22
+ getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
23
+ getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode): number;
24
+ hasResizedListener: () => void;
21
25
  createDomRef(): HTMLElement;
22
26
  viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
23
27
  stopEvent(event: Event): boolean;
@@ -27,9 +31,14 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
27
31
  height: number;
28
32
  width: number;
29
33
  }) => void;
30
- renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
34
+ getMaxCardDimensions: () => {
35
+ width: string;
36
+ height: string;
37
+ };
38
+ renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
31
39
  renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
32
40
  render(): React.JSX.Element;
41
+ destroy(): void;
33
42
  }
34
43
  export declare const ReactMediaNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaNodeView;
35
44
  export {};
@@ -15,6 +15,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
15
15
  forceViewUpdate: boolean;
16
16
  selectionType: number | null;
17
17
  unsubscribeToViewModeChange: (() => void) | undefined;
18
+ hasResized: boolean;
18
19
  createDomRef(): HTMLElement;
19
20
  getContentDOM(): {
20
21
  dom: HTMLDivElement;
@@ -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;
@@ -13,6 +13,7 @@ type State = {
13
13
  resizedPctWidth?: number;
14
14
  };
15
15
  export default class ResizableMediaSingle extends React.Component<Props, State> {
16
+ private hasResized;
16
17
  state: State;
17
18
  componentDidUpdate(prevProps: Props): boolean;
18
19
  private displayGrid;
@@ -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
  };
@@ -4,20 +4,24 @@ import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
4
4
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
5
5
  import type { ContextIdentifierProvider, MediaProvider, ProviderFactory, Providers } from '@atlaskit/editor-common/provider-factory';
6
6
  import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
7
- import type { ExtractInjectionAPI, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
7
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
8
  import type { SharedInteractionState } from '@atlaskit/editor-plugin-interaction';
9
9
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
10
10
  import type { Decoration, EditorView } from '@atlaskit/editor-prosemirror/view';
11
11
  import type { MediaNextEditorPluginType } from '../../mediaPluginType';
12
- import type { getPosHandler, MediaOptions } from '../../types';
12
+ import type { getPosHandler, getPosHandlerNode, MediaOptions } from '../../types';
13
13
  import type { MediaNodeViewProps } from '../types';
14
14
  interface MediaNodeWithPluginStateComponentProps {
15
15
  interactionState?: SharedInteractionState['interactionState'];
16
16
  mediaProvider?: Promise<MediaProvider>;
17
- width?: WidthPluginState;
18
17
  }
19
18
  declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
20
19
  private isSelected;
20
+ private hasBeenResized;
21
+ private resizeListenerBinding?;
22
+ getMediaSingleNode(getPos: getPosHandlerNode): PMNode | null;
23
+ getMaxWidthFromMediaSingleNode(mediaSingleNode: PMNode): number;
24
+ hasResizedListener: () => void;
21
25
  createDomRef(): HTMLElement;
22
26
  viewShouldUpdate(nextNode: PMNode, decorations: Decoration[]): boolean;
23
27
  stopEvent(event: Event): boolean;
@@ -27,9 +31,14 @@ declare class MediaNodeView extends SelectionBasedNodeView<MediaNodeViewProps> {
27
31
  height: number;
28
32
  width: number;
29
33
  }) => void;
30
- renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ width: editorWidth, mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
34
+ getMaxCardDimensions: () => {
35
+ width: string;
36
+ height: string;
37
+ };
38
+ renderMediaNodeWithState: (contextIdentifierProvider?: Promise<ContextIdentifierProvider>) => ({ mediaProvider, interactionState, }: MediaNodeWithPluginStateComponentProps) => React.JSX.Element;
31
39
  renderMediaNodeWithProviders: ({ contextIdentifierProvider }: Providers) => React.JSX.Element;
32
40
  render(): React.JSX.Element;
41
+ destroy(): void;
33
42
  }
34
43
  export declare const ReactMediaNode: (portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, mediaOptions: MediaOptions | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => (node: PMNode, view: EditorView, getPos: getPosHandler) => MediaNodeView;
35
44
  export {};
@@ -15,6 +15,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
15
15
  forceViewUpdate: boolean;
16
16
  selectionType: number | null;
17
17
  unsubscribeToViewModeChange: (() => void) | undefined;
18
+ hasResized: boolean;
18
19
  createDomRef(): HTMLElement;
19
20
  getContentDOM(): {
20
21
  dom: HTMLDivElement;
@@ -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;
@@ -13,6 +13,7 @@ type State = {
13
13
  resizedPctWidth?: number;
14
14
  };
15
15
  export default class ResizableMediaSingle extends React.Component<Props, State> {
16
+ private hasResized;
16
17
  state: State;
17
18
  componentDidUpdate(prevProps: Props): boolean;
18
19
  private displayGrid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "8.8.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.0.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.46.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
- };
@@ -1,58 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { MediaClient } from '@atlaskit/media-client';
3
- import { isExternalMedia } from '../toolbar/utils';
4
- import { ImageEditor } from './index';
5
- export const RenderImageEditor = ({
6
- mediaClientConfig,
7
- onClose,
8
- selectedNodeAttrs,
9
- errorReporter,
10
- // TODO: EDITOR-3779 - To implement saving image
11
- // eslint-disable-next-line
12
- onSave
13
- }) => {
14
- const [imageUrl, setImageUrl] = useState('');
15
- useEffect(() => {
16
- const getImageUrl = () => {
17
- if (isExternalMedia(selectedNodeAttrs)) {
18
- // External image - use the URL directly
19
- setImageUrl(selectedNodeAttrs.url || '');
20
- } else {
21
- // File media - use MediaClient to get the image URL
22
- const {
23
- id,
24
- collection = ''
25
- } = selectedNodeAttrs;
26
- try {
27
- const mediaClient = new MediaClient(mediaClientConfig);
28
-
29
- // Subscribe to file state to get file information
30
- const subscription = mediaClient.file.getFileState(id, {
31
- collectionName: collection
32
- }).subscribe(fileState => {
33
- if (fileState.status === 'processed' || fileState.status === 'processing') {
34
- // Get the image URL from the processed file
35
- mediaClient.file.getFileBinaryURL(id, collection).then(url => {
36
- setImageUrl(url);
37
- });
38
- }
39
- });
40
-
41
- // Cleanup subscription on unmount
42
- return () => subscription.unsubscribe();
43
- } catch (error) {
44
- if (errorReporter) {
45
- errorReporter.captureException(error instanceof Error ? error : new Error(String(error)));
46
- }
47
- setImageUrl('');
48
- }
49
- }
50
- };
51
- getImageUrl();
52
- }, [selectedNodeAttrs, mediaClientConfig, errorReporter]);
53
- return /*#__PURE__*/React.createElement(ImageEditor, {
54
- isOpen: true,
55
- onClose: onClose,
56
- imageUrl: imageUrl
57
- });
58
- };
@@ -1,53 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
-
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { css, jsx } from '@emotion/react';
8
- import { FormattedMessage } from 'react-intl-next';
9
- import Button from '@atlaskit/button/new';
10
- import Modal, { ModalBody, ModalFooter, ModalTransition } from '@atlaskit/modal-dialog';
11
- const imageWrapper = css({
12
- maxHeight: 'calc(100vh - 250px)',
13
- width: '100%',
14
- overflow: 'hidden',
15
- display: 'flex',
16
- justifyContent: 'center',
17
- alignItems: 'center'
18
- });
19
- const imageStyle = css({
20
- maxWidth: '100%',
21
- maxHeight: 'calc(100vh - 250px)',
22
- width: 'auto',
23
- height: 'auto',
24
- objectFit: 'contain'
25
- });
26
- export const ImageEditor = ({
27
- isOpen,
28
- onClose,
29
- imageUrl
30
- }) => {
31
- return jsx(ModalTransition, null, isOpen && jsx(Modal, {
32
- onClose: onClose,
33
- width: 1800
34
- }, jsx("br", null), jsx(ModalBody, null, jsx("div", {
35
- css: imageWrapper
36
- }, imageUrl && jsx("img", {
37
- src: imageUrl,
38
- alt: "Edit preview",
39
- css: imageStyle
40
- }))), jsx(ModalFooter, null, jsx(Button, {
41
- appearance: "subtle",
42
- onClick: onClose
43
- }, jsx(FormattedMessage, {
44
- id: "editor.imageEditor.cancel",
45
- defaultMessage: "Cancel"
46
- })), jsx(Button, {
47
- appearance: "primary",
48
- onClick: onClose
49
- }, jsx(FormattedMessage, {
50
- id: "editor.imageEditor.done",
51
- defaultMessage: "Done"
52
- })))));
53
- };
@@ -1,60 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import React, { useEffect, useState } from 'react';
3
- import { MediaClient } from '@atlaskit/media-client';
4
- import { isExternalMedia } from '../toolbar/utils';
5
- import { ImageEditor } from './index';
6
- export var RenderImageEditor = function RenderImageEditor(_ref) {
7
- var mediaClientConfig = _ref.mediaClientConfig,
8
- onClose = _ref.onClose,
9
- selectedNodeAttrs = _ref.selectedNodeAttrs,
10
- errorReporter = _ref.errorReporter,
11
- onSave = _ref.onSave;
12
- var _useState = useState(''),
13
- _useState2 = _slicedToArray(_useState, 2),
14
- imageUrl = _useState2[0],
15
- setImageUrl = _useState2[1];
16
- useEffect(function () {
17
- var getImageUrl = function getImageUrl() {
18
- if (isExternalMedia(selectedNodeAttrs)) {
19
- // External image - use the URL directly
20
- setImageUrl(selectedNodeAttrs.url || '');
21
- } else {
22
- // File media - use MediaClient to get the image URL
23
- var id = selectedNodeAttrs.id,
24
- _selectedNodeAttrs$co = selectedNodeAttrs.collection,
25
- collection = _selectedNodeAttrs$co === void 0 ? '' : _selectedNodeAttrs$co;
26
- try {
27
- var mediaClient = new MediaClient(mediaClientConfig);
28
-
29
- // Subscribe to file state to get file information
30
- var subscription = mediaClient.file.getFileState(id, {
31
- collectionName: collection
32
- }).subscribe(function (fileState) {
33
- if (fileState.status === 'processed' || fileState.status === 'processing') {
34
- // Get the image URL from the processed file
35
- mediaClient.file.getFileBinaryURL(id, collection).then(function (url) {
36
- setImageUrl(url);
37
- });
38
- }
39
- });
40
-
41
- // Cleanup subscription on unmount
42
- return function () {
43
- return subscription.unsubscribe();
44
- };
45
- } catch (error) {
46
- if (errorReporter) {
47
- errorReporter.captureException(error instanceof Error ? error : new Error(String(error)));
48
- }
49
- setImageUrl('');
50
- }
51
- }
52
- };
53
- getImageUrl();
54
- }, [selectedNodeAttrs, mediaClientConfig, errorReporter]);
55
- return /*#__PURE__*/React.createElement(ImageEditor, {
56
- isOpen: true,
57
- onClose: onClose,
58
- imageUrl: imageUrl
59
- });
60
- };
@@ -1,52 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
-
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
7
- import { css, jsx } from '@emotion/react';
8
- import { FormattedMessage } from 'react-intl-next';
9
- import Button from '@atlaskit/button/new';
10
- import Modal, { ModalBody, ModalFooter, ModalTransition } from '@atlaskit/modal-dialog';
11
- var imageWrapper = css({
12
- maxHeight: 'calc(100vh - 250px)',
13
- width: '100%',
14
- overflow: 'hidden',
15
- display: 'flex',
16
- justifyContent: 'center',
17
- alignItems: 'center'
18
- });
19
- var imageStyle = css({
20
- maxWidth: '100%',
21
- maxHeight: 'calc(100vh - 250px)',
22
- width: 'auto',
23
- height: 'auto',
24
- objectFit: 'contain'
25
- });
26
- export var ImageEditor = function ImageEditor(_ref) {
27
- var isOpen = _ref.isOpen,
28
- onClose = _ref.onClose,
29
- imageUrl = _ref.imageUrl;
30
- return jsx(ModalTransition, null, isOpen && jsx(Modal, {
31
- onClose: onClose,
32
- width: 1800
33
- }, jsx("br", null), jsx(ModalBody, null, jsx("div", {
34
- css: imageWrapper
35
- }, imageUrl && jsx("img", {
36
- src: imageUrl,
37
- alt: "Edit preview",
38
- css: imageStyle
39
- }))), jsx(ModalFooter, null, jsx(Button, {
40
- appearance: "subtle",
41
- onClick: onClose
42
- }, jsx(FormattedMessage, {
43
- id: "editor.imageEditor.cancel",
44
- defaultMessage: "Cancel"
45
- })), jsx(Button, {
46
- appearance: "primary",
47
- onClick: onClose
48
- }, jsx(FormattedMessage, {
49
- id: "editor.imageEditor.done",
50
- defaultMessage: "Done"
51
- })))));
52
- };