@ndla/article-converter 6.0.53 → 6.0.55

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.
@@ -24,6 +24,7 @@ import { imageEmbedPlugin } from "./imageEmbedPlugin";
24
24
  import { keyFigureEmbedPlugin } from "./KeyFigureEmbedPlugin";
25
25
  import { linkBlockPlugin } from "./linkBlockEmbedPlugin";
26
26
  import { relatedContentEmbedPlugin } from "./relatedContentEmbedPlugin";
27
+ import { uuDisclaimerEmbedPlugin } from "./uuDisclaimerEmbedPlugin";
27
28
  export const embedPlugins = {
28
29
  image: imageEmbedPlugin,
29
30
  audio: audioEmbedPlugin,
@@ -42,5 +43,6 @@ export const embedPlugins = {
42
43
  "key-figure": keyFigureEmbedPlugin,
43
44
  "contact-block": contactBlockEmbedPlugin,
44
45
  "campaign-block": campaignBlockPlugin,
45
- "link-block": linkBlockPlugin
46
+ "link-block": linkBlockPlugin,
47
+ "uu-disclaimer": uuDisclaimerEmbedPlugin
46
48
  };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2024-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 { attributesToProps, domToReact } from "html-react-parser";
10
+ import { UuDisclaimerEmbed } from "@ndla/ui";
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export const uuDisclaimerEmbedPlugin = (element, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props["data-json"]);
15
+ return _jsx(UuDisclaimerEmbed, {
16
+ embed: data,
17
+ children: domToReact(element.children, opts)
18
+ });
19
+ };
@@ -22,6 +22,7 @@ var _imageEmbedPlugin = require("./imageEmbedPlugin");
22
22
  var _KeyFigureEmbedPlugin = require("./KeyFigureEmbedPlugin");
23
23
  var _linkBlockEmbedPlugin = require("./linkBlockEmbedPlugin");
24
24
  var _relatedContentEmbedPlugin = require("./relatedContentEmbedPlugin");
25
+ var _uuDisclaimerEmbedPlugin = require("./uuDisclaimerEmbedPlugin");
25
26
  /**
26
27
  * Copyright (c) 2023-present, NDLA.
27
28
  *
@@ -48,5 +49,6 @@ const embedPlugins = exports.embedPlugins = {
48
49
  "key-figure": _KeyFigureEmbedPlugin.keyFigureEmbedPlugin,
49
50
  "contact-block": _contactBlockEmbedPlugin.contactBlockEmbedPlugin,
50
51
  "campaign-block": _campaignBlockPlugin.campaignBlockPlugin,
51
- "link-block": _linkBlockEmbedPlugin.linkBlockPlugin
52
+ "link-block": _linkBlockEmbedPlugin.linkBlockPlugin,
53
+ "uu-disclaimer": _uuDisclaimerEmbedPlugin.uuDisclaimerEmbedPlugin
52
54
  };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2024-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 uuDisclaimerEmbedPlugin: PluginType;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uuDisclaimerEmbedPlugin = void 0;
7
+ var _htmlReactParser = require("html-react-parser");
8
+ var _ui = require("@ndla/ui");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2024-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
+ const uuDisclaimerEmbedPlugin = (element, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props["data-json"]);
21
+ return (0, _jsxRuntime.jsx)(_ui.UuDisclaimerEmbed, {
22
+ embed: data,
23
+ children: (0, _htmlReactParser.domToReact)(element.children, opts)
24
+ });
25
+ };
26
+ exports.uuDisclaimerEmbedPlugin = uuDisclaimerEmbedPlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "6.0.53",
3
+ "version": "6.0.55",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -28,11 +28,11 @@
28
28
  ],
29
29
  "devDependencies": {
30
30
  "@ndla/types-backend": "^0.2.21",
31
- "@ndla/types-embed": "^4.0.13"
31
+ "@ndla/types-embed": "^4.0.14"
32
32
  },
33
33
  "dependencies": {
34
- "@ndla/code": "^5.0.36",
35
- "@ndla/ui": "^50.9.7",
34
+ "@ndla/code": "^5.0.37",
35
+ "@ndla/ui": "^50.9.9",
36
36
  "html-react-parser": "^4.2.2",
37
37
  "lodash": "^4.17.20"
38
38
  },
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "0ac986c583fdda4957ce9dd298043ac459052704"
51
+ "gitHead": "fc3f24dabc60ff3f1f00984a38a9de4ff8fde3c7"
52
52
  }
@@ -24,6 +24,7 @@ import { imageEmbedPlugin } from "./imageEmbedPlugin";
24
24
  import { keyFigureEmbedPlugin } from "./KeyFigureEmbedPlugin";
25
25
  import { linkBlockPlugin } from "./linkBlockEmbedPlugin";
26
26
  import { relatedContentEmbedPlugin } from "./relatedContentEmbedPlugin";
27
+ import { uuDisclaimerEmbedPlugin } from "./uuDisclaimerEmbedPlugin";
27
28
  import { PluginType } from "../types";
28
29
 
29
30
  export const embedPlugins: Record<string, PluginType> = {
@@ -45,4 +46,5 @@ export const embedPlugins: Record<string, PluginType> = {
45
46
  "contact-block": contactBlockEmbedPlugin,
46
47
  "campaign-block": campaignBlockPlugin,
47
48
  "link-block": linkBlockPlugin,
49
+ "uu-disclaimer": uuDisclaimerEmbedPlugin,
48
50
  };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2024-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 { attributesToProps, domToReact } from "html-react-parser";
10
+ import { UuDisclaimerMetaData } from "@ndla/types-embed";
11
+ import { UuDisclaimerEmbed } from "@ndla/ui";
12
+ import { PluginType } from "../types";
13
+
14
+ export const uuDisclaimerEmbedPlugin: PluginType = (element, opts) => {
15
+ const props = attributesToProps(element.attribs);
16
+ const data = JSON.parse(props["data-json"]) as UuDisclaimerMetaData;
17
+ return <UuDisclaimerEmbed embed={data}>{domToReact(element.children, opts)}</UuDisclaimerEmbed>;
18
+ };