@ndla/article-converter 6.0.14 → 6.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/extractEmbedMeta.js +6 -10
- package/es/plugins/anchorPlugin.js +9 -12
- package/es/plugins/asidePlugin.js +1 -1
- package/es/plugins/copyParagraphPlugin.js +3 -4
- package/es/plugins/ddPlugin.js +5 -10
- package/es/plugins/divPlugin.js +16 -34
- package/es/plugins/dtPlugin.js +5 -10
- package/es/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
- package/es/plugins/embed/audioEmbedPlugin.js +4 -5
- package/es/plugins/embed/blogPostEmbedPlugin.js +15 -15
- package/es/plugins/embed/brightcoveEmbedPlugin.js +4 -5
- package/es/plugins/embed/campaignBlockPlugin.js +4 -4
- package/es/plugins/embed/codeEmbedPlugin.js +3 -3
- package/es/plugins/embed/conceptEmbedPlugin.js +4 -5
- package/es/plugins/embed/conceptListEmbedPlugin.js +3 -3
- package/es/plugins/embed/contactBlockEmbedPlugin.js +13 -13
- package/es/plugins/embed/contentLinkEmbedPlugin.js +6 -4
- package/es/plugins/embed/externalEmbedPlugin.js +3 -3
- package/es/plugins/embed/fileEmbedPlugin.js +9 -8
- package/es/plugins/embed/footnoteEmbedPlugin.js +3 -3
- package/es/plugins/embed/h5pEmbedPlugin.js +3 -3
- package/es/plugins/embed/iframeEmbedPlugin.js +3 -3
- package/es/plugins/embed/imageEmbedPlugin.js +6 -7
- package/es/plugins/embed/index.js +1 -1
- package/es/plugins/embed/linkBlockEmbedPlugin.js +6 -11
- package/es/plugins/embed/relatedContentEmbedPlugin.js +3 -3
- package/es/plugins/h3Plugin.js +5 -10
- package/es/plugins/index.js +4 -9
- package/es/plugins/mathPlugin.js +8 -15
- package/es/plugins/navPlugin.js +5 -10
- package/es/plugins/oembed/anchorPlugin.js +9 -12
- package/es/plugins/olPlugin.js +9 -17
- package/es/plugins/paragraphPlugin.js +9 -16
- package/es/plugins/spanPlugin.js +6 -12
- package/es/plugins/tablePlugin.js +5 -10
- package/es/plugins/ulPlugin.js +6 -14
- package/es/transform.js +6 -6
- package/lib/extractEmbedMeta.js +7 -12
- package/lib/index.js +5 -6
- package/lib/plugins/anchorPlugin.js +17 -18
- package/lib/plugins/asidePlugin.js +1 -1
- package/lib/plugins/copyParagraphPlugin.js +3 -4
- package/lib/plugins/ddPlugin.js +13 -16
- package/lib/plugins/divPlugin.js +25 -41
- package/lib/plugins/dtPlugin.js +13 -16
- package/lib/plugins/embed/KeyFigureEmbedPlugin.js +8 -7
- package/lib/plugins/embed/audioEmbedPlugin.js +4 -5
- package/lib/plugins/embed/blogPostEmbedPlugin.js +15 -16
- package/lib/plugins/embed/brightcoveEmbedPlugin.js +4 -5
- package/lib/plugins/embed/campaignBlockPlugin.js +4 -4
- package/lib/plugins/embed/codeEmbedPlugin.js +3 -3
- package/lib/plugins/embed/conceptEmbedPlugin.js +4 -5
- package/lib/plugins/embed/conceptListEmbedPlugin.js +3 -3
- package/lib/plugins/embed/contactBlockEmbedPlugin.js +13 -13
- package/lib/plugins/embed/contentLinkEmbedPlugin.js +6 -4
- package/lib/plugins/embed/externalEmbedPlugin.js +3 -3
- package/lib/plugins/embed/fileEmbedPlugin.js +9 -8
- package/lib/plugins/embed/footnoteEmbedPlugin.js +3 -3
- package/lib/plugins/embed/h5pEmbedPlugin.js +3 -3
- package/lib/plugins/embed/iframeEmbedPlugin.js +3 -3
- package/lib/plugins/embed/imageEmbedPlugin.js +6 -7
- package/lib/plugins/embed/index.js +2 -3
- package/lib/plugins/embed/linkBlockEmbedPlugin.js +14 -17
- package/lib/plugins/embed/relatedContentEmbedPlugin.js +3 -3
- package/lib/plugins/h3Plugin.js +13 -16
- package/lib/plugins/index.js +12 -17
- package/lib/plugins/mathPlugin.js +9 -15
- package/lib/plugins/navPlugin.js +13 -16
- package/lib/plugins/oembed/anchorPlugin.js +17 -18
- package/lib/plugins/olPlugin.js +17 -23
- package/lib/plugins/paragraphPlugin.js +17 -22
- package/lib/plugins/spanPlugin.js +14 -18
- package/lib/plugins/tablePlugin.js +13 -16
- package/lib/plugins/ulPlugin.js +14 -20
- package/lib/transform.js +7 -8
- package/package.json +8 -5
|
@@ -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
|
|
13
|
-
|
|
14
|
-
|
|
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,
|
package/es/plugins/h3Plugin.js
CHANGED
|
@@ -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
|
|
18
|
-
|
|
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",
|
|
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
|
};
|
package/es/plugins/index.js
CHANGED
|
@@ -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
|
|
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
|
|
40
|
+
export const oembedPlugins = {
|
|
41
|
+
...basePlugins,
|
|
47
42
|
a: oembedAnchorPlugin
|
|
48
|
-
}
|
|
43
|
+
};
|
package/es/plugins/mathPlugin.js
CHANGED
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
props
|
|
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",
|
|
17
|
+
return _jsx("math", {
|
|
18
|
+
...props,
|
|
26
19
|
dangerouslySetInnerHTML: {
|
|
27
20
|
__html: mathContent
|
|
28
21
|
}
|
|
29
|
-
})
|
|
22
|
+
});
|
|
30
23
|
};
|
package/es/plugins/navPlugin.js
CHANGED
|
@@ -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
|
|
12
|
+
export const navPlugin = (node, opts) => {
|
|
19
13
|
if (node.attribs['data-type'] === 'link-block-list') {
|
|
20
|
-
|
|
21
|
-
return _jsx(LinkBlockSection,
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
};
|
package/es/plugins/olPlugin.js
CHANGED
|
@@ -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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
18
|
-
|
|
11
|
+
export const paragraphPlugin = (node, converterOpts, opts) => {
|
|
12
|
+
const props = attributesToProps(node.attribs);
|
|
19
13
|
if (node.attribs['data-align'] === 'center') {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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",
|
|
23
|
+
return _jsx("p", {
|
|
24
|
+
...props,
|
|
32
25
|
lang: opts.articleLanguage,
|
|
33
26
|
children: domToReact(node.children, converterOpts)
|
|
34
|
-
})
|
|
27
|
+
});
|
|
35
28
|
};
|
package/es/plugins/spanPlugin.js
CHANGED
|
@@ -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
|
|
11
|
+
export const spanPlugin = (node, opts) => {
|
|
18
12
|
if (node.attribs['data-size'] === 'large') {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const props = attributesToProps(node.attribs);
|
|
14
|
+
return _jsx("span", {
|
|
15
|
+
...props,
|
|
22
16
|
"data-size": undefined,
|
|
23
|
-
className:
|
|
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
|
|
19
|
-
|
|
20
|
-
return _jsx(Table,
|
|
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
|
};
|
package/es/plugins/ulPlugin.js
CHANGED
|
@@ -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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
replace:
|
|
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
|
-
|
|
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
|
-
|
|
36
|
+
const replaced = parse(content, options);
|
|
37
37
|
return replaced;
|
|
38
38
|
};
|
|
39
39
|
export default transform;
|
package/lib/extractEmbedMeta.js
CHANGED
|
@@ -14,15 +14,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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(
|
|
37
|
-
return n
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
28
|
-
function _interopRequireWildcard(
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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,
|
package/lib/plugins/ddPlugin.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|