@ndla/article-converter 1.0.34 → 1.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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { ContactBlock } from '@ndla/ui';
10
+ import { attributesToProps } from 'html-react-parser';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
13
+ var props = attributesToProps(element.attribs);
14
+ var embedData = JSON.parse(props['data-json']);
15
+ var _embedData$embedData = embedData.embedData,
16
+ name = _embedData$embedData.name,
17
+ email = _embedData$embedData.email,
18
+ description = _embedData$embedData.description,
19
+ blob = _embedData$embedData.blob,
20
+ blobColor = _embedData$embedData.blobColor,
21
+ jobTitle = _embedData$embedData.jobTitle;
22
+ return _jsx(ContactBlock, {
23
+ image: embedData.status === 'success' ? embedData.data.image : undefined,
24
+ description: description,
25
+ email: email,
26
+ blobColor: blobColor,
27
+ jobTitle: jobTitle,
28
+ name: name,
29
+ blob: blob
30
+ });
31
+ };
@@ -20,6 +20,8 @@ import { conceptListEmbedPlugin } from './conceptListEmbedPlugin';
20
20
  import { fileEmbedPlugin } from './fileEmbedPlugin';
21
21
  import { codeEmbedPlugin } from './codeEmbedPlugin';
22
22
  import { blogPostEmbedPlugin } from './blogPostEmbedPlugin';
23
+ import { keyPerformanceIndicatorEmbedPlugin } from './keyPerformanceIndicatorEmbedPlugin';
24
+ import { contactBlockEmbedPlugin } from './contactBlockEmbedPlugin';
23
25
  export var embedPlugins = {
24
26
  image: imageEmbedPlugin,
25
27
  audio: audioEmbedPlugin,
@@ -34,5 +36,7 @@ export var embedPlugins = {
34
36
  concept: conceptEmbedPlugin,
35
37
  'concept-list': conceptListEmbedPlugin,
36
38
  'blog-post': blogPostEmbedPlugin,
37
- file: fileEmbedPlugin
39
+ file: fileEmbedPlugin,
40
+ 'key-performance-indicator': keyPerformanceIndicatorEmbedPlugin,
41
+ 'contact-block': contactBlockEmbedPlugin
38
42
  };
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { KeyPerformanceIndicator } from '@ndla/ui';
10
+ import { attributesToProps } from 'html-react-parser';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var keyPerformanceIndicatorEmbedPlugin = function keyPerformanceIndicatorEmbedPlugin(element, _, opts) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ var _data$embedData = data.embedData,
16
+ title = _data$embedData.title,
17
+ subTitle = _data$embedData.subTitle;
18
+ return _jsx(KeyPerformanceIndicator, {
19
+ title: title,
20
+ subTitle: subTitle,
21
+ image: data.status === 'success' ? data.data.metaImage : undefined
22
+ });
23
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { PluginType } from '../types';
9
+ export declare const contactBlockEmbedPlugin: PluginType;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contactBlockEmbedPlugin = void 0;
7
+ var _ui = require("@ndla/ui");
8
+ var _htmlReactParser = require("html-react-parser");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
19
+ var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ var embedData = JSON.parse(props['data-json']);
21
+ var _embedData$embedData = embedData.embedData,
22
+ name = _embedData$embedData.name,
23
+ email = _embedData$embedData.email,
24
+ description = _embedData$embedData.description,
25
+ blob = _embedData$embedData.blob,
26
+ blobColor = _embedData$embedData.blobColor,
27
+ jobTitle = _embedData$embedData.jobTitle;
28
+ return (0, _jsxRuntime.jsx)(_ui.ContactBlock, {
29
+ image: embedData.status === 'success' ? embedData.data.image : undefined,
30
+ description: description,
31
+ email: email,
32
+ blobColor: blobColor,
33
+ jobTitle: jobTitle,
34
+ name: name,
35
+ blob: blob
36
+ });
37
+ };
38
+ exports.contactBlockEmbedPlugin = contactBlockEmbedPlugin;
@@ -18,6 +18,8 @@ var _conceptListEmbedPlugin = require("./conceptListEmbedPlugin");
18
18
  var _fileEmbedPlugin = require("./fileEmbedPlugin");
19
19
  var _codeEmbedPlugin = require("./codeEmbedPlugin");
20
20
  var _blogPostEmbedPlugin = require("./blogPostEmbedPlugin");
