@ndla/article-converter 6.0.14 → 6.0.16

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 (76) hide show
  1. package/es/extractEmbedMeta.js +6 -10
  2. package/es/plugins/anchorPlugin.js +9 -12
  3. package/es/plugins/asidePlugin.js +1 -1
  4. package/es/plugins/copyParagraphPlugin.js +3 -4
  5. package/es/plugins/ddPlugin.js +5 -10
  6. package/es/plugins/divPlugin.js +16 -34
  7. package/es/plugins/dtPlugin.js +5 -10
  8. package/es/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
  9. package/es/plugins/embed/audioEmbedPlugin.js +4 -5
  10. package/es/plugins/embed/blogPostEmbedPlugin.js +15 -15
  11. package/es/plugins/embed/brightcoveEmbedPlugin.js +4 -5
  12. package/es/plugins/embed/campaignBlockPlugin.js +4 -4
  13. package/es/plugins/embed/codeEmbedPlugin.js +3 -3
  14. package/es/plugins/embed/conceptEmbedPlugin.js +4 -5
  15. package/es/plugins/embed/conceptListEmbedPlugin.js +3 -3
  16. package/es/plugins/embed/contactBlockEmbedPlugin.js +13 -13
  17. package/es/plugins/embed/contentLinkEmbedPlugin.js +6 -4
  18. package/es/plugins/embed/externalEmbedPlugin.js +3 -3
  19. package/es/plugins/embed/fileEmbedPlugin.js +9 -8
  20. package/es/plugins/embed/footnoteEmbedPlugin.js +3 -3
  21. package/es/plugins/embed/h5pEmbedPlugin.js +3 -3
  22. package/es/plugins/embed/iframeEmbedPlugin.js +3 -3
  23. package/es/plugins/embed/imageEmbedPlugin.js +6 -7
  24. package/es/plugins/embed/index.js +1 -1
  25. package/es/plugins/embed/linkBlockEmbedPlugin.js +6 -11
  26. package/es/plugins/embed/relatedContentEmbedPlugin.js +3 -3
  27. package/es/plugins/h3Plugin.js +5 -10
  28. package/es/plugins/index.js +4 -9
  29. package/es/plugins/mathPlugin.js +8 -15
  30. package/es/plugins/navPlugin.js +5 -10
  31. package/es/plugins/oembed/anchorPlugin.js +9 -12
  32. package/es/plugins/olPlugin.js +9 -17
  33. package/es/plugins/paragraphPlugin.js +9 -16
  34. package/es/plugins/spanPlugin.js +6 -12
  35. package/es/plugins/tablePlugin.js +5 -10
  36. package/es/plugins/ulPlugin.js +6 -14
  37. package/es/transform.js +6 -6
  38. package/lib/extractEmbedMeta.js +7 -12
  39. package/lib/index.js +5 -6
  40. package/lib/plugins/anchorPlugin.js +17 -18
  41. package/lib/plugins/asidePlugin.js +1 -1
  42. package/lib/plugins/copyParagraphPlugin.js +3 -4
  43. package/lib/plugins/ddPlugin.js +13 -16
  44. package/lib/plugins/divPlugin.js +25 -41
  45. package/lib/plugins/dtPlugin.js +13 -16
  46. package/lib/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
  47. package/lib/plugins/embed/audioEmbedPlugin.js +4 -5
  48. package/lib/plugins/embed/blogPostEmbedPlugin.js +15 -16
  49. package/lib/plugins/embed/brightcoveEmbedPlugin.js +4 -5
  50. package/lib/plugins/embed/campaignBlockPlugin.js +4 -4
  51. package/lib/plugins/embed/codeEmbedPlugin.js +3 -3
  52. package/lib/plugins/embed/conceptEmbedPlugin.js +4 -5
  53. package/lib/plugins/embed/conceptListEmbedPlugin.js +3 -3
  54. package/lib/plugins/embed/contactBlockEmbedPlugin.js +13 -13
  55. package/lib/plugins/embed/contentLinkEmbedPlugin.js +6 -4
  56. package/lib/plugins/embed/externalEmbedPlugin.js +3 -3
  57. package/lib/plugins/embed/fileEmbedPlugin.js +9 -8
  58. package/lib/plugins/embed/footnoteEmbedPlugin.js +3 -3
  59. package/lib/plugins/embed/h5pEmbedPlugin.js +3 -3
  60. package/lib/plugins/embed/iframeEmbedPlugin.js +3 -3
  61. package/lib/plugins/embed/imageEmbedPlugin.js +6 -7
  62. package/lib/plugins/embed/index.js +2 -3
  63. package/lib/plugins/embed/linkBlockEmbedPlugin.js +14 -17
  64. package/lib/plugins/embed/relatedContentEmbedPlugin.js +3 -3
  65. package/lib/plugins/h3Plugin.js +13 -16
  66. package/lib/plugins/index.js +12 -17
  67. package/lib/plugins/mathPlugin.js +9 -15
  68. package/lib/plugins/navPlugin.js +13 -16
  69. package/lib/plugins/oembed/anchorPlugin.js +17 -18
  70. package/lib/plugins/olPlugin.js +17 -23
  71. package/lib/plugins/paragraphPlugin.js +17 -22
  72. package/lib/plugins/spanPlugin.js +14 -18
  73. package/lib/plugins/tablePlugin.js +13 -16
  74. package/lib/plugins/ulPlugin.js +14 -20
  75. package/lib/transform.js +7 -8
  76. package/package.json +8 -5
