@ndla/article-converter 4.0.19 → 4.1.0
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/plugins/embed/audioEmbedPlugin.js +2 -1
- package/es/plugins/embed/blogPostEmbedPlugin.js +5 -4
- package/es/plugins/embed/campaignBlockPlugin.js +1 -1
- package/es/plugins/olPlugin.js +3 -2
- package/es/plugins/paragraphPlugin.js +8 -4
- package/es/plugins/ulPlugin.js +3 -2
- package/lib/plugins/embed/audioEmbedPlugin.js +2 -1
- package/lib/plugins/embed/blogPostEmbedPlugin.js +5 -4
- package/lib/plugins/embed/campaignBlockPlugin.js +1 -1
- package/lib/plugins/olPlugin.js +3 -2
- package/lib/plugins/paragraphPlugin.js +8 -4
- package/lib/plugins/types.d.ts +1 -0
- package/lib/plugins/ulPlugin.js +3 -2
- package/package.json +5 -5
- package/src/plugins/embed/audioEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/blogPostEmbedPlugin.tsx +2 -2
- package/src/plugins/embed/campaignBlockPlugin.tsx +1 -1
- package/src/plugins/olPlugin.tsx +3 -3
- package/src/plugins/paragraphPlugin.tsx +9 -6
- package/src/plugins/types.ts +1 -0
- package/src/plugins/ulPlugin.tsx +3 -3
|
@@ -15,6 +15,7 @@ export var audioEmbedPlugin = function audioEmbedPlugin(element, _, opts) {
|
|
|
15
15
|
var data = JSON.parse(props['data-json']);
|
|
16
16
|
return _jsx(AudioEmbed, {
|
|
17
17
|
embed: data,
|
|
18
|
-
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
|
|
18
|
+
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
|
|
19
|
+
lang: opts.articleLanguage
|
|
19
20
|
});
|
|
20
21
|
};
|
|
@@ -11,7 +11,7 @@ import { BlogPostV2 } from '@ndla/ui';
|
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
12
|
export var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
|
|
13
13
|
export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
14
|
-
var _data$data$metaImage$, _data$data$metaImage;
|
|
14
|
+
var _data$data$metaImage$, _data$data$metaImage, _data$data$metaImage$2, _data$data$metaImage2;
|
|
15
15
|
var props = attributesToProps(element.attribs);
|
|
16
16
|
var data = JSON.parse(props['data-json']);
|
|
17
17
|
var _data$embedData = data.embedData,
|
|
@@ -19,7 +19,8 @@ export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts)
|
|
|
19
19
|
author = _data$embedData.author,
|
|
20
20
|
url = _data$embedData.url,
|
|
21
21
|
size = _data$embedData.size,
|
|
22
|
-
language = _data$embedData.language
|
|
22
|
+
language = _data$embedData.language,
|
|
23
|
+
alt = _data$embedData.alt;
|
|
23
24
|
return _jsx(BlogPostV2, {
|
|
24
25
|
title: {
|
|
25
26
|
title: title,
|
|
@@ -30,8 +31,8 @@ export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts)
|
|
|
30
31
|
size: size,
|
|
31
32
|
path: opts.path,
|
|
32
33
|
metaImage: {
|
|
33
|
-
alt: '',
|
|
34
|
-
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$
|
|
34
|
+
alt: alt ? alt : data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.alttext.alttext) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : '' : '',
|
|
35
|
+
url: data.status === 'success' ? (_data$data$metaImage$2 = (_data$data$metaImage2 = data.data.metaImage) === null || _data$data$metaImage2 === void 0 ? void 0 : _data$data$metaImage2.image.imageUrl) !== null && _data$data$metaImage$2 !== void 0 ? _data$data$metaImage$2 : errorSvgSrc : errorSvgSrc
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
};
|
|
@@ -30,7 +30,7 @@ export var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts)
|
|
|
30
30
|
imageSide: embed.imageSide,
|
|
31
31
|
image: data.status === 'success' && data.data.image ? {
|
|
32
32
|
src: data.data.image.image.imageUrl,
|
|
33
|
-
alt: data.data.image.alttext.alttext
|
|
33
|
+
alt: embed.alt ? embed.alt : data.data.image.alttext.alttext
|
|
34
34
|
} : undefined
|
|
35
35
|
});
|
|
36
36
|
};
|
package/es/plugins/olPlugin.js
CHANGED
|
@@ -15,7 +15,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
15
15
|
import { OrderedList } from '@ndla/ui';
|
|
16
16
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
17
17
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
18
|
-
export var olPlugin = function olPlugin(node, opts) {
|
|
18
|
+
export var olPlugin = function olPlugin(node, converterOpts, opts) {
|
|
19
19
|
var _node$attribs$class;
|
|
20
20
|
var props = attributesToProps(node.attribs);
|
|
21
21
|
var letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
|
|
@@ -26,6 +26,7 @@ export var olPlugin = function olPlugin(node, opts) {
|
|
|
26
26
|
}).join(' ');
|
|
27
27
|
return _jsx(OrderedList, _objectSpread(_objectSpread({}, props), {}, {
|
|
28
28
|
className: classes.length ? classes : undefined,
|
|
29
|
-
|
|
29
|
+
lang: opts.articleLanguage,
|
|
30
|
+
children: domToReact(node.children, converterOpts)
|
|
30
31
|
}));
|
|
31
32
|
};
|
|
@@ -14,18 +14,22 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
14
14
|
|
|
15
15
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
16
16
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
-
export var paragraphPlugin = function paragraphPlugin(node, opts) {
|
|
17
|
+
export var paragraphPlugin = function paragraphPlugin(node, converterOpts, opts) {
|
|
18
|
+
var props = attributesToProps(node.attribs);
|
|
18
19
|
if (node.attribs['data-align'] === 'center') {
|
|
19
20
|
var _node$attribs$class;
|
|
20
|
-
var props = attributesToProps(node.attribs);
|
|
21
21
|
var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'u-text-center'].filter(function (c) {
|
|
22
22
|
return !!c;
|
|
23
23
|
}).join(' ');
|
|
24
24
|
return _jsx("p", _objectSpread(_objectSpread({}, props), {}, {
|
|
25
|
+
lang: opts.articleLanguage,
|
|
25
26
|
"data-align": undefined,
|
|
26
27
|
className: classes,
|
|
27
|
-
children: domToReact(node.children,
|
|
28
|
+
children: domToReact(node.children, converterOpts)
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
30
|
-
return
|
|
31
|
+
return _jsx("p", _objectSpread(_objectSpread({}, props), {}, {
|
|
32
|
+
lang: opts.articleLanguage,
|
|
33
|
+
children: domToReact(node.children, converterOpts)
|
|
34
|
+
}));
|
|
31
35
|
};
|
package/es/plugins/ulPlugin.js
CHANGED
|
@@ -15,7 +15,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
15
15
|
import { UnOrderedList } from '@ndla/ui';
|
|
16
16
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
17
17
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
18
|
-
export var ulPlugin = function ulPlugin(node, opts) {
|
|
18
|
+
export var ulPlugin = function ulPlugin(node, converterOpts, opts) {
|
|
19
19
|
var _node$attribs$class;
|
|
20
20
|
var props = attributesToProps(node.attribs);
|
|
21
21
|
var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(function (c) {
|
|
@@ -23,6 +23,7 @@ export var ulPlugin = function ulPlugin(node, opts) {
|
|
|
23
23
|
}).join(' ');
|
|
24
24
|
return _jsx(UnOrderedList, _objectSpread(_objectSpread({}, props), {}, {
|
|
25
25
|
className: classes,
|
|
26
|
-
|
|
26
|
+
lang: opts.articleLanguage,
|
|
27
|
+
children: domToReact(node.children, converterOpts)
|
|
27
28
|
}));
|
|
28
29
|
};
|
|
@@ -21,7 +21,8 @@ var audioEmbedPlugin = function audioEmbedPlugin(element, _, opts) {
|
|
|
21
21
|
var data = JSON.parse(props['data-json']);
|
|
22
22
|
return (0, _jsxRuntime.jsx)(_ui.AudioEmbed, {
|
|
23
23
|
embed: data,
|
|
24
|
-
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
|
|
24
|
+
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
|
|
25
|
+
lang: opts.articleLanguage
|
|
25
26
|
});
|
|
26
27
|
};
|
|
27
28
|
exports.audioEmbedPlugin = audioEmbedPlugin;
|
|
@@ -18,7 +18,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
18
18
|
var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
|
|
19
19
|
exports.errorSvgSrc = errorSvgSrc;
|
|
20
20
|
var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
21
|
-
var _data$data$metaImage$, _data$data$metaImage;
|
|
21
|
+
var _data$data$metaImage$, _data$data$metaImage, _data$data$metaImage$2, _data$data$metaImage2;
|
|
22
22
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
23
23
|
var data = JSON.parse(props['data-json']);
|
|
24
24
|
var _data$embedData = data.embedData,
|
|
@@ -26,7 +26,8 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
|
26
26
|
author = _data$embedData.author,
|
|
27
27
|
url = _data$embedData.url,
|
|
28
28
|
size = _data$embedData.size,
|
|
29
|
-
language = _data$embedData.language
|
|
29
|
+
language = _data$embedData.language,
|
|
30
|
+
alt = _data$embedData.alt;
|
|
30
31
|
return (0, _jsxRuntime.jsx)(_ui.BlogPostV2, {
|
|
31
32
|
title: {
|
|
32
33
|
title: title,
|
|
@@ -37,8 +38,8 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
|
37
38
|
size: size,
|
|
38
39
|
path: opts.path,
|
|
39
40
|
metaImage: {
|
|
40
|
-
alt: '',
|
|
41
|
-
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$
|
|
41
|
+
alt: alt ? alt : data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.alttext.alttext) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : '' : '',
|
|
42
|
+
url: data.status === 'success' ? (_data$data$metaImage$2 = (_data$data$metaImage2 = data.data.metaImage) === null || _data$data$metaImage2 === void 0 ? void 0 : _data$data$metaImage2.image.imageUrl) !== null && _data$data$metaImage$2 !== void 0 ? _data$data$metaImage$2 : errorSvgSrc : errorSvgSrc
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
};
|
|
@@ -36,7 +36,7 @@ var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
|
|
|
36
36
|
imageSide: embed.imageSide,
|
|
37
37
|
image: data.status === 'success' && data.data.image ? {
|
|
38
38
|
src: data.data.image.image.imageUrl,
|
|
39
|
-
alt: data.data.image.alttext.alttext
|
|
39
|
+
alt: embed.alt ? embed.alt : data.data.image.alttext.alttext
|
|
40
40
|
} : undefined
|
|
41
41
|
});
|
|
42
42
|
};
|
package/lib/plugins/olPlugin.js
CHANGED
|
@@ -19,7 +19,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
var olPlugin = function olPlugin(node, opts) {
|
|
22
|
+
var olPlugin = function olPlugin(node, converterOpts, opts) {
|
|
23
23
|
var _node$attribs$class;
|
|
24
24
|
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
25
25
|
var letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
|
|
@@ -30,7 +30,8 @@ var olPlugin = function olPlugin(node, opts) {
|
|
|
30
30
|
}).join(' ');
|
|
31
31
|
return (0, _jsxRuntime.jsx)(_ui.OrderedList, _objectSpread(_objectSpread({}, props), {}, {
|
|
32
32
|
className: classes.length ? classes : undefined,
|
|
33
|
-
|
|
33
|
+
lang: opts.articleLanguage,
|
|
34
|
+
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
34
35
|
}));
|
|
35
36
|
};
|
|
36
37
|
exports.olPlugin = olPlugin;
|
|
@@ -18,19 +18,23 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
|
-
var paragraphPlugin = function paragraphPlugin(node, opts) {
|
|
21
|
+
var paragraphPlugin = function paragraphPlugin(node, converterOpts, opts) {
|
|
22
|
+
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
22
23
|
if (node.attribs['data-align'] === 'center') {
|
|
23
24
|
var _node$attribs$class;
|
|
24
|
-
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
25
25
|
var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', 'u-text-center'].filter(function (c) {
|
|
26
26
|
return !!c;
|
|
27
27
|
}).join(' ');
|
|
28
28
|
return (0, _jsxRuntime.jsx)("p", _objectSpread(_objectSpread({}, props), {}, {
|
|
29
|
+
lang: opts.articleLanguage,
|
|
29
30
|
"data-align": undefined,
|
|
30
31
|
className: classes,
|
|
31
|
-
children: (0, _htmlReactParser.domToReact)(node.children,
|
|
32
|
+
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
32
33
|
}));
|
|
33
34
|
}
|
|
34
|
-
return
|
|
35
|
+
return (0, _jsxRuntime.jsx)("p", _objectSpread(_objectSpread({}, props), {}, {
|
|
36
|
+
lang: opts.articleLanguage,
|
|
37
|
+
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
38
|
+
}));
|
|
35
39
|
};
|
|
36
40
|
exports.paragraphPlugin = paragraphPlugin;
|
package/lib/plugins/types.d.ts
CHANGED
|
@@ -18,5 +18,6 @@ export interface TransformOptions {
|
|
|
18
18
|
previewAlt?: boolean;
|
|
19
19
|
frontendDomain?: string;
|
|
20
20
|
components?: DynamicComponents;
|
|
21
|
+
articleLanguage?: string;
|
|
21
22
|
}
|
|
22
23
|
export type PluginType = (element: Element, options: HTMLReactParserOptions, metaData: TransformOptions) => JSX.Element | undefined | null;
|
package/lib/plugins/ulPlugin.js
CHANGED
|
@@ -19,7 +19,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
var ulPlugin = function ulPlugin(node, opts) {
|
|
22
|
+
var ulPlugin = function ulPlugin(node, converterOpts, opts) {
|
|
23
23
|
var _node$attribs$class;
|
|
24
24
|
var props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
25
25
|
var classes = [(_node$attribs$class = node.attribs.class) !== null && _node$attribs$class !== void 0 ? _node$attribs$class : '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : ''].filter(function (c) {
|
|
@@ -27,7 +27,8 @@ var ulPlugin = function ulPlugin(node, opts) {
|
|
|
27
27
|
}).join(' ');
|
|
28
28
|
return (0, _jsxRuntime.jsx)(_ui.UnOrderedList, _objectSpread(_objectSpread({}, props), {}, {
|
|
29
29
|
className: classes,
|
|
30
|
-
|
|
30
|
+
lang: opts.articleLanguage,
|
|
31
|
+
children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
|
|
31
32
|
}));
|
|
32
33
|
};
|
|
33
34
|
exports.ulPlugin = ulPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ndla/types-embed": "^4.0.
|
|
30
|
+
"@ndla/types-embed": "^4.0.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^4.0.
|
|
34
|
-
"@ndla/ui": "^46.0.
|
|
33
|
+
"@ndla/code": "^4.0.6",
|
|
34
|
+
"@ndla/ui": "^46.0.2",
|
|
35
35
|
"html-react-parser": "^3.0.8",
|
|
36
36
|
"lodash": "^4.17.20"
|
|
37
37
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "6beec50182999798fe82aa9aad1499d33a175b97"
|
|
48
48
|
}
|
|
@@ -14,5 +14,5 @@ import { PluginType } from '../types';
|
|
|
14
14
|
export const audioEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as AudioMetaData;
|
|
17
|
-
return <AudioEmbed embed={data} heartButton={opts.components?.heartButton} />;
|
|
17
|
+
return <AudioEmbed embed={data} heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -16,7 +16,7 @@ export const errorSvgSrc = `data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8
|
|
|
16
16
|
export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
17
17
|
const props = attributesToProps(element.attribs);
|
|
18
18
|
const data = JSON.parse(props['data-json']) as BlogPostMetaData;
|
|
19
|
-
const { title, author, url, size, language } = data.embedData;
|
|
19
|
+
const { title, author, url, size, language, alt } = data.embedData;
|
|
20
20
|
return (
|
|
21
21
|
<BlogPostV2
|
|
22
22
|
title={{ title, language }}
|
|
@@ -25,7 +25,7 @@ export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
|
25
25
|
size={size}
|
|
26
26
|
path={opts.path}
|
|
27
27
|
metaImage={{
|
|
28
|
-
alt: '',
|
|
28
|
+
alt: alt ? alt : data.status === 'success' ? data.data.metaImage?.alttext.alttext ?? '' : '',
|
|
29
29
|
url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc,
|
|
30
30
|
}}
|
|
31
31
|
/>
|
|
@@ -24,7 +24,7 @@ export const campaignBlockPlugin: PluginType = (element, _, opts) => {
|
|
|
24
24
|
imageSide={embed.imageSide}
|
|
25
25
|
image={
|
|
26
26
|
data.status === 'success' && data.data.image
|
|
27
|
-
? { src: data.data.image.image.imageUrl, alt: data.data.image.alttext.alttext }
|
|
27
|
+
? { src: data.data.image.image.imageUrl, alt: embed.alt ? embed.alt : data.data.image.alttext.alttext }
|
|
28
28
|
: undefined
|
|
29
29
|
}
|
|
30
30
|
/>
|
package/src/plugins/olPlugin.tsx
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { OrderedList } from '@ndla/ui';
|
|
10
10
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
11
11
|
import { PluginType } from './types';
|
|
12
|
-
export const olPlugin: PluginType = (node, opts) => {
|
|
12
|
+
export const olPlugin: PluginType = (node, converterOpts, opts) => {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
const letterClass = node.attribs['data-type'] === 'letters' ? 'ol-list--roman' : false;
|
|
15
15
|
const num = node.attribs['start'];
|
|
@@ -17,8 +17,8 @@ export const olPlugin: PluginType = (node, opts) => {
|
|
|
17
17
|
const classes = [node.attribs.class ?? false, letterClass, numClass].filter((c): c is string => !!c).join(' ');
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<OrderedList {...props} className={classes.length ? classes : undefined}>
|
|
21
|
-
{domToReact(node.children,
|
|
20
|
+
<OrderedList {...props} className={classes.length ? classes : undefined} lang={opts.articleLanguage}>
|
|
21
|
+
{domToReact(node.children, converterOpts)}
|
|
22
22
|
</OrderedList>
|
|
23
23
|
);
|
|
24
24
|
};
|
|
@@ -8,16 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
10
10
|
import { PluginType } from './types';
|
|
11
|
-
export const paragraphPlugin: PluginType = (node, opts) => {
|
|
11
|
+
export const paragraphPlugin: PluginType = (node, converterOpts, opts) => {
|
|
12
|
+
const props = attributesToProps(node.attribs);
|
|
12
13
|
if (node.attribs['data-align'] === 'center') {
|
|
13
|
-
const props = attributesToProps(node.attribs);
|
|
14
14
|
const classes = [node.attribs.class ?? '', 'u-text-center'].filter((c) => !!c).join(' ');
|
|
15
15
|
return (
|
|
16
|
-
<p {...props} data-align={undefined} className={classes}>
|
|
17
|
-
{domToReact(node.children,
|
|
16
|
+
<p {...props} lang={opts.articleLanguage} data-align={undefined} className={classes}>
|
|
17
|
+
{domToReact(node.children, converterOpts)}
|
|
18
18
|
</p>
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return (
|
|
22
|
+
<p {...props} lang={opts.articleLanguage}>
|
|
23
|
+
{domToReact(node.children, converterOpts)}
|
|
24
|
+
</p>
|
|
25
|
+
);
|
|
23
26
|
};
|
package/src/plugins/types.ts
CHANGED
package/src/plugins/ulPlugin.tsx
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
import { UnOrderedList } from '@ndla/ui';
|
|
10
10
|
import { attributesToProps, domToReact } from 'html-react-parser';
|
|
11
11
|
import { PluginType } from './types';
|
|
12
|
-
export const ulPlugin: PluginType = (node, opts) => {
|
|
12
|
+
export const ulPlugin: PluginType = (node, converterOpts, opts) => {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
const classes = [node.attribs.class ?? '', node.attribs['data-type'] === 'two-column' ? 'o-list--two-columns' : '']
|
|
15
15
|
.filter((c) => !!c)
|
|
16
16
|
.join(' ');
|
|
17
17
|
return (
|
|
18
|
-
<UnOrderedList {...props} className={classes}>
|
|
19
|
-
{domToReact(node.children,
|
|
18
|
+
<UnOrderedList {...props} className={classes} lang={opts.articleLanguage}>
|
|
19
|
+
{domToReact(node.children, converterOpts)}
|
|
20
20
|
</UnOrderedList>
|
|
21
21
|
);
|
|
22
22
|
};
|