21
+ var _keyPerformanceIndicatorEmbedPlugin = require("./keyPerformanceIndicatorEmbedPlugin");
22
+ var _contactBlockEmbedPlugin = require("./contactBlockEmbedPlugin");
21
23
  /**
22
24
  * Copyright (c) 2023-present, NDLA.
23
25
  *
@@ -40,6 +42,8 @@ var embedPlugins = {
40
42
  concept: _conceptEmbedPlugin.conceptEmbedPlugin,
41
43
  'concept-list': _conceptListEmbedPlugin.conceptListEmbedPlugin,
42
44
  'blog-post': _blogPostEmbedPlugin.blogPostEmbedPlugin,
43
- file: _fileEmbedPlugin.fileEmbedPlugin
45
+ file: _fileEmbedPlugin.fileEmbedPlugin,
46
+ 'key-performance-indicator': _keyPerformanceIndicatorEmbedPlugin.keyPerformanceIndicatorEmbedPlugin,
47
+ 'contact-block': _contactBlockEmbedPlugin.contactBlockEmbedPlugin
44
48
  };
45
49
  exports.embedPlugins = embedPlugins;
@@ -0,0 +1,2 @@
1
+ import { PluginType } from '../types';
2
+ export declare const keyPerformanceIndicatorEmbedPlugin: PluginType;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.keyPerformanceIndicatorEmbedPlugin = void 0;
7
+ var _ui = require("@ndla/ui");
8
+ var _htmlReactParser = require("html-react-parser");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ /*
11
+ * Copyright (c) 2023-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ var keyPerformanceIndicatorEmbedPlugin = function keyPerformanceIndicatorEmbedPlugin(element, _, opts) {
19
+ var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ var data = JSON.parse(props['data-json']);
21
+ var _data$embedData = data.embedData,
22
+ title = _data$embedData.title,
23
+ subTitle = _data$embedData.subTitle;
24
+ return (0, _jsxRuntime.jsx)(_ui.KeyPerformanceIndicator, {
25
+ title: title,
26
+ subTitle: subTitle,
27
+ image: data.status === 'success' ? data.data.metaImage : undefined
28
+ });
29
+ };
30
+ exports.keyPerformanceIndicatorEmbedPlugin = keyPerformanceIndicatorEmbedPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "1.0.34",
3
+ "version": "1.1.0",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -27,11 +27,11 @@
27
27
  "src"
28
28
  ],
29
29
  "devDependencies": {
30
- "@ndla/types-embed": "^1.0.11"
30
+ "@ndla/types-embed": "^1.1.0"
31
31
  },
32
32
  "dependencies": {
33
- "@ndla/code": "^2.1.40",
34
- "@ndla/ui": "^35.0.28",
33
+ "@ndla/code": "^2.1.41",
34
+ "@ndla/ui": "^35.1.0",
35
35
  "html-react-parser": "^3.0.8",
36
36
  "lodash": "^4.17.20"
37
37
  },
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "5409272e9cd733486c528ae68d576721e25d4674"
47
+ "gitHead": "c055a24586a13acac494f7cecda6b301fba80249"
48
48
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { ContactBlock } from '@ndla/ui';
10
+ import { attributesToProps } from 'html-react-parser';
11
+ import { ContactBlockMetaData } from '@ndla/types-embed';
12
+ import { PluginType } from '../types';
13
+
14
+ export const contactBlockEmbedPlugin: PluginType = (element) => {
15
+ const props = attributesToProps(element.attribs);
16
+ const embedData = JSON.parse(props['data-json']) as ContactBlockMetaData;
17
+ const { name, email, description, blob, blobColor, jobTitle } = embedData.embedData;
18
+ return (
19
+ <ContactBlock
20
+ image={embedData.status === 'success' ? embedData.data.image : undefined}
21
+ description={description}
22
+ email={email}
23
+ blobColor={blobColor}
24
+ jobTitle={jobTitle}
25
+ name={name}
26
+ blob={blob}
27
+ />
28
+ );
29
+ };
@@ -21,6 +21,8 @@ import { conceptListEmbedPlugin } from './conceptListEmbedPlugin';
21
21
  import { fileEmbedPlugin } from './fileEmbedPlugin';
22
22
  import { codeEmbedPlugin } from './codeEmbedPlugin';
23
23
  import { blogPostEmbedPlugin } from './blogPostEmbedPlugin';
24
+ import { keyPerformanceIndicatorEmbedPlugin } from './keyPerformanceIndicatorEmbedPlugin';
25
+ import { contactBlockEmbedPlugin } from './contactBlockEmbedPlugin';
24
26
 
25
27
  export const embedPlugins: Record<string, PluginType> = {
26
28
  image: imageEmbedPlugin,
@@ -37,4 +39,6 @@ export const embedPlugins: Record<string, PluginType> = {
37
39
  'concept-list': conceptListEmbedPlugin,
38
40
  'blog-post': blogPostEmbedPlugin,
39
41
  file: fileEmbedPlugin,
42
+ 'key-performance-indicator': keyPerformanceIndicatorEmbedPlugin,
43
+ 'contact-block': contactBlockEmbedPlugin,
40
44
  };
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { KeyPerformanceIndicator } from '@ndla/ui';
10
+ import { attributesToProps } from 'html-react-parser';
11
+ import { KeyPerformanceIndicatorMetaData } from '@ndla/types-embed';
12
+ import { PluginType } from '../types';
13
+
14
+ export const keyPerformanceIndicatorEmbedPlugin: PluginType = (element, _, opts) => {
15
+ const props = attributesToProps(element.attribs);
16
+ const data = JSON.parse(props['data-json']) as KeyPerformanceIndicatorMetaData;
17
+ const { title, subTitle } = data.embedData;
18
+ return (
19
+ <KeyPerformanceIndicator
20
+ title={title}
21
+ subTitle={subTitle}
22
+ image={data.status === 'success' ? data.data.metaImage : undefined}
23
+ />
24
+ );
25
+ };