@elice/material-video 1.240306.0-runboxtutoring.0 → 1.240306.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/cjs/components/material-video/MaterialVideo.d.ts +3 -3
- package/cjs/components/material-video/MaterialVideo.js +33 -40
- package/cjs/components/material-video/MaterialVideo.styled.js +1 -5
- package/cjs/components/material-video/MaterialVideoContent.js +30 -32
- package/cjs/components/material-video/locales.d.ts +5 -0
- package/cjs/components/material-video/locales.js +13 -0
- package/cjs/components/youtube-player/YoutubePlayer.js +20 -28
- package/cjs/components/youtube-player/YoutubePlayer.styled.js +1 -5
- package/cjs/utils/youtubeUrlParser.js +4 -11
- package/es/components/material-video/MaterialVideo.d.ts +3 -3
- package/es/components/material-video/MaterialVideo.js +34 -35
- package/es/components/material-video/MaterialVideo.styled.js +1 -1
- package/es/components/material-video/MaterialVideoContent.js +30 -32
- package/es/components/material-video/locales.d.ts +5 -0
- package/es/components/material-video/locales.js +10 -0
- package/es/components/youtube-player/YoutubePlayer.js +19 -22
- package/es/components/youtube-player/YoutubePlayer.styled.js +1 -1
- package/es/utils/youtubeUrlParser.js +4 -11
- package/package.json +14 -11
- package/cjs/components/material-video/index.js +0 -7
- package/cjs/components/material-video/locales/en.json.js +0 -7
- package/cjs/components/material-video/locales/index.d.ts +0 -4
- package/cjs/components/material-video/locales/index.js +0 -13
- package/cjs/components/material-video/locales/ja.json.js +0 -7
- package/cjs/components/material-video/locales/ko.json.js +0 -7
- package/cjs/components/material-video/locales/th.json.js +0 -7
- package/cjs/components/youtube-player/index.js +0 -7
- package/es/components/material-video/index.js +0 -1
- package/es/components/material-video/locales/en.json.js +0 -3
- package/es/components/material-video/locales/index.d.ts +0 -4
- package/es/components/material-video/locales/index.js +0 -4
- package/es/components/material-video/locales/ja.json.js +0 -3
- package/es/components/material-video/locales/ko.json.js +0 -3
- package/es/components/material-video/locales/th.json.js +0 -3
- package/es/components/youtube-player/index.js +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { WithIntlComponentBuilderProps } from '@elice/intl';
|
|
3
2
|
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
4
3
|
export interface MaterialVideoProps extends YoutubePlayerSharedProps {
|
|
5
4
|
className?: string;
|
|
6
5
|
materialVideoId: number;
|
|
6
|
+
locale?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const MaterialVideo: React.FC<MaterialVideoProps>;
|
|
9
|
+
export default MaterialVideo;
|
|
@@ -3,53 +3,46 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
6
|
var React = require('react');
|
|
7
|
+
var reactIntl = require('react-intl');
|
|
8
8
|
var apiClient = require('@elice/api-client');
|
|
9
9
|
var blocks = require('@elice/blocks');
|
|
10
|
-
var intl = require('@elice/intl');
|
|
11
10
|
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
12
11
|
var types = require('@elice/types');
|
|
13
12
|
var classnames = require('classnames');
|
|
14
|
-
var
|
|
15
|
-
var ko = require('./locales/ko.json.js');
|
|
13
|
+
var locales = require('./locales.js');
|
|
16
14
|
var MaterialVideoContent = require('./MaterialVideoContent.js');
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
videoGetStatus: materialVideoStatus
|
|
49
|
-
}, youtubeProps))
|
|
50
|
-
})
|
|
51
|
-
});
|
|
16
|
+
const MaterialVideo = _a => {
|
|
17
|
+
var {
|
|
18
|
+
className,
|
|
19
|
+
materialVideoId,
|
|
20
|
+
locale = 'en'
|
|
21
|
+
} = _a,
|
|
22
|
+
youtubeProps = tslib.__rest(_a, ["className", "materialVideoId", "locale"]);
|
|
23
|
+
const prefixCls = 'em-material-video';
|
|
24
|
+
const {
|
|
25
|
+
materialVideo,
|
|
26
|
+
status: materialVideoStatus
|
|
27
|
+
} = materialSharedUtils.useMaterialFetch(types.enums.LectureMaterialType.Video, React.useCallback(signal => apiClient.getOrgMaterialVideoGet({
|
|
28
|
+
materialVideoId
|
|
29
|
+
}, {
|
|
30
|
+
signal
|
|
31
|
+
}), [materialVideoId]), apiClient.config.init);
|
|
32
|
+
return React.createElement(blocks.Flex, {
|
|
33
|
+
className: classnames(prefixCls, className),
|
|
34
|
+
align: "center",
|
|
35
|
+
justify: "center",
|
|
36
|
+
width: "100%",
|
|
37
|
+
height: "100%"
|
|
38
|
+
}, React.createElement(reactIntl.IntlProvider, {
|
|
39
|
+
locale: locale,
|
|
40
|
+
defaultLocale: "en",
|
|
41
|
+
messages: locale in locales ? locales[locale] : locales.en
|
|
42
|
+
}, React.createElement(MaterialVideoContent.default, Object.assign({
|
|
43
|
+
materialVideo: materialVideo !== null && materialVideo !== void 0 ? materialVideo : null,
|
|
44
|
+
videoGetStatus: materialVideoStatus
|
|
45
|
+
}, youtubeProps))));
|
|
52
46
|
};
|
|
53
|
-
var MaterialVideo$1 = new intl.IntlComponentBuilder(MaterialVideo).add('en', en.default).add('ko', ko.default).addAsync('th', Promise.resolve().then(function () { return require('./locales/th.json.js'); })).addAsync('ja', Promise.resolve().then(function () { return require('./locales/ja.json.js'); })).build();
|
|
54
47
|
|
|
55
|
-
exports.default = MaterialVideo
|
|
48
|
+
exports.default = MaterialVideo;
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
var blocks = require('@elice/blocks');
|
|
4
4
|
var styled = require('styled-components');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
9
|
-
|
|
10
|
-
var StyledMaterialVideoStatus = styled__default.default(blocks.Flex).withConfig({
|
|
6
|
+
const StyledMaterialVideoStatus = styled(blocks.Flex).withConfig({
|
|
11
7
|
componentId: "sc-dg3csq-0"
|
|
12
8
|
})(["width:100%;height:100%;background-color:#22222c;"]);
|
|
13
9
|
|
|
@@ -3,52 +3,50 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var reactIntl = require('react-intl');
|
|
7
8
|
var blocks = require('@elice/blocks');
|
|
8
9
|
var designTokens = require('@elice/design-tokens');
|
|
9
10
|
var icons = require('@elice/icons');
|
|
10
|
-
var intl = require('@elice/intl');
|
|
11
11
|
var youtubeUrlParser = require('../../utils/youtubeUrlParser.js');
|
|
12
12
|
var YoutubePlayer = require('../youtube-player/YoutubePlayer.js');
|
|
13
13
|
var MaterialVideo_styled = require('./MaterialVideo.styled.js');
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
|
|
15
|
+
const MaterialVideoContent = _a => {
|
|
16
|
+
var {
|
|
17
|
+
videoGetStatus,
|
|
18
|
+
materialVideo
|
|
19
|
+
} = _a,
|
|
18
20
|
youtubeProps = tslib.__rest(_a, ["videoGetStatus", "materialVideo"]);
|
|
19
|
-
|
|
21
|
+
const intl = reactIntl.useIntl();
|
|
20
22
|
if (videoGetStatus === 'pending') {
|
|
21
|
-
return
|
|
23
|
+
return React.createElement(MaterialVideo_styled.StyledMaterialVideoStatus, {
|
|
22
24
|
align: "center",
|
|
23
|
-
justify: "center"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})]
|
|
32
|
-
});
|
|
25
|
+
justify: "center"
|
|
26
|
+
}, React.createElement(blocks.Spinner, null), React.createElement(blocks.Hspace, {
|
|
27
|
+
width: 0.5
|
|
28
|
+
}), React.createElement(blocks.Text, {
|
|
29
|
+
role: "white"
|
|
30
|
+
}, intl.formatMessage({
|
|
31
|
+
id: 'video.status.loading'
|
|
32
|
+
})));
|
|
33
33
|
}
|
|
34
34
|
if (!(materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.url) || videoGetStatus === 'rejected') {
|
|
35
|
-
return
|
|
35
|
+
return React.createElement(MaterialVideo_styled.StyledMaterialVideoStatus, {
|
|
36
36
|
align: "center",
|
|
37
|
-
justify: "center"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
37
|
+
justify: "center"
|
|
38
|
+
}, React.createElement(blocks.Icon, {
|
|
39
|
+
icon: icons.eilStatusWarn,
|
|
40
|
+
color: designTokens.base.color.white
|
|
41
|
+
}), React.createElement(blocks.Hspace, {
|
|
42
|
+
width: 0.5
|
|
43
|
+
}), React.createElement(blocks.Text, {
|
|
44
|
+
role: "white"
|
|
45
|
+
}, intl.formatMessage({
|
|
46
|
+
id: 'video.status.error'
|
|
47
|
+
})));
|
|
50
48
|
}
|
|
51
|
-
return
|
|
49
|
+
return React.createElement(YoutubePlayer.default, Object.assign({
|
|
52
50
|
videoId: youtubeUrlParser.youtubeUrlParser(materialVideo.url)
|
|
53
51
|
}, youtubeProps));
|
|
54
52
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const en = {
|
|
4
|
+
'video.status.loading': 'Loading video...',
|
|
5
|
+
'video.status.error': 'Error occurred while loading video'
|
|
6
|
+
};
|
|
7
|
+
const ko = {
|
|
8
|
+
'video.status.loading': '수업 자료 로딩 중...',
|
|
9
|
+
'video.status.error': '수업 자료를 가져오는 중 문제가 발생하였습니다.'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.en = en;
|
|
13
|
+
exports.ko = ko;
|
|
@@ -3,34 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var Youtube = require('react-youtube');
|
|
8
8
|
var classnames = require('classnames');
|
|
9
9
|
var YoutubePlayer_styled = require('./YoutubePlayer.styled.js');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
autoPlay = _a$autoPlay === void 0 ? false : _a$autoPlay,
|
|
21
|
-
_a$disableControl = _a.disableControl,
|
|
22
|
-
disableControl = _a$disableControl === void 0 ? false : _a$disableControl,
|
|
23
|
-
_a$disableKeyboardEve = _a.disableKeyboardEvent,
|
|
24
|
-
disableKeyboardEvent = _a$disableKeyboardEve === void 0 ? false : _a$disableKeyboardEve,
|
|
25
|
-
_a$disableFullscreen = _a.disableFullscreen,
|
|
26
|
-
disableFullscreen = _a$disableFullscreen === void 0 ? false : _a$disableFullscreen,
|
|
11
|
+
const YoutubePlayer = _a => {
|
|
12
|
+
var {
|
|
13
|
+
className,
|
|
14
|
+
videoId,
|
|
15
|
+
autoPlay = false,
|
|
16
|
+
disableControl = false,
|
|
17
|
+
disableKeyboardEvent = false,
|
|
18
|
+
disableFullscreen = false
|
|
19
|
+
} = _a,
|
|
27
20
|
youtubeProps = tslib.__rest(_a, ["className", "videoId", "autoPlay", "disableControl", "disableKeyboardEvent", "disableFullscreen"]);
|
|
28
|
-
|
|
21
|
+
const prefixCls = 'em-youtube-player';
|
|
29
22
|
/**
|
|
30
23
|
* Get options for YouTube IFrame player API.
|
|
31
24
|
* ref: https://developers.google.com/youtube/player_parameters#Parameters
|
|
32
25
|
*/
|
|
33
|
-
|
|
26
|
+
const getYoutubeOptions = () => {
|
|
34
27
|
return {
|
|
35
28
|
width: '100%',
|
|
36
29
|
height: '100%',
|
|
@@ -42,16 +35,15 @@ var YoutubePlayer = function YoutubePlayer(_a) {
|
|
|
42
35
|
}
|
|
43
36
|
};
|
|
44
37
|
};
|
|
45
|
-
return
|
|
46
|
-
className:
|
|
38
|
+
return React.createElement(YoutubePlayer_styled.StyledYoutubePlayerWrapper, {
|
|
39
|
+
className: classnames(prefixCls, className),
|
|
47
40
|
justify: "center",
|
|
48
|
-
align: "center"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
41
|
+
align: "center"
|
|
42
|
+
}, React.createElement(Youtube, Object.assign({
|
|
43
|
+
videoId: videoId,
|
|
44
|
+
opts: getYoutubeOptions(),
|
|
45
|
+
containerClassName: `${prefixCls}__inner`
|
|
46
|
+
}, youtubeProps)));
|
|
55
47
|
};
|
|
56
48
|
|
|
57
49
|
exports.default = YoutubePlayer;
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
var blocks = require('@elice/blocks');
|
|
4
4
|
var styled = require('styled-components');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
9
|
-
|
|
10
|
-
var StyledYoutubePlayerWrapper = styled__default.default(blocks.Flex).withConfig({
|
|
6
|
+
const StyledYoutubePlayerWrapper = styled(blocks.Flex).withConfig({
|
|
11
7
|
componentId: "sc-ao5iuk-0"
|
|
12
8
|
})(["width:100%;height:100%;background-color:#22222c;& .em-youtube-player__inner{width:90%;height:90%;}"]);
|
|
13
9
|
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var YOUTUBE_DOMAIN = 'https://www.youtube.com';
|
|
4
|
-
var YOUTUBE_SHORT_DOMAIN = 'https://youtu.be';
|
|
5
|
-
var YOUTUBE_VIDEO_ID_LENGTH = 11;
|
|
6
3
|
/**
|
|
7
4
|
* Get YouTube video id from url using regex
|
|
8
5
|
* @param url URL of youtube
|
|
9
6
|
* @returns id of youtube video OR null when URL is invalid
|
|
10
7
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.videoId.length) === YOUTUBE_VIDEO_ID_LENGTH) {
|
|
16
|
-
return (_b = match.groups) === null || _b === void 0 ? void 0 : _b.videoId;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
8
|
+
const youtubeUrlParser = url => {
|
|
9
|
+
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
10
|
+
const match = regExp.exec(url);
|
|
11
|
+
return match && match[7].length === 11 ? match[7] : null;
|
|
19
12
|
};
|
|
20
13
|
|
|
21
14
|
exports.youtubeUrlParser = youtubeUrlParser;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { WithIntlComponentBuilderProps } from '@elice/intl';
|
|
3
2
|
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
4
3
|
export interface MaterialVideoProps extends YoutubePlayerSharedProps {
|
|
5
4
|
className?: string;
|
|
6
5
|
materialVideoId: number;
|
|
6
|
+
locale?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const MaterialVideo: React.FC<MaterialVideoProps>;
|
|
9
|
+
export default MaterialVideo;
|
|
@@ -1,46 +1,45 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
4
|
import { getOrgMaterialVideoGet, config } from '@elice/api-client';
|
|
5
5
|
import { Flex } from '@elice/blocks';
|
|
6
|
-
import { IntlComponentBuilder, RawEliceIntlProvider } from '@elice/intl';
|
|
7
6
|
import { useMaterialFetch } from '@elice/material-shared-utils';
|
|
8
7
|
import { enums } from '@elice/types';
|
|
9
8
|
import classnames from 'classnames';
|
|
10
|
-
import
|
|
11
|
-
import
|
|
9
|
+
import * as locales from './locales.js';
|
|
10
|
+
import { en } from './locales.js';
|
|
12
11
|
import MaterialVideoContent from './MaterialVideoContent.js';
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
const MaterialVideo = _a => {
|
|
14
|
+
var {
|
|
15
|
+
className,
|
|
16
|
+
materialVideoId,
|
|
17
|
+
locale = 'en'
|
|
18
|
+
} = _a,
|
|
19
|
+
youtubeProps = __rest(_a, ["className", "materialVideoId", "locale"]);
|
|
20
|
+
const prefixCls = 'em-material-video';
|
|
21
|
+
const {
|
|
22
|
+
materialVideo,
|
|
23
|
+
status: materialVideoStatus
|
|
24
|
+
} = useMaterialFetch(enums.LectureMaterialType.Video, React.useCallback(signal => getOrgMaterialVideoGet({
|
|
25
|
+
materialVideoId
|
|
26
|
+
}, {
|
|
27
|
+
signal
|
|
28
|
+
}), [materialVideoId]), config.init);
|
|
29
|
+
return React.createElement(Flex, {
|
|
30
|
+
className: classnames(prefixCls, className),
|
|
31
|
+
align: "center",
|
|
32
|
+
justify: "center",
|
|
33
|
+
width: "100%",
|
|
34
|
+
height: "100%"
|
|
35
|
+
}, React.createElement(IntlProvider, {
|
|
36
|
+
locale: locale,
|
|
37
|
+
defaultLocale: "en",
|
|
38
|
+
messages: locale in locales ? locales[locale] : en
|
|
39
|
+
}, React.createElement(MaterialVideoContent, Object.assign({
|
|
40
|
+
materialVideo: materialVideo !== null && materialVideo !== void 0 ? materialVideo : null,
|
|
41
|
+
videoGetStatus: materialVideoStatus
|
|
42
|
+
}, youtubeProps))));
|
|
43
43
|
};
|
|
44
|
-
var MaterialVideo$1 = new IntlComponentBuilder(MaterialVideo).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
|
|
45
44
|
|
|
46
|
-
export { MaterialVideo
|
|
45
|
+
export { MaterialVideo as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flex } from '@elice/blocks';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const StyledMaterialVideoStatus = styled(Flex).withConfig({
|
|
5
5
|
componentId: "sc-dg3csq-0"
|
|
6
6
|
})(["width:100%;height:100%;background-color:#22222c;"]);
|
|
7
7
|
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
3
4
|
import { Spinner, Hspace, Text, Icon } from '@elice/blocks';
|
|
4
5
|
import { base } from '@elice/design-tokens';
|
|
5
6
|
import { eilStatusWarn } from '@elice/icons';
|
|
6
|
-
import { useRawEliceIntl } from '@elice/intl';
|
|
7
7
|
import { youtubeUrlParser } from '../../utils/youtubeUrlParser.js';
|
|
8
8
|
import YoutubePlayer from '../youtube-player/YoutubePlayer.js';
|
|
9
9
|
import { StyledMaterialVideoStatus } from './MaterialVideo.styled.js';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
11
|
+
const MaterialVideoContent = _a => {
|
|
12
|
+
var {
|
|
13
|
+
videoGetStatus,
|
|
14
|
+
materialVideo
|
|
15
|
+
} = _a,
|
|
14
16
|
youtubeProps = __rest(_a, ["videoGetStatus", "materialVideo"]);
|
|
15
|
-
|
|
17
|
+
const intl = useIntl();
|
|
16
18
|
if (videoGetStatus === 'pending') {
|
|
17
|
-
return
|
|
19
|
+
return React.createElement(StyledMaterialVideoStatus, {
|
|
18
20
|
align: "center",
|
|
19
|
-
justify: "center"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})]
|
|
28
|
-
});
|
|
21
|
+
justify: "center"
|
|
22
|
+
}, React.createElement(Spinner, null), React.createElement(Hspace, {
|
|
23
|
+
width: 0.5
|
|
24
|
+
}), React.createElement(Text, {
|
|
25
|
+
role: "white"
|
|
26
|
+
}, intl.formatMessage({
|
|
27
|
+
id: 'video.status.loading'
|
|
28
|
+
})));
|
|
29
29
|
}
|
|
30
30
|
if (!(materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.url) || videoGetStatus === 'rejected') {
|
|
31
|
-
return
|
|
31
|
+
return React.createElement(StyledMaterialVideoStatus, {
|
|
32
32
|
align: "center",
|
|
33
|
-
justify: "center"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
})]
|
|
45
|
-
});
|
|
33
|
+
justify: "center"
|
|
34
|
+
}, React.createElement(Icon, {
|
|
35
|
+
icon: eilStatusWarn,
|
|
36
|
+
color: base.color.white
|
|
37
|
+
}), React.createElement(Hspace, {
|
|
38
|
+
width: 0.5
|
|
39
|
+
}), React.createElement(Text, {
|
|
40
|
+
role: "white"
|
|
41
|
+
}, intl.formatMessage({
|
|
42
|
+
id: 'video.status.error'
|
|
43
|
+
})));
|
|
46
44
|
}
|
|
47
|
-
return
|
|
45
|
+
return React.createElement(YoutubePlayer, Object.assign({
|
|
48
46
|
videoId: youtubeUrlParser(materialVideo.url)
|
|
49
47
|
}, youtubeProps));
|
|
50
48
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
'video.status.loading': 'Loading video...',
|
|
3
|
+
'video.status.error': 'Error occurred while loading video'
|
|
4
|
+
};
|
|
5
|
+
const ko = {
|
|
6
|
+
'video.status.loading': '수업 자료 로딩 중...',
|
|
7
|
+
'video.status.error': '수업 자료를 가져오는 중 문제가 발생하였습니다.'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { en, ko };
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import Youtube from 'react-youtube';
|
|
4
4
|
import classnames from 'classnames';
|
|
5
5
|
import { StyledYoutubePlayerWrapper } from './YoutubePlayer.styled.js';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
_a$disableFullscreen = _a.disableFullscreen,
|
|
17
|
-
disableFullscreen = _a$disableFullscreen === void 0 ? false : _a$disableFullscreen,
|
|
7
|
+
const YoutubePlayer = _a => {
|
|
8
|
+
var {
|
|
9
|
+
className,
|
|
10
|
+
videoId,
|
|
11
|
+
autoPlay = false,
|
|
12
|
+
disableControl = false,
|
|
13
|
+
disableKeyboardEvent = false,
|
|
14
|
+
disableFullscreen = false
|
|
15
|
+
} = _a,
|
|
18
16
|
youtubeProps = __rest(_a, ["className", "videoId", "autoPlay", "disableControl", "disableKeyboardEvent", "disableFullscreen"]);
|
|
19
|
-
|
|
17
|
+
const prefixCls = 'em-youtube-player';
|
|
20
18
|
/**
|
|
21
19
|
* Get options for YouTube IFrame player API.
|
|
22
20
|
* ref: https://developers.google.com/youtube/player_parameters#Parameters
|
|
23
21
|
*/
|
|
24
|
-
|
|
22
|
+
const getYoutubeOptions = () => {
|
|
25
23
|
return {
|
|
26
24
|
width: '100%',
|
|
27
25
|
height: '100%',
|
|
@@ -33,16 +31,15 @@ var YoutubePlayer = function YoutubePlayer(_a) {
|
|
|
33
31
|
}
|
|
34
32
|
};
|
|
35
33
|
};
|
|
36
|
-
return
|
|
34
|
+
return React.createElement(StyledYoutubePlayerWrapper, {
|
|
37
35
|
className: classnames(prefixCls, className),
|
|
38
36
|
justify: "center",
|
|
39
|
-
align: "center"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
37
|
+
align: "center"
|
|
38
|
+
}, React.createElement(Youtube, Object.assign({
|
|
39
|
+
videoId: videoId,
|
|
40
|
+
opts: getYoutubeOptions(),
|
|
41
|
+
containerClassName: `${prefixCls}__inner`
|
|
42
|
+
}, youtubeProps)));
|
|
46
43
|
};
|
|
47
44
|
|
|
48
45
|
export { YoutubePlayer as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flex } from '@elice/blocks';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const StyledYoutubePlayerWrapper = styled(Flex).withConfig({
|
|
5
5
|
componentId: "sc-ao5iuk-0"
|
|
6
6
|
})(["width:100%;height:100%;background-color:#22222c;& .em-youtube-player__inner{width:90%;height:90%;}"]);
|
|
7
7
|
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
var YOUTUBE_DOMAIN = 'https://www.youtube.com';
|
|
2
|
-
var YOUTUBE_SHORT_DOMAIN = 'https://youtu.be';
|
|
3
|
-
var YOUTUBE_VIDEO_ID_LENGTH = 11;
|
|
4
1
|
/**
|
|
5
2
|
* Get YouTube video id from url using regex
|
|
6
3
|
* @param url URL of youtube
|
|
7
4
|
* @returns id of youtube video OR null when URL is invalid
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.videoId.length) === YOUTUBE_VIDEO_ID_LENGTH) {
|
|
14
|
-
return (_b = match.groups) === null || _b === void 0 ? void 0 : _b.videoId;
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
6
|
+
const youtubeUrlParser = url => {
|
|
7
|
+
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
8
|
+
const match = regExp.exec(url);
|
|
9
|
+
return match && match[7].length === 11 ? match[7] : null;
|
|
17
10
|
};
|
|
18
11
|
|
|
19
12
|
export { youtubeUrlParser };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-video",
|
|
3
|
-
"version": "1.240306.0
|
|
3
|
+
"version": "1.240306.0",
|
|
4
4
|
"description": "User view and editing components of Elice material video",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"start": "run-s watch",
|
|
19
19
|
"prebuild": "run-s clean",
|
|
20
|
-
"build": "
|
|
21
|
-
"
|
|
20
|
+
"build": "run-p build:es build:cjs",
|
|
21
|
+
"build:es": "rollup -c ../../rollup.config.ts --configPlugin typescript -f es",
|
|
22
|
+
"build:cjs": "rollup -c ../../rollup.config.ts --configPlugin typescript -f cjs",
|
|
23
|
+
"watch": "rollup -c ../../rollup.config.ts --configPlugin typescript -f es -w",
|
|
22
24
|
"lint": "eslint --ext .ts,.tsx ./src --max-warnings=0",
|
|
23
25
|
"clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
|
|
24
26
|
},
|
|
@@ -27,11 +29,11 @@
|
|
|
27
29
|
"@elice/blocks": "^1",
|
|
28
30
|
"@elice/design-tokens": "^1",
|
|
29
31
|
"@elice/icons": "^1",
|
|
30
|
-
"@elice/intl": "^0",
|
|
31
32
|
"@elice/material-shared-types": "*",
|
|
32
33
|
"@elice/material-shared-utils": "*",
|
|
33
34
|
"@elice/types": "^1",
|
|
34
35
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
36
|
+
"react-intl": "^5.0.0",
|
|
35
37
|
"react-use": "^17.0.0",
|
|
36
38
|
"styled-components": "^5.2.0"
|
|
37
39
|
},
|
|
@@ -41,20 +43,21 @@
|
|
|
41
43
|
"tslib": "^2.6.1"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@elice/api-client": "^1.
|
|
45
|
-
"@elice/blocks": "1.
|
|
46
|
+
"@elice/api-client": "^1.230815.0",
|
|
47
|
+
"@elice/blocks": "^1.230816.0",
|
|
46
48
|
"@elice/design-tokens": "^1.220803.0",
|
|
47
49
|
"@elice/icons": "^1.230814.0",
|
|
48
50
|
"@elice/icons-legacy": "npm:@elice/icons@0.230814.0",
|
|
49
|
-
"@elice/
|
|
50
|
-
"@elice/material-shared-
|
|
51
|
-
"@elice/
|
|
52
|
-
"@elice/types": "1.241220.0",
|
|
51
|
+
"@elice/material-shared-types": "1.240306.0",
|
|
52
|
+
"@elice/material-shared-utils": "1.240306.0",
|
|
53
|
+
"@elice/types": "^1.240208.0",
|
|
53
54
|
"@types/classnames": "^2.3.1",
|
|
54
55
|
"@types/react": "~17.0.9",
|
|
55
56
|
"@types/styled-components": "^5.1.21",
|
|
56
57
|
"react": "^17.0.2",
|
|
58
|
+
"react-intl": "^5.20.10",
|
|
57
59
|
"react-use": "^17.2.4",
|
|
58
60
|
"styled-components": "^5.3.0"
|
|
59
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "c60a4ee0a90459f286596540aa4ac53240c21f7c"
|
|
60
63
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var en = require('./en.json.js');
|
|
4
|
-
var ko = require('./ko.json.js');
|
|
5
|
-
var th = require('./th.json.js');
|
|
6
|
-
var ja = require('./ja.json.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.messageEn = en.default;
|
|
11
|
-
exports.messageKo = ko.default;
|
|
12
|
-
exports.messageTh = th.default;
|
|
13
|
-
exports.messageJa = ja.default;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var messageKo = {"video.status.loading":"{_termLibraryLecture} {_termLibraryLecturePage} 로딩 중...","video.status.error":"{_termLibraryLecture} {_termLibraryLecturePage}를 가져오는 중 문제가 발생하였습니다."};
|
|
6
|
-
|
|
7
|
-
exports.default = messageKo;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as MaterialVideo } from './MaterialVideo.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as YoutubePlayer } from './YoutubePlayer.js';
|