@ndla/article-converter 1.0.1

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 (122) hide show
  1. package/LICENSE +674 -0
  2. package/es/extractEmbedMeta.js +17 -0
  3. package/es/index.js +10 -0
  4. package/es/plugins/AsidePlugin.js +25 -0
  5. package/es/plugins/CopyParagraphPlugin.js +17 -0
  6. package/es/plugins/DivPlugin.js +48 -0
  7. package/es/plugins/H3Plugin.js +23 -0
  8. package/es/plugins/MathPlugin.js +18 -0
  9. package/es/plugins/OLPlugin.js +28 -0
  10. package/es/plugins/ParagraphPlugin.js +28 -0
  11. package/es/plugins/SpanPlugin.js +25 -0
  12. package/es/plugins/TablePlugin.js +20 -0
  13. package/es/plugins/ULPlugin.js +28 -0
  14. package/es/plugins/embed/AudioEmbedPlugin.js +19 -0
  15. package/es/plugins/embed/BrightcoveEmbedPlugin.js +18 -0
  16. package/es/plugins/embed/CodeEmbedPlugin.js +18 -0
  17. package/es/plugins/embed/ConceptEmbedPlugin.js +19 -0
  18. package/es/plugins/embed/ConceptListEmbedPlugin.js +18 -0
  19. package/es/plugins/embed/ContentLinkEmbedPlugin.js +20 -0
  20. package/es/plugins/embed/ExternalEmbedPlugin.js +18 -0
  21. package/es/plugins/embed/FileEmbedPlugin.js +33 -0
  22. package/es/plugins/embed/FootnoteEmbedPlugin.js +18 -0
  23. package/es/plugins/embed/H5pEmbedPlugin.js +18 -0
  24. package/es/plugins/embed/IframeEmbedPlugin.js +18 -0
  25. package/es/plugins/embed/ImageEmbedPlugin.js +20 -0
  26. package/es/plugins/embed/RelatedContentEmbedPlugin.js +20 -0
  27. package/es/plugins/embed/index.js +36 -0
  28. package/es/plugins/index.js +35 -0
  29. package/es/plugins/oembed/AnchorPlugin.js +20 -0
  30. package/es/plugins/types.js +1 -0
  31. package/es/transform.js +39 -0
  32. package/lib/extractEmbedMeta.d.ts +10 -0
  33. package/lib/extractEmbedMeta.js +25 -0
  34. package/lib/index.d.ts +10 -0
  35. package/lib/index.js +20 -0
  36. package/lib/plugins/AsidePlugin.d.ts +9 -0
  37. package/lib/plugins/AsidePlugin.js +32 -0
  38. package/lib/plugins/CopyParagraphPlugin.d.ts +9 -0
  39. package/lib/plugins/CopyParagraphPlugin.js +24 -0
  40. package/lib/plugins/DivPlugin.d.ts +9 -0
  41. package/lib/plugins/DivPlugin.js +46 -0
  42. package/lib/plugins/H3Plugin.d.ts +9 -0
  43. package/lib/plugins/H3Plugin.js +22 -0
  44. package/lib/plugins/MathPlugin.d.ts +9 -0
  45. package/lib/plugins/MathPlugin.js +25 -0
  46. package/lib/plugins/OLPlugin.d.ts +9 -0
  47. package/lib/plugins/OLPlugin.js +27 -0
  48. package/lib/plugins/ParagraphPlugin.d.ts +9 -0
  49. package/lib/plugins/ParagraphPlugin.js +27 -0
  50. package/lib/plugins/SpanPlugin.d.ts +9 -0
  51. package/lib/plugins/SpanPlugin.js +24 -0
  52. package/lib/plugins/TablePlugin.d.ts +9 -0
  53. package/lib/plugins/TablePlugin.js +19 -0
  54. package/lib/plugins/ULPlugin.d.ts +9 -0
  55. package/lib/plugins/ULPlugin.js +27 -0
  56. package/lib/plugins/embed/AudioEmbedPlugin.d.ts +9 -0
  57. package/lib/plugins/embed/AudioEmbedPlugin.js +26 -0
  58. package/lib/plugins/embed/BrightcoveEmbedPlugin.d.ts +9 -0
  59. package/lib/plugins/embed/BrightcoveEmbedPlugin.js +25 -0
  60. package/lib/plugins/embed/CodeEmbedPlugin.d.ts +9 -0
  61. package/lib/plugins/embed/CodeEmbedPlugin.js +25 -0
  62. package/lib/plugins/embed/ConceptEmbedPlugin.d.ts +9 -0
  63. package/lib/plugins/embed/ConceptEmbedPlugin.js +26 -0
  64. package/lib/plugins/embed/ConceptListEmbedPlugin.d.ts +9 -0
  65. package/lib/plugins/embed/ConceptListEmbedPlugin.js +25 -0
  66. package/lib/plugins/embed/ContentLinkEmbedPlugin.d.ts +9 -0
  67. package/lib/plugins/embed/ContentLinkEmbedPlugin.js +27 -0
  68. package/lib/plugins/embed/ExternalEmbedPlugin.d.ts +9 -0
  69. package/lib/plugins/embed/ExternalEmbedPlugin.js +25 -0
  70. package/lib/plugins/embed/FileEmbedPlugin.d.ts +9 -0
  71. package/lib/plugins/embed/FileEmbedPlugin.js +40 -0
  72. package/lib/plugins/embed/FootnoteEmbedPlugin.d.ts +9 -0
  73. package/lib/plugins/embed/FootnoteEmbedPlugin.js +25 -0
  74. package/lib/plugins/embed/H5pEmbedPlugin.d.ts +9 -0
  75. package/lib/plugins/embed/H5pEmbedPlugin.js +25 -0
  76. package/lib/plugins/embed/IframeEmbedPlugin.d.ts +9 -0
  77. package/lib/plugins/embed/IframeEmbedPlugin.js +25 -0
  78. package/lib/plugins/embed/ImageEmbedPlugin.d.ts +9 -0
  79. package/lib/plugins/embed/ImageEmbedPlugin.js +27 -0
  80. package/lib/plugins/embed/RelatedContentEmbedPlugin.d.ts +9 -0
  81. package/lib/plugins/embed/RelatedContentEmbedPlugin.js +27 -0
  82. package/lib/plugins/embed/index.d.ts +9 -0
  83. package/lib/plugins/embed/index.js +43 -0
  84. package/lib/plugins/index.d.ts +10 -0
  85. package/lib/plugins/index.js +35 -0
  86. package/lib/plugins/oembed/AnchorPlugin.d.ts +9 -0
  87. package/lib/plugins/oembed/AnchorPlugin.js +19 -0
  88. package/lib/plugins/types.d.ts +17 -0
  89. package/lib/plugins/types.js +5 -0
  90. package/lib/transform.d.ts +11 -0
  91. package/lib/transform.js +47 -0
  92. package/package.json +48 -0
  93. package/src/extractEmbedMeta.ts +21 -0
  94. package/src/index.ts +11 -0
  95. package/src/plugins/AsidePlugin.tsx +24 -0
  96. package/src/plugins/CopyParagraphPlugin.tsx +18 -0
  97. package/src/plugins/DivPlugin.tsx +40 -0
  98. package/src/plugins/H3Plugin.tsx +19 -0
  99. package/src/plugins/MathPlugin.tsx +14 -0
  100. package/src/plugins/OLPlugin.tsx +23 -0
  101. package/src/plugins/ParagraphPlugin.tsx +23 -0
  102. package/src/plugins/SpanPlugin.tsx +22 -0
  103. package/src/plugins/TablePlugin.tsx +15 -0
  104. package/src/plugins/ULPlugin.tsx +23 -0
  105. package/src/plugins/embed/AudioEmbedPlugin.tsx +18 -0
  106. package/src/plugins/embed/BrightcoveEmbedPlugin.tsx +18 -0
  107. package/src/plugins/embed/CodeEmbedPlugin.tsx +18 -0
  108. package/src/plugins/embed/ConceptEmbedPlugin.tsx +18 -0
  109. package/src/plugins/embed/ConceptListEmbedPlugin.tsx +18 -0
  110. package/src/plugins/embed/ContentLinkEmbedPlugin.tsx +18 -0
  111. package/src/plugins/embed/ExternalEmbedPlugin.tsx +18 -0
  112. package/src/plugins/embed/FileEmbedPlugin.tsx +31 -0
  113. package/src/plugins/embed/FootnoteEmbedPlugin.tsx +18 -0
  114. package/src/plugins/embed/H5pEmbedPlugin.tsx +18 -0
  115. package/src/plugins/embed/IframeEmbedPlugin.tsx +18 -0
  116. package/src/plugins/embed/ImageEmbedPlugin.tsx +18 -0
  117. package/src/plugins/embed/RelatedContentEmbedPlugin.tsx +18 -0
  118. package/src/plugins/embed/index.ts +38 -0
  119. package/src/plugins/index.ts +36 -0
  120. package/src/plugins/oembed/AnchorPlugin.tsx +18 -0
  121. package/src/plugins/types.ts +23 -0
  122. package/src/transform.tsx +41 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import parse from 'html-react-parser';
