@ndla/article-converter 6.0.15 → 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 +3 -3
@@ -4,65 +4,49 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.divPlugin = void 0;
7
- var _partition3 = _interopRequireDefault(require("lodash/partition"));
7
+ var _partition = _interopRequireDefault(require("lodash/partition"));
8
8
  var _htmlReactParser = require("html-react-parser");
9
9
  var _ui = require("@ndla/ui");
10
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
- 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); }
13
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
- 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."); }
15
- 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); }
16
- 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; }
17
- 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; } }
18
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
- 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; }
20
- 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; }
21
- 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; }
22
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
23
- 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); } /**
24
- * Copyright (c) 2023-present, NDLA.
25
- *
26
- * This source code is licensed under the GPLv3 license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- *
29
- */
30
- var divPlugin = function divPlugin(node, opts) {
12
+ /**
13
+ * Copyright (c) 2023-present, NDLA.
14
+ *
15
+ * This source code is licensed under the GPLv3 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+
20
+ const divPlugin = (node, opts) => {
31
21
  if (node.attribs['data-type'] === 'related-content' && node.children.length) {
32
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
33
- return (0, _jsxRuntime.jsx)(_ui.RelatedArticleList, _objectSpread(_objectSpread({}, props), {}, {
22
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
23
+ return (0, _jsxRuntime.jsx)(_ui.RelatedArticleList, {
24
+ ...props,
34
25
  headingLevel: "h3",
35
26
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
36
- }));
37
- } else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
38
- var elements = node.childNodes.filter(function (c) {
39
- return c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file';
40
27
  });
41
- var _partition = (0, _partition3.default)(elements, function (el) {
42
- return el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block';
43
- }),
44
- _partition2 = _slicedToArray(_partition, 2),
45
- pdfs = _partition2[0],
46
- files = _partition2[1];
28
+ } else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
29
+ const elements = node.childNodes.filter(c => c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file');
30
+ const [pdfs, files] = (0, _partition.default)(elements, el => el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block');
47
31
  return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
48
32
  children: [files.length ? (0, _jsxRuntime.jsx)(_ui.FileList, {
49
33
  children: (0, _htmlReactParser.domToReact)(files, opts)
50
34
  }) : undefined, (0, _htmlReactParser.domToReact)(pdfs, opts)]
51
35
  });
52
36
  } else if (node.attribs['data-type'] === 'grid' && node.children.length > 0) {
53
- var _props = (0, _htmlReactParser.attributesToProps)(node.attribs);
54
- var columns = _props['data-columns'];
55
- var border = _props['data-border'];
56
- var background = _props['data-background'];
57
- var frontpage = !!_props['data-size'];
58
- return (0, _jsxRuntime.jsx)(_ui.Grid, _objectSpread(_objectSpread({
37
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
38
+ const columns = props['data-columns'];
39
+ const border = props['data-border'];
40
+ const background = props['data-background'];
41
+ const frontpage = !!props['data-size'];
42
+ return (0, _jsxRuntime.jsx)(_ui.Grid, {
59
43
  isFrontpage: frontpage,
60
44
  border: border,
61
45
  columns: columns,
62
- background: background
63
- }, _props), {}, {
46
+ background: background,
47
+ ...props,
64
48
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
65
- }));
49
+ });
66
50
  } else if (node.attribs['data-parallax-cell'] === 'true' && node.children.length) {
67
51
  return (0, _jsxRuntime.jsx)(_ui.GridParallaxItem, {
68
52
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
@@ -7,23 +7,20 @@ exports.dtPlugin = void 0;
7
7
  var _ui = require("@ndla/ui");
8
8
  var _htmlReactParser = require("html-react-parser");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- 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); }
11
- 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; }
12
- 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; }
13
- 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; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
- 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); } /**
16
- * Copyright (c) 2023-present, NDLA.
17
- *
18
- * This source code is licensed under the GPLv3 license found in the
19
- * LICENSE file in the root directory of this source tree.
20
- *
21
- */
22
- var dtPlugin = function dtPlugin(node, converterOpts, opts) {
23
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
- return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
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
+ const dtPlugin = (node, converterOpts, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, {
21
+ ...props,
25
22
  lang: opts.articleLanguage,
26
23
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
27
- }));
24
+ });
28
25
  };
