@ndla/article-converter 5.1.4 → 5.1.6

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.
Files changed (37) hide show
  1. package/es/plugins/copyParagraphPlugin.js +3 -2
  2. package/es/plugins/ddPlugin.js +3 -2
  3. package/es/plugins/dtPlugin.js +3 -2
  4. package/es/plugins/embed/KeyFigureEmbedPlugin.js +4 -3
  5. package/es/plugins/embed/blogPostEmbedPlugin.js +3 -3
  6. package/es/plugins/embed/campaignBlockPlugin.js +1 -1
  7. package/es/plugins/embed/conceptEmbedPlugin.js +2 -1
  8. package/es/plugins/embed/conceptListEmbedPlugin.js +3 -2
  9. package/es/plugins/embed/contactBlockEmbedPlugin.js +3 -2
  10. package/es/plugins/embed/imageEmbedPlugin.js +2 -1
  11. package/es/plugins/h3Plugin.js +3 -2
  12. package/es/plugins/tablePlugin.js +3 -2
  13. package/lib/plugins/copyParagraphPlugin.js +3 -2
  14. package/lib/plugins/ddPlugin.js +3 -2
  15. package/lib/plugins/dtPlugin.js +3 -2
  16. package/lib/plugins/embed/KeyFigureEmbedPlugin.js +4 -3
  17. package/lib/plugins/embed/blogPostEmbedPlugin.js +3 -3
  18. package/lib/plugins/embed/campaignBlockPlugin.js +1 -1
  19. package/lib/plugins/embed/conceptEmbedPlugin.js +2 -1
  20. package/lib/plugins/embed/conceptListEmbedPlugin.js +3 -2
  21. package/lib/plugins/embed/contactBlockEmbedPlugin.js +3 -2
  22. package/lib/plugins/embed/imageEmbedPlugin.js +2 -1
  23. package/lib/plugins/h3Plugin.js +3 -2
  24. package/lib/plugins/tablePlugin.js +3 -2
  25. package/package.json +5 -5
  26. package/src/plugins/copyParagraphPlugin.tsx +3 -3
  27. package/src/plugins/ddPlugin.tsx +6 -2
  28. package/src/plugins/dtPlugin.tsx +6 -2
  29. package/src/plugins/embed/KeyFigureEmbedPlugin.tsx +3 -2
  30. package/src/plugins/embed/blogPostEmbedPlugin.tsx +1 -1
  31. package/src/plugins/embed/campaignBlockPlugin.tsx +1 -1
  32. package/src/plugins/embed/conceptEmbedPlugin.tsx +1 -1
  33. package/src/plugins/embed/conceptListEmbedPlugin.tsx +2 -2
  34. package/src/plugins/embed/contactBlockEmbedPlugin.tsx +2 -1
  35. package/src/plugins/embed/imageEmbedPlugin.tsx +1 -0
  36. package/src/plugins/h3Plugin.tsx +3 -3
  37. package/src/plugins/tablePlugin.tsx +6 -2
@@ -9,13 +9,14 @@
9
9
  import { CopyParagraphButtonV2 } from '@ndla/ui';
