@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
@@ -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
- };
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import type { MediaADFAttrs } from '@atlaskit/adf-schema';
3
- import type { ErrorReporter } from '@atlaskit/editor-common/error-reporter';
4
- import type { MediaClientConfig } from '@atlaskit/media-client';
5
- interface RenderImageEditorProps {
6
- errorReporter?: ErrorReporter;
7
- mediaClientConfig: MediaClientConfig;
8
- onClose: () => void;
9
- onSave?: (updatedAttrs: MediaADFAttrs) => void;
10
- selectedNodeAttrs: MediaADFAttrs;
11
- }
12
- export declare const RenderImageEditor: ({ mediaClientConfig, onClose, selectedNodeAttrs, errorReporter, onSave, }: RenderImageEditorProps) => React.JSX.Element;
13
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { jsx } from '@emotion/react';
6
- interface ImageEditModalProps {
7
- imageUrl?: string;
8
- isOpen: boolean;
9
- onClose: () => void;
10
- }
11
- export declare const ImageEditor: ({ isOpen, onClose, imageUrl, }: ImageEditModalProps) => jsx.JSX.Element;
12
- export {};
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import type { MediaADFAttrs } from '@atlaskit/adf-schema';
3
- import type { ErrorReporter } from '@atlaskit/editor-common/error-reporter';
4
- import type { MediaClientConfig } from '@atlaskit/media-client';
5
- interface RenderImageEditorProps {
6
- errorReporter?: ErrorReporter;
7
- mediaClientConfig: MediaClientConfig;
8
- onClose: () => void;
9
- onSave?: (updatedAttrs: MediaADFAttrs) => void;
10
- selectedNodeAttrs: MediaADFAttrs;
11
- }
12
- export declare const RenderImageEditor: ({ mediaClientConfig, onClose, selectedNodeAttrs, errorReporter, onSave, }: RenderImageEditorProps) => React.JSX.Element;
13
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import { jsx } from '@emotion/react';
6
- interface ImageEditModalProps {
7
- imageUrl?: string;
8
- isOpen: boolean;
9
- onClose: () => void;
10
- }
11
- export declare const ImageEditor: ({ isOpen, onClose, imageUrl, }: ImageEditModalProps) => jsx.JSX.Element;
12
- export {};