29
26
  exports.dtPlugin = dtPlugin;
@@ -15,13 +15,14 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var keyFigureEmbedPlugin = function keyFigureEmbedPlugin(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
- alt = _data$embedData.alt;
18
+ const keyFigureEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
+ const {
22
+ title,
23
+ subtitle,
24
+ alt
25
+ } = data.embedData;
25
26
  return (0, _jsxRuntime.jsx)(_ui.KeyFigure, {
26
27
  title: title,
27
28
  subtitle: subtitle,
@@ -15,13 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var audioEmbedPlugin = function audioEmbedPlugin(element, _, opts) {
19
- var _opts$components;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var data = JSON.parse(props['data-json']);
18
+ const audioEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
22
21
  return (0, _jsxRuntime.jsx)(_ui.AudioEmbed, {
23
22
  embed: data,
24
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
23
+ heartButton: opts.components?.heartButton,
25
24
  lang: opts.articleLanguage
26
25
  });
27
26
  };
@@ -15,23 +15,22 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
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
- exports.errorSvgSrc = errorSvgSrc;
20
- var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
21
- var _data$data$metaImage$, _data$data$metaImage;
22
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
23
- var data = JSON.parse(props['data-json']);
24
- var _data$embedData = data.embedData,
25
- title = _data$embedData.title,
26
- author = _data$embedData.author,
27
- url = _data$embedData.url,
28
- size = _data$embedData.size,
29
- language = _data$embedData.language,
30
- alt = _data$embedData.alt;
18
+ const errorSvgSrc = exports.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
+ const blogPostEmbedPlugin = (element, _, opts) => {
20
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
+ const data = JSON.parse(props['data-json']);
22
+ const {
23
+ title,
24
+ author,
25
+ url,
26
+ size,
27
+ language,
28
+ alt
29
+ } = data.embedData;
31
30
  return (0, _jsxRuntime.jsx)(_ui.BlogPostV2, {
32
31
  title: {
33
- title: title,
34
- language: language
32
+ title,
33
+ language
35
34
  },
36
35
  author: author,
37
36
  url: url,
@@ -39,7 +38,7 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
39
38
  path: opts.path,
40
39
  metaImage: {
41
40
  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
41
+ url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc
43
42
  }
44
43
  });
45
44
  };
@@ -15,13 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var brightcoveEmbedPlugin = function brightcoveEmbedPlugin(element, _, opts) {
19
- var _opts$components;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var data = JSON.parse(props['data-json']);
18
+ const brightcoveEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
22
21
  return (0, _jsxRuntime.jsx)(_ui.BrightcoveEmbed, {
23
22
  embed: data,
24
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
23
+ heartButton: opts.components?.heartButton,
25
24
  renderContext: opts.renderContext
26
25
  });
27
26
  };
@@ -15,10 +15,10 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
21
- var embed = data.embedData;
18
+ const campaignBlockPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
+ const embed = data.embedData;
22
22
  return (0, _jsxRuntime.jsx)(_ui.CampaignBlock, {
23
23
  title: {
24
24
  title: embed.title,
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var codeEmbedPlugin = function codeEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const codeEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_code.CodeEmbed, {
22
22
  embed: data
23
23
  });
@@ -15,14 +15,13 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var conceptEmbedPlugin = function conceptEmbedPlugin(element, _, opts) {
19
- var _opts$components;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var data = JSON.parse(props['data-json']);
18
+ const conceptEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
22
21
  return (0, _jsxRuntime.jsx)(_ui.ConceptEmbed, {
23
22
  embed: data,
24
23
  fullWidth: true,
25
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
24
+ heartButton: opts.components?.heartButton,
26
25
  lang: opts.articleLanguage
27
26
  });
28
27
  };
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var conceptListEmbedPlugin = function conceptListEmbedPlugin(element, _, opts) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const conceptListEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.ConceptListEmbed, {
22
22
  embed: data,
23
23
  lang: opts.articleLanguage
@@ -15,18 +15,18 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts) {
19
- var _opts$canonicalUrls;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var embedData = JSON.parse(props['data-json']);
22
- var _embedData$embedData = embedData.embedData,
23
- name = _embedData$embedData.name,
24
- email = _embedData$embedData.email,
25
- description = _embedData$embedData.description,
26
- blob = _embedData$embedData.blob,
27
- blobColor = _embedData$embedData.blobColor,
28
- jobTitle = _embedData$embedData.jobTitle,
29
- alt = _embedData$embedData.alt;
18
+ const contactBlockEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const embedData = JSON.parse(props['data-json']);
21
+ const {
22
+ name,
23
+ email,
24
+ description,
25
+ blob,
26
+ blobColor,
27
+ jobTitle,
28
+ alt
29
+ } = embedData.embedData;
30
30
  return (0, _jsxRuntime.jsx)(_ui.ContactBlock, {
31
31
  image: embedData.status === 'success' ? embedData.data.image : undefined,
32
32
  embedAlt: alt,
@@ -37,7 +37,7 @@ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts)
37
37
  name: name,
38
38
  blob: blob,
39
39
  lang: opts.articleLanguage,
40
- imageCanonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image
40
+ imageCanonicalUrl: opts.canonicalUrls?.image
41
41
  });
42
42
  };
43
43
  exports.contactBlockEmbedPlugin = contactBlockEmbedPlugin;
@@ -15,10 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var contentLinkEmbedPlugin = function contentLinkEmbedPlugin(element, _, _ref) {
19
- var isOembed = _ref.isOembed;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var data = JSON.parse(props['data-json']);
18
+ const contentLinkEmbedPlugin = (element, _, _ref) => {
19
+ let {
20
+ isOembed
21
+ } = _ref;
22
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
23
+ const data = JSON.parse(props['data-json']);
22
24
  return (0, _jsxRuntime.jsx)(_ui.ContentLinkEmbed, {
23
25
  embed: data,
24
26
  isOembed: isOembed
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var externalEmbedPlugin = function externalEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const externalEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.ExternalEmbed, {
22
22
  embed: data
23
23
  });
@@ -15,14 +15,15 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var fileEmbedPlugin = function fileEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
21
- var _data$embedData = data.embedData,
22
- type = _data$embedData.type,
23
- title = _data$embedData.title,
24
- url = _data$embedData.url,
25
- display = _data$embedData.display;
18
+ const fileEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
+ const {
22
+ type,
23
+ title,
24
+ url,
25
+ display
26
+ } = data.embedData;
26
27
  if (type === 'pdf' && display === 'block') {
27
28
  return (0, _jsxRuntime.jsx)(_ui.PdfFile, {
28
29
  title: title,
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var footnoteEmbedPlugin = function footnoteEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const footnoteEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.FootnoteEmbed, {
22
22
  embed: data
23
23
  });
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var h5pEmbedPlugin = function h5pEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const h5pEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.H5pEmbed, {
22
22
  embed: data
23
23
  });
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var iframeEmbedPlugin = function iframeEmbedPlugin(element) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const iframeEmbedPlugin = element => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.IframeEmbed, {
22
22
  embed: data
23
23
  });
@@ -15,18 +15,17 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
19
- var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components, _opts$canonicalUrls;
20
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
21
- var data = JSON.parse(props['data-json']);
22
- 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';
18
+ const imageEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
+ const inGrid = element.parentNode?.parentNode?.attribs?.['data-type'] === 'grid';
23
22
  return (0, _jsxRuntime.jsx)(_ui.ImageEmbed, {
24
23
  inGrid: inGrid,
25
24
  embed: data,
26
25
  path: opts.path,
27
26
  previewAlt: opts.previewAlt,
28
- heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
29
- canonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image,
27
+ heartButton: opts.components?.heartButton,
28
+ canonicalUrl: opts.canonicalUrls?.image,
30
29
  lang: opts.articleLanguage,
31
30
  renderContext: opts.renderContext
32
31
  });
@@ -30,7 +30,7 @@ var _linkBlockEmbedPlugin = require("./linkBlockEmbedPlugin");
30
30
  *
31
31
  */
32
32
 
33
- var embedPlugins = {
33
+ const embedPlugins = exports.embedPlugins = {
34
34
  image: _imageEmbedPlugin.imageEmbedPlugin,
35
35
  audio: _audioEmbedPlugin.audioEmbedPlugin,
36
36
  h5p: _h5pEmbedPlugin.h5pEmbedPlugin,
@@ -49,5 +49,4 @@ var embedPlugins = {
49
49
  'contact-block': _contactBlockEmbedPlugin.contactBlockEmbedPlugin,
50
50
  'campaign-block': _campaignBlockPlugin.campaignBlockPlugin,
51
51
  'link-block': _linkBlockEmbedPlugin.linkBlockPlugin
52
- };
53
- exports.embedPlugins = embedPlugins;
52
+ };
@@ -7,23 +7,20 @@ exports.linkBlockPlugin = void 0;
7
7
  var _ui = require("@ndla/ui");
8
8
  var _htmlReactParser = require("html-react-parser");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- 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); }
11
- 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; }
12
- 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; }
13
- 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; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
- 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); } /**
16
- * Copyright (c) 2023-present, NDLA.
17
- *
18
- * This source code is licensed under the GPLv3 license found in the
19
- * LICENSE file in the root directory of this source tree.
20
- *
21
- */
22
- var linkBlockPlugin = function linkBlockPlugin(element, _, opts) {
23
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
24
- var data = JSON.parse(props['data-json']);
25
- return (0, _jsxRuntime.jsx)(_ui.LinkBlock, _objectSpread(_objectSpread({}, data.embedData), {}, {
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
+ const linkBlockPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
+ return (0, _jsxRuntime.jsx)(_ui.LinkBlock, {
22
+ ...data.embedData,
26
23
  path: opts.path
27
- }));
24
+ });
28
25
  };
29
26
  exports.linkBlockPlugin = linkBlockPlugin;
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var relatedContentEmbedPlugin = function relatedContentEmbedPlugin(element, _, opts) {
19
- var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
- var data = JSON.parse(props['data-json']);
18
+ const relatedContentEmbedPlugin = (element, _, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
20
+ const data = JSON.parse(props['data-json']);
21
21
  return (0, _jsxRuntime.jsx)(_ui.RelatedContentEmbed, {
22
22
  embed: data,
23
23
  subject: opts.subject,
@@ -6,27 +6,24 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.h3Plugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
8
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
9
- 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); }
10
- 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; }
11
- 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; }
12
- 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; }
13
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
- 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); } /**
15
- * Copyright (c) 2023-present, NDLA.
16
- *
17
- * This source code is licensed under the GPLv3 license found in the
18
- * LICENSE file in the root directory of this source tree.
19
- *
20
- */
21
- var h3Plugin = function h3Plugin(node, converterOpts, opts) {
22
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
9
+ /**
10
+ * Copyright (c) 2023-present, NDLA.
11
+ *
12
+ * This source code is licensed under the GPLv3 license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ *
15
+ */
16
+
17
+ const h3Plugin = (node, converterOpts, opts) => {
18
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
23
19
  return (
24
20
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
25
- (0, _jsxRuntime.jsx)("h3", _objectSpread(_objectSpread({}, props), {}, {
21
+ (0, _jsxRuntime.jsx)("h3", {
22
+ ...props,
26
23
  tabIndex: 0,
27
24
  lang: opts.articleLanguage,
28
25
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
29
- }))
26
+ })
30
27
  );
31
28
  };
32
29
  exports.h3Plugin = h3Plugin;