10
10
  import { domToReact } from 'html-react-parser';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var copyParagraphPlugin = function copyParagraphPlugin(node, opts) {
12
+ export var copyParagraphPlugin = function copyParagraphPlugin(node, converterOpts, opts) {
13
13
  var _parent$attribs;
14
14
  var parent = node.parent;
15
15
  if ((parent === null || parent === void 0 ? void 0 : parent.name) === 'section' || (parent === null || parent === void 0 ? void 0 : parent.name) === 'div' && Object.keys((_parent$attribs = parent.attribs) !== null && _parent$attribs !== void 0 ? _parent$attribs : {}).length === 0) {
16
16
  return _jsx(CopyParagraphButtonV2, {
17
17
  copyText: node.attribs['data-text'],
18
- children: domToReact(node.children, opts)
18
+ lang: opts.articleLanguage,
19
+ children: domToReact(node.children, converterOpts)
19
20
  });
20
21
  }
21
22
  return null;
@@ -15,9 +15,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  import { DefinitionDescription } from '@ndla/ui';
16
16
  import { attributesToProps, domToReact } from 'html-react-parser';
17
17
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var ddPlugin = function ddPlugin(node, opts) {
18
+ export var ddPlugin = function ddPlugin(node, converterOpts, opts) {
19
19
  var props = attributesToProps(node.attribs);
20
20
  return _jsx(DefinitionDescription, _objectSpread(_objectSpread({}, props), {}, {
21
- children: domToReact(node.children, opts)
21
+ lang: opts.articleLanguage,
22
+ children: domToReact(node.children, converterOpts)
22
23
  }));
23
24
  };
@@ -15,9 +15,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  import { DefinitionTerm } from '@ndla/ui';
16
16
  import { attributesToProps, domToReact } from 'html-react-parser';
17
17
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var dtPlugin = function dtPlugin(node, opts) {
18
+ export var dtPlugin = function dtPlugin(node, converterOpts, opts) {
19
19
  var props = attributesToProps(node.attribs);
20
20
  return _jsx(DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
21
- children: domToReact(node.children, opts)
21
+ lang: opts.articleLanguage,
22
+ children: domToReact(node.children, converterOpts)
22
23
  }));
23
24
  };
@@ -9,7 +9,7 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { KeyFigure } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _) {
12
+ export var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _, opts) {
13
13
  var props = attributesToProps(element.attribs);
14
14
  var data = JSON.parse(props['data-json']);
15
15
  var _data$embedData = data.embedData,
@@ -21,7 +21,8 @@ export var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _) {
21
21
  subtitle: subtitle,
22
22
  image: data.status === 'success' && data.data.metaImage ? {
23
23
  src: data.data.metaImage.image.imageUrl,
24
- alt: alt === undefined ? '' : alt === '' ? data.data.metaImage.alttext.alttext : alt
25
- } : undefined
24
+ alt: alt === undefined ? '' : alt
25
+ } : undefined,
26
+ lang: opts.articleLanguage
26
27
  });
27
28
  };
@@ -11,7 +11,7 @@ import { BlogPostV2 } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
12
  export var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
13
13
  export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
14
- var _data$data$metaImage$, _data$data$metaImage, _data$data$metaImage$2, _data$data$metaImage2;
14
+ var _data$data$metaImage$, _data$data$metaImage;
15
15
  var props = attributesToProps(element.attribs);
16
16
  var data = JSON.parse(props['data-json']);
17
17
  var _data$embedData = data.embedData,
@@ -31,8 +31,8 @@ export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts)
31
31
  size: size,
32
32
  path: opts.path,
33
33
  metaImage: {
34
- alt: alt ? alt : data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.alttext.alttext) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : '' : '',
35
- url: data.status === 'success' ? (_data$data$metaImage$2 = (_data$data$metaImage2 = data.data.metaImage) === null || _data$data$metaImage2 === void 0 ? void 0 : _data$data$metaImage2.image.imageUrl) !== null && _data$data$metaImage$2 !== void 0 ? _data$data$metaImage$2 : errorSvgSrc : errorSvgSrc
34
+ alt: alt ? alt : '',
35
+ url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.image.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
36
36
  }
37
37
  });
38
38
  };
@@ -30,7 +30,7 @@ export var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts)
30
30
  imageSide: embed.imageSide,
31
31
  image: data.status === 'success' && data.data.image ? {
32
32
  src: data.data.image.image.imageUrl,
33
- alt: embed.alt === undefined ? '' : embed.alt === '' ? data.data.image.alttext.alttext : embed.alt
33
+ alt: embed.alt === undefined ? '' : embed.alt
34
34
  } : undefined
35
35
  });
36
36
  };