10
+ var extractEmbedMeta = function extractEmbedMeta(embed) {
11
+ var node = parse(embed);
12
+ if (typeof node === 'string' || Array.isArray(node) || node.type !== 'ndlaembed' || !node.props['data-json']) {
13
+ return;
14
+ }
15
+ return JSON.parse(node.props['data-json']);
16
+ };
17
+ export default extractEmbedMeta;
package/es/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export { default as transform } from './transform';
10
+ export { default as extractEmbedMeta } from './extractEmbedMeta';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { domToReact } from 'html-react-parser';
10
+ import { Aside, FactBoxV2 } from '@ndla/ui';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var AsidePlugin = function AsidePlugin(node, opts) {
13
+ if (node.attribs['data-type'] === 'factAside') {
14
+ return _jsx(FactBoxV2, {
15
+ children: domToReact(node.children, opts)
16
+ });
17
+ } else if (node.attribs['data-type'] === 'rightAside') {
18
+ return _jsx(Aside, {
19
+ wideScreen: true,
20
+ alwaysShow: true,
21
+ children: domToReact(node.children, opts)
22
+ });
23
+ }
24
+ return null;
25
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { CopyParagraphButtonV2 } from '@ndla/ui';
10
+ import { domToReact } from 'html-react-parser';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var CopyParagraphPlugin = function CopyParagraphPlugin(node, opts) {
13
+ return _jsx(CopyParagraphButtonV2, {
14
+ copyText: node.attribs['data-text'],
15
+ children: domToReact(node.children, opts)
16
+ });
17
+ };
@@ -0,0 +1,48 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ 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; }
8
+ 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; }
9
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
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
+ import partition from 'lodash/partition';
19
+ import { domToReact, attributesToProps } from 'html-react-parser';
20
+ import { FileListV2, RelatedArticleListV2 } from '@ndla/ui';
21
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
22
+ import { Fragment as _Fragment } from "@emotion/react/jsx-runtime";
23
+ import { jsxs as _jsxs } from "@emotion/react/jsx-runtime";
24
+ export var DivPlugin = function DivPlugin(node, opts) {
25
+ if (node.attribs['data-type'] === 'related-content' && node.children.length) {
26
+ var props = attributesToProps(node.attribs);
27
+ return _jsx(RelatedArticleListV2, _objectSpread(_objectSpread({}, props), {}, {
28
+ headingLevel: "h3",
29
+ children: domToReact(node.children, opts)
30
+ }));
31
+ } else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
32
+ var elements = node.childNodes.filter(function (c) {
33
+ return c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file';
34
+ });
35
+ var _partition = partition(elements, function (el) {
36
+ return el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block';
37
+ }),
38
+ _partition2 = _slicedToArray(_partition, 2),
39
+ pdfs = _partition2[0],
40
+ files = _partition2[1];
41
+ return _jsxs(_Fragment, {
42
+ children: [files.length ? _jsx(FileListV2, {
43
+ children: domToReact(files, opts)
44
+ }) : undefined, domToReact(pdfs, opts)]
45
+ });
46
+ }
47
+ return null;
48
+ };
@@ -0,0 +1,23 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { attributesToProps, domToReact } from 'html-react-parser';
13
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
+ export var H3Plugin = function H3Plugin(node, opts) {
15
+ var props = attributesToProps(node.attribs);
16
+ return (
17
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
18
+ _jsx("h3", _objectSpread(_objectSpread({}, props), {}, {
19
+ tabIndex: 0,
20
+ children: domToReact(node.children, opts)
21
+ }))
22
+ );
23
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
11
+ export var MathPlugin = function MathPlugin(node) {
12
+ var props = attributesToProps(node.attribs);
13
+ return _jsx("span", {
14
+ dangerouslySetInnerHTML: {
15
+ __html: "<math display=\"block\">".concat(props['data-math'], "</math>")
16
+ }
17
+ });
18
+ };
@@ -0,0 +1,28 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { attributesToProps, domToReact } from 'html-react-parser';
13
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
+ export var OLPlugin = function OLPlugin(node, opts) {
15
+ var _node$attribs$class;
16
+ var props = attributesToProps(node.attribs);
17
+ var letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
18
+ var num = node.attribs['start'];
19
+ var numClass = num ? "ol-reset-".concat(num) : false;
20
+ var classes = [(_node$attribs$class = node.attribs["class"]) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : false, letterClass, numClass].filter(function (c) {
21
+ return !!c;
22
+ }).join(' ');
23
+ return _jsx("ol", _objectSpread(_objectSpread({}, props), {}, {
24
+ "data-type": undefined,
25
+ className: classes.length ? classes : undefined,
26
+ children: domToReact(node.children, opts)
27
+ }));
28
+ };
@@ -0,0 +1,28 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { attributesToProps, domToReact } from 'html-react-parser';
13
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
+ export var ParagraphPlugin = function ParagraphPlugin(node, opts) {
15
+ if (node.attribs['data-align'] === 'center') {
16
+ var _node$attribs$class;
17
+ var props = attributesToProps(node.attribs);
18
+ var classes = [(_node$attribs$class = node.attribs["class"]) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'u-text-center'].filter(function (c) {
19
+ return !!c;
20
+ }).join(' ');
21
+ return _jsx("p", _objectSpread(_objectSpread({}, props), {}, {
22
+ "data-align": undefined,
23
+ className: classes,
24
+ children: domToReact(node.children, opts)
25
+ }));
26
+ }
27
+ return null;
28
+ };
@@ -0,0 +1,25 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { attributesToProps, domToReact } from 'html-react-parser';
13
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
+ export var SpanPlugin = function SpanPlugin(node, opts) {
15
+ if (node.attribs['data-size'] === 'large') {
16
+ var _node$attribs$class;
17
+ var props = attributesToProps(node.attribs);
18
+ return _jsx("span", _objectSpread(_objectSpread({}, props), {}, {
19
+ "data-size": undefined,
20
+ className: "".concat((_node$attribs$class = node.attribs["class"]) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', " u-large-body-text"),
21
+ children: domToReact(node.children, opts)
22
+ }));
23
+ }
24
+ return null;
25
+ };
@@ -0,0 +1,20 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { Table } from '@ndla/ui';
13
+ import { attributesToProps, domToReact } from 'html-react-parser';
14
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
15
+ export var TablePlugin = function TablePlugin(node, opts) {
16
+ var props = attributesToProps(node.attribs);
17
+ return _jsx(Table, _objectSpread(_objectSpread({}, props), {}, {
18
+ children: domToReact(node.children, opts)
19
+ }));
20
+ };
@@ -0,0 +1,28 @@
1
+ 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; }
2
+ 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; }
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ /**
5
+ * Copyright (c) 2023-present, NDLA.
6
+ *
7
+ * This source code is licensed under the GPLv3 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ *
10
+ */
11
+
12
+ import { attributesToProps, domToReact } from 'html-react-parser';
13
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
14
+ export var OLPlugin = function OLPlugin(node, opts) {
15
+ if (node.attribs['data-type'] === 'two-column') {
16
+ var _node$attribs$class;
17
+ var props = attributesToProps(node.attribs);
18
+ var classes = [(_node$attribs$class = node.attribs["class"]) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'o-list--two-columns'].filter(function (c) {
19
+ return !!c;
20
+ }).join(' ');
21
+ return _jsx("ul", _objectSpread(_objectSpread({}, props), {}, {
22
+ "data-type": undefined,
23
+ className: classes,
24
+ children: domToReact(node.children, opts)
25
+ }));
26
+ }
27
+ return null;
28
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { AudioEmbed } from '@ndla/ui';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var AudioEmbedPlugin = function AudioEmbedPlugin(element, _, opts) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ return _jsx(AudioEmbed, {
16
+ embed: data,
17
+ articlePath: opts.path
18
+ });
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { BrightcoveEmbed } from '@ndla/ui';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var BrightcoveEmbedPlugin = function BrightcoveEmbedPlugin(element) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ return _jsx(BrightcoveEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { CodeEmbed } from '@ndla/code';
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']);
15
+ return _jsx(CodeEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { ConceptEmbed } from '@ndla/ui';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var ConceptEmbedPlugin = function ConceptEmbedPlugin(element) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ return _jsx(ConceptEmbed, {
16
+ embed: data,
17
+ fullWidth: true
18
+ });
19
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { ConceptListEmbed } from '@ndla/ui';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var ConceptListEmbedPlugin = function ConceptListEmbedPlugin(element) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ return _jsx(ConceptListEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { ContentLinkEmbed } from '@ndla/ui';
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']);
16
+ return _jsx(ContentLinkEmbed, {
17
+ embed: data,
18
+ isOembed: isOembed
19
+ });
20
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { ExternalEmbed } from '@ndla/ui';
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']);
15
+ return _jsx(ExternalEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { PdfFile, FileV2 } from '@ndla/ui';
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
+ if (type === 'pdf') {
20
+ return _jsx(PdfFile, {
21
+ title: title,
22
+ url: url
23
+ });
24
+ } else {
25
+ return _jsx(FileV2, {
26
+ id: "file-".concat(data.seq),
27
+ url: url,
28
+ title: title,
29
+ fileExists: data.status === 'success' ? !!data.data.exists : false,
30
+ fileType: type
31
+ });
32
+ }
33
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { FootnoteEmbed } from '@ndla/ui';
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']);
15
+ return _jsx(FootnoteEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { H5pEmbed } from '@ndla/ui';
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']);
15
+ return _jsx(H5pEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { IframeEmbed } from '@ndla/ui';
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']);
15
+ return _jsx(IframeEmbed, {
16
+ embed: data
17
+ });
18
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { ImageEmbed } from '@ndla/ui';
10
+ import { attributesToProps } from 'html-react-parser';
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export var ImageEmbedPlugin = function ImageEmbedPlugin(element, _, opts) {
13
+ var props = attributesToProps(element.attribs);
14
+ var data = JSON.parse(props['data-json']);
15
+ return _jsx(ImageEmbed, {
16
+ embed: data,
17
+ articlePath: opts.path,
18
+ previewAlt: opts.previewAlt
19
+ });
20
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps } from 'html-react-parser';
10
+ import { RelatedContentEmbed } from '@ndla/ui';
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']);
15
+ return _jsx(RelatedContentEmbed, {
16
+ embed: data,
17
+ subject: opts.subject,
18
+ ndlaFrontendDomain: opts.frontendDomain
19
+ });
20
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) 2023-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { AudioEmbedPlugin } from './AudioEmbedPlugin';
10
+ import { ExternalEmbedPlugin } from './ExternalEmbedPlugin';
11
+ import { H5pEmbedPlugin } from './H5pEmbedPlugin';
12
+ import { IframeEmbedPlugin } from './IframeEmbedPlugin';
13
+ import { ImageEmbedPlugin } from './ImageEmbedPlugin';
14
+ import { FootnoteEmbedPlugin } from './FootnoteEmbedPlugin';
15
+ import { BrightcoveEmbedPlugin } from './BrightcoveEmbedPlugin';
16
+ import { RelatedContentEmbedPlugin } from './RelatedContentEmbedPlugin';
17
+ import { ContentLinkEmbedPlugin } from './ContentLinkEmbedPlugin';
18
+ import { ConceptEmbedPlugin } from './ConceptEmbedPlugin';
19
+ import { ConceptListEmbedPlugin } from './ConceptListEmbedPlugin';
20
+ import { FileEmbedPlugin } from './FileEmbedPlugin';
21
+ import { CodeEmbedPlugin } from './CodeEmbedPlugin';
22
+ export var embedPlugins = {
23
+ image: ImageEmbedPlugin,
24
+ audio: AudioEmbedPlugin,
25
+ h5p: H5pEmbedPlugin,
26
+ 'code-block': CodeEmbedPlugin,
27
+ external: ExternalEmbedPlugin,
28
+ iframe: IframeEmbedPlugin,
29
+ footnote: FootnoteEmbedPlugin,
30
+ brightcove: BrightcoveEmbedPlugin,
31
+ 'related-content': RelatedContentEmbedPlugin,
32
+ 'content-link': ContentLinkEmbedPlugin,
33
+ concept: ConceptEmbedPlugin,
34
+ 'concept-list': ConceptListEmbedPlugin,
35
+ file: FileEmbedPlugin
36
+ };