@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
@@ -9,9 +9,9 @@
9
9
  import { attributesToProps } from 'html-react-parser';
10
10
  import { RelatedContentEmbed } from '@ndla/ui';
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export var relatedContentEmbedPlugin = function relatedContentEmbedPlugin(element, _, opts) {
13
- var props = attributesToProps(element.attribs);
14
- var data = JSON.parse(props['data-json']);
12
+ export const relatedContentEmbedPlugin = (element, _, opts) => {
13
+ const props = attributesToProps(element.attribs);
14
+ const data = JSON.parse(props['data-json']);
15
15
  return _jsx(RelatedContentEmbed, {
16
16
  embed: data,
17
17
  subject: opts.subject,
@@ -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
  *
@@ -14,14 +8,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
14
8
 
15
9
  import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
17
- export var h3Plugin = function h3Plugin(node, converterOpts, opts) {
18
- var props = attributesToProps(node.attribs);
11
+ export const h3Plugin = (node, converterOpts, opts) => {
12
+ const props = attributesToProps(node.attribs);
19
13
  return (
20
14
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
21
- _jsx("h3", _objectSpread(_objectSpread({}, props), {}, {
15
+ _jsx("h3", {
16
+ ...props,
22
17
  tabIndex: 0,
23
18
  lang: opts.articleLanguage,
24
19
  children: domToReact(node.children, converterOpts)
25
- }))
20
+ })
26
21
  );
27
22
  };
@@ -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
  *
@@ -27,7 +21,7 @@ import { ddPlugin } from './ddPlugin';
27
21
  import { dtPlugin } from './dtPlugin';
28
22
  import { navPlugin } from './navPlugin';
29
23
  import { anchorPlugin } from './anchorPlugin';
30
- export var basePlugins = {
24
+ export const basePlugins = {
31
25
  h2: copyParagraphPlugin,
32
26
  h3: h3Plugin,
33
27
  ol: olPlugin,
@@ -43,6 +37,7 @@ export var basePlugins = {
43
37
  nav: navPlugin,
44
38
  a: anchorPlugin
45
39
  };
46
- export var oembedPlugins = _objectSpread(_objectSpread({}, basePlugins), {}, {
40
+ export const oembedPlugins = {
41
+ ...basePlugins,
47
42
  a: oembedAnchorPlugin
48
- });
43
+ };
@@ -1,12 +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
- var _excluded = ["data-math"];
3
- 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; }
4
- 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; }
5
- 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; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- 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); }
8
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
1
  /**
11
2
  * Copyright (c) 2023-present, NDLA.
12
3
  *
@@ -17,14 +8,16 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
17
8
 
18
9
  import { attributesToProps } from 'html-react-parser';
19
10
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
20
- export var mathPlugin = function mathPlugin(node) {
21
- var _attributesToProps = attributesToProps(node.attribs),
22
- mathContent = _attributesToProps['data-math'],
23
- props = _objectWithoutProperties(_attributesToProps, _excluded);
11
+ export const mathPlugin = node => {
12
+ const {
13
+ 'data-math': mathContent,
14
+ ...props
15
+ } = attributesToProps(node.attribs);
24
16
  // @ts-ignore
25
- return _jsx("math", _objectSpread(_objectSpread({}, props), {}, {
17
+ return _jsx("math", {
18
+ ...props,
26
19
  dangerouslySetInnerHTML: {
27
20
  __html: mathContent
28
21
  }
29
- }));
22
+ });
30
23
  };
@@ -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,12 +9,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import { LinkBlockSection } from '@ndla/ui';
17
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
18
- export var navPlugin = function navPlugin(node, opts) {
12
+ export const navPlugin = (node, opts) => {
19
13
  if (node.attribs['data-type'] === 'link-block-list') {
20
- var props = attributesToProps(node.attribs);
21
- return _jsx(LinkBlockSection, _objectSpread(_objectSpread({}, props), {}, {
14
+ const props = attributesToProps(node.attribs);
15
+ return _jsx(LinkBlockSection, {
16
+ ...props,
22
17
  children: domToReact(node.children, opts)
23
- }));
18
+ });
24
19
  }
25
20
  return null;
26
21
  };
@@ -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,14 +10,17 @@ import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import { getPossiblyRelativeUrl } from '@ndla/ui';
17
11
  import SafeLink from '@ndla/safelink';
18
12
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
19
- export var anchorPlugin = function anchorPlugin(node, options, _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, options, _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
  target: "_blank",
25
22
  to: href,
26
23
  rel: "noreferrer",
27
24
  children: domToReact(node.children, options)
28
- }));
25
+ });
29
26
  };
@@ -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,18 +9,16 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { OrderedList } 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 olPlugin = function olPlugin(node, converterOpts, opts) {
19
- var _node$attribs$class;
20
- var props = attributesToProps(node.attribs);
21
- var letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
22
- var num = node.attribs['start'];
23
- var numClass = num ? "ol-reset-".concat(num) : false;
24
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : false, letterClass, numClass].filter(function (c) {
25
- return !!c;
26
- }).join(' ');
27
- return _jsx(OrderedList, _objectSpread(_objectSpread({}, props), {}, {
12
+ export const olPlugin = (node, converterOpts, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ const letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
15
+ const num = node.attribs['start'];
16
+ const numClass = num ? `ol-reset-${num}` : false;
17
+ const classes = [node.attribs.class ?? false, letterClass, numClass].filter(c => !!c).join(' ');
18
+ return _jsx(OrderedList, {
19
+ ...props,
28
20
  className: classes.length ? classes : undefined,
29
21
  lang: opts.articleLanguage,
30
22
  children: domToReact(node.children, converterOpts)
31
- }));
23
+ });
32
24
  };
@@ -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
  *
@@ -14,22 +8,21 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
14
8
 
15
9
  import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
17
- export var paragraphPlugin = function paragraphPlugin(node, converterOpts, opts) {
18
- var props = attributesToProps(node.attribs);
11
+ export const paragraphPlugin = (node, converterOpts, opts) => {
12
+ const props = attributesToProps(node.attribs);
19
13
  if (node.attribs['data-align'] === 'center') {
20
- var _node$attribs$class;
21
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'u-text-center'].filter(function (c) {
22
- return !!c;
23
- }).join(' ');
24
- return _jsx("p", _objectSpread(_objectSpread({}, props), {}, {
14
+ const classes = [node.attribs.class ?? '', 'u-text-center'].filter(c => !!c).join(' ');
15
+ return _jsx("p", {
16
+ ...props,
25
17
  lang: opts.articleLanguage,
26
18
  "data-align": undefined,
27
19
  className: classes,
28
20
  children: domToReact(node.children, converterOpts)
29
- }));
21
+ });
30
22
  }
31
- return _jsx("p", _objectSpread(_objectSpread({}, props), {}, {
23
+ return _jsx("p", {
24
+ ...props,
32
25
  lang: opts.articleLanguage,
33
26
  children: domToReact(node.children, converterOpts)
34
- }));
27
+ });
35
28
  };
@@ -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
  *
@@ -14,15 +8,15 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
14
8
 
15
9
  import { attributesToProps, domToReact } from 'html-react-parser';
16
10
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
17
- export var spanPlugin = function spanPlugin(node, opts) {
11
+ export const spanPlugin = (node, opts) => {
18
12
  if (node.attribs['data-size'] === 'large') {
19
- var _node$attribs$class;
20
- var props = attributesToProps(node.attribs);
21
- return _jsx("span", _objectSpread(_objectSpread({}, props), {}, {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx("span", {
15
+ ...props,
22
16
  "data-size": undefined,
23
- className: "".concat((_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', " u-large-body-text"),
17
+ className: `${node.attribs.class ?? ''} u-large-body-text`,
24
18
  children: domToReact(node.children, opts)
25
- }));
19
+ });
26
20
  }
27
21
  return null;
28
22
  };
@@ -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 { Table } 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 tablePlugin = function tablePlugin(node, converterOpts, opts) {
19
- var props = attributesToProps(node.attribs);
20
- return _jsx(Table, _objectSpread(_objectSpread({}, props), {}, {
12
+ export const tablePlugin = (node, converterOpts, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx(Table, {
15
+ ...props,
21
16
  lang: opts.articleLanguage,
22
17
  children: domToReact(node.children, converterOpts)
23
- }));
18
+ });
24
19
  };
@@ -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,15 +9,13 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
9
  import { UnOrderedList } 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 ulPlugin = function ulPlugin(node, converterOpts, opts) {
19
- var _node$attribs$class;
20
- var props = attributesToProps(node.attribs);
21
- var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(function (c) {
22
- return !!c;
23
- }).join(' ');
24
- return _jsx(UnOrderedList, _objectSpread(_objectSpread({}, props), {}, {
12
+ export const ulPlugin = (node, converterOpts, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ const classes = [node.attribs.class ?? '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(c => !!c).join(' ');
15
+ return _jsx(UnOrderedList, {
16
+ ...props,
25
17
  className: classes,
26
18
  lang: opts.articleLanguage,
27
19
  children: domToReact(node.children, converterOpts)
28
- }));
20
+ });
29
21
  };
package/es/transform.js CHANGED
@@ -11,10 +11,10 @@ import { UnknownEmbed } from '@ndla/ui';
11
11
  import { basePlugins, oembedPlugins } from './plugins';
12
12
  import { embedPlugins } from './plugins/embed';
13
13
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
- var transform = function transform(content, opts) {
15
- var plugins = opts !== null && opts !== void 0 && opts.isOembed ? oembedPlugins : basePlugins;
16
- var options = {
17
- replace: function replace(node) {
14
+ const transform = (content, opts) => {
15
+ const plugins = opts?.isOembed ? oembedPlugins : basePlugins;
16
+ const options = {
17
+ replace: node => {
18
18
  if (!('attribs' in node)) {
19
19
  return;
20
20
  }
@@ -25,7 +25,7 @@ var transform = function transform(content, opts) {
25
25
  if (embedPlugins[node.attribs['data-resource']]) {
26
26
  return embedPlugins[node.attribs['data-resource']](node, options, opts);
27
27
  } else {
28
- var embed = JSON.parse(node.attribs['data-json']);
28
+ const embed = JSON.parse(node.attribs['data-json']);
29
29
  return _jsx(UnknownEmbed, {
30
30
  embed: embed
31
31
  });
@@ -33,7 +33,7 @@ var transform = function transform(content, opts) {
33
33
  }
34
34
  }
35
35
  };
36
- var replaced = parse(content, options);
36
+ const replaced = parse(content, options);
37
37
  return replaced;
38
38
  };
39
39
  export default transform;
@@ -14,15 +14,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  *
15
15
  */
16
16
 
17
- var extractEmbedMeta = function extractEmbedMeta(embed) {
18
- var node = (0, _htmlReactParser.default)(embed);
17
+ const extractEmbedMeta = embed => {
18
+ const node = (0, _htmlReactParser.default)(embed);
19
19
  if (typeof node === 'string' || Array.isArray(node) || node.type !== 'ndlaembed' || !node.props['data-json']) {
20
20
  return;
21
21
  }
22
22
  return JSON.parse(node.props['data-json']);
23
23
  };
24
- var extractEmbedMetas = function extractEmbedMetas(embed) {
25
- var nodes = (0, _htmlReactParser.default)(embed);
24
+ const extractEmbedMetas = embed => {
25
+ const nodes = (0, _htmlReactParser.default)(embed);
26
26
 
27
27
  // There are no embeds in the string
28
28
  if (typeof nodes === 'string') {
@@ -33,16 +33,11 @@ var extractEmbedMetas = function extractEmbedMetas(embed) {
33
33
  return [JSON.parse(nodes.props['data-json'])];
34
34
  }
35
35
  // There are multiple embeds in the string
36
- else if (Array.isArray(nodes) && nodes.length && nodes.every(function (n) {
37
- return n.type === 'ndlaembed' && !!n.props['data-json'];
38
- })) {
39
- return nodes.map(function (n) {
40
- return JSON.parse(n.props['data-json']);
41
- });
36
+ else if (Array.isArray(nodes) && nodes.length && nodes.every(n => n.type === 'ndlaembed' && !!n.props['data-json'])) {
37
+ return nodes.map(n => JSON.parse(n.props['data-json']));
42
38
  } else {
43
39
  return [];
44
40
  }
45
41
  };
46
42
  exports.extractEmbedMetas = extractEmbedMetas;
47
- var _default = extractEmbedMeta;
48
- exports.default = _default;
43
+ var _default = exports.default = extractEmbedMeta;
package/lib/index.js CHANGED
@@ -1,29 +1,28 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  Object.defineProperty(exports, "extractEmbedMeta", {
8
7
  enumerable: true,
9
- get: function get() {
8
+ get: function () {
10
9
  return _extractEmbedMeta.default;
11
10
  }
12
11
  });
13
12
  Object.defineProperty(exports, "extractEmbedMetas", {
14
13
  enumerable: true,
15
- get: function get() {
14
+ get: function () {
16
15
  return _extractEmbedMeta.extractEmbedMetas;
17
16
  }
18
17
  });
19
18
  Object.defineProperty(exports, "transform", {
20
19
  enumerable: true,
21
- get: function get() {
20
+ get: function () {
22
21
  return _transform.default;
23
22
  }
24
23
  });
25
24
  var _transform = _interopRequireDefault(require("./transform"));
26
25
  var _extractEmbedMeta = _interopRequireWildcard(require("./extractEmbedMeta"));
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
27
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -9,25 +9,24 @@ var _safelink = _interopRequireDefault(require("@ndla/safelink"));
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 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; }
14
- 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; }
15
- 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; }
16
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
- 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); } /**
18
- * Copyright (c) 2023-present, NDLA.
19
- *
20
- * This source code is licensed under the GPLv3 license found in the
21
- * LICENSE file in the root directory of this source tree.
22
- *
23
- */
24
- var anchorPlugin = function anchorPlugin(node, opts, _ref) {
25
- var path = _ref.path;
26
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
27
- var href = (0, _ui.getPossiblyRelativeUrl)(props.href, path);
28
- return (0, _jsxRuntime.jsx)(_safelink.default, _objectSpread(_objectSpread({}, props), {}, {
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 anchorPlugin = (node, opts, _ref) => {
21
+ let {
22
+ path
23
+ } = _ref;
24
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
25
+ const href = (0, _ui.getPossiblyRelativeUrl)(props.href, path);
26
+ return (0, _jsxRuntime.jsx)(_safelink.default, {
27
+ ...props,
29
28
  to: href,
30
29
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
31
- }));
30
+ });
32
31
  };
33
32
  exports.anchorPlugin = anchorPlugin;
@@ -15,7 +15,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var asidePlugin = function asidePlugin(node, opts) {
18
+ const asidePlugin = (node, opts) => {
19
19
  if (node.attribs['data-type'] === 'factAside') {
20
20
  return (0, _jsxRuntime.jsx)(_ui.FactBox, {
21
21
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
@@ -15,10 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- var copyParagraphPlugin = function copyParagraphPlugin(node, converterOpts, opts) {
19
- var _parent$attribs;
20
- var parent = node.parent;
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) {
18
+ const copyParagraphPlugin = (node, converterOpts, opts) => {
19
+ const parent = node.parent;
20
+ if (parent?.name === 'section' || parent?.name === 'div' && Object.keys(parent.attribs ?? {}).length === 0) {
22
21
  return (0, _jsxRuntime.jsx)(_ui.CopyParagraphButton, {
23
22
  copyText: node.attribs['data-text'],
24
23
  lang: opts.articleLanguage,
@@ -7,23 +7,20 @@ exports.ddPlugin = 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 ddPlugin = function ddPlugin(node, converterOpts, opts) {
23
- var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
24
- return (0, _jsxRuntime.jsx)(_ui.DefinitionDescription, _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 ddPlugin = (node, converterOpts, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)(_ui.DefinitionDescription, {
21
+ ...props,
25
22
  lang: opts.articleLanguage,
26
23
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
27
- }));
24
+ });
28
25
  };
29
26
  exports.ddPlugin = ddPlugin;