@elice/material-pdf 1.240522.0 → 1.240524.0-ppsx.1
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.
|
@@ -12,44 +12,62 @@ var types = require('@elice/types');
|
|
|
12
12
|
//
|
|
13
13
|
//
|
|
14
14
|
//
|
|
15
|
+
const POWERPOINT_EXTENSIONS = ['ppt', 'pptx', 'pps', 'ppsx'];
|
|
15
16
|
const MaterialPdfContent = ({
|
|
16
17
|
materialPdfId,
|
|
17
18
|
cMapUrl
|
|
18
19
|
}) => {
|
|
19
|
-
var _a;
|
|
20
20
|
const intl$1 = intl.useRawEliceIntl();
|
|
21
21
|
const {
|
|
22
22
|
materialPdf,
|
|
23
23
|
status: materialPdfStatus
|
|
24
24
|
} = materialSharedUtils.useMaterialFetch(types.enums.LectureMaterialType.PDF, React.useCallback(signal => apiClient.getOrgMaterialPdfGet({
|
|
25
|
-
materialPdfId
|
|
25
|
+
materialPdfId: materialPdfId
|
|
26
26
|
}, {
|
|
27
27
|
signal
|
|
28
28
|
}), [materialPdfId]), apiClient.config.init);
|
|
29
|
+
const isPowerPointFile = React.useMemo(() => {
|
|
30
|
+
if (!(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url)) return false;
|
|
31
|
+
const file = new URL(materialPdf.attachment.url).pathname;
|
|
32
|
+
return POWERPOINT_EXTENSIONS.some(extension => file.includes(extension));
|
|
33
|
+
}, [materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url]);
|
|
34
|
+
const componentProps = React.useMemo(() => {
|
|
35
|
+
var _a;
|
|
36
|
+
return isPowerPointFile ? {
|
|
37
|
+
type: 'powerpoint',
|
|
38
|
+
src: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
39
|
+
i18n: {
|
|
40
|
+
error: intl$1.formatMessage({
|
|
41
|
+
id: 'pdf.status.error'
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
} : {
|
|
45
|
+
type: 'pdf',
|
|
46
|
+
key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
47
|
+
file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
|
|
48
|
+
title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
|
|
49
|
+
cMapUrl: cMapUrl,
|
|
50
|
+
hasError: !(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) || materialPdfStatus === 'rejected',
|
|
51
|
+
i18n: {
|
|
52
|
+
fullscreen: intl$1.formatMessage({
|
|
53
|
+
id: 'pdf.fullScreen'
|
|
54
|
+
}),
|
|
55
|
+
download: intl$1.formatMessage({
|
|
56
|
+
id: 'pdf.download'
|
|
57
|
+
}),
|
|
58
|
+
loading: intl$1.formatMessage({
|
|
59
|
+
id: 'pdf.status.loading'
|
|
60
|
+
}),
|
|
61
|
+
error: intl$1.formatMessage({
|
|
62
|
+
id: 'pdf.status.error'
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}, [cMapUrl, intl$1, isPowerPointFile, materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url, materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title, materialPdfStatus]);
|
|
29
67
|
if (materialPdfStatus === 'pending') {
|
|
30
68
|
return React.createElement(blocks.Spinner, null);
|
|
31
69
|
}
|
|
32
|
-
return React.createElement(blocks.
|
|
33
|
-
key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
34
|
-
file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
|
|
35
|
-
title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
|
|
36
|
-
cMapUrl: cMapUrl,
|
|
37
|
-
hasError: !(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) || materialPdfStatus === 'rejected',
|
|
38
|
-
i18n: {
|
|
39
|
-
fullscreen: intl$1.formatMessage({
|
|
40
|
-
id: 'pdf.fullScreen'
|
|
41
|
-
}),
|
|
42
|
-
download: intl$1.formatMessage({
|
|
43
|
-
id: 'pdf.download'
|
|
44
|
-
}),
|
|
45
|
-
loading: intl$1.formatMessage({
|
|
46
|
-
id: 'pdf.status.loading'
|
|
47
|
-
}),
|
|
48
|
-
error: intl$1.formatMessage({
|
|
49
|
-
id: 'pdf.status.error'
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
});
|
|
70
|
+
return React.createElement(blocks.DocumentRenderer, Object.assign({}, componentProps));
|
|
53
71
|
};
|
|
54
72
|
|
|
55
73
|
exports.default = MaterialPdfContent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import { getOrgMaterialPdfGet, config } from '@elice/api-client';
|
|
3
|
-
import { Spinner,
|
|
3
|
+
import { Spinner, DocumentRenderer } from '@elice/blocks';
|
|
4
4
|
import { useRawEliceIntl } from '@elice/intl';
|
|
5
5
|
import { useMaterialFetch } from '@elice/material-shared-utils';
|
|
6
6
|
import { enums } from '@elice/types';
|
|
@@ -8,44 +8,62 @@ import { enums } from '@elice/types';
|
|
|
8
8
|
//
|
|
9
9
|
//
|
|
10
10
|
//
|
|
11
|
+
const POWERPOINT_EXTENSIONS = ['ppt', 'pptx', 'pps', 'ppsx'];
|
|
11
12
|
const MaterialPdfContent = ({
|
|
12
13
|
materialPdfId,
|
|
13
14
|
cMapUrl
|
|
14
15
|
}) => {
|
|
15
|
-
var _a;
|
|
16
16
|
const intl = useRawEliceIntl();
|
|
17
17
|
const {
|
|
18
18
|
materialPdf,
|
|
19
19
|
status: materialPdfStatus
|
|
20
20
|
} = useMaterialFetch(enums.LectureMaterialType.PDF, React.useCallback(signal => getOrgMaterialPdfGet({
|
|
21
|
-
materialPdfId
|
|
21
|
+
materialPdfId: materialPdfId
|
|
22
22
|
}, {
|
|
23
23
|
signal
|
|
24
24
|
}), [materialPdfId]), config.init);
|
|
25
|
+
const isPowerPointFile = useMemo(() => {
|
|
26
|
+
if (!(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url)) return false;
|
|
27
|
+
const file = new URL(materialPdf.attachment.url).pathname;
|
|
28
|
+
return POWERPOINT_EXTENSIONS.some(extension => file.includes(extension));
|
|
29
|
+
}, [materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url]);
|
|
30
|
+
const componentProps = useMemo(() => {
|
|
31
|
+
var _a;
|
|
32
|
+
return isPowerPointFile ? {
|
|
33
|
+
type: 'powerpoint',
|
|
34
|
+
src: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
35
|
+
i18n: {
|
|
36
|
+
error: intl.formatMessage({
|
|
37
|
+
id: 'pdf.status.error'
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
} : {
|
|
41
|
+
type: 'pdf',
|
|
42
|
+
key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
43
|
+
file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
|
|
44
|
+
title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
|
|
45
|
+
cMapUrl: cMapUrl,
|
|
46
|
+
hasError: !(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) || materialPdfStatus === 'rejected',
|
|
47
|
+
i18n: {
|
|
48
|
+
fullscreen: intl.formatMessage({
|
|
49
|
+
id: 'pdf.fullScreen'
|
|
50
|
+
}),
|
|
51
|
+
download: intl.formatMessage({
|
|
52
|
+
id: 'pdf.download'
|
|
53
|
+
}),
|
|
54
|
+
loading: intl.formatMessage({
|
|
55
|
+
id: 'pdf.status.loading'
|
|
56
|
+
}),
|
|
57
|
+
error: intl.formatMessage({
|
|
58
|
+
id: 'pdf.status.error'
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [cMapUrl, intl, isPowerPointFile, materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url, materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title, materialPdfStatus]);
|
|
25
63
|
if (materialPdfStatus === 'pending') {
|
|
26
64
|
return React.createElement(Spinner, null);
|
|
27
65
|
}
|
|
28
|
-
return React.createElement(
|
|
29
|
-
key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
|
|
30
|
-
file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
|
|
31
|
-
title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
|
|
32
|
-
cMapUrl: cMapUrl,
|
|
33
|
-
hasError: !(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) || materialPdfStatus === 'rejected',
|
|
34
|
-
i18n: {
|
|
35
|
-
fullscreen: intl.formatMessage({
|
|
36
|
-
id: 'pdf.fullScreen'
|
|
37
|
-
}),
|
|
38
|
-
download: intl.formatMessage({
|
|
39
|
-
id: 'pdf.download'
|
|
40
|
-
}),
|
|
41
|
-
loading: intl.formatMessage({
|
|
42
|
-
id: 'pdf.status.loading'
|
|
43
|
-
}),
|
|
44
|
-
error: intl.formatMessage({
|
|
45
|
-
id: 'pdf.status.error'
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
});
|
|
66
|
+
return React.createElement(DocumentRenderer, Object.assign({}, componentProps));
|
|
49
67
|
};
|
|
50
68
|
|
|
51
69
|
export { MaterialPdfContent as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-pdf",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.240524.0-ppsx.1",
|
|
4
4
|
"description": "User view and editing components of Elice material PDF",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@elice/api-client": "^1.230815.0",
|
|
47
|
-
"@elice/blocks": "
|
|
47
|
+
"@elice/blocks": "1.240524.0-ppsx.1",
|
|
48
48
|
"@elice/design-tokens": "^1.220803.0",
|
|
49
49
|
"@elice/icons": "^1.230814.0",
|
|
50
50
|
"@elice/icons-legacy": "npm:@elice/icons@0.230814.0",
|
|
51
51
|
"@elice/intl": "0.240425.0-rc.2",
|
|
52
52
|
"@elice/markdown": "^1.220815.0",
|
|
53
|
-
"@elice/material-shared-types": "1.
|
|
54
|
-
"@elice/material-shared-utils": "1.
|
|
53
|
+
"@elice/material-shared-types": "1.240524.0-ppsx.1",
|
|
54
|
+
"@elice/material-shared-utils": "1.240524.0-ppsx.1",
|
|
55
55
|
"@elice/types": "^1.240208.0",
|
|
56
56
|
"@types/classnames": "^2.3.1",
|
|
57
57
|
"@types/react": "~17.0.9",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react-use": "^17.2.4",
|
|
61
61
|
"styled-components": "^5.3.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "cd480a43ca17e38036582b510a67c2b7fe6dfc65"
|
|
64
64
|
}
|