@elice/material-pdf 1.240521.2 → 1.240524.0-ppsx.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.
@@ -12,6 +12,7 @@ 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
@@ -26,10 +27,22 @@ const MaterialPdfContent = ({
26
27
  }, {
27
28
  signal
28
29
  }), [materialPdfId]), apiClient.config.init);
30
+ const isPowerPointFile = React.useMemo(() => {
31
+ if (!(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url)) return false;
32
+ const file = new URL(materialPdf.attachment.url).pathname;
33
+ return POWERPOINT_EXTENSIONS.some(extension => file.includes(extension));
34
+ }, [materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url]);
29
35
  if (materialPdfStatus === 'pending') {
30
36
  return React.createElement(blocks.Spinner, null);
31
37
  }
32
- return React.createElement(blocks.PdfRenderer, {
38
+ return React.createElement(React.Fragment, null, isPowerPointFile ? React.createElement(blocks.PowerpointRenderer, {
39
+ src: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
40
+ i18n: {
41
+ error: intl$1.formatMessage({
42
+ id: 'pdf.status.error'
43
+ })
44
+ }
45
+ }) : React.createElement(blocks.PdfRenderer, {
33
46
  key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
34
47
  file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
35
48
  title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
@@ -49,7 +62,7 @@ const MaterialPdfContent = ({
49
62
  id: 'pdf.status.error'
50
63
  })
51
64
  }
52
- });
65
+ }));
53
66
  };
54
67
 
55
68
  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, PdfRenderer } from '@elice/blocks';
3
+ import { Spinner, PowerpointRenderer, PdfRenderer } 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,6 +8,7 @@ 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
@@ -22,10 +23,22 @@ const MaterialPdfContent = ({
22
23
  }, {
23
24
  signal
24
25
  }), [materialPdfId]), config.init);
26
+ const isPowerPointFile = useMemo(() => {
27
+ if (!(materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url)) return false;
28
+ const file = new URL(materialPdf.attachment.url).pathname;
29
+ return POWERPOINT_EXTENSIONS.some(extension => file.includes(extension));
30
+ }, [materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url]);
25
31
  if (materialPdfStatus === 'pending') {
26
32
  return React.createElement(Spinner, null);
27
33
  }
28
- return React.createElement(PdfRenderer, {
34
+ return React.createElement(React.Fragment, null, isPowerPointFile ? React.createElement(PowerpointRenderer, {
35
+ src: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
36
+ i18n: {
37
+ error: intl.formatMessage({
38
+ id: 'pdf.status.error'
39
+ })
40
+ }
41
+ }) : React.createElement(PdfRenderer, {
29
42
  key: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url,
30
43
  file: (_a = materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.attachment.url) !== null && _a !== void 0 ? _a : '',
31
44
  title: materialPdf === null || materialPdf === void 0 ? void 0 : materialPdf.title,
@@ -45,7 +58,7 @@ const MaterialPdfContent = ({
45
58
  id: 'pdf.status.error'
46
59
  })
47
60
  }
48
- });
61
+ }));
49
62
  };
50
63
 
51
64
  export { MaterialPdfContent as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elice/material-pdf",
3
- "version": "1.240521.2",
3
+ "version": "1.240524.0-ppsx.0",
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": "^1.240514.0",
47
+ "@elice/blocks": "1.240524.0-ppsx.0",
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.240521.2",
54
- "@elice/material-shared-utils": "1.240521.2",
53
+ "@elice/material-shared-types": "1.240524.0-ppsx.0",
54
+ "@elice/material-shared-utils": "1.240524.0-ppsx.0",
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": "b7335a4ad3c869dde5ac7407cdd270d53f1864bf"
63
+ "gitHead": "ece5ee64cae5bdb175cd695c93c16597abe2eac0"
64
64
  }