@@ -16,6 +16,7 @@ export var conceptEmbedPlugin = function conceptEmbedPlugin(element, _, opts) {
16
16
  return _jsx(ConceptEmbed, {
17
17
  embed: data,
18
18
  fullWidth: true,
19
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
19
+ heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
20
+ lang: opts.articleLanguage
20
21
  });
21
22
  };
@@ -9,10 +9,11 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { ConceptListEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var conceptListEmbedPlugin = function conceptListEmbedPlugin(element) {
12
+ export var conceptListEmbedPlugin = function conceptListEmbedPlugin(element, _, opts) {
13
13
  var props = attributesToProps(element.attribs);
14
14
  var data = JSON.parse(props['data-json']);
15
15
  return _jsx(ConceptListEmbed, {
16
- embed: data
16
+ embed: data,
17
+ lang: opts.articleLanguage
17
18
  });
18
19
  };
@@ -9,7 +9,7 @@
9
9
  import { ContactBlock } from '@ndla/ui';
10
10
  import { attributesToProps } from 'html-react-parser';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
12
+ export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts) {
13
13
  var props = attributesToProps(element.attribs);
14
14
  var embedData = JSON.parse(props['data-json']);
15
15
  var _embedData$embedData = embedData.embedData,
@@ -26,6 +26,7 @@ export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
26
26
  blobColor: blobColor,
27
27
  jobTitle: jobTitle,
28
28
  name: name,
29
- blob: blob
29
+ blob: blob,
30
+ lang: opts.articleLanguage
30
31
  });
31
32
  };
@@ -19,6 +19,7 @@ export var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
19
19
  embed: data,
20
20
  path: opts.path,
21
21
  previewAlt: opts.previewAlt,
22
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
22
+ heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
23
+ lang: opts.articleLanguage
23
24
  });
24
25
  };
@@ -14,13 +14,14 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
14
14
 
15
15
  import { attributesToProps, domToReact } from 'html-react-parser';
16
16
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
17
- export var h3Plugin = function h3Plugin(node, opts) {
17
+ export var h3Plugin = function h3Plugin(node, converterOpts, opts) {
18
18
  var props = attributesToProps(node.attribs);
19
19
  return (
20
20
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
21
21
  _jsx("h3", _objectSpread(_objectSpread({}, props), {}, {
22
22
  tabIndex: 0,
23
- children: domToReact(node.children, opts)
23
+ lang: opts.articleLanguage,
24
+ children: domToReact(node.children, converterOpts)
24
25
  }))
25
26
  );
26
27
  };
@@ -15,9 +15,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  import { Table } from '@ndla/ui';
16
16
  import { attributesToProps, domToReact } from 'html-react-parser';
17
17
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var tablePlugin = function tablePlugin(node, opts) {
18
+ export var tablePlugin = function tablePlugin(node, converterOpts, opts) {
19
19
  var props = attributesToProps(node.attribs);
20
20
  return _jsx(Table, _objectSpread(_objectSpread({}, props), {}, {
21
- children: domToReact(node.children, opts)
21
+ lang: opts.articleLanguage,
22
+ children: domToReact(node.children, converterOpts)
22
23
  }));
23
24
  };
@@ -15,13 +15,14 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var copyParagraphPlugin = function copyParagraphPlugin(node, opts) {
18
+ var copyParagraphPlugin = function copyParagraphPlugin(node, converterOpts, opts) {
19
19
  var _parent$attribs;
20
20
  var parent = node.parent;
21
21
  if ((parent === null || parent === void 0 ? void 0 : parent.name) === 'section' || (parent === null || parent === void 0 ? void 0 : parent.name) === 'div' && Object.keys((_parent$attribs = parent.attribs) !== null && _parent$attribs !== void 0 ? _parent$attribs : {}).length === 0) {
22
22
  return (0, _jsxRuntime.jsx)(_ui.CopyParagraphButtonV2, {
23
23
  copyText: node.attribs['data-text'],
24
- children: (0, _htmlReactParser.domToReact)(node.children, opts)
24
+ lang: opts.articleLanguage,
25
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
25
26
  });
26
27
  }
27
28
  return null;
@@ -19,10 +19,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
19
19
  * LICENSE file in the root directory of this source tree.
20
20
  *
21
21
  */
22
- var ddPlugin = function ddPlugin(node, opts) {
22
+ var ddPlugin = function ddPlugin(node, converterOpts, opts) {
23
23
  var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
24
  return (0, _jsxRuntime.jsx)(_ui.DefinitionDescription, _objectSpread(_objectSpread({}, props), {}, {
25
- children: (0, _htmlReactParser.domToReact)(node.children, opts)
25
+ lang: opts.articleLanguage,
26
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
26
27
  }));
27
28
  };
28
29
  exports.ddPlugin = ddPlugin;
@@ -19,10 +19,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
19
19
  * LICENSE file in the root directory of this source tree.
20
20
  *
21
21
  */
22
- var dtPlugin = function dtPlugin(node, opts) {
22
+ var dtPlugin = function dtPlugin(node, converterOpts, opts) {
23
23
  var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
24
  return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
25
- children: (0, _htmlReactParser.domToReact)(node.children, opts)
25
+ lang: opts.articleLanguage,
26
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
26
27
  }));
27
28
  };
28
29
  exports.dtPlugin = dtPlugin;
@@ -15,7 +15,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _) {
18
+ var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _, opts) {
19
19
  var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
20
  var data = JSON.parse(props['data-json']);
21
21
  var _data$embedData = data.embedData,
@@ -27,8 +27,9 @@ var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(element, _) {
27
27
  subtitle: subtitle,
28
28
  image: data.status === 'success' && data.data.metaImage ? {
29
29
  src: data.data.metaImage.image.imageUrl,
30
- alt: alt === undefined ? '' : alt === '' ? data.data.metaImage.alttext.alttext : alt
31
- } : undefined
30
+ alt: alt === undefined ? '' : alt
31
+ } : undefined,
32
+ lang: opts.articleLanguage
32
33
  });
33
34
  };
