@imposium-hub/components 1.63.0 → 2.1.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/dist/cjs/components/assets/AssetsTablePreviewCell.js +3 -3
- package/dist/cjs/components/assets/AssetsTablePreviewCell.js.map +1 -1
- package/dist/cjs/components/error-message-preview/ErrorMessagePreview.d.ts +15 -0
- package/dist/cjs/components/error-message-preview/ErrorMessagePreview.js +91 -0
- package/dist/cjs/components/error-message-preview/ErrorMessagePreview.js.map +1 -0
- package/dist/cjs/components/players/AudioPreview.d.ts +12 -3
- package/dist/cjs/components/players/AudioPreview.js +32 -9
- package/dist/cjs/components/players/AudioPreview.js.map +1 -1
- package/dist/cjs/components/players/ImagePreview.d.ts +7 -1
- package/dist/cjs/components/players/ImagePreview.js +28 -10
- package/dist/cjs/components/players/ImagePreview.js.map +1 -1
- package/dist/cjs/components/players/VideoPreview.d.ts +11 -2
- package/dist/cjs/components/players/VideoPreview.js +32 -9
- package/dist/cjs/components/players/VideoPreview.js.map +1 -1
- package/dist/cjs/components/publish-wizard/PublishWizard.js.map +1 -1
- package/dist/cjs/services/API.d.ts +2 -0
- package/dist/cjs/services/API.js +7 -0
- package/dist/cjs/services/API.js.map +1 -1
- package/dist/cjs/utils/assets.d.ts +1 -1
- package/dist/cjs/utils/assets.js +7 -4
- package/dist/cjs/utils/assets.js.map +1 -1
- package/dist/esm/components/assets/AssetsTablePreviewCell.js +4 -4
- package/dist/esm/components/assets/AssetsTablePreviewCell.js.map +1 -1
- package/dist/esm/components/error-message-preview/ErrorMessagePreview.d.ts +15 -0
- package/dist/esm/components/error-message-preview/ErrorMessagePreview.js +35 -0
- package/dist/esm/components/error-message-preview/ErrorMessagePreview.js.map +1 -0
- package/dist/esm/components/players/AudioPreview.d.ts +12 -3
- package/dist/esm/components/players/AudioPreview.js +31 -9
- package/dist/esm/components/players/AudioPreview.js.map +1 -1
- package/dist/esm/components/players/ImagePreview.d.ts +7 -1
- package/dist/esm/components/players/ImagePreview.js +28 -10
- package/dist/esm/components/players/ImagePreview.js.map +1 -1
- package/dist/esm/components/players/VideoPreview.d.ts +11 -2
- package/dist/esm/components/players/VideoPreview.js +31 -9
- package/dist/esm/components/players/VideoPreview.js.map +1 -1
- package/dist/esm/components/publish-wizard/PublishWizard.js.map +1 -1
- package/dist/esm/services/API.d.ts +2 -0
- package/dist/esm/services/API.js +7 -0
- package/dist/esm/services/API.js.map +1 -1
- package/dist/esm/utils/assets.d.ts +1 -1
- package/dist/esm/utils/assets.js +7 -4
- package/dist/esm/utils/assets.js.map +1 -1
- package/dist/styles.css +8 -0
- package/dist/styles.less +9 -0
- package/less/components/assets.less +10 -0
- package/package.json +1 -1
- package/src/components/assets/AssetsTablePreviewCell.tsx +3 -6
- package/src/components/players/AudioPreview.tsx +58 -13
- package/src/components/players/ImagePreview.tsx +47 -15
- package/src/components/players/VideoPreview.tsx +58 -12
- package/src/components/publish-wizard/PublishWizard.tsx +2 -4
- package/src/components/publish-wizard/publish/EmailWorkflow.tsx +2 -2
- package/src/services/API.ts +9 -0
- package/src/utils/assets.ts +8 -4
|
@@ -5,37 +5,76 @@ import { assets as copy } from '../../constants/copy';
|
|
|
5
5
|
import { ICON_TIMES } from '../../constants/icons';
|
|
6
6
|
|
|
7
7
|
interface IVideoPreviewProps {
|
|
8
|
-
showMedia: boolean;
|
|
9
8
|
url: string;
|
|
10
9
|
playbackSettings?: any;
|
|
11
10
|
style?: React.CSSProperties | any;
|
|
12
11
|
onRequestClose?(): void;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
interface IVideoPreviewState {
|
|
15
|
+
error: boolean;
|
|
16
|
+
loaded: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class VideoPreview extends React.PureComponent<IVideoPreviewProps, IVideoPreviewState> {
|
|
16
20
|
private videoNode: any = null;
|
|
17
21
|
|
|
22
|
+
private videoRef: any = null;
|
|
23
|
+
|
|
18
24
|
private evtHandlers: any;
|
|
19
25
|
|
|
26
|
+
private clickHandler: any = (e) => this.detectOutsideClick(e);
|
|
27
|
+
|
|
28
|
+
private clickOutsideTimeout: any;
|
|
29
|
+
|
|
20
30
|
constructor(props) {
|
|
21
31
|
super(props);
|
|
22
32
|
this.videoNode = React.createRef();
|
|
33
|
+
this.videoRef = React.createRef();
|
|
23
34
|
this.evtHandlers = {
|
|
24
35
|
onClose: (e) => this.onClose(e)
|
|
25
36
|
};
|
|
37
|
+
|
|
38
|
+
this.state = {
|
|
39
|
+
error: false,
|
|
40
|
+
loaded: false
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public componentDidMount() {
|
|
45
|
+
clearTimeout(this.clickOutsideTimeout);
|
|
46
|
+
this.clickOutsideTimeout = setTimeout(() => {
|
|
47
|
+
window.addEventListener('click', this.clickHandler);
|
|
48
|
+
}, 25);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public componentWillUnmount(): void {
|
|
52
|
+
clearTimeout(this.clickOutsideTimeout);
|
|
53
|
+
window.removeEventListener('click', this.clickHandler);
|
|
26
54
|
}
|
|
27
55
|
|
|
56
|
+
private detectOutsideClick = (e: any): void => {
|
|
57
|
+
const { target } = e;
|
|
58
|
+
|
|
59
|
+
const clickInside =
|
|
60
|
+
this.videoRef.current && this.videoRef.current.contains(target) ? true : false;
|
|
61
|
+
|
|
62
|
+
if (!clickInside) {
|
|
63
|
+
this.onClose(e);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
28
67
|
private onClose(e) {
|
|
29
68
|
const { onRequestClose } = this.props;
|
|
30
|
-
e.stopPropagation();
|
|
31
69
|
onRequestClose();
|
|
32
70
|
}
|
|
33
71
|
|
|
34
72
|
public render() {
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
73
|
+
const { url, playbackSettings, style } = this.props;
|
|
74
|
+
const { error } = this.state;
|
|
75
|
+
return (
|
|
76
|
+
<Portal id='portal-root'>
|
|
77
|
+
<div ref={this.videoRef}>
|
|
39
78
|
<div
|
|
40
79
|
style={{ ...style }}
|
|
41
80
|
className={'close-icon-preview'}>
|
|
@@ -49,6 +88,8 @@ class VideoPreview extends React.PureComponent<IVideoPreviewProps> {
|
|
|
49
88
|
</Button>
|
|
50
89
|
</div>
|
|
51
90
|
<video
|
|
91
|
+
onError={() => this.setState({ error: true, loaded: true })}
|
|
92
|
+
onCanPlayThrough={() => this.setState({ loaded: true })}
|
|
52
93
|
style={style}
|
|
53
94
|
muted
|
|
54
95
|
ref={this.videoNode}
|
|
@@ -60,11 +101,16 @@ class VideoPreview extends React.PureComponent<IVideoPreviewProps> {
|
|
|
60
101
|
src={url}
|
|
61
102
|
className='asset-preview-background media-preview'
|
|
62
103
|
/>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
104
|
+
{error ? (
|
|
105
|
+
<div
|
|
106
|
+
className='error-preview'
|
|
107
|
+
style={style}>
|
|
108
|
+
Video not found
|
|
109
|
+
</div>
|
|
110
|
+
) : null}
|
|
111
|
+
</div>
|
|
112
|
+
</Portal>
|
|
113
|
+
);
|
|
68
114
|
}
|
|
69
115
|
}
|
|
70
116
|
|
|
@@ -49,8 +49,7 @@ interface IPublishWizardProps {
|
|
|
49
49
|
accessKey: string,
|
|
50
50
|
compId: string,
|
|
51
51
|
addEmbed: boolean,
|
|
52
|
-
addMedia: boolean
|
|
53
|
-
overrides?: any
|
|
52
|
+
addMedia: boolean
|
|
54
53
|
) => any;
|
|
55
54
|
publishDataset: boolean;
|
|
56
55
|
activeDatasetId?: string;
|
|
@@ -60,8 +59,7 @@ interface IPublishWizardProps {
|
|
|
60
59
|
accessKey: string,
|
|
61
60
|
compId: string,
|
|
62
61
|
addEmbed: boolean,
|
|
63
|
-
addMedia: boolean
|
|
64
|
-
overrides?: any
|
|
62
|
+
addMedia: boolean
|
|
65
63
|
) => any;
|
|
66
64
|
handleNotification?: (n) => void;
|
|
67
65
|
batchJobs: any;
|
|
@@ -29,7 +29,7 @@ interface IEmailWorkflowProps {
|
|
|
29
29
|
compId: string,
|
|
30
30
|
embed: boolean,
|
|
31
31
|
addMedia: boolean,
|
|
32
|
-
|
|
32
|
+
addEmbed?: any
|
|
33
33
|
) => any;
|
|
34
34
|
publishDataset: boolean;
|
|
35
35
|
activeDatasetId?: string;
|
|
@@ -40,7 +40,7 @@ interface IEmailWorkflowProps {
|
|
|
40
40
|
compId: string,
|
|
41
41
|
embed: boolean,
|
|
42
42
|
addMedia: boolean,
|
|
43
|
-
|
|
43
|
+
addEmbed?: any
|
|
44
44
|
) => any;
|
|
45
45
|
renderBatch: (batchId: string, postRenderActions?: any) => any;
|
|
46
46
|
status: string;
|
package/src/services/API.ts
CHANGED
|
@@ -131,6 +131,7 @@ export interface IImposiumAPI {
|
|
|
131
131
|
);
|
|
132
132
|
getDataset(storyId: string, datasetId: string);
|
|
133
133
|
deleteDataset(storyId: string, datasetId: string);
|
|
134
|
+
textToSpeech(text: string, voice: string);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
137
|
interface ICancelTokenCache {
|
|
@@ -1524,4 +1525,12 @@ export default class API {
|
|
|
1524
1525
|
method: 'DELETE'
|
|
1525
1526
|
});
|
|
1526
1527
|
};
|
|
1528
|
+
|
|
1529
|
+
public textToSpeech = (text, voice): Promise<any> => {
|
|
1530
|
+
return this.doRequest({
|
|
1531
|
+
url: `/text-to-speech?text=${encodeURIComponent(text)}&voice=${voice}`,
|
|
1532
|
+
method: 'GET',
|
|
1533
|
+
responseType: 'blob'
|
|
1534
|
+
});
|
|
1535
|
+
};
|
|
1527
1536
|
}
|
package/src/utils/assets.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { CSSProperties } from 'react';
|
|
|
4
4
|
export const getMediaPreviewStyle = (
|
|
5
5
|
mediaWidth: number,
|
|
6
6
|
mediaHeight: number,
|
|
7
|
-
|
|
7
|
+
element: any
|
|
8
8
|
): CSSProperties => {
|
|
9
|
-
if (!
|
|
9
|
+
if (!element) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
if (!mediaWidth) {
|
|
@@ -15,8 +15,12 @@ export const getMediaPreviewStyle = (
|
|
|
15
15
|
if (!mediaHeight) {
|
|
16
16
|
mediaHeight = PREVIEW_MAX_HEIGHT;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
const
|
|
18
|
+
|
|
19
|
+
const elementDiv = element.current !== undefined ? element.current : element;
|
|
20
|
+
if (!elementDiv) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const iconRect = elementDiv.getBoundingClientRect();
|
|
20
24
|
const aspect: number = mediaWidth / mediaHeight;
|
|
21
25
|
let width: number = PREVIEW_MAX_WIDTH;
|
|
22
26
|
let height: number = width / aspect;
|