@ndla/article-converter 10.0.38-alpha.0 → 10.0.40-alpha.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.
@@ -7,12 +7,20 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { BlockQuote } from "@ndla/primitives";
10
+ import { ContentTypeBlockQuote } from "@ndla/ui";
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
- export const blockquotePlugin = (node, opts) => {
13
- const props = attributesToProps(node.attribs);
14
- return /*#__PURE__*/_jsx(BlockQuote, {
12
+ export const blockquotePlugin = (node, opts, _ref) => {
13
+ let {
14
+ contentType
15
+ } = _ref;
16
+ const {
17
+ "data-variant": variant,
18
+ ...props
19
+ } = attributesToProps(node.attribs);
20
+ return /*#__PURE__*/_jsx(ContentTypeBlockQuote, {
15
21
  ...props,
22
+ variant: variant,
23
+ contentType: contentType,
16
24
  children: domToReact(node.children, opts)
17
25
  });
18
26
  };
@@ -7,12 +7,21 @@
7
7
  */
8
8
 
9
9
  import { domToReact, attributesToProps } from "html-react-parser";
10
- import { FramedContent } from "@ndla/primitives";
11
- import { FileListEmbed, RelatedArticleList, Grid, GridParallaxItem } from "@ndla/ui";
10
+ import { FileListEmbed, RelatedArticleList, Grid, GridParallaxItem, ContentTypeFramedContent } from "@ndla/ui";
12
11
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- export const divPlugin = (node, opts) => {
12
+ export const divPlugin = (node, opts, _ref) => {
13
+ let {
14
+ contentType
15
+ } = _ref;
14
16
  if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
15
- return /*#__PURE__*/_jsx(FramedContent, {
17
+ const {
18
+ "data-variant": variant,
19
+ ...props
20
+ } = attributesToProps(node.attribs);
21
+ return /*#__PURE__*/_jsx(ContentTypeFramedContent, {
22
+ contentType: contentType,
23
+ variant: variant,
24
+ ...props,
16
25
  children: domToReact(node.children, opts)
17
26
  });
18
27
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.blockquotePlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _primitives = require("@ndla/primitives");
8
+ var _ui = require("@ndla/ui");
9
9
  var _jsxRuntime = require("react/jsx-runtime");
10
10
  /**
11
11
  * Copyright (c) 2024-present, NDLA.
@@ -15,10 +15,18 @@ var _jsxRuntime = require("react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- const blockquotePlugin = (node, opts) => {
19
- const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.BlockQuote, {
18
+ const blockquotePlugin = (node, opts, _ref) => {
19
+ let {
20
+ contentType
21
+ } = _ref;
22
+ const {
23
+ "data-variant": variant,
24
+ ...props
25
+ } = (0, _htmlReactParser.attributesToProps)(node.attribs);
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.ContentTypeBlockQuote, {
21
27
  ...props,
28
+ variant: variant,
29
+ contentType: contentType,
22
30
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
23
31
  });
24
32
  };
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.divPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _primitives = require("@ndla/primitives");
9
8
  var _ui = require("@ndla/ui");
10
9
  var _jsxRuntime = require("react/jsx-runtime");
11
10
  /**
@@ -16,9 +15,19 @@ var _jsxRuntime = require("react/jsx-runtime");
16
15
  *
17
16
  */
18
17
 
19
- const divPlugin = (node, opts) => {
18
+ const divPlugin = (node, opts, _ref) => {
19
+ let {
20
+ contentType
21
+ } = _ref;
20
22
  if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
21
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_primitives.FramedContent, {
23
+ const {
24
+ "data-variant": variant,
25
+ ...props
26
+ } = (0, _htmlReactParser.attributesToProps)(node.attribs);
27
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.ContentTypeFramedContent, {
28
+ contentType: contentType,
29
+ variant: variant,
30
+ ...props,
22
31
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
23
32
  });
24
33
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /// <reference types="react" />
9
9
  import { Element, HTMLReactParserOptions } from "html-react-parser";
10
- import { RenderContext, CanonicalUrlFuncs } from "@ndla/ui";
10
+ import { RenderContext, CanonicalUrlFuncs, ContentType } from "@ndla/ui";
11
11
  export interface TransformOptions {
12
12
  isOembed?: boolean;
13
13
  subject?: string;
@@ -17,5 +17,6 @@ export interface TransformOptions {
17
17
  articleLanguage?: string;
18
18
  canonicalUrls?: CanonicalUrlFuncs;
19
19
  renderContext?: RenderContext;
20
+ contentType?: ContentType;
20
21
  }
21
22
  export type PluginType = (element: Element, options: HTMLReactParserOptions, metaData: TransformOptions) => JSX.Element | undefined | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "10.0.38-alpha.0",
3
+ "version": "10.0.40-alpha.0",
4
4
  "description": "Transforms NDLA articles into extended html versions",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,8 +31,8 @@
31
31
  "@ndla/types-embed": "^5.0.3-alpha.0"
32
32
  },
33
33
  "dependencies": {
34
- "@ndla/primitives": "^1.0.33-alpha.0",
35
- "@ndla/ui": "^56.0.36-alpha.0",
34
+ "@ndla/primitives": "^1.0.34-alpha.0",
35
+ "@ndla/ui": "^56.0.37-alpha.0",
36
36
  "html-react-parser": "^5.1.8"
37
37
  },
38
38
  "peerDependencies": {
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "183d252ef9c40520099fadd2ee6a48e46eb1c71e"
48
+ "gitHead": "fc25549110f961f71c8f06bad8a217f0272ffb9b"
49
49
  }
@@ -7,10 +7,18 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { BlockQuote } from "@ndla/primitives";
10
+ import { ContentTypeBlockQuote, ContentTypeBlockQuoteVariant } from "@ndla/ui";
11
11
  import { PluginType } from "./types";
12
12
 
13
- export const blockquotePlugin: PluginType = (node, opts) => {
14
- const props = attributesToProps(node.attribs);
15
- return <BlockQuote {...props}>{domToReact(node.children as DOMNode[], opts)}</BlockQuote>;
13
+ export const blockquotePlugin: PluginType = (node, opts, { contentType }) => {
14
+ const { "data-variant": variant, ...props } = attributesToProps(node.attribs);
15
+ return (
16
+ <ContentTypeBlockQuote
17
+ {...props}
18
+ variant={variant as ContentTypeBlockQuoteVariant | undefined}
19
+ contentType={contentType}
20
+ >
21
+ {domToReact(node.children as DOMNode[], opts)}
22
+ </ContentTypeBlockQuote>
23
+ );
16
24
  };
@@ -7,13 +7,29 @@
7
7
  */
8
8
 
9
9
  import { domToReact, attributesToProps, Element, DOMNode } from "html-react-parser";
10
- import { FramedContent } from "@ndla/primitives";
11
- import { FileListEmbed, RelatedArticleList, Grid, GridType, GridParallaxItem } from "@ndla/ui";
10
+ import {
11
+ FileListEmbed,
12
+ RelatedArticleList,
13
+ Grid,
14
+ GridType,
15
+ GridParallaxItem,
16
+ ContentTypeFramedContent,
17
+ ContentTypeFramedContentVariant,
18
+ } from "@ndla/ui";
12
19
  import { PluginType } from "./types";
13
20
 
14
- export const divPlugin: PluginType = (node, opts) => {
21
+ export const divPlugin: PluginType = (node, opts, { contentType }) => {
15
22
  if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
16
- return <FramedContent>{domToReact(node.children as DOMNode[], opts)}</FramedContent>;
23
+ const { "data-variant": variant, ...props } = attributesToProps(node.attribs);
24
+ return (
25
+ <ContentTypeFramedContent
26
+ contentType={contentType}
27
+ variant={variant as ContentTypeFramedContentVariant | undefined}
28
+ {...props}
29
+ >
30
+ {domToReact(node.children as DOMNode[], opts)}
31
+ </ContentTypeFramedContent>
32
+ );
17
33
  }
18
34
  if (node.attribs["data-type"] === "related-content" && node.children.length) {
19
35
  const props = attributesToProps(node.attribs);
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { Element, HTMLReactParserOptions } from "html-react-parser";
10
- import { RenderContext, CanonicalUrlFuncs } from "@ndla/ui";
10
+ import { RenderContext, CanonicalUrlFuncs, ContentType } from "@ndla/ui";
11
11
 
12
12
  export interface TransformOptions {
13
13
  isOembed?: boolean;
@@ -18,6 +18,7 @@ export interface TransformOptions {
18
18
  articleLanguage?: string;
19
19
  canonicalUrls?: CanonicalUrlFuncs;
20
20
  renderContext?: RenderContext;
21
+ contentType?: ContentType;
21
22
  }
22
23
 
23
24
  export type PluginType = (