34
35
  exports.keyFigureEmbedPlugin = keyFigureEmbedPlugin;
@@ -18,7 +18,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
18
18
  var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
19
19
  exports.errorSvgSrc = errorSvgSrc;
20
20
  var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
21
- var _data$data$metaImage$, _data$data$metaImage, _data$data$metaImage$2, _data$data$metaImage2;
21
+ var _data$data$metaImage$, _data$data$metaImage;
22
22
  var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
23
23
  var data = JSON.parse(props['data-json']);
24
24
  var _data$embedData = data.embedData,
@@ -38,8 +38,8 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
38
38
  size: size,
39
39
  path: opts.path,
40
40
  metaImage: {
41
- alt: alt ? alt : data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.alttext.alttext) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : '' : '',
42
- url: data.status === 'success' ? (_data$data$metaImage$2 = (_data$data$metaImage2 = data.data.metaImage) === null || _data$data$metaImage2 === void 0 ? void 0 : _data$data$metaImage2.image.imageUrl) !== null && _data$data$metaImage$2 !== void 0 ? _data$data$metaImage$2 : errorSvgSrc : errorSvgSrc
41
+ alt: alt ? alt : '',
42
+ url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.image.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
43
43
  }
44
44
  });
45
45
  };
@@ -36,7 +36,7 @@ var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
36
36
  imageSide: embed.imageSide,
37
37
  image: data.status === 'success' && data.data.image ? {
38
38
  src: data.data.image.image.imageUrl,
39
- alt: embed.alt === undefined ? '' : embed.alt === '' ? data.data.image.alttext.alttext : embed.alt
39
+ alt: embed.alt === undefined ? '' : embed.alt
40
40
  } : undefined
41
41
  });
42
42
  };
