@ndla/article-converter 6.1.7 → 6.2.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/lib/transform.d.ts +1 -1
- package/package.json +7 -7
- package/src/plugins/anchorPlugin.tsx +3 -3
- package/src/plugins/asidePlugin.tsx +3 -3
- package/src/plugins/copyParagraphPlugin.tsx +2 -2
- package/src/plugins/ddPlugin.tsx +2 -2
- package/src/plugins/divPlugin.tsx +3 -3
- package/src/plugins/dtPlugin.tsx +2 -2
- package/src/plugins/embed/KeyFigureEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/audioEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/blogPostEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/brightcoveEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/campaignBlockPlugin.tsx +1 -1
- package/src/plugins/embed/codeEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/conceptEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/conceptListEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/contactBlockEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/contentLinkEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/copyrightEmbedPlugin.tsx +3 -3
- package/src/plugins/embed/externalEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/fileEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/footnoteEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/h5pEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/iframeEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/imageEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/linkBlockEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/relatedContentEmbedPlugin.tsx +1 -1
- package/src/plugins/embed/uuDisclaimerEmbedPlugin.tsx +3 -3
- package/src/plugins/h3Plugin.tsx +2 -2
- package/src/plugins/navPlugin.tsx +2 -2
- package/src/plugins/oembed/anchorPlugin.tsx +3 -3
- package/src/plugins/olPlugin.tsx +2 -2
- package/src/plugins/paragraphPlugin.tsx +3 -3
- package/src/plugins/spanPlugin.tsx +2 -2
- package/src/plugins/tablePlugin.tsx +2 -2
- package/src/plugins/ulPlugin.tsx +2 -2
package/lib/transform.d.ts
CHANGED
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="react" />
|
|
9
9
|
import { TransformOptions } from "./plugins/types";
|
|
10
|
-
declare const transform: (content: string, opts: TransformOptions) => string | JSX.Element | JSX.Element[];
|
|
10
|
+
declare const transform: (content: string, opts: TransformOptions) => string | import("react").JSX.Element | import("react").JSX.Element[];
|
|
11
11
|
export default transform;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ndla/types-backend": "^0.2.
|
|
31
|
-
"@ndla/types-embed": "^4.1.
|
|
30
|
+
"@ndla/types-backend": "^0.2.64",
|
|
31
|
+
"@ndla/types-embed": "^4.1.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ndla/code": "^5.0.
|
|
35
|
-
"@ndla/ui": "^50.
|
|
36
|
-
"html-react-parser": "^
|
|
34
|
+
"@ndla/code": "^5.0.49",
|
|
35
|
+
"@ndla/ui": "^50.12.0",
|
|
36
|
+
"html-react-parser": "^5.1.8",
|
|
37
37
|
"lodash": "^4.17.20"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5a808c292eb3b4ca8281c1084930c7316051a375"
|
|
52
52
|
}
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { SafeLink } from "@ndla/safelink";
|
|
11
11
|
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
12
12
|
import { PluginType } from "./types";
|
|
13
13
|
|
|
14
14
|
export const anchorPlugin: PluginType = (node, opts, { path }) => {
|
|
15
15
|
const props = attributesToProps(node.attribs);
|
|
16
|
-
const href = getPossiblyRelativeUrl(props.href, path);
|
|
16
|
+
const href = getPossiblyRelativeUrl(props.href as string, path);
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<SafeLink {...props} to={href}>
|
|
20
|
-
{domToReact(node.children, opts)}
|
|
20
|
+
{domToReact(node.children as DOMNode[], opts)}
|
|
21
21
|
</SafeLink>
|
|
22
22
|
);
|
|
23
23
|
};
|
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, domToReact } from "html-react-parser";
|
|
10
10
|
import { Aside, FactBox } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
export const asidePlugin: PluginType = (node, opts) => {
|
|
13
13
|
if (node.attribs["data-type"] === "factAside") {
|
|
14
|
-
return <FactBox>{domToReact(node.children, opts)}</FactBox>;
|
|
14
|
+
return <FactBox>{domToReact(node.children as DOMNode[], opts)}</FactBox>;
|
|
15
15
|
} else if (node.attribs["data-type"] === "rightAside") {
|
|
16
16
|
return (
|
|
17
17
|
<Aside wideScreen alwaysShow>
|
|
18
|
-
{domToReact(node.children, opts)}
|
|
18
|
+
{domToReact(node.children as DOMNode[], opts)}
|
|
19
19
|
</Aside>
|
|
20
20
|
);
|
|
21
21
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { Element, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, Element, domToReact } from "html-react-parser";
|
|
10
10
|
import { CopyParagraphButton } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
export const copyParagraphPlugin: PluginType = (node, converterOpts, opts) => {
|
|
@@ -14,7 +14,7 @@ export const copyParagraphPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
14
14
|
if (parent?.name === "section" || (parent?.name === "div" && Object.keys(parent.attribs ?? {}).length === 0)) {
|
|
15
15
|
return (
|
|
16
16
|
<CopyParagraphButton copyText={node.attribs["data-text"]} lang={opts.articleLanguage}>
|
|
17
|
-
{domToReact(node.children, converterOpts)}
|
|
17
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
18
18
|
</CopyParagraphButton>
|
|
19
19
|
);
|
|
20
20
|
}
|
package/src/plugins/ddPlugin.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { DefinitionDescription } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ export const ddPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<DefinitionDescription {...props} lang={opts.articleLanguage}>
|
|
18
|
-
{domToReact(node.children, converterOpts)}
|
|
18
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
19
19
|
</DefinitionDescription>
|
|
20
20
|
);
|
|
21
21
|
};
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { domToReact, attributesToProps, Element } from "html-react-parser";
|
|
9
|
+
import { domToReact, attributesToProps, Element, DOMNode } from "html-react-parser";
|
|
10
10
|
import partition from "lodash/partition";
|
|
11
11
|
import { FileList, RelatedArticleList, Grid, GridType, GridParallaxItem, FramedContent } from "@ndla/ui";
|
|
12
12
|
import { PluginType } from "./types";
|
|
13
13
|
|
|
14
14
|
export const divPlugin: PluginType = (node, opts) => {
|
|
15
15
|
if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
|
|
16
|
-
return <FramedContent>{domToReact(node.children, opts)}</FramedContent>;
|
|
16
|
+
return <FramedContent>{domToReact(node.children as DOMNode[], opts)}</FramedContent>;
|
|
17
17
|
}
|
|
18
18
|
if (node.attribs["data-type"] === "related-content" && node.children.length) {
|
|
19
19
|
const props = attributesToProps(node.attribs);
|
|
@@ -52,7 +52,7 @@ export const divPlugin: PluginType = (node, opts) => {
|
|
|
52
52
|
</Grid>
|
|
53
53
|
);
|
|
54
54
|
} else if (node.attribs["data-parallax-cell"] === "true" && node.children.length) {
|
|
55
|
-
return <GridParallaxItem>{domToReact(node.children, opts)}</GridParallaxItem>;
|
|
55
|
+
return <GridParallaxItem>{domToReact(node.children as DOMNode[], opts)}</GridParallaxItem>;
|
|
56
56
|
}
|
|
57
57
|
return null;
|
|
58
58
|
};
|
package/src/plugins/dtPlugin.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { DefinitionTerm } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
|
|
@@ -15,7 +15,7 @@ export const dtPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<DefinitionTerm {...props} lang={opts.articleLanguage}>
|
|
18
|
-
{domToReact(node.children, converterOpts)}
|
|
18
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
19
19
|
</DefinitionTerm>
|
|
20
20
|
);
|
|
21
21
|
};
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as KeyFigureMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as KeyFigureMetaData;
|
|
17
17
|
const { title, subtitle, alt } = data.embedData;
|
|
18
18
|
return (
|
|
19
19
|
<KeyFigure
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as AudioMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as AudioMetaData;
|
|
17
17
|
return <AudioEmbed embed={data} heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -15,7 +15,7 @@ export const errorSvgSrc = `data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8
|
|
|
15
15
|
|
|
16
16
|
export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
17
17
|
const props = attributesToProps(element.attribs);
|
|
18
|
-
const data = JSON.parse(props["data-json"]) as BlogPostMetaData;
|
|
18
|
+
const data = JSON.parse(props["data-json"] as string) as BlogPostMetaData;
|
|
19
19
|
const { title, author, url, size, language, alt } = data.embedData;
|
|
20
20
|
return (
|
|
21
21
|
<BlogPostV2
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as BrightcoveMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as BrightcoveMetaData;
|
|
17
17
|
return <BrightcoveEmbed embed={data} heartButton={opts.components?.heartButton} renderContext={opts.renderContext} />;
|
|
18
18
|
};
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as CampaignBlockMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as CampaignBlockMetaData;
|
|
17
17
|
const embed = data.embedData;
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as CodeMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as CodeMetaData;
|
|
17
17
|
return <CodeEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as ConceptMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as ConceptMetaData;
|
|
17
17
|
return <ConceptEmbed embed={data} fullWidth heartButton={opts.components?.heartButton} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as ConceptListMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as ConceptListMetaData;
|
|
17
17
|
return <ConceptListEmbed embed={data} lang={opts.articleLanguage} />;
|
|
18
18
|
};
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as ContactBlockMetaData;
|
|
16
|
+
const embedData = JSON.parse(props["data-json"] as string) as ContactBlockMetaData;
|
|
17
17
|
const { name, email, description, blob, blobColor, jobTitle, alt } = embedData.embedData;
|
|
18
18
|
return (
|
|
19
19
|
<ContactBlock
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as ContentLinkMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) 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, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { CopyrightMetaData } from "@ndla/types-embed";
|
|
11
11
|
import { CopyrightEmbed } from "@ndla/ui";
|
|
12
12
|
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const copyrightEmbedPlugin: PluginType = (element, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props["data-json"]) as CopyrightMetaData;
|
|
17
|
-
return <CopyrightEmbed embed={data}>{domToReact(element.children, opts)}</CopyrightEmbed>;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as CopyrightMetaData;
|
|
17
|
+
return <CopyrightEmbed embed={data}>{domToReact(element.children as DOMNode[], opts)}</CopyrightEmbed>;
|
|
18
18
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as OembedMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as OembedMetaData;
|
|
17
17
|
return <ExternalEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as FileMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as FileMetaData;
|
|
17
17
|
const { type, title, url, display } = data.embedData;
|
|
18
18
|
if (type === "pdf" && display === "block") {
|
|
19
19
|
return <PdfFile title={title} url={url} />;
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as FootnoteMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as FootnoteMetaData;
|
|
17
17
|
return <FootnoteEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as H5pMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as H5pMetaData;
|
|
17
17
|
return <H5pEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as IframeMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as IframeMetaData;
|
|
17
17
|
return <IframeEmbed embed={data} />;
|
|
18
18
|
};
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as ImageMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as ImageMetaData;
|
|
17
17
|
const inGrid = (element.parentNode?.parentNode as Element)?.attribs?.["data-type"] === "grid";
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -13,7 +13,7 @@ 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["data-json"]) as LinkBlockMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as LinkBlockMetaData;
|
|
17
17
|
|
|
18
18
|
return <LinkBlock {...data.embedData} path={opts.path} />;
|
|
19
19
|
};
|
|
@@ -13,6 +13,6 @@ 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["data-json"]) as RelatedContentMetaData;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as RelatedContentMetaData;
|
|
17
17
|
return <RelatedContentEmbed embed={data} subject={opts.subject} ndlaFrontendDomain={opts.frontendDomain} />;
|
|
18
18
|
};
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { UuDisclaimerMetaData } from "@ndla/types-embed";
|
|
11
11
|
import { UuDisclaimerEmbed } from "@ndla/ui";
|
|
12
12
|
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const uuDisclaimerEmbedPlugin: PluginType = (element, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
|
-
const data = JSON.parse(props["data-json"]) as UuDisclaimerMetaData;
|
|
17
|
-
return <UuDisclaimerEmbed embed={data}>{domToReact(element.children, opts)}</UuDisclaimerEmbed>;
|
|
16
|
+
const data = JSON.parse(props["data-json"] as string) as UuDisclaimerMetaData;
|
|
17
|
+
return <UuDisclaimerEmbed embed={data}>{domToReact(element.children as DOMNode[], opts)}</UuDisclaimerEmbed>;
|
|
18
18
|
};
|
package/src/plugins/h3Plugin.tsx
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { PluginType } from "./types";
|
|
11
11
|
export const h3Plugin: PluginType = (node, converterOpts, opts) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
13
13
|
return (
|
|
14
14
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
15
15
|
<h3 {...props} tabIndex={0} lang={opts.articleLanguage}>
|
|
16
|
-
{domToReact(node.children, converterOpts)}
|
|
16
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
17
17
|
</h3>
|
|
18
18
|
);
|
|
19
19
|
};
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { LinkBlockSection } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
|
|
13
13
|
export const navPlugin: PluginType = (node, opts) => {
|
|
14
14
|
if (node.attribs["data-type"] === "link-block-list") {
|
|
15
15
|
const props = attributesToProps(node.attribs);
|
|
16
|
-
return <LinkBlockSection {...props}>{domToReact(node.children, opts)}</LinkBlockSection>;
|
|
16
|
+
return <LinkBlockSection {...props}>{domToReact(node.children as DOMNode[], opts)}</LinkBlockSection>;
|
|
17
17
|
}
|
|
18
18
|
return null;
|
|
19
19
|
};
|
|
@@ -6,17 +6,17 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { SafeLink } from "@ndla/safelink";
|
|
11
11
|
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
12
12
|
import { PluginType } from "../types";
|
|
13
13
|
|
|
14
14
|
export const anchorPlugin: PluginType = (node, options, { path }) => {
|
|
15
15
|
const props = attributesToProps(node.attribs);
|
|
16
|
-
const href = getPossiblyRelativeUrl(props.href, path);
|
|
16
|
+
const href = getPossiblyRelativeUrl(props.href as string, path);
|
|
17
17
|
return (
|
|
18
18
|
<SafeLink {...props} target="_blank" to={href} rel="noreferrer">
|
|
19
|
-
{domToReact(node.children, options)}
|
|
19
|
+
{domToReact(node.children as DOMNode[], options)}
|
|
20
20
|
</SafeLink>
|
|
21
21
|
);
|
|
22
22
|
};
|
package/src/plugins/olPlugin.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { OrderedList } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
export const olPlugin: PluginType = (node, converterOpts, opts) => {
|
|
@@ -18,7 +18,7 @@ export const olPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<OrderedList {...props} className={classes.length ? classes : undefined} lang={opts.articleLanguage}>
|
|
21
|
-
{domToReact(node.children, converterOpts)}
|
|
21
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
22
22
|
</OrderedList>
|
|
23
23
|
);
|
|
24
24
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { PluginType } from "./types";
|
|
11
11
|
export const paragraphPlugin: PluginType = (node, converterOpts, opts) => {
|
|
12
12
|
const props = attributesToProps(node.attribs);
|
|
@@ -14,13 +14,13 @@ export const paragraphPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
14
14
|
const classes = [node.attribs.class ?? "", "u-text-center"].filter((c) => !!c).join(" ");
|
|
15
15
|
return (
|
|
16
16
|
<p {...props} lang={opts.articleLanguage} data-align={undefined} className={classes}>
|
|
17
|
-
{domToReact(node.children, converterOpts)}
|
|
17
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
18
18
|
</p>
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
return (
|
|
22
22
|
<p {...props} lang={opts.articleLanguage}>
|
|
23
|
-
{domToReact(node.children, converterOpts)}
|
|
23
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
24
24
|
</p>
|
|
25
25
|
);
|
|
26
26
|
};
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { PluginType } from "./types";
|
|
11
11
|
export const spanPlugin: PluginType = (node, opts) => {
|
|
12
12
|
if (node.attribs["data-size"] === "large") {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
return (
|
|
15
15
|
<span {...props} data-size={undefined} className={`${node.attribs.class ?? ""} u-large-body-text`}>
|
|
16
|
-
{domToReact(node.children, opts)}
|
|
16
|
+
{domToReact(node.children as DOMNode[], opts)}
|
|
17
17
|
</span>
|
|
18
18
|
);
|
|
19
19
|
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { Table } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
export const tablePlugin: PluginType = (node, converterOpts, opts) => {
|
|
13
13
|
const props = attributesToProps(node.attribs);
|
|
14
14
|
return (
|
|
15
15
|
<Table {...props} lang={opts.articleLanguage}>
|
|
16
|
-
{domToReact(node.children, converterOpts)}
|
|
16
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
17
17
|
</Table>
|
|
18
18
|
);
|
|
19
19
|
};
|
package/src/plugins/ulPlugin.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { attributesToProps, domToReact } from "html-react-parser";
|
|
9
|
+
import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { UnOrderedList } from "@ndla/ui";
|
|
11
11
|
import { PluginType } from "./types";
|
|
12
12
|
export const ulPlugin: PluginType = (node, converterOpts, opts) => {
|
|
@@ -16,7 +16,7 @@ export const ulPlugin: PluginType = (node, converterOpts, opts) => {
|
|
|
16
16
|
.join(" ");
|
|
17
17
|
return (
|
|
18
18
|
<UnOrderedList {...props} className={classes} lang={opts.articleLanguage}>
|
|
19
|
-
{domToReact(node.children, converterOpts)}
|
|
19
|
+
{domToReact(node.children as DOMNode[], converterOpts)}
|
|
20
20
|
</UnOrderedList>
|
|
21
21
|
);
|
|
22
22
|
};
|