@atlaskit/renderer 108.17.4 → 108.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/afm-cc/tsconfig.json +109 -0
- package/dist/cjs/react/marks/alignment.js +3 -2
- package/dist/cjs/react/marks/breakout.js +3 -2
- package/dist/cjs/react/marks/link.js +4 -3
- package/dist/cjs/react/nodes/blockCard.js +13 -11
- package/dist/cjs/react/nodes/codeBlock/codeBlock.js +5 -2
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -4
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +3 -2
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockCopyButton.js +11 -8
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockWrapButton.js +11 -8
- package/dist/cjs/react/nodes/codeBlock/components/lightWeightCodeBlock.js +8 -7
- package/dist/cjs/react/nodes/codeBlock/windowedCodeBlock.js +6 -5
- package/dist/cjs/react/nodes/embedCard.js +9 -8
- package/dist/cjs/react/nodes/heading-anchor.js +5 -4
- package/dist/cjs/react/nodes/layoutColumn.js +3 -2
- package/dist/cjs/react/nodes/media/index.js +9 -10
- package/dist/cjs/react/nodes/mediaInline.js +46 -50
- package/dist/cjs/react/nodes/mediaSingle/index.js +6 -3
- package/dist/cjs/react/nodes/mediaSingle/styles.js +1 -0
- package/dist/cjs/react/nodes/panel.js +9 -7
- package/dist/cjs/react/nodes/table/sticky.js +7 -6
- package/dist/cjs/react/utils/EditorMediaClientProvider.js +40 -0
- package/dist/cjs/ui/Expand.js +18 -16
- package/dist/cjs/ui/MediaCard.js +71 -74
- package/dist/cjs/ui/Renderer/index.js +36 -27
- package/dist/cjs/ui/Renderer/truncated-wrapper.js +3 -2
- package/dist/cjs/ui/SortingIcon.js +5 -4
- package/dist/cjs/ui/annotations/draft/component.js +9 -8
- package/dist/cjs/ui/annotations/element/mark.js +2 -1
- package/dist/es2019/react/marks/alignment.js +4 -3
- package/dist/es2019/react/marks/breakout.js +4 -3
- package/dist/es2019/react/marks/link.js +5 -4
- package/dist/es2019/react/nodes/blockCard.js +13 -12
- package/dist/es2019/react/nodes/codeBlock/codeBlock.js +4 -2
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -5
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +4 -3
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockCopyButton.js +7 -5
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockWrapButton.js +9 -7
- package/dist/es2019/react/nodes/codeBlock/components/lightWeightCodeBlock.js +9 -8
- package/dist/es2019/react/nodes/codeBlock/windowedCodeBlock.js +6 -4
- package/dist/es2019/react/nodes/embedCard.js +10 -9
- package/dist/es2019/react/nodes/heading-anchor.js +6 -5
- package/dist/es2019/react/nodes/layoutColumn.js +4 -3
- package/dist/es2019/react/nodes/media/index.js +10 -10
- package/dist/es2019/react/nodes/mediaInline.js +37 -23
- package/dist/es2019/react/nodes/mediaSingle/index.js +6 -3
- package/dist/es2019/react/nodes/mediaSingle/styles.js +1 -0
- package/dist/es2019/react/nodes/panel.js +8 -7
- package/dist/es2019/react/nodes/table/sticky.js +8 -7
- package/dist/es2019/react/utils/EditorMediaClientProvider.js +27 -0
- package/dist/es2019/ui/Expand.js +17 -16
- package/dist/es2019/ui/MediaCard.js +25 -29
- package/dist/es2019/ui/Renderer/index.js +38 -29
- package/dist/es2019/ui/Renderer/truncated-wrapper.js +4 -3
- package/dist/es2019/ui/SortingIcon.js +6 -5
- package/dist/es2019/ui/annotations/draft/component.js +10 -9
- package/dist/es2019/ui/annotations/element/mark.js +3 -2
- package/dist/esm/react/marks/alignment.js +4 -3
- package/dist/esm/react/marks/breakout.js +4 -3
- package/dist/esm/react/marks/link.js +5 -4
- package/dist/esm/react/nodes/blockCard.js +13 -12
- package/dist/esm/react/nodes/codeBlock/codeBlock.js +4 -2
- package/dist/esm/react/nodes/codeBlock/components/codeBlockButtonContainer.js +6 -5
- package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +4 -3
- package/dist/esm/react/nodes/codeBlock/components/codeBlockCopyButton.js +7 -5
- package/dist/esm/react/nodes/codeBlock/components/codeBlockWrapButton.js +9 -7
- package/dist/esm/react/nodes/codeBlock/components/lightWeightCodeBlock.js +9 -8
- package/dist/esm/react/nodes/codeBlock/windowedCodeBlock.js +6 -4
- package/dist/esm/react/nodes/embedCard.js +10 -9
- package/dist/esm/react/nodes/heading-anchor.js +6 -5
- package/dist/esm/react/nodes/layoutColumn.js +4 -3
- package/dist/esm/react/nodes/media/index.js +11 -11
- package/dist/esm/react/nodes/mediaInline.js +47 -51
- package/dist/esm/react/nodes/mediaSingle/index.js +6 -3
- package/dist/esm/react/nodes/mediaSingle/styles.js +1 -0
- package/dist/esm/react/nodes/panel.js +8 -7
- package/dist/esm/react/nodes/table/sticky.js +8 -7
- package/dist/esm/react/utils/EditorMediaClientProvider.js +30 -0
- package/dist/esm/ui/Expand.js +17 -16
- package/dist/esm/ui/MediaCard.js +71 -74
- package/dist/esm/ui/Renderer/index.js +38 -29
- package/dist/esm/ui/Renderer/truncated-wrapper.js +4 -3
- package/dist/esm/ui/SortingIcon.js +6 -5
- package/dist/esm/ui/annotations/draft/component.js +10 -9
- package/dist/esm/ui/annotations/element/mark.js +3 -2
- package/dist/types/react/nodes/index.d.ts +1 -1
- package/dist/types/react/nodes/media/index.d.ts +2 -3
- package/dist/types/react/nodes/mediaInline.d.ts +5 -3
- package/dist/types/react/utils/EditorMediaClientProvider.d.ts +5 -0
- package/dist/types/ui/MediaCard.d.ts +6 -5
- package/dist/types/ui/Renderer/index.d.ts +2 -1
- package/dist/types-ts4.5/react/nodes/index.d.ts +1 -1
- package/dist/types-ts4.5/react/nodes/media/index.d.ts +2 -3
- package/dist/types-ts4.5/react/nodes/mediaInline.d.ts +5 -3
- package/dist/types-ts4.5/react/utils/EditorMediaClientProvider.d.ts +5 -0
- package/dist/types-ts4.5/ui/MediaCard.d.ts +6 -5
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +2 -1
- package/package.json +3 -2
|
@@ -3,40 +3,45 @@ import React, { useEffect, useState, useCallback } from 'react';
|
|
|
3
3
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
4
4
|
import { MediaInlineCardErroredView, MediaInlineCardLoadingView, messages } from '@atlaskit/media-ui';
|
|
5
5
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
6
|
-
import {
|
|
6
|
+
import { MediaClientContext } from '@atlaskit/media-client-react';
|
|
7
7
|
import { getClipboardAttrs, mediaIdentifierMap } from '../../ui/MediaCard';
|
|
8
8
|
import { createIntl, injectIntl } from 'react-intl-next';
|
|
9
|
+
import { shouldShowInlineImage, MediaInlineImageCard } from '@atlaskit/editor-common/media-inline';
|
|
9
10
|
export const RenderMediaInline = ({
|
|
10
11
|
rendererAppearance,
|
|
11
12
|
intl,
|
|
12
13
|
clipboardAttrs,
|
|
13
14
|
mediaInlineProviders,
|
|
14
15
|
collection: collectionName,
|
|
15
|
-
featureFlags,
|
|
16
16
|
eventHandlers,
|
|
17
|
-
identifier
|
|
17
|
+
identifier,
|
|
18
|
+
alt,
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
type = ''
|
|
18
22
|
}) => {
|
|
19
23
|
const [contextIdentifierProvider, setContextIdentifierProvider] = useState();
|
|
20
|
-
const [viewMediaClientConfigState, setViewMediaClientConfigState] = useState();
|
|
21
24
|
const [fileState, setFileState] = useState();
|
|
25
|
+
const mediaClient = React.useContext(MediaClientContext);
|
|
22
26
|
const updateContext = async contextIdentifierProvider => {
|
|
23
27
|
if (contextIdentifierProvider) {
|
|
24
28
|
const resolvedContextID = await contextIdentifierProvider;
|
|
25
29
|
setContextIdentifierProvider(resolvedContextID);
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
|
-
const updateFileState = useCallback(async
|
|
29
|
-
const mediaClient = getMediaClient(mediaClientConfig);
|
|
32
|
+
const updateFileState = useCallback(async id => {
|
|
30
33
|
const options = {
|
|
31
34
|
collectionName
|
|
32
35
|
};
|
|
33
36
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
if (mediaClient) {
|
|
38
|
+
const fileState = await mediaClient.file.getCurrentState(id, options);
|
|
39
|
+
setFileState(fileState);
|
|
40
|
+
}
|
|
36
41
|
} catch (error) {
|
|
37
42
|
// do not set state on error
|
|
38
43
|
}
|
|
39
|
-
}, [collectionName]);
|
|
44
|
+
}, [collectionName, mediaClient]);
|
|
40
45
|
useEffect(() => {
|
|
41
46
|
const {
|
|
42
47
|
id
|
|
@@ -54,28 +59,20 @@ export const RenderMediaInline = ({
|
|
|
54
59
|
}, [identifier, collectionName]);
|
|
55
60
|
useEffect(() => {
|
|
56
61
|
const {
|
|
57
|
-
mediaProvider,
|
|
58
62
|
contextIdentifierProvider
|
|
59
63
|
} = mediaInlineProviders;
|
|
60
64
|
const {
|
|
61
65
|
id
|
|
62
66
|
} = clipboardAttrs;
|
|
63
|
-
updateViewMediaClientConfigState(mediaProvider);
|
|
64
67
|
updateContext(contextIdentifierProvider);
|
|
65
|
-
id &&
|
|
66
|
-
}, [mediaInlineProviders, contextIdentifierProvider, clipboardAttrs,
|
|
67
|
-
const updateViewMediaClientConfigState = async mediaProvider => {
|
|
68
|
-
if (mediaProvider) {
|
|
69
|
-
const mediaClientConfig = await mediaProvider;
|
|
70
|
-
setViewMediaClientConfigState(mediaClientConfig.viewMediaClientConfig);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
68
|
+
id && updateFileState(id);
|
|
69
|
+
}, [mediaInlineProviders, contextIdentifierProvider, clipboardAttrs, updateFileState]);
|
|
73
70
|
|
|
74
71
|
/*
|
|
75
72
|
* Only show the loading view if the media provider is not ready
|
|
76
73
|
* prevents calling the media API before the provider is ready
|
|
77
74
|
*/
|
|
78
|
-
if (!
|
|
75
|
+
if (!mediaClient) {
|
|
79
76
|
return /*#__PURE__*/React.createElement(MediaInlineCardLoadingView, {
|
|
80
77
|
message: "",
|
|
81
78
|
isSelected: false
|
|
@@ -97,6 +94,15 @@ export const RenderMediaInline = ({
|
|
|
97
94
|
id,
|
|
98
95
|
collection
|
|
99
96
|
} = clipboardAttrs;
|
|
97
|
+
if (shouldShowInlineImage(type)) {
|
|
98
|
+
return /*#__PURE__*/React.createElement(MediaInlineImageCard, {
|
|
99
|
+
mediaClient: mediaClient,
|
|
100
|
+
identifier: identifier,
|
|
101
|
+
alt: alt,
|
|
102
|
+
width: width,
|
|
103
|
+
height: height
|
|
104
|
+
});
|
|
105
|
+
}
|
|
100
106
|
return /*#__PURE__*/React.createElement("span", _extends({}, getClipboardAttrs({
|
|
101
107
|
id,
|
|
102
108
|
collection,
|
|
@@ -109,7 +115,7 @@ export const RenderMediaInline = ({
|
|
|
109
115
|
onClick: handleMediaInlineClick,
|
|
110
116
|
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
111
117
|
shouldDisplayToolTip: shouldDisplayToolTip,
|
|
112
|
-
mediaClientConfig:
|
|
118
|
+
mediaClientConfig: mediaClient.mediaClientConfig,
|
|
113
119
|
mediaViewerItems: Array.from(mediaIdentifierMap.values())
|
|
114
120
|
}) : /*#__PURE__*/React.createElement(MediaInlineCardErroredView, {
|
|
115
121
|
message: (intl || createIntl({
|
|
@@ -124,7 +130,11 @@ const MediaInline = props => {
|
|
|
124
130
|
providers: providerFactory,
|
|
125
131
|
intl,
|
|
126
132
|
rendererAppearance,
|
|
127
|
-
featureFlags
|
|
133
|
+
featureFlags,
|
|
134
|
+
type: fileType,
|
|
135
|
+
alt,
|
|
136
|
+
width,
|
|
137
|
+
height
|
|
128
138
|
} = props;
|
|
129
139
|
const clipboardAttrs = {
|
|
130
140
|
id,
|
|
@@ -147,7 +157,11 @@ const MediaInline = props => {
|
|
|
147
157
|
intl: intl,
|
|
148
158
|
mediaInlineProviders: mediaInlineProviders,
|
|
149
159
|
collection: collection,
|
|
150
|
-
featureFlags: featureFlags
|
|
160
|
+
featureFlags: featureFlags,
|
|
161
|
+
type: fileType,
|
|
162
|
+
alt: alt,
|
|
163
|
+
width: width,
|
|
164
|
+
height: height
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
|
|
1
3
|
import { default as React, Fragment } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
2
5
|
import { injectIntl } from 'react-intl-next';
|
|
3
6
|
import { MediaSingle as UIMediaSingle, WidthConsumer } from '@atlaskit/editor-common/ui';
|
|
4
7
|
import { akEditorFullWidthLayoutWidth, akEditorDefaultLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -150,7 +153,7 @@ const MediaSingle = props => {
|
|
|
150
153
|
featureFlags
|
|
151
154
|
});
|
|
152
155
|
const uiMediaSingleStyles = layout === 'full-width' || layout === 'wide' ? [uiMediaSingleBaseStyles, uiMediaSingleLayoutStyles] : [uiMediaSingleBaseStyles];
|
|
153
|
-
return
|
|
156
|
+
return jsx(UIMediaSingle, {
|
|
154
157
|
css: uiMediaSingleStyles,
|
|
155
158
|
handleMediaSingleRef: ref,
|
|
156
159
|
layout: layout,
|
|
@@ -163,9 +166,9 @@ const MediaSingle = props => {
|
|
|
163
166
|
widthType
|
|
164
167
|
},
|
|
165
168
|
fullWidthMode: isFullWidth
|
|
166
|
-
},
|
|
169
|
+
}, jsx(Fragment, null, mediaComponent), allowCaptions && caption);
|
|
167
170
|
};
|
|
168
|
-
return
|
|
171
|
+
return jsx(WidthConsumer, null, ({
|
|
169
172
|
width
|
|
170
173
|
}) => {
|
|
171
174
|
// Note: in SSR mode the `window` object is not defined,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import TipIcon from '@atlaskit/icon/glyph/editor/hint';
|
|
5
6
|
import { PanelType } from '@atlaskit/adf-schema';
|
|
6
7
|
import { getPanelBackgroundDarkModeColors, panelSharedStylesWithoutPrefix, PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
@@ -50,7 +51,7 @@ const PanelStyled = ({
|
|
|
50
51
|
`;
|
|
51
52
|
};
|
|
52
53
|
}
|
|
53
|
-
return
|
|
54
|
+
return jsx("div", _extends({
|
|
54
55
|
css: styles
|
|
55
56
|
}, props), props.children);
|
|
56
57
|
};
|
|
@@ -81,7 +82,7 @@ const Panel = props => {
|
|
|
81
82
|
const getIcon = () => {
|
|
82
83
|
if (panelType === PanelType.CUSTOM) {
|
|
83
84
|
if (panelIcon && providers) {
|
|
84
|
-
return
|
|
85
|
+
return jsx(EmojiItem, {
|
|
85
86
|
id: panelIconId,
|
|
86
87
|
text: panelIconText,
|
|
87
88
|
shortName: panelIcon,
|
|
@@ -91,19 +92,19 @@ const Panel = props => {
|
|
|
91
92
|
return null;
|
|
92
93
|
}
|
|
93
94
|
const Icon = panelIcons[panelType];
|
|
94
|
-
return
|
|
95
|
+
return jsx(Icon, {
|
|
95
96
|
label: `Panel ${panelType}`
|
|
96
97
|
});
|
|
97
98
|
};
|
|
98
99
|
const icon = getIcon();
|
|
99
100
|
const renderIcon = () => {
|
|
100
101
|
if (icon) {
|
|
101
|
-
return
|
|
102
|
+
return jsx("div", {
|
|
102
103
|
className: PanelSharedCssClassName.icon
|
|
103
104
|
}, icon);
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
|
-
return
|
|
107
|
+
return jsx(PanelStyled, {
|
|
107
108
|
className: PanelSharedCssClassName.prefix,
|
|
108
109
|
"data-panel-type": panelType,
|
|
109
110
|
"data-panel-color": panelColor,
|
|
@@ -112,7 +113,7 @@ const Panel = props => {
|
|
|
112
113
|
"data-panel-icon-text": panelIconText,
|
|
113
114
|
backgroundColor: panelColor,
|
|
114
115
|
hasIcon: Boolean(icon)
|
|
115
|
-
}, renderIcon(),
|
|
116
|
+
}, renderIcon(), jsx("div", {
|
|
116
117
|
className: PanelSharedCssClassName.content
|
|
117
118
|
}, children));
|
|
118
119
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
5
6
|
import { akEditorStickyHeaderZIndex } from '@atlaskit/editor-shared-styles';
|
|
6
7
|
import { N40A } from '@atlaskit/theme/colors';
|
|
@@ -73,7 +74,7 @@ export const FixedTableDiv = props => {
|
|
|
73
74
|
const attrs = {
|
|
74
75
|
mode
|
|
75
76
|
};
|
|
76
|
-
return
|
|
77
|
+
return jsx("div", _extends({}, attrs, {
|
|
77
78
|
"data-testid": "sticky-table-fixed",
|
|
78
79
|
css: fixedTableCss
|
|
79
80
|
}), props.children);
|
|
@@ -110,26 +111,26 @@ export const StickyTable = ({
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
113
|
-
return
|
|
114
|
+
return jsx("div", {
|
|
114
115
|
css: styles
|
|
115
|
-
},
|
|
116
|
+
}, jsx(FixedTableDiv, {
|
|
116
117
|
top: mode === 'stick' ? top : undefined,
|
|
117
118
|
mode: rowHeight > 300 ? 'none' : mode,
|
|
118
119
|
wrapperWidth: wrapperWidth,
|
|
119
120
|
rendererAppearance: rendererAppearance
|
|
120
|
-
},
|
|
121
|
+
}, jsx("div", {
|
|
121
122
|
className: `${TableSharedCssClassName.TABLE_CONTAINER} is-sticky ${shadowClassNames || ''}`,
|
|
122
123
|
"data-layout": layout,
|
|
123
124
|
style: {
|
|
124
125
|
width: tableWidth
|
|
125
126
|
}
|
|
126
|
-
},
|
|
127
|
+
}, jsx("div", {
|
|
127
128
|
ref: innerRef,
|
|
128
129
|
className: `${TableSharedCssClassName.TABLE_STICKY_WRAPPER}`,
|
|
129
130
|
style: {
|
|
130
131
|
overflow: 'hidden'
|
|
131
132
|
}
|
|
132
|
-
},
|
|
133
|
+
}, jsx(Table, {
|
|
133
134
|
columnWidths: columnWidths,
|
|
134
135
|
layout: layout,
|
|
135
136
|
isNumberColumnEnabled: isNumberColumnEnabled,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { MediaClientProvider } from '@atlaskit/media-client-react';
|
|
3
|
+
import { useProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
|
+
export const EditorMediaClientProvider = ({
|
|
5
|
+
children,
|
|
6
|
+
ssr
|
|
7
|
+
}) => {
|
|
8
|
+
const [mediaClientConfig, setMediaClientConfig] = useState();
|
|
9
|
+
const mediaProvider = useProvider('mediaProvider');
|
|
10
|
+
|
|
11
|
+
// Consumers can override the mediaClient for renderer,
|
|
12
|
+
// by not providing ssr config and mediaProvider,
|
|
13
|
+
// and provide a top level mediaClient context
|
|
14
|
+
// This is useful for testing and creating examples.
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (ssr && ssr.mode === 'server' && ssr.config) {
|
|
17
|
+
setMediaClientConfig(ssr.config);
|
|
18
|
+
} else if (mediaProvider) {
|
|
19
|
+
mediaProvider.then(provider => {
|
|
20
|
+
setMediaClientConfig(provider.viewMediaClientConfig);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}, [mediaProvider, ssr]);
|
|
24
|
+
return mediaClientConfig ? /*#__PURE__*/React.createElement(MediaClientProvider, {
|
|
25
|
+
clientConfig: mediaClientConfig
|
|
26
|
+
}, children) : children;
|
|
27
|
+
};
|
package/dist/es2019/ui/Expand.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
2
3
|
import React, { useRef, useCallback, useMemo } from 'react';
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
+
import { css, jsx } from '@emotion/react';
|
|
4
5
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
5
6
|
import { gridSize, fontSize } from '@atlaskit/theme/constants';
|
|
6
7
|
import ChevronRightIcon from '@atlaskit/icon/glyph/chevron-right';
|
|
@@ -35,7 +36,7 @@ const Container = props => {
|
|
|
35
36
|
padding: 0;
|
|
36
37
|
padding-bottom: ${paddingBottom};
|
|
37
38
|
`;
|
|
38
|
-
return
|
|
39
|
+
return jsx("div", _extends({
|
|
39
40
|
css: styles
|
|
40
41
|
}, props), props.children);
|
|
41
42
|
};
|
|
@@ -48,7 +49,7 @@ const TitleContainer = props => {
|
|
|
48
49
|
padding: ${"var(--ds-space-100, 8px)"};
|
|
49
50
|
padding-bottom: ${paddingBottom};
|
|
50
51
|
`;
|
|
51
|
-
return
|
|
52
|
+
return jsx("button", _extends({
|
|
52
53
|
css: styles
|
|
53
54
|
}, props), props.children);
|
|
54
55
|
};
|
|
@@ -66,7 +67,7 @@ const ContentContainer = props => {
|
|
|
66
67
|
padding-left: ${gridSize() * 5 - gridSize() / 2}px;
|
|
67
68
|
visibility: ${visibility};
|
|
68
69
|
`;
|
|
69
|
-
return
|
|
70
|
+
return jsx("div", _extends({
|
|
70
71
|
css: styles
|
|
71
72
|
}, props), props.children);
|
|
72
73
|
};
|
|
@@ -103,16 +104,16 @@ function Expand({
|
|
|
103
104
|
} = useRef(_uniqueId('expand-title-'));
|
|
104
105
|
const handleFocus = useCallback(() => setFocused(true), []);
|
|
105
106
|
const handleBlur = useCallback(() => setFocused(false), []);
|
|
106
|
-
return
|
|
107
|
+
return jsx(Container, {
|
|
107
108
|
"data-node-type": nodeType,
|
|
108
109
|
"data-title": title,
|
|
109
110
|
"data-expanded": expanded,
|
|
110
111
|
expanded: expanded,
|
|
111
112
|
focused: focused
|
|
112
|
-
}, nestedHeaderIds && nestedHeaderIds.length > 0 ?
|
|
113
|
+
}, nestedHeaderIds && nestedHeaderIds.length > 0 ? jsx(ActiveHeaderIdConsumer, {
|
|
113
114
|
nestedHeaderIds: nestedHeaderIds,
|
|
114
115
|
onNestedHeaderIdMatch: () => setExpanded(true)
|
|
115
|
-
}) : null,
|
|
116
|
+
}) : null, jsx(TitleContainer, {
|
|
116
117
|
onClick: e => {
|
|
117
118
|
e.stopPropagation();
|
|
118
119
|
fireExpandToggleAnalytics(nodeType, expanded, fireAnalyticsEvent);
|
|
@@ -127,27 +128,27 @@ function Expand({
|
|
|
127
128
|
"aria-expanded": expanded,
|
|
128
129
|
contentEditable: false,
|
|
129
130
|
expanded: expanded
|
|
130
|
-
}, isMobile ?
|
|
131
|
+
}, isMobile ? jsx(ExpandIconWrapper, {
|
|
131
132
|
expanded: expanded
|
|
132
|
-
},
|
|
133
|
+
}, jsx(ChevronRightIcon, {
|
|
133
134
|
label: label
|
|
134
|
-
})) :
|
|
135
|
+
})) : jsx(Tooltip, {
|
|
135
136
|
content: label,
|
|
136
137
|
position: "top",
|
|
137
138
|
tag: ExpandLayoutWrapperWithRef,
|
|
138
139
|
testId: 'tooltip'
|
|
139
|
-
},
|
|
140
|
+
}, jsx(ExpandIconWrapper, {
|
|
140
141
|
expanded: expanded
|
|
141
|
-
},
|
|
142
|
+
}, jsx(ChevronRightIcon, {
|
|
142
143
|
label: label
|
|
143
|
-
}))),
|
|
144
|
+
}))), jsx("span", {
|
|
144
145
|
css: titleStyles,
|
|
145
146
|
id: id
|
|
146
|
-
}, title || intl.formatMessage(expandMessages.expandDefaultTitle))),
|
|
147
|
+
}, title || intl.formatMessage(expandMessages.expandDefaultTitle))), jsx(ContentContainer, {
|
|
147
148
|
expanded: expanded
|
|
148
|
-
},
|
|
149
|
+
}, jsx("div", {
|
|
149
150
|
className: `${nodeType}-content-wrapper`
|
|
150
|
-
},
|
|
151
|
+
}, jsx(WidthProvider, null, jsx("div", {
|
|
151
152
|
css: clearNextSiblingMarginTopStyle
|
|
152
153
|
}), children))));
|
|
153
154
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
import React, { Component } from 'react';
|
|
3
4
|
import { filter } from '@atlaskit/adf-utils/traverse';
|
|
4
5
|
import { Card, CardLoading, CardError } from '@atlaskit/media-card';
|
|
5
|
-
import {
|
|
6
|
+
import { MediaClientContext } from '@atlaskit/media-client-react';
|
|
6
7
|
import { withImageLoader } from '@atlaskit/editor-common/utils';
|
|
7
8
|
export const mediaIdentifierMap = new Map();
|
|
8
9
|
export const getListOfIdentifiersFromDoc = doc => {
|
|
@@ -32,23 +33,25 @@ export const getListOfIdentifiersFromDoc = doc => {
|
|
|
32
33
|
return identifierList;
|
|
33
34
|
}, []);
|
|
34
35
|
};
|
|
35
|
-
export class
|
|
36
|
+
export class MediaCardView extends Component {
|
|
36
37
|
constructor(...args) {
|
|
37
38
|
super(...args);
|
|
38
39
|
_defineProperty(this, "state", {});
|
|
39
|
-
_defineProperty(this, "saveFileState", async
|
|
40
|
+
_defineProperty(this, "saveFileState", async id => {
|
|
40
41
|
const {
|
|
41
|
-
collection: collectionName
|
|
42
|
+
collection: collectionName,
|
|
43
|
+
mediaClient
|
|
42
44
|
} = this.props;
|
|
43
|
-
const mediaClient = getMediaClient(mediaClientConfig);
|
|
44
45
|
const options = {
|
|
45
46
|
collectionName
|
|
46
47
|
};
|
|
47
48
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
if (mediaClient) {
|
|
50
|
+
const fileState = await mediaClient.file.getCurrentState(id, options);
|
|
51
|
+
this.setState({
|
|
52
|
+
fileState
|
|
53
|
+
});
|
|
54
|
+
}
|
|
52
55
|
} catch (error) {
|
|
53
56
|
// do not set state on error
|
|
54
57
|
}
|
|
@@ -86,22 +89,16 @@ export class MediaCardInternal extends Component {
|
|
|
86
89
|
async componentDidMount() {
|
|
87
90
|
const {
|
|
88
91
|
rendererContext,
|
|
89
|
-
mediaProvider,
|
|
90
92
|
contextIdentifierProvider,
|
|
91
93
|
id,
|
|
92
94
|
url,
|
|
93
95
|
collection: collectionName
|
|
94
96
|
} = this.props;
|
|
95
|
-
if (!mediaProvider) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
97
|
if (contextIdentifierProvider) {
|
|
99
98
|
this.setState({
|
|
100
99
|
contextIdentifierProvider: await contextIdentifierProvider
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
|
-
const mediaProviderObject = await mediaProvider;
|
|
104
|
-
const mediaClientConfig = mediaProviderObject.viewMediaClientConfig;
|
|
105
102
|
const nodeIsInCache = id && mediaIdentifierMap.has(id) || url && mediaIdentifierMap.has(url);
|
|
106
103
|
if (rendererContext && rendererContext.adDoc && !nodeIsInCache) {
|
|
107
104
|
getListOfIdentifiersFromDoc(rendererContext.adDoc).forEach(identifier => {
|
|
@@ -115,22 +112,16 @@ export class MediaCardInternal extends Component {
|
|
|
115
112
|
}
|
|
116
113
|
});
|
|
117
114
|
}
|
|
118
|
-
this.setState({
|
|
119
|
-
mediaClientConfig: mediaClientConfig
|
|
120
|
-
});
|
|
121
115
|
if (id) {
|
|
122
|
-
this.saveFileState(id
|
|
116
|
+
this.saveFileState(id);
|
|
123
117
|
}
|
|
124
118
|
}
|
|
125
119
|
UNSAFE_componentWillReceiveProps(newProps) {
|
|
126
|
-
const {
|
|
127
|
-
mediaClientConfig
|
|
128
|
-
} = this.state;
|
|
129
120
|
const {
|
|
130
121
|
id: newId
|
|
131
122
|
} = newProps;
|
|
132
|
-
if (
|
|
133
|
-
this.saveFileState(newId
|
|
123
|
+
if (newId && newId !== this.props.id) {
|
|
124
|
+
this.saveFileState(newId);
|
|
134
125
|
}
|
|
135
126
|
}
|
|
136
127
|
componentWillUnmount() {
|
|
@@ -145,9 +136,7 @@ export class MediaCardInternal extends Component {
|
|
|
145
136
|
}
|
|
146
137
|
}
|
|
147
138
|
renderExternal(shouldOpenMediaViewer) {
|
|
148
|
-
|
|
149
|
-
mediaClientConfig
|
|
150
|
-
} = this.state;
|
|
139
|
+
var _this$props$mediaClie;
|
|
151
140
|
const {
|
|
152
141
|
cardDimensions,
|
|
153
142
|
resizeMode,
|
|
@@ -168,6 +157,7 @@ export class MediaCardInternal extends Component {
|
|
|
168
157
|
name: url,
|
|
169
158
|
mediaItemType: 'external-image'
|
|
170
159
|
};
|
|
160
|
+
const mediaClientConfig = (_this$props$mediaClie = this.props.mediaClient) === null || _this$props$mediaClie === void 0 ? void 0 : _this$props$mediaClie.mediaClientConfig;
|
|
171
161
|
return /*#__PURE__*/React.createElement(Card
|
|
172
162
|
// TODO MPT-315: clean up after we move mediaClientConfig into FileIdentifier
|
|
173
163
|
// context is not really used when the type is external and we want to render the component asap
|
|
@@ -187,9 +177,9 @@ export class MediaCardInternal extends Component {
|
|
|
187
177
|
});
|
|
188
178
|
}
|
|
189
179
|
render() {
|
|
180
|
+
var _this$props$mediaClie2;
|
|
190
181
|
const {
|
|
191
182
|
contextIdentifierProvider,
|
|
192
|
-
mediaClientConfig: mediaClientConfigInState,
|
|
193
183
|
fileState
|
|
194
184
|
} = this.state;
|
|
195
185
|
const {
|
|
@@ -220,7 +210,7 @@ export class MediaCardInternal extends Component {
|
|
|
220
210
|
if (type === 'link') {
|
|
221
211
|
return null;
|
|
222
212
|
}
|
|
223
|
-
const mediaClientConfig = !!ssr ? ssr.config :
|
|
213
|
+
const mediaClientConfig = !!ssr ? ssr.config : (_this$props$mediaClie2 = this.props.mediaClient) === null || _this$props$mediaClie2 === void 0 ? void 0 : _this$props$mediaClie2.mediaClientConfig;
|
|
224
214
|
if (!mediaClientConfig || !id) {
|
|
225
215
|
return this.renderLoadingCard();
|
|
226
216
|
}
|
|
@@ -298,4 +288,10 @@ export const getClipboardAttrs = ({
|
|
|
298
288
|
'data-alt': alt
|
|
299
289
|
};
|
|
300
290
|
};
|
|
291
|
+
export const MediaCardInternal = props => {
|
|
292
|
+
const mediaClient = React.useContext(MediaClientContext);
|
|
293
|
+
return /*#__PURE__*/React.createElement(MediaCardView, _extends({}, props, {
|
|
294
|
+
mediaClient: mediaClient
|
|
295
|
+
}));
|
|
296
|
+
};
|
|
301
297
|
export const MediaCard = withImageLoader(MediaCardInternal);
|