@@ -22,7 +22,8 @@ var conceptEmbedPlugin = function conceptEmbedPlugin(element, _, opts) {
22
22
  return (0, _jsxRuntime.jsx)(_ui.ConceptEmbed, {
23
23
  embed: data,
24
24
  fullWidth: true,
25
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
25
+ heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
26
+ lang: opts.articleLanguage
26
27
  });
27
28
  };
28
29
  exports.conceptEmbedPlugin = conceptEmbedPlugin;
@@ -15,11 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var conceptListEmbedPlugin = function conceptListEmbedPlugin(element) {
18
+ var conceptListEmbedPlugin = function conceptListEmbedPlugin(element, _, opts) {
19
19
  var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
20
  var data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.ConceptListEmbed, {
22
- embed: data
22
+ embed: data,
23
+ lang: opts.articleLanguage
23
24
  });
24
25
  };
25
26
  exports.conceptListEmbedPlugin = conceptListEmbedPlugin;
@@ -15,7 +15,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
18
+ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts) {
19
19
  var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
20
  var embedData = JSON.parse(props['data-json']);
21
21
  var _embedData$embedData = embedData.embedData,
@@ -32,7 +32,8 @@ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element) {
32
32
  blobColor: blobColor,
33
33
  jobTitle: jobTitle,
34
34
  name: name,
35
- blob: blob
35
+ blob: blob,
36
+ lang: opts.articleLanguage
36
37
  });
37
38
  };
38
39
  exports.contactBlockEmbedPlugin = contactBlockEmbedPlugin;
@@ -25,7 +25,8 @@ var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
25
25
  embed: data,
26
26
  path: opts.path,
27
27
  previewAlt: opts.previewAlt,
28
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
28
+ heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
29
+ lang: opts.articleLanguage
29
30
  });
30
31
  };
31
32
  exports.imageEmbedPlugin = imageEmbedPlugin;
@@ -18,13 +18,14 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  *
20
20
  */
21
- var h3Plugin = function h3Plugin(node, opts) {
21
+ var h3Plugin = function h3Plugin(node, converterOpts, opts) {
22
22
  var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
23
23
  return (
24
24
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
25
25
  (0, _jsxRuntime.jsx)("h3", _objectSpread(_objectSpread({}, props), {}, {
26
26
  tabIndex: 0,
27
- children: (0, _htmlReactParser.domToReact)(node.children, opts)
27
+ lang: opts.articleLanguage,
28
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
28
29
  }))
29
30
  );
30
31
  };
@@ -19,10 +19,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
19
19
  * LICENSE file in the root directory of this source tree.
20
20
  *
21
21
  */
22
- var tablePlugin = function tablePlugin(node, opts) {
22
+ var tablePlugin = function tablePlugin(node, converterOpts, opts) {
23
23
  var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
24
  return (0, _jsxRuntime.jsx)(_ui.Table, _objectSpread(_objectSpread({}, props), {}, {
25
- children: (0, _htmlReactParser.domToReact)(node.children, opts)
25
+ lang: opts.articleLanguage,
26
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
26
27
  }));
27
28
  };
28
29
  exports.tablePlugin = tablePlugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "5.1.4",
3
+ "version": "5.1.6",
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": "^4.0.4"
30
+ "@ndla/types-embed": "^4.0.5"
31
31
  },
32
32
  "dependencies": {
33
- "@ndla/code": "^5.0.7",
34
- "@ndla/ui": "^47.3.1",
33
+ "@ndla/code": "^5.0.8",
34
+ "@ndla/ui": "^47.4.1",
35
35
  "html-react-parser": "^4.2.2",
36
36
  "lodash": "^4.17.20"
37
37
  },
@@ -44,5 +44,5 @@
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "82ca8bd42374c69bb550b4c3cc156bffada22c14"
47
+ "gitHead": "de410ca8c4f83133def88e9ed04eb4984d9b0896"
48
48
  }
@@ -9,12 +9,12 @@
9
9
  import { CopyParagraphButtonV2 } from '@ndla/ui';
10
10
  import { Element, domToReact } from 'html-react-parser';