@@ -7,15 +7,15 @@
7
7
  */
8
8
 
9
9
  import parse from 'html-react-parser';
10
- var extractEmbedMeta = function extractEmbedMeta(embed) {
11
- var node = parse(embed);
10
+ const extractEmbedMeta = embed => {
11
+ const node = parse(embed);
12
12
  if (typeof node === 'string' || Array.isArray(node) || node.type !== 'ndlaembed' || !node.props['data-json']) {
13
13
  return;
14
14
  }
15
15
  return JSON.parse(node.props['data-json']);
16
16
  };
17
- export var extractEmbedMetas = function extractEmbedMetas(embed) {
18
- var nodes = parse(embed);
17
+ export const extractEmbedMetas = embed => {
18
+ const nodes = parse(embed);
19
19
 
20
20
  // There are no embeds in the string
21
21
  if (typeof nodes === 'string') {
@@ -26,12 +26,8 @@ export var extractEmbedMetas = function extractEmbedMetas(embed) {
26
26
  return [JSON.parse(nodes.props['data-json'])];
27
27
  }
28
28
  // There are multiple embeds in the string
29
- else if (Array.isArray(nodes) && nodes.length && nodes.every(function (n) {
30
- return n.type === 'ndlaembed' && !!n.props['data-json'];
31
- })) {
32
- return nodes.map(function (n) {
33
- return JSON.parse(n.props['data-json']);
34
- });
29
+ else if (Array.isArray(nodes) && nodes.length && nodes.every(n => n.type === 'ndlaembed' && !!n.props['data-json'])) {
30
+ return nodes.map(n => JSON.parse(n.props['data-json']));
35
31
  } else {
36
32
  return [];
37
33
  }
@@ -1,9 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
1
  /**
8
2
  * Copyright (c) 2023-present, NDLA.
9
3
  *
@@ -16,12 +10,15 @@ import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import SafeLink from '@ndla/safelink';
17
11
  import { getPossiblyRelativeUrl } from '@ndla/ui';
18
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
19
- export var anchorPlugin = function anchorPlugin(node, opts, _ref) {
20
- var path = _ref.path;
21
- var props = attributesToProps(node.attribs);
22
- var href = getPossiblyRelativeUrl(props.href, path);
23
- return _jsx(SafeLink, _objectSpread(_objectSpread({}, props), {}, {
13
+ export const anchorPlugin = (node, opts, _ref) => {
14
+ let {
15
+ path
16
+ } = _ref;
17
+ const props = attributesToProps(node.attribs);
18
+ const href = getPossiblyRelativeUrl(props.href, path);
19
+ return _jsx(SafeLink, {
20
+ ...props,
24
21
  to: href,
25
22
  children: domToReact(node.children, opts)
26
- }));
23
+ });
27
24
  };
@@ -9,7 +9,7 @@
9
9
  import { domToReact } from 'html-react-parser';
10
10
  import { Aside, FactBox } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var asidePlugin = function asidePlugin(node, opts) {
12
+ export const asidePlugin = (node, opts) => {
13
13
  if (node.attribs['data-type'] === 'factAside') {
14
14
  return _jsx(FactBox, {
15
15
  children: domToReact(node.children, opts)
@@ -9,10 +9,9 @@
9
9
  import { CopyParagraphButton } 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, converterOpts, opts) {
13
- var _parent$attribs;
14
- var parent = node.parent;
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) {
12
+ export const copyParagraphPlugin = (node, converterOpts, opts) => {
13
+ const parent = node.parent;
14
+ if (parent?.name === 'section' || parent?.name === 'div' && Object.keys(parent.attribs ?? {}).length === 0) {
16
15
  return _jsx(CopyParagraphButton, {
17
16
  copyText: node.attribs['data-text'],
18
17
  lang: opts.articleLanguage,
@@ -1,9 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
1
  /**
8
2
  * Copyright (c) 2023-present, NDLA.
9
3
  *
@@ -15,10 +9,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { DefinitionDescription } from '@ndla/ui';
16
10
  import { attributesToProps, domToReact } from 'html-react-parser';
17
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var ddPlugin = function ddPlugin(node, converterOpts, opts) {
19
- var props = attributesToProps(node.attribs);
20
- return _jsx(DefinitionDescription, _objectSpread(_objectSpread({}, props), {}, {
12
+ export const ddPlugin = (node, converterOpts, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx(DefinitionDescription, {
15
+ ...props,
21
16
  lang: opts.articleLanguage,
22
17
  children: domToReact(node.children, converterOpts)
23
- }));
18
+ });
24
19
  };
@@ -1,15 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
6
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
7
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
1
  /**
14
2
  * Copyright (c) 2023-present, NDLA.
15
3
  *
@@ -24,42 +12,36 @@ import { FileList, RelatedArticleList, Grid, GridParallaxItem } from '@ndla/ui';
24
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
25
13
  import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
26
14
  import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
27
- export var divPlugin = function divPlugin(node, opts) {
15
+ export const divPlugin = (node, opts) => {
28
16
  if (node.attribs['data-type'] === 'related-content' && node.children.length) {
29
- var props = attributesToProps(node.attribs);
30
- return _jsx(RelatedArticleList, _objectSpread(_objectSpread({}, props), {}, {
17
+ const props = attributesToProps(node.attribs);
18
+ return _jsx(RelatedArticleList, {
19
+ ...props,
31
20
  headingLevel: "h3",
32
21
  children: domToReact(node.children, opts)
33
- }));
34
- } else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
35
- var elements = node.childNodes.filter(function (c) {
36
- return c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file';
37
22
  });
38
- var _partition = partition(elements, function (el) {
39
- return el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block';
40
- }),
41
- _partition2 = _slicedToArray(_partition, 2),
42
- pdfs = _partition2[0],
43
- files = _partition2[1];
23
+ } else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
24
+ const elements = node.childNodes.filter(c => c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file');
25
+ const [pdfs, files] = partition(elements, el => el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block');
44
26
  return _jsxs(_Fragment, {
45
27
  children: [files.length ? _jsx(FileList, {
46
28
  children: domToReact(files, opts)
47
29
  }) : undefined, domToReact(pdfs, opts)]
48
30
  });
49
31
  } else if (node.attribs['data-type'] === 'grid' && node.children.length > 0) {
50
- var _props = attributesToProps(node.attribs);
51
- var columns = _props['data-columns'];
52
- var border = _props['data-border'];
53
- var background = _props['data-background'];
54
- var frontpage = !!_props['data-size'];
55
- return _jsx(Grid, _objectSpread(_objectSpread({
32
+ const props = attributesToProps(node.attribs);
33
+ const columns = props['data-columns'];
34
+ const border = props['data-border'];
35
+ const background = props['data-background'];
36
+ const frontpage = !!props['data-size'];
37
+ return _jsx(Grid, {
56
38
  isFrontpage: frontpage,
57
39
  border: border,
58
40
  columns: columns,
59
- background: background
60
- }, _props), {}, {
41
+ background: background,
42
+ ...props,
61
43
  children: domToReact(node.children, opts)
62
- }));
44
+ });
63
45
  } else if (node.attribs['data-parallax-cell'] === 'true' && node.children.length) {
64
46
  return _jsx(GridParallaxItem, {
65
47
  children: domToReact(node.children, opts)
@@ -1,9 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
1
  /**
8
2
  * Copyright (c) 2023-present, NDLA.
9
3
  *
@@ -15,10 +9,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { DefinitionTerm } from '@ndla/ui';
16
10
  import { attributesToProps, domToReact } from 'html-react-parser';
17
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var dtPlugin = function dtPlugin(node, converterOpts, opts) {
19
- var props = attributesToProps(node.attribs);
20
- return _jsx(DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
12
+ export const dtPlugin = (node, converterOpts, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx(DefinitionTerm, {
15
+ ...props,
21
16
  lang: opts.articleLanguage,
22
17
  children: domToReact(node.children, converterOpts)
23
- }));
18
+ });
24
19
  };
@@ -9,13 +9,14 @@
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, _, 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
- alt = _data$embedData.alt;
12
+ export const keyFigureEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
+ const {
16
+ title,
17
+ subtitle,
18
+ alt
19
+ } = data.embedData;
19
20
  return _jsx(KeyFigure, {
20
21
  title: title,
21
22
  subtitle: subtitle,
@@ -9,13 +9,12 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { AudioEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var audioEmbedPlugin = function audioEmbedPlugin(element, _, opts) {
13
- var _opts$components;
14
- var props = attributesToProps(element.attribs);
15
- var data = JSON.parse(props['data-json']);
12
+ export const audioEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
16
15
  return _jsx(AudioEmbed, {
17
16
  embed: data,
18
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
17
+ heartButton: opts.components?.heartButton,
19
18
  lang: opts.articleLanguage
20
19
  });
21
20
  };
@@ -9,22 +9,22 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { BlogPostV2 } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
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
- export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
14
- var _data$data$metaImage$, _data$data$metaImage;
15
- var props = attributesToProps(element.attribs);
16
- var data = JSON.parse(props['data-json']);
17
- var _data$embedData = data.embedData,
18
- title = _data$embedData.title,
19
- author = _data$embedData.author,
20
- url = _data$embedData.url,
21
- size = _data$embedData.size,
22
- language = _data$embedData.language,
23
- alt = _data$embedData.alt;
12
+ export const 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
+ export const blogPostEmbedPlugin = (element, _, opts) => {
14
+ const props = attributesToProps(element.attribs);
15
+ const data = JSON.parse(props['data-json']);
16
+ const {
17
+ title,
18
+ author,
19
+ url,
20
+ size,
21
+ language,
22
+ alt
23
+ } = data.embedData;
24
24
  return _jsx(BlogPostV2, {
25
25
  title: {
26
- title: title,
27
- language: language
26
+ title,
27
+ language
28
28
  },
29
29
  author: author,
30
30
  url: url,
@@ -32,7 +32,7 @@ export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts)
32
32
  path: opts.path,
33
33
  metaImage: {
34
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
35
+ url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc
36
36
  }
37
37
  });
38
38
  };
@@ -9,13 +9,12 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { BrightcoveEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var brightcoveEmbedPlugin = function brightcoveEmbedPlugin(element, _, opts) {
13
- var _opts$components;
14
- var props = attributesToProps(element.attribs);
15
- var data = JSON.parse(props['data-json']);
12
+ export const brightcoveEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
16
15
  return _jsx(BrightcoveEmbed, {
17
16
  embed: data,
18
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
17
+ heartButton: opts.components?.heartButton,
19
18
  renderContext: opts.renderContext
20
19
  });
21
20
  };
@@ -9,10 +9,10 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { CampaignBlock } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
15
- var embed = data.embedData;
12
+ export const campaignBlockPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
+ const embed = data.embedData;
16
16
  return _jsx(CampaignBlock, {
17
17
  title: {
18
18
  title: embed.title,
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { CodeEmbed } from '@ndla/code';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var codeEmbedPlugin = function codeEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const codeEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(CodeEmbed, {
16
16
  embed: data
17
17
  });
@@ -9,14 +9,13 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { ConceptEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var conceptEmbedPlugin = function conceptEmbedPlugin(element, _, opts) {
13
- var _opts$components;
14
- var props = attributesToProps(element.attribs);
15
- var data = JSON.parse(props['data-json']);
12
+ export const conceptEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
16
15
  return _jsx(ConceptEmbed, {
17
16
  embed: data,
18
17
  fullWidth: true,
19
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
18
+ heartButton: opts.components?.heartButton,
20
19
  lang: opts.articleLanguage
21
20
  });
22
21
  };
@@ -9,9 +9,9 @@
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, _, opts) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const conceptListEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(ConceptListEmbed, {
16
16
  embed: data,
17
17
  lang: opts.articleLanguage
@@ -9,18 +9,18 @@
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, _, opts) {
13
- var _opts$canonicalUrls;
14
- var props = attributesToProps(element.attribs);
15
- var embedData = JSON.parse(props['data-json']);
16
- var _embedData$embedData = embedData.embedData,
17
- name = _embedData$embedData.name,
18
- email = _embedData$embedData.email,
19
- description = _embedData$embedData.description,
20
- blob = _embedData$embedData.blob,
21
- blobColor = _embedData$embedData.blobColor,
22
- jobTitle = _embedData$embedData.jobTitle,
23
- alt = _embedData$embedData.alt;
12
+ export const contactBlockEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const embedData = JSON.parse(props['data-json']);
15
+ const {
16
+ name,
17
+ email,
18
+ description,
19
+ blob,
20
+ blobColor,
21
+ jobTitle,
22
+ alt
23
+ } = embedData.embedData;
24
24
  return _jsx(ContactBlock, {
25
25
  image: embedData.status === 'success' ? embedData.data.image : undefined,
26
26
  embedAlt: alt,
@@ -31,6 +31,6 @@ export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _
31
31
  name: name,
32
32
  blob: blob,
33
33
  lang: opts.articleLanguage,
34
- imageCanonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image
34
+ imageCanonicalUrl: opts.canonicalUrls?.image
35
35
  });
36
36
  };
@@ -9,10 +9,12 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { ContentLinkEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var contentLinkEmbedPlugin = function contentLinkEmbedPlugin(element, _, _ref) {
13
- var isOembed = _ref.isOembed;
14
- var props = attributesToProps(element.attribs);
15
- var data = JSON.parse(props['data-json']);
12
+ export const contentLinkEmbedPlugin = (element, _, _ref) => {
13
+ let {
14
+ isOembed
15
+ } = _ref;
16
+ const props = attributesToProps(element.attribs);
17
+ const data = JSON.parse(props['data-json']);
16
18
  return _jsx(ContentLinkEmbed, {
17
19
  embed: data,
18
20
  isOembed: isOembed
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { ExternalEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var externalEmbedPlugin = function externalEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const externalEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(ExternalEmbed, {
16
16
  embed: data
17
17
  });
@@ -9,14 +9,15 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { PdfFile, File } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var fileEmbedPlugin = function fileEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
15
- var _data$embedData = data.embedData,
16
- type = _data$embedData.type,
17
- title = _data$embedData.title,
18
- url = _data$embedData.url,
19
- display = _data$embedData.display;
12
+ export const fileEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
+ const {
16
+ type,
17
+ title,
18
+ url,
19
+ display
20
+ } = data.embedData;
20
21
  if (type === 'pdf' && display === 'block') {
21
22
  return _jsx(PdfFile, {
22
23
  title: title,
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { FootnoteEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var footnoteEmbedPlugin = function footnoteEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const footnoteEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(FootnoteEmbed, {
16
16
  embed: data
17
17
  });
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { H5pEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var h5pEmbedPlugin = function h5pEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const h5pEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(H5pEmbed, {
16
16
  embed: data
17
17
  });
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { IframeEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var iframeEmbedPlugin = function iframeEmbedPlugin(element) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const iframeEmbedPlugin = element => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(IframeEmbed, {
16
16
  embed: data
17
17
  });
@@ -9,18 +9,17 @@
9
9
  import { ImageEmbed } 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 imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
13
- var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components, _opts$canonicalUrls;
14
- var props = attributesToProps(element.attribs);
15
- var data = JSON.parse(props['data-json']);
16
- var inGrid = ((_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : (_element$parentNode$p = _element$parentNode.parentNode) === null || _element$parentNode$p === void 0 ? void 0 : (_element$parentNode$p2 = _element$parentNode$p.attribs) === null || _element$parentNode$p2 === void 0 ? void 0 : _element$parentNode$p2['data-type']) === 'grid';
12
+ export const imageEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
+ const inGrid = element.parentNode?.parentNode?.attribs?.['data-type'] === 'grid';
17
16
  return _jsx(ImageEmbed, {
18
17
  inGrid: inGrid,
19
18
  embed: data,
20
19
  path: opts.path,
21
20
  previewAlt: opts.previewAlt,
22
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
23
- canonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image,
21
+ heartButton: opts.components?.heartButton,
22
+ canonicalUrl: opts.canonicalUrls?.image,
24
23
  lang: opts.articleLanguage,
25
24
  renderContext: opts.renderContext
26
25
  });
@@ -24,7 +24,7 @@ import { keyFigureEmbedPlugin } from './KeyFigureEmbedPlugin';
24
24
  import { contactBlockEmbedPlugin } from './contactBlockEmbedPlugin';
25
25
  import { campaignBlockPlugin } from './campaignBlockPlugin';
26
26
  import { linkBlockPlugin } from './linkBlockEmbedPlugin';
27
- export var embedPlugins = {
27
+ export const embedPlugins = {
28
28
  image: imageEmbedPlugin,
29
29
  audio: audioEmbedPlugin,
30
30
  h5p: h5pEmbedPlugin,
@@ -1,9 +1,3 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
1
  /**
8
2
  * Copyright (c) 2023-present, NDLA.
9
3
  *
@@ -15,10 +9,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { LinkBlock } from '@ndla/ui';
16
10
  import { attributesToProps } from 'html-react-parser';
17
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var linkBlockPlugin = function linkBlockPlugin(element, _, opts) {
19
- var props = attributesToProps(element.attribs);
20
- var data = JSON.parse(props['data-json']);
21
- return _jsx(LinkBlock, _objectSpread(_objectSpread({}, data.embedData), {}, {
12
+ export const linkBlockPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
+ return _jsx(LinkBlock, {
16
+ ...data.embedData,
22
17
  path: opts.path
23
- }));
18
+ });
24
19
  };