@ndla/article-converter 6.0.15 → 6.0.17
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 +3 -3
package/lib/plugins/divPlugin.js
CHANGED
|
@@ -4,65 +4,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.divPlugin = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _partition = _interopRequireDefault(require("lodash/partition"));
|
|
8
8
|
var _htmlReactParser = require("html-react-parser");
|
|
9
9
|
var _ui = require("@ndla/ui");
|
|
10
10
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
24
|
-
* Copyright (c) 2023-present, NDLA.
|
|
25
|
-
*
|
|
26
|
-
* This source code is licensed under the GPLv3 license found in the
|
|
27
|
-
* LICENSE file in the root directory of this source tree.
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
var divPlugin = function divPlugin(node, opts) {
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) 2023-present, NDLA.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const divPlugin = (node, opts) => {
|
|
31
21
|
if (node.attribs['data-type'] === 'related-content' && node.children.length) {
|
|
32
|
-
|
|
33
|
-
return (0, _jsxRuntime.jsx)(_ui.RelatedArticleList,
|
|
22
|
+
const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
23
|
+
return (0, _jsxRuntime.jsx)(_ui.RelatedArticleList, {
|
|
24
|
+
...props,
|
|
34
25
|
headingLevel: "h3",
|
|
35
26
|
children: (0, _htmlReactParser.domToReact)(node.children, opts)
|
|
36
|
-
}));
|
|
37
|
-
} else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
|
|
38
|
-
var elements = node.childNodes.filter(function (c) {
|
|
39
|
-
return c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file';
|
|
40
27
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_partition2 = _slicedToArray(_partition, 2),
|
|
45
|
-
pdfs = _partition2[0],
|
|
46
|
-
files = _partition2[1];
|
|
28
|
+
} else if (node.attribs['data-type'] === 'file' && node.childNodes.length) {
|
|
29
|
+
const elements = node.childNodes.filter(c => c.type === 'tag' && c.name === 'ndlaembed' && c.attribs['data-resource'] === 'file');
|
|
30
|
+
const [pdfs, files] = (0, _partition.default)(elements, el => el.attribs['data-type'] === 'pdf' && el.attribs['data-display'] === 'block');
|
|
47
31
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
48
32
|
children: [files.length ? (0, _jsxRuntime.jsx)(_ui.FileList, {
|
|
49
33
|
children: (0, _htmlReactParser.domToReact)(files, opts)
|
|
50
34
|
}) : undefined, (0, _htmlReactParser.domToReact)(pdfs, opts)]
|
|
51
35
|
});
|
|
52
36
|
} else if (node.attribs['data-type'] === 'grid' && node.children.length > 0) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return (0, _jsxRuntime.jsx)(_ui.Grid,
|
|
37
|
+
const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
38
|
+
const columns = props['data-columns'];
|
|
39
|
+
const border = props['data-border'];
|
|
40
|
+
const background = props['data-background'];
|
|
41
|
+
const frontpage = !!props['data-size'];
|
|
42
|
+
return (0, _jsxRuntime.jsx)(_ui.Grid, {
|
|
59
43
|
isFrontpage: frontpage,
|
|
60
44
|
border: border,
|
|
61
45
|
columns: columns,
|
|
62
|
-
background: background
|
|
63
|
-
|
|
46
|
+
background: background,
|
|
47
|
+
...props,
|
|
64
48
|
children: (0, _htmlReactParser.domToReact)(node.children, opts)
|
|
65
|
-
})
|
|
49
|
+
});
|
|
66
50
|
} else if (node.attribs['data-parallax-cell'] === 'true' && node.children.length) {
|
|
67
51
|
return (0, _jsxRuntime.jsx)(_ui.GridParallaxItem, {
|
|
68
52
|
children: (0, _htmlReactParser.domToReact)(node.children, opts)
|
package/lib/plugins/dtPlugin.js
CHANGED
|
@@ -7,23 +7,20 @@ exports.dtPlugin = void 0;
|
|
|
7
7
|
var _ui = require("@ndla/ui");
|
|
8
8
|
var _htmlReactParser = require("html-react-parser");
|
|
9
9
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var dtPlugin = function dtPlugin(node, converterOpts, opts) {
|
|
23
|
-
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
24
|
-
return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, _objectSpread(_objectSpread({}, props), {}, {
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) 2023-present, NDLA.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const dtPlugin = (node, converterOpts, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
20
|
+
return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, {
|
|
21
|
+
...props,
|
|
25
22
|
lang: opts.articleLanguage,
|
|
26
23
|
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
27
|
-
})
|
|
24
|
+
});
|
|
28
25
|
};
|
|
29
26
|
exports.dtPlugin = dtPlugin;
|
|
@@ -15,13 +15,14 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
title
|
|
23
|
-
subtitle
|
|
24
|
-
alt
|
|
18
|
+
const keyFigureEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
|
+
const {
|
|
22
|
+
title,
|
|
23
|
+
subtitle,
|
|
24
|
+
alt
|
|
25
|
+
} = data.embedData;
|
|
25
26
|
return (0, _jsxRuntime.jsx)(_ui.KeyFigure, {
|
|
26
27
|
title: title,
|
|
27
28
|
subtitle: subtitle,
|
|
@@ -15,13 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var data = JSON.parse(props['data-json']);
|
|
18
|
+
const audioEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
22
21
|
return (0, _jsxRuntime.jsx)(_ui.AudioEmbed, {
|
|
23
22
|
embed: data,
|
|
24
|
-
heartButton:
|
|
23
|
+
heartButton: opts.components?.heartButton,
|
|
25
24
|
lang: opts.articleLanguage
|
|
26
25
|
});
|
|
27
26
|
};
|
|
@@ -15,23 +15,22 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
alt = _data$embedData.alt;
|
|
18
|
+
const errorSvgSrc = exports.errorSvgSrc = `data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E`;
|
|
19
|
+
const blogPostEmbedPlugin = (element, _, opts) => {
|
|
20
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
21
|
+
const data = JSON.parse(props['data-json']);
|
|
22
|
+
const {
|
|
23
|
+
title,
|
|
24
|
+
author,
|
|
25
|
+
url,
|
|
26
|
+
size,
|
|
27
|
+
language,
|
|
28
|
+
alt
|
|
29
|
+
} = data.embedData;
|
|
31
30
|
return (0, _jsxRuntime.jsx)(_ui.BlogPostV2, {
|
|
32
31
|
title: {
|
|
33
|
-
title
|
|
34
|
-
language
|
|
32
|
+
title,
|
|
33
|
+
language
|
|
35
34
|
},
|
|
36
35
|
author: author,
|
|
37
36
|
url: url,
|
|
@@ -39,7 +38,7 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
|
39
38
|
path: opts.path,
|
|
40
39
|
metaImage: {
|
|
41
40
|
alt: alt ? alt : '',
|
|
42
|
-
url: data.status === 'success' ?
|
|
41
|
+
url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
44
|
};
|
|
@@ -15,13 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var data = JSON.parse(props['data-json']);
|
|
18
|
+
const brightcoveEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
22
21
|
return (0, _jsxRuntime.jsx)(_ui.BrightcoveEmbed, {
|
|
23
22
|
embed: data,
|
|
24
|
-
heartButton:
|
|
23
|
+
heartButton: opts.components?.heartButton,
|
|
25
24
|
renderContext: opts.renderContext
|
|
26
25
|
});
|
|
27
26
|
};
|
|
@@ -15,10 +15,10 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const campaignBlockPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
|
+
const embed = data.embedData;
|
|
22
22
|
return (0, _jsxRuntime.jsx)(_ui.CampaignBlock, {
|
|
23
23
|
title: {
|
|
24
24
|
title: embed.title,
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const codeEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_code.CodeEmbed, {
|
|
22
22
|
embed: data
|
|
23
23
|
});
|
|
@@ -15,14 +15,13 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var data = JSON.parse(props['data-json']);
|
|
18
|
+
const conceptEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
22
21
|
return (0, _jsxRuntime.jsx)(_ui.ConceptEmbed, {
|
|
23
22
|
embed: data,
|
|
24
23
|
fullWidth: true,
|
|
25
|
-
heartButton:
|
|
24
|
+
heartButton: opts.components?.heartButton,
|
|
26
25
|
lang: opts.articleLanguage
|
|
27
26
|
});
|
|
28
27
|
};
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const conceptListEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.ConceptListEmbed, {
|
|
22
22
|
embed: data,
|
|
23
23
|
lang: opts.articleLanguage
|
|
@@ -15,18 +15,18 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
const contactBlockEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const embedData = JSON.parse(props['data-json']);
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
email,
|
|
24
|
+
description,
|
|
25
|
+
blob,
|
|
26
|
+
blobColor,
|
|
27
|
+
jobTitle,
|
|
28
|
+
alt
|
|
29
|
+
} = embedData.embedData;
|
|
30
30
|
return (0, _jsxRuntime.jsx)(_ui.ContactBlock, {
|
|
31
31
|
image: embedData.status === 'success' ? embedData.data.image : undefined,
|
|
32
32
|
embedAlt: alt,
|
|
@@ -37,7 +37,7 @@ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts)
|
|
|
37
37
|
name: name,
|
|
38
38
|
blob: blob,
|
|
39
39
|
lang: opts.articleLanguage,
|
|
40
|
-
imageCanonicalUrl:
|
|
40
|
+
imageCanonicalUrl: opts.canonicalUrls?.image
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
exports.contactBlockEmbedPlugin = contactBlockEmbedPlugin;
|
|
@@ -15,10 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const contentLinkEmbedPlugin = (element, _, _ref) => {
|
|
19
|
+
let {
|
|
20
|
+
isOembed
|
|
21
|
+
} = _ref;
|
|
22
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
23
|
+
const data = JSON.parse(props['data-json']);
|
|
22
24
|
return (0, _jsxRuntime.jsx)(_ui.ContentLinkEmbed, {
|
|
23
25
|
embed: data,
|
|
24
26
|
isOembed: isOembed
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const externalEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.ExternalEmbed, {
|
|
22
22
|
embed: data
|
|
23
23
|
});
|
|
@@ -15,14 +15,15 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type
|
|
23
|
-
title
|
|
24
|
-
url
|
|
25
|
-
display
|
|
18
|
+
const fileEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
|
+
const {
|
|
22
|
+
type,
|
|
23
|
+
title,
|
|
24
|
+
url,
|
|
25
|
+
display
|
|
26
|
+
} = data.embedData;
|
|
26
27
|
if (type === 'pdf' && display === 'block') {
|
|
27
28
|
return (0, _jsxRuntime.jsx)(_ui.PdfFile, {
|
|
28
29
|
title: title,
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const footnoteEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.FootnoteEmbed, {
|
|
22
22
|
embed: data
|
|
23
23
|
});
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const h5pEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.H5pEmbed, {
|
|
22
22
|
embed: data
|
|
23
23
|
});
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const iframeEmbedPlugin = element => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.IframeEmbed, {
|
|
22
22
|
embed: data
|
|
23
23
|
});
|
|
@@ -15,18 +15,17 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var inGrid = ((_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : (_element$parentNode$p = _element$parentNode.parentNode) === null || _element$parentNode$p === void 0 ? void 0 : (_element$parentNode$p2 = _element$parentNode$p.attribs) === null || _element$parentNode$p2 === void 0 ? void 0 : _element$parentNode$p2['data-type']) === 'grid';
|
|
18
|
+
const imageEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
|
+
const inGrid = element.parentNode?.parentNode?.attribs?.['data-type'] === 'grid';
|
|
23
22
|
return (0, _jsxRuntime.jsx)(_ui.ImageEmbed, {
|
|
24
23
|
inGrid: inGrid,
|
|
25
24
|
embed: data,
|
|
26
25
|
path: opts.path,
|
|
27
26
|
previewAlt: opts.previewAlt,
|
|
28
|
-
heartButton:
|
|
29
|
-
canonicalUrl:
|
|
27
|
+
heartButton: opts.components?.heartButton,
|
|
28
|
+
canonicalUrl: opts.canonicalUrls?.image,
|
|
30
29
|
lang: opts.articleLanguage,
|
|
31
30
|
renderContext: opts.renderContext
|
|
32
31
|
});
|
|
@@ -30,7 +30,7 @@ var _linkBlockEmbedPlugin = require("./linkBlockEmbedPlugin");
|
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const embedPlugins = exports.embedPlugins = {
|
|
34
34
|
image: _imageEmbedPlugin.imageEmbedPlugin,
|
|
35
35
|
audio: _audioEmbedPlugin.audioEmbedPlugin,
|
|
36
36
|
h5p: _h5pEmbedPlugin.h5pEmbedPlugin,
|
|
@@ -49,5 +49,4 @@ var embedPlugins = {
|
|
|
49
49
|
'contact-block': _contactBlockEmbedPlugin.contactBlockEmbedPlugin,
|
|
50
50
|
'campaign-block': _campaignBlockPlugin.campaignBlockPlugin,
|
|
51
51
|
'link-block': _linkBlockEmbedPlugin.linkBlockPlugin
|
|
52
|
-
};
|
|
53
|
-
exports.embedPlugins = embedPlugins;
|
|
52
|
+
};
|
|
@@ -7,23 +7,20 @@ exports.linkBlockPlugin = void 0;
|
|
|
7
7
|
var _ui = require("@ndla/ui");
|
|
8
8
|
var _htmlReactParser = require("html-react-parser");
|
|
9
9
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
24
|
-
var data = JSON.parse(props['data-json']);
|
|
25
|
-
return (0, _jsxRuntime.jsx)(_ui.LinkBlock, _objectSpread(_objectSpread({}, data.embedData), {}, {
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) 2023-present, NDLA.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const linkBlockPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
|
+
return (0, _jsxRuntime.jsx)(_ui.LinkBlock, {
|
|
22
|
+
...data.embedData,
|
|
26
23
|
path: opts.path
|
|
27
|
-
})
|
|
24
|
+
});
|
|
28
25
|
};
|
|
29
26
|
exports.linkBlockPlugin = linkBlockPlugin;
|
|
@@ -15,9 +15,9 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const relatedContentEmbedPlugin = (element, _, opts) => {
|
|
19
|
+
const props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
|
+
const data = JSON.parse(props['data-json']);
|
|
21
21
|
return (0, _jsxRuntime.jsx)(_ui.RelatedContentEmbed, {
|
|
22
22
|
embed: data,
|
|
23
23
|
subject: opts.subject,
|
package/lib/plugins/h3Plugin.js
CHANGED
|
@@ -6,27 +6,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.h3Plugin = void 0;
|
|
7
7
|
var _htmlReactParser = require("html-react-parser");
|
|
8
8
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
var h3Plugin = function h3Plugin(node, converterOpts, opts) {
|
|
22
|
-
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
9
|
+
/**
|
|
10
|
+
* Copyright (c) 2023-present, NDLA.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const h3Plugin = (node, converterOpts, opts) => {
|
|
18
|
+
const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
23
19
|
return (
|
|
24
20
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
25
|
-
(0, _jsxRuntime.jsx)("h3",
|
|
21
|
+
(0, _jsxRuntime.jsx)("h3", {
|
|
22
|
+
...props,
|
|
26
23
|
tabIndex: 0,
|
|
27
24
|
lang: opts.articleLanguage,
|
|
28
25
|
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
29
|
-
})
|
|
26
|
+
})
|
|
30
27
|
);
|
|
31
28
|
};
|
|
32
29
|
exports.h3Plugin = h3Plugin;
|