11
11
  import { PluginType } from './types';
12
- export const copyParagraphPlugin: PluginType = (node, opts) => {
12
+ export const copyParagraphPlugin: PluginType = (node, converterOpts, opts) => {
13
13
  const parent = node.parent as Element | undefined;
14
14
  if (parent?.name === 'section' || (parent?.name === 'div' && Object.keys(parent.attribs ?? {}).length === 0)) {
15
15
  return (
16
- <CopyParagraphButtonV2 copyText={node.attribs['data-text']}>
17
- {domToReact(node.children, opts)}
16
+ <CopyParagraphButtonV2 copyText={node.attribs['data-text']} lang={opts.articleLanguage}>
17
+ {domToReact(node.children, converterOpts)}
18
18
  </CopyParagraphButtonV2>
19
19
  );
20
20
  }
@@ -10,8 +10,12 @@ import { DefinitionDescription } from '@ndla/ui';
10
10
  import { attributesToProps, domToReact } from 'html-react-parser';
11
11
  import { PluginType } from './types';
12
12
 
13
- export const ddPlugin: PluginType = (node, opts) => {
13
+ export const ddPlugin: PluginType = (node, converterOpts, opts) => {
14
14
  const props = attributesToProps(node.attribs);
15
15
 
16
- return <DefinitionDescription {...props}>{domToReact(node.children, opts)}</DefinitionDescription>;
16
+ return (
17
+ <DefinitionDescription {...props} lang={opts.articleLanguage}>
18
+ {domToReact(node.children, converterOpts)}
19
+ </DefinitionDescription>
20
+ );
17
21
  };
@@ -10,8 +10,12 @@ import { DefinitionTerm } from '@ndla/ui';
10
10
  import { attributesToProps, domToReact } from 'html-react-parser';
11
11
  import { PluginType } from './types';
12
12
 
13
- export const dtPlugin: PluginType = (node, opts) => {
13
+ export const dtPlugin: PluginType = (node, converterOpts, opts) => {
14
14
  const props = attributesToProps(node.attribs);
15
15
 
16
- return <DefinitionTerm {...props}>{domToReact(node.children, opts)}</DefinitionTerm>;
16
+ return (
17
+ <DefinitionTerm {...props} lang={opts.articleLanguage}>
18
+ {domToReact(node.children, converterOpts)}
19
+ </DefinitionTerm>
20
+ );
17
21
  };
@@ -11,7 +11,7 @@ import { KeyFigureMetaData } from '@ndla/types-embed';
11
11
  import { KeyFigure } from '@ndla/ui';
12
12
  import { PluginType } from '../types';
13
13
 
14
- export const keyFigureEmbedPlugin: PluginType = (element, _) => {
14
+ export const keyFigureEmbedPlugin: PluginType = (element, _, opts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const data = JSON.parse(props['data-json']) as KeyFigureMetaData;
17
17
  const { title, subtitle, alt } = data.embedData;
@@ -23,10 +23,11 @@ export const keyFigureEmbedPlugin: PluginType = (element, _) => {
23
23
  data.status === 'success' && data.data.metaImage
24
24
  ? {
25
25
  src: data.data.metaImage.image.imageUrl,
26
- alt: alt === undefined ? '' : alt === '' ? data.data.metaImage.alttext.alttext : alt,
26
+ alt: alt === undefined ? '' : alt,
27
27
  }
28
28
  : undefined
29
29
  }
30
+ lang={opts.articleLanguage}
30
31
  />
31
32
  );
32
33
  };
@@ -25,7 +25,7 @@ export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
25
25
  size={size}
26
26
  path={opts.path}
27
27
  metaImage={{
28
- alt: alt ? alt : data.status === 'success' ? data.data.metaImage?.alttext.alttext ?? '' : '',
28
+ alt: alt ? alt : '',
29
29
  url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc,
30
30
  }}
31
31
  />
@@ -27,7 +27,7 @@ export const campaignBlockPlugin: PluginType = (element, _, opts) => {
27
27
  data.status === 'success' && data.data.image
28
28
  ? {
29
29
  src: data.data.image.image.imageUrl,
30
- alt: embed.alt === undefined ? '' : embed.alt === '' ? data.data.image.alttext.alttext : embed.alt,
30
+ alt: embed.alt === undefined ? '' : embed.alt,
31
31
  }
32
32
  : undefined
33
33
  }
@@ -14,5 +14,5 @@ import { PluginType } from '../types';
14
14
  export const conceptEmbedPlugin: PluginType = (element, _, opts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const data = JSON.parse(props['data-json']) as ConceptMetaData;
17
- return <ConceptEmbed embed={data} fullWidth heartButton={opts.components?.heartButton} />;
17
+ return <ConceptEmbed embed={data} fullWidth heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
18
18
  };
@@ -11,8 +11,8 @@ import { ConceptListMetaData } from '@ndla/types-embed';
11
11
  import { ConceptListEmbed } from '@ndla/ui';
12
12
  import { PluginType } from '../types';
13
13
 
14
- export const conceptListEmbedPlugin: PluginType = (element) => {
14
+ export const conceptListEmbedPlugin: PluginType = (element, _, opts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const data = JSON.parse(props['data-json']) as ConceptListMetaData;
17
- return <ConceptListEmbed embed={data} />;
17
+ return <ConceptListEmbed embed={data} lang={opts.articleLanguage} />;
18
18
  };
@@ -11,7 +11,7 @@ import { attributesToProps } from 'html-react-parser';
11
11
  import { ContactBlockMetaData } from '@ndla/types-embed';
12
12
  import { PluginType } from '../types';
13
13
 
14
- export const contactBlockEmbedPlugin: PluginType = (element) => {
14
+ export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const embedData = JSON.parse(props['data-json']) as ContactBlockMetaData;
17
17
  const { name, email, description, blob, blobColor, jobTitle } = embedData.embedData;
@@ -24,6 +24,7 @@ export const contactBlockEmbedPlugin: PluginType = (element) => {
24
24
  jobTitle={jobTitle}
25
25
  name={name}
26
26
  blob={blob}
27
+ lang={opts.articleLanguage}
27
28
  />
28
29
  );
29
30
  };
@@ -23,6 +23,7 @@ export const imageEmbedPlugin: PluginType = (element, _, opts) => {
23
23
  path={opts.path}
24
24
  previewAlt={opts.previewAlt}
25
25
  heartButton={opts.components?.heartButton}
26
+ lang={opts.articleLanguage}
26
27
  />
27
28
  );
28
29
  };
@@ -8,12 +8,12 @@
8
8
 
9
9
  import { attributesToProps, domToReact } from 'html-react-parser';
10
10
  import { PluginType } from './types';
11
- export const h3Plugin: PluginType = (node, opts) => {
11
+ export const h3Plugin: PluginType = (node, converterOpts, opts) => {
12
12
  const props = attributesToProps(node.attribs);
13
13
  return (
14
14
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
15
- <h3 {...props} tabIndex={0}>
16
- {domToReact(node.children, opts)}
15
+ <h3 {...props} tabIndex={0} lang={opts.articleLanguage}>
16
+ {domToReact(node.children, converterOpts)}
17
17
  </h3>
18
18
  );
19
19
  };
@@ -9,7 +9,11 @@
9
9
  import { Table } from '@ndla/ui';
10
10
  import { attributesToProps, domToReact } from 'html-react-parser';
11
11
  import { PluginType } from './types';
12
- export const tablePlugin: PluginType = (node, opts) => {
12
+ export const tablePlugin: PluginType = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
14
- return <Table {...props}>{domToReact(node.children, opts)}</Table>;
14
+ return (
15
+ <Table {...props} lang={opts.articleLanguage}>
16
+ {domToReact(node.children, converterOpts)}
17
+ </Table>
18
+ );
15
19
  };