@ndla/article-converter 6.0.41 → 6.0.43
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 +8 -8
- package/es/index.js +2 -2
- package/es/plugins/anchorPlugin.js +3 -3
- package/es/plugins/asidePlugin.js +4 -4
- package/es/plugins/copyParagraphPlugin.js +4 -4
- package/es/plugins/ddPlugin.js +2 -2
- package/es/plugins/divPlugin.js +14 -14
- package/es/plugins/dtPlugin.js +2 -2
- package/es/plugins/embed/KeyFigureEmbedPlugin.js +5 -5
- package/es/plugins/embed/audioEmbedPlugin.js +3 -3
- package/es/plugins/embed/blogPostEmbedPlugin.js +5 -5
- package/es/plugins/embed/brightcoveEmbedPlugin.js +3 -3
- package/es/plugins/embed/campaignBlockPlugin.js +5 -5
- package/es/plugins/embed/codeEmbedPlugin.js +3 -3
- package/es/plugins/embed/conceptEmbedPlugin.js +3 -3
- package/es/plugins/embed/conceptListEmbedPlugin.js +3 -3
- package/es/plugins/embed/contactBlockEmbedPlugin.js +4 -4
- package/es/plugins/embed/contentLinkEmbedPlugin.js +3 -3
- package/es/plugins/embed/externalEmbedPlugin.js +3 -3
- package/es/plugins/embed/fileEmbedPlugin.js +5 -5
- 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 +4 -4
- package/es/plugins/embed/index.js +27 -27
- package/es/plugins/embed/linkBlockEmbedPlugin.js +3 -3
- package/es/plugins/embed/relatedContentEmbedPlugin.js +3 -3
- package/es/plugins/h3Plugin.js +1 -1
- package/es/plugins/index.js +15 -15
- package/es/plugins/mathPlugin.js +2 -2
- package/es/plugins/navPlugin.js +3 -3
- package/es/plugins/oembed/anchorPlugin.js +3 -3
- package/es/plugins/olPlugin.js +5 -5
- package/es/plugins/paragraphPlugin.js +3 -3
- package/es/plugins/spanPlugin.js +3 -3
- package/es/plugins/tablePlugin.js +2 -2
- package/es/plugins/ulPlugin.js +3 -3
- package/es/transform.js +9 -9
- package/lib/extractEmbedMeta.d.ts +1 -1
- package/lib/extractEmbedMeta.js +7 -7
- package/lib/index.d.ts +3 -3
- package/lib/plugins/anchorPlugin.d.ts +1 -1
- package/lib/plugins/asidePlugin.d.ts +1 -1
- package/lib/plugins/asidePlugin.js +2 -2
- package/lib/plugins/copyParagraphPlugin.d.ts +1 -1
- package/lib/plugins/copyParagraphPlugin.js +2 -2
- package/lib/plugins/ddPlugin.d.ts +1 -1
- package/lib/plugins/divPlugin.d.ts +1 -1
- package/lib/plugins/divPlugin.js +11 -11
- package/lib/plugins/dtPlugin.d.ts +1 -1
- package/lib/plugins/embed/KeyFigureEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/KeyFigureEmbedPlugin.js +3 -3
- package/lib/plugins/embed/audioEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/audioEmbedPlugin.js +1 -1
- package/lib/plugins/embed/blogPostEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/blogPostEmbedPlugin.js +3 -3
- package/lib/plugins/embed/brightcoveEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/brightcoveEmbedPlugin.js +1 -1
- package/lib/plugins/embed/campaignBlockPlugin.d.ts +1 -1
- package/lib/plugins/embed/campaignBlockPlugin.js +3 -3
- package/lib/plugins/embed/codeEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/codeEmbedPlugin.js +1 -1
- package/lib/plugins/embed/conceptEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/conceptEmbedPlugin.js +1 -1
- package/lib/plugins/embed/conceptListEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/conceptListEmbedPlugin.js +1 -1
- package/lib/plugins/embed/contactBlockEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/contactBlockEmbedPlugin.js +2 -2
- package/lib/plugins/embed/contentLinkEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/contentLinkEmbedPlugin.js +1 -1
- package/lib/plugins/embed/externalEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/externalEmbedPlugin.js +1 -1
- package/lib/plugins/embed/fileEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/fileEmbedPlugin.js +3 -3
- package/lib/plugins/embed/footnoteEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/footnoteEmbedPlugin.js +1 -1
- package/lib/plugins/embed/h5pEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/h5pEmbedPlugin.js +1 -1
- package/lib/plugins/embed/iframeEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/iframeEmbedPlugin.js +1 -1
- package/lib/plugins/embed/imageEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/imageEmbedPlugin.js +2 -2
- package/lib/plugins/embed/index.d.ts +1 -1
- package/lib/plugins/embed/index.js +9 -9
- package/lib/plugins/embed/linkBlockEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/linkBlockEmbedPlugin.js +1 -1
- package/lib/plugins/embed/relatedContentEmbedPlugin.d.ts +1 -1
- package/lib/plugins/embed/relatedContentEmbedPlugin.js +1 -1
- package/lib/plugins/h3Plugin.d.ts +1 -1
- package/lib/plugins/index.d.ts +1 -1
- package/lib/plugins/mathPlugin.d.ts +1 -1
- package/lib/plugins/mathPlugin.js +1 -1
- package/lib/plugins/navPlugin.d.ts +1 -1
- package/lib/plugins/navPlugin.js +1 -1
- package/lib/plugins/oembed/anchorPlugin.d.ts +1 -1
- package/lib/plugins/olPlugin.d.ts +1 -1
- package/lib/plugins/olPlugin.js +3 -3
- package/lib/plugins/paragraphPlugin.d.ts +1 -1
- package/lib/plugins/paragraphPlugin.js +2 -2
- package/lib/plugins/spanPlugin.d.ts +1 -1
- package/lib/plugins/spanPlugin.js +2 -2
- package/lib/plugins/tablePlugin.d.ts +1 -1
- package/lib/plugins/types.d.ts +2 -2
- package/lib/plugins/ulPlugin.d.ts +1 -1
- package/lib/plugins/ulPlugin.js +1 -1
- package/lib/transform.d.ts +1 -1
- package/lib/transform.js +5 -5
- package/package.json +5 -5
- package/src/extractEmbedMeta.ts +9 -9
- package/src/index.ts +3 -3
- package/src/plugins/anchorPlugin.tsx +4 -4
- package/src/plugins/asidePlugin.tsx +5 -5
- package/src/plugins/copyParagraphPlugin.tsx +5 -5
- package/src/plugins/ddPlugin.tsx +3 -3
- package/src/plugins/divPlugin.tsx +15 -15
- package/src/plugins/dtPlugin.tsx +3 -3
- package/src/plugins/embed/KeyFigureEmbedPlugin.tsx +7 -7
- package/src/plugins/embed/audioEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/blogPostEmbedPlugin.tsx +7 -7
- package/src/plugins/embed/brightcoveEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/campaignBlockPlugin.tsx +11 -8
- package/src/plugins/embed/codeEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/conceptEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/conceptListEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/contactBlockEmbedPlugin.tsx +6 -6
- package/src/plugins/embed/contentLinkEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/externalEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/fileEmbedPlugin.tsx +7 -7
- package/src/plugins/embed/footnoteEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/h5pEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/iframeEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/imageEmbedPlugin.tsx +6 -6
- package/src/plugins/embed/index.ts +28 -28
- package/src/plugins/embed/linkBlockEmbedPlugin.tsx +5 -5
- package/src/plugins/embed/relatedContentEmbedPlugin.tsx +5 -5
- package/src/plugins/h3Plugin.tsx +2 -2
- package/src/plugins/index.ts +16 -16
- package/src/plugins/mathPlugin.tsx +3 -3
- package/src/plugins/navPlugin.tsx +4 -4
- package/src/plugins/oembed/anchorPlugin.tsx +4 -4
- package/src/plugins/olPlugin.tsx +6 -6
- package/src/plugins/paragraphPlugin.tsx +4 -4
- package/src/plugins/spanPlugin.tsx +4 -4
- package/src/plugins/tablePlugin.tsx +3 -3
- package/src/plugins/types.ts +2 -2
- package/src/plugins/ulPlugin.tsx +5 -5
- package/src/transform.tsx +11 -11
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { domToReact, attributesToProps, Element } from
|
|
10
|
-
import partition from
|
|
11
|
-
import { FileList, RelatedArticleList, Grid, GridType, GridParallaxItem, FramedContent } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { domToReact, attributesToProps, Element } from "html-react-parser";
|
|
10
|
+
import partition from "lodash/partition";
|
|
11
|
+
import { FileList, RelatedArticleList, Grid, GridType, GridParallaxItem, FramedContent } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "./types";
|
|
13
13
|
|
|
14
14
|
export const divPlugin: PluginType = (node, opts) => {
|
|
15
|
-
if (node.attribs[
|
|
15
|
+
if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
|
|
16
16
|
return <FramedContent>{domToReact(node.children, opts)}</FramedContent>;
|
|
17
17
|
}
|
|
18
|
-
if (node.attribs[
|
|
18
|
+
if (node.attribs["data-type"] === "related-content" && node.children.length) {
|
|
19
19
|
const props = attributesToProps(node.attribs);
|
|
20
20
|
|
|
21
21
|
return (
|
|
@@ -24,13 +24,13 @@ export const divPlugin: PluginType = (node, opts) => {
|
|
|
24
24
|
{domToReact(node.children, opts)}
|
|
25
25
|
</RelatedArticleList>
|
|
26
26
|
);
|
|
27
|
-
} else if (node.attribs[
|
|
27
|
+
} else if (node.attribs["data-type"] === "file" && node.childNodes.length) {
|
|
28
28
|
const elements = node.childNodes.filter(
|
|
29
|
-
(c): c is Element => c.type ===
|
|
29
|
+
(c): c is Element => c.type === "tag" && c.name === "ndlaembed" && c.attribs["data-resource"] === "file",
|
|
30
30
|
);
|
|
31
31
|
const [pdfs, files] = partition(
|
|
32
32
|
elements,
|
|
33
|
-
(el) => el.attribs[
|
|
33
|
+
(el) => el.attribs["data-type"] === "pdf" && el.attribs["data-display"] === "block",
|
|
34
34
|
);
|
|
35
35
|
|
|
36
36
|
return (
|
|
@@ -39,19 +39,19 @@ export const divPlugin: PluginType = (node, opts) => {
|
|
|
39
39
|
{domToReact(pdfs, opts)}
|
|
40
40
|
</>
|
|
41
41
|
);
|
|
42
|
-
} else if (node.attribs[
|
|
42
|
+
} else if (node.attribs["data-type"] === "grid" && node.children.length > 0) {
|
|
43
43
|
const props = attributesToProps(node.attribs);
|
|
44
|
-
const columns = props[
|
|
45
|
-
const border = props[
|
|
46
|
-
const background = props[
|
|
47
|
-
const frontpage = !!props[
|
|
44
|
+
const columns = props["data-columns"] as GridType["columns"];
|
|
45
|
+
const border = props["data-border"] as GridType["border"];
|
|
46
|
+
const background = props["data-background"] as GridType["background"];
|
|
47
|
+
const frontpage = !!props["data-size"] as GridType["size"];
|
|
48
48
|
return (
|
|
49
49
|
<Grid isFrontpage={frontpage} border={border} columns={columns} background={background} {...props}>
|
|
50
50
|
{/* @ts-ignore */}
|
|
51
51
|
{domToReact(node.children, opts)}
|
|
52
52
|
</Grid>
|
|
53
53
|
);
|
|
54
|
-
} else if (node.attribs[
|
|
54
|
+
} else if (node.attribs["data-parallax-cell"] === "true" && node.children.length) {
|
|
55
55
|
return <GridParallaxItem>{domToReact(node.children, opts)}</GridParallaxItem>;
|
|
56
56
|
}
|
|
57
57
|
return null;
|
package/src/plugins/dtPlugin.tsx
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from
|
|
10
|
-
import { DefinitionTerm } from
|
|
11
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps, domToReact } from "html-react-parser";
|
|
10
|
+
import { DefinitionTerm } from "@ndla/ui";
|
|
11
|
+
import { PluginType } from "./types";
|
|
12
12
|
|
|
13
13
|
export const dtPlugin: PluginType = (node, converterOpts, opts) => {
|
|
14
14
|
const props = attributesToProps(node.attribs);
|
|
@@ -6,24 +6,24 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { KeyFigureMetaData } from
|
|
11
|
-
import { KeyFigure } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { KeyFigureMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { KeyFigure } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const keyFigureEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as KeyFigureMetaData;
|
|
17
17
|
const { title, subtitle, alt } = data.embedData;
|
|
18
18
|
return (
|
|
19
19
|
<KeyFigure
|
|
20
20
|
title={title}
|
|
21
21
|
subtitle={subtitle}
|
|
22
22
|
image={
|
|
23
|
-
data.status ===
|
|
23
|
+
data.status === "success" && data.data.metaImage
|
|
24
24
|
? {
|
|
25
25
|
src: data.data.metaImage.image.imageUrl,
|
|
26
|
-
alt: alt === undefined ?
|
|
26
|
+
alt: alt === undefined ? "" : alt,
|
|
27
27
|
}
|
|
28
28
|
: undefined
|
|
29
29
|
}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { AudioMetaData } from
|
|
11
|
-
import { AudioEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { AudioMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { AudioEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const audioEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as AudioMetaData;
|
|
17
17
|
return <AudioEmbed embed={data} heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { BlogPostMetaData } from
|
|
11
|
-
import { BlogPostV2 } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { BlogPostMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { BlogPostV2 } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const 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`;
|
|
15
15
|
|
|
16
16
|
export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
17
17
|
const props = attributesToProps(element.attribs);
|
|
18
|
-
const data = JSON.parse(props[
|
|
18
|
+
const data = JSON.parse(props["data-json"]) as BlogPostMetaData;
|
|
19
19
|
const { title, author, url, size, language, alt } = data.embedData;
|
|
20
20
|
return (
|
|
21
21
|
<BlogPostV2
|
|
@@ -25,8 +25,8 @@ export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
|
25
25
|
size={size}
|
|
26
26
|
path={opts.path}
|
|
27
27
|
metaImage={{
|
|
28
|
-
alt: alt ? alt :
|
|
29
|
-
url: data.status ===
|
|
28
|
+
alt: alt ? alt : "",
|
|
29
|
+
url: data.status === "success" ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc,
|
|
30
30
|
}}
|
|
31
31
|
/>
|
|
32
32
|
);
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { BrightcoveMetaData } from
|
|
11
|
-
import { BrightcoveEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { BrightcoveMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { BrightcoveEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const brightcoveEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as BrightcoveMetaData;
|
|
17
17
|
return <BrightcoveEmbed embed={data} heartButton={opts.components?.heartButton} renderContext={opts.renderContext} />;
|
|
18
18
|
};
|
|
@@ -6,28 +6,31 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { CampaignBlockMetaData } from
|
|
11
|
-
import { CampaignBlock } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { CampaignBlockMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { CampaignBlock } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const campaignBlockPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as CampaignBlockMetaData;
|
|
17
17
|
const embed = data.embedData;
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<CampaignBlock
|
|
21
21
|
title={{ title: embed.title, language: embed.titleLanguage }}
|
|
22
|
-
description={{
|
|
22
|
+
description={{
|
|
23
|
+
text: embed.description,
|
|
24
|
+
language: embed.descriptionLanguage,
|
|
25
|
+
}}
|
|
23
26
|
url={{ url: embed.url, text: embed.urlText }}
|
|
24
27
|
path={opts.path}
|
|
25
28
|
imageSide={embed.imageSide}
|
|
26
29
|
image={
|
|
27
|
-
data.status ===
|
|
30
|
+
data.status === "success" && data.data.image
|
|
28
31
|
? {
|
|
29
32
|
src: data.data.image.image.imageUrl,
|
|
30
|
-
alt: embed.alt === undefined ?
|
|
33
|
+
alt: embed.alt === undefined ? "" : embed.alt,
|
|
31
34
|
}
|
|
32
35
|
: undefined
|
|
33
36
|
}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { CodeEmbed } from
|
|
11
|
-
import { CodeMetaData } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { CodeEmbed } from "@ndla/code";
|
|
11
|
+
import { CodeMetaData } from "@ndla/types-embed";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const codeEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as CodeMetaData;
|
|
17
17
|
return <CodeEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { ConceptMetaData } from
|
|
11
|
-
import { ConceptEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { ConceptMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ConceptEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const conceptEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as ConceptMetaData;
|
|
17
17
|
return <ConceptEmbed embed={data} fullWidth heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { ConceptListMetaData } from
|
|
11
|
-
import { ConceptListEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { ConceptListMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ConceptListEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const conceptListEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as ConceptListMetaData;
|
|
17
17
|
return <ConceptListEmbed embed={data} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { ContactBlockMetaData } from
|
|
11
|
-
import { ContactBlock } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { ContactBlockMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ContactBlock } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const embedData = JSON.parse(props[
|
|
16
|
+
const embedData = JSON.parse(props["data-json"]) as ContactBlockMetaData;
|
|
17
17
|
const { name, email, description, blob, blobColor, jobTitle, alt } = embedData.embedData;
|
|
18
18
|
return (
|
|
19
19
|
<ContactBlock
|
|
20
|
-
image={embedData.status ===
|
|
20
|
+
image={embedData.status === "success" ? embedData.data.image : undefined}
|
|
21
21
|
embedAlt={alt}
|
|
22
22
|
description={description}
|
|
23
23
|
email={email}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { ContentLinkMetaData } from
|
|
11
|
-
import { ContentLinkEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { ContentLinkMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ContentLinkEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const contentLinkEmbedPlugin: PluginType = (element, _, { isOembed }) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as ContentLinkMetaData;
|
|
17
17
|
return <ContentLinkEmbed embed={data} isOembed={isOembed} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { OembedMetaData } from
|
|
11
|
-
import { ExternalEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { OembedMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ExternalEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const externalEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as OembedMetaData;
|
|
17
17
|
return <ExternalEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -6,23 +6,23 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { FileMetaData } from
|
|
11
|
-
import { PdfFile, File } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { FileMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { PdfFile, File } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const fileEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as FileMetaData;
|
|
17
17
|
const { type, title, url, display } = data.embedData;
|
|
18
|
-
if (type ===
|
|
18
|
+
if (type === "pdf" && display === "block") {
|
|
19
19
|
return <PdfFile title={title} url={url} />;
|
|
20
20
|
} else {
|
|
21
21
|
return (
|
|
22
22
|
<File
|
|
23
23
|
url={url}
|
|
24
24
|
title={title}
|
|
25
|
-
fileExists={data.status ===
|
|
25
|
+
fileExists={data.status === "success" ? !!data.data.exists : false}
|
|
26
26
|
fileType={type}
|
|
27
27
|
/>
|
|
28
28
|
);
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { FootnoteMetaData } from
|
|
11
|
-
import { FootnoteEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { FootnoteMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { FootnoteEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const footnoteEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as FootnoteMetaData;
|
|
17
17
|
return <FootnoteEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { H5pMetaData } from
|
|
11
|
-
import { H5pEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { H5pMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { H5pEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const h5pEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as H5pMetaData;
|
|
17
17
|
return <H5pEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { IframeMetaData } from
|
|
11
|
-
import { IframeEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { IframeMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { IframeEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const iframeEmbedPlugin: PluginType = (element) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as IframeMetaData;
|
|
17
17
|
return <IframeEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, Element } from
|
|
10
|
-
import { ImageMetaData } from
|
|
11
|
-
import { ImageEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps, Element } from "html-react-parser";
|
|
10
|
+
import { ImageMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { ImageEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const imageEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
17
|
-
const inGrid = (element.parentNode?.parentNode as Element)?.attribs?.[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as ImageMetaData;
|
|
17
|
+
const inGrid = (element.parentNode?.parentNode as Element)?.attribs?.["data-type"] === "grid";
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<ImageEmbed
|
|
@@ -6,43 +6,43 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { audioEmbedPlugin } from
|
|
10
|
-
import { blogPostEmbedPlugin } from
|
|
11
|
-
import { brightcoveEmbedPlugin } from
|
|
12
|
-
import { campaignBlockPlugin } from
|
|
13
|
-
import { codeEmbedPlugin } from
|
|
14
|
-
import { conceptEmbedPlugin } from
|
|
15
|
-
import { conceptListEmbedPlugin } from
|
|
16
|
-
import { contactBlockEmbedPlugin } from
|
|
17
|
-
import { contentLinkEmbedPlugin } from
|
|
18
|
-
import { externalEmbedPlugin } from
|
|
19
|
-
import { fileEmbedPlugin } from
|
|
20
|
-
import { footnoteEmbedPlugin } from
|
|
21
|
-
import { h5pEmbedPlugin } from
|
|
22
|
-
import { iframeEmbedPlugin } from
|
|
23
|
-
import { imageEmbedPlugin } from
|
|
24
|
-
import { keyFigureEmbedPlugin } from
|
|
25
|
-
import { linkBlockPlugin } from
|
|
26
|
-
import { relatedContentEmbedPlugin } from
|
|
27
|
-
import { PluginType } from
|
|
9
|
+
import { audioEmbedPlugin } from "./audioEmbedPlugin";
|
|
10
|
+
import { blogPostEmbedPlugin } from "./blogPostEmbedPlugin";
|
|
11
|
+
import { brightcoveEmbedPlugin } from "./brightcoveEmbedPlugin";
|
|
12
|
+
import { campaignBlockPlugin } from "./campaignBlockPlugin";
|
|
13
|
+
import { codeEmbedPlugin } from "./codeEmbedPlugin";
|
|
14
|
+
import { conceptEmbedPlugin } from "./conceptEmbedPlugin";
|
|
15
|
+
import { conceptListEmbedPlugin } from "./conceptListEmbedPlugin";
|
|
16
|
+
import { contactBlockEmbedPlugin } from "./contactBlockEmbedPlugin";
|
|
17
|
+
import { contentLinkEmbedPlugin } from "./contentLinkEmbedPlugin";
|
|
18
|
+
import { externalEmbedPlugin } from "./externalEmbedPlugin";
|
|
19
|
+
import { fileEmbedPlugin } from "./fileEmbedPlugin";
|
|
20
|
+
import { footnoteEmbedPlugin } from "./footnoteEmbedPlugin";
|
|
21
|
+
import { h5pEmbedPlugin } from "./h5pEmbedPlugin";
|
|
22
|
+
import { iframeEmbedPlugin } from "./iframeEmbedPlugin";
|
|
23
|
+
import { imageEmbedPlugin } from "./imageEmbedPlugin";
|
|
24
|
+
import { keyFigureEmbedPlugin } from "./KeyFigureEmbedPlugin";
|
|
25
|
+
import { linkBlockPlugin } from "./linkBlockEmbedPlugin";
|
|
26
|
+
import { relatedContentEmbedPlugin } from "./relatedContentEmbedPlugin";
|
|
27
|
+
import { PluginType } from "../types";
|
|
28
28
|
|
|
29
29
|
export const embedPlugins: Record<string, PluginType> = {
|
|
30
30
|
image: imageEmbedPlugin,
|
|
31
31
|
audio: audioEmbedPlugin,
|
|
32
32
|
h5p: h5pEmbedPlugin,
|
|
33
|
-
|
|
33
|
+
"code-block": codeEmbedPlugin,
|
|
34
34
|
external: externalEmbedPlugin,
|
|
35
35
|
iframe: iframeEmbedPlugin,
|
|
36
36
|
footnote: footnoteEmbedPlugin,
|
|
37
37
|
brightcove: brightcoveEmbedPlugin,
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
"related-content": relatedContentEmbedPlugin,
|
|
39
|
+
"content-link": contentLinkEmbedPlugin,
|
|
40
40
|
concept: conceptEmbedPlugin,
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
"concept-list": conceptListEmbedPlugin,
|
|
42
|
+
"blog-post": blogPostEmbedPlugin,
|
|
43
43
|
file: fileEmbedPlugin,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
"key-figure": keyFigureEmbedPlugin,
|
|
45
|
+
"contact-block": contactBlockEmbedPlugin,
|
|
46
|
+
"campaign-block": campaignBlockPlugin,
|
|
47
|
+
"link-block": linkBlockPlugin,
|
|
48
48
|
};
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { LinkBlockMetaData } from
|
|
11
|
-
import { LinkBlock } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { LinkBlockMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { LinkBlock } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const linkBlockPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as LinkBlockMetaData;
|
|
17
17
|
|
|
18
18
|
return <LinkBlock {...data.embedData} path={opts.path} />;
|
|
19
19
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps } from
|
|
10
|
-
import { RelatedContentMetaData } from
|
|
11
|
-
import { RelatedContentEmbed } from
|
|
12
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps } from "html-react-parser";
|
|
10
|
+
import { RelatedContentMetaData } from "@ndla/types-embed";
|
|
11
|
+
import { RelatedContentEmbed } from "@ndla/ui";
|
|
12
|
+
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const relatedContentEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props[
|
|
16
|
+
const data = JSON.parse(props["data-json"]) as RelatedContentMetaData;
|
|
17
17
|
return <RelatedContentEmbed embed={data} subject={opts.subject} ndlaFrontendDomain={opts.frontendDomain} />;
|
|
18
18
|
};
|
package/src/plugins/h3Plugin.tsx
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from
|
|
10
|
-
import { PluginType } from
|
|
9
|
+
import { attributesToProps, domToReact } from "html-react-parser";
|
|
10
|
+
import { PluginType } from "./types";
|
|
11
11
|
export const h3Plugin: PluginType = (node, converterOpts, opts) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
return (
|