@ndla/article-converter 2.3.15 → 2.3.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.
|
@@ -10,10 +10,12 @@ import { ImageEmbed } from '@ndla/ui';
|
|
|
10
10
|
import { attributesToProps } from 'html-react-parser';
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
12
|
export var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
13
|
-
var _opts$components;
|
|
13
|
+
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components;
|
|
14
14
|
var props = attributesToProps(element.attribs);
|
|
15
15
|
var data = JSON.parse(props['data-json']);
|
|
16
|
+
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';
|
|
16
17
|
return _jsx(ImageEmbed, {
|
|
18
|
+
inGrid: inGrid,
|
|
17
19
|
embed: data,
|
|
18
20
|
previewAlt: opts.previewAlt,
|
|
19
21
|
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
|
|
@@ -16,10 +16,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
19
|
-
var _opts$components;
|
|
19
|
+
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components;
|
|
20
20
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
21
21
|
var data = JSON.parse(props['data-json']);
|
|
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';
|
|
22
23
|
return (0, _jsxRuntime.jsx)(_ui.ImageEmbed, {
|
|
24
|
+
inGrid: inGrid,
|
|
23
25
|
embed: data,
|
|
24
26
|
previewAlt: opts.previewAlt,
|
|
25
27
|
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.17",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@ndla/code": "^2.2.14",
|
|
34
|
-
"@ndla/ui": "^41.
|
|
34
|
+
"@ndla/ui": "^41.3.0",
|
|
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": "8f9e3f62713e77a08c6c27442e5567fd4e8282a4"
|
|
48
48
|
}
|
|
@@ -7,12 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { ImageEmbed } from '@ndla/ui';
|
|
10
|
-
import { attributesToProps } from 'html-react-parser';
|
|
10
|
+
import { attributesToProps, Element } from 'html-react-parser';
|
|
11
11
|
import { ImageMetaData } from '@ndla/types-embed';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
14
|
export const imageEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as ImageMetaData;
|
|
17
|
-
|
|
17
|
+
const inGrid = (element.parentNode?.parentNode as Element)?.attribs?.['data-type'] === 'grid';
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ImageEmbed inGrid={inGrid} embed={data} previewAlt={opts.previewAlt} heartButton={opts.components?.heartButton} />
|
|
21
|
+
);
|
|
18
22
|
};
|