@ndla/article-converter 9.0.13-alpha.0 → 9.0.15-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.
Files changed (35) hide show
  1. package/es/plugins/blockquotePlugin.js +18 -0
  2. package/es/plugins/{ddPlugin.js → detailsPlugin.js} +4 -5
  3. package/es/plugins/divPlugin.js +2 -1
  4. package/es/plugins/{dtPlugin.js → dlPlugin.js} +3 -3
  5. package/es/plugins/embed/conceptEmbedPlugin.js +0 -1
  6. package/es/plugins/index.js +9 -5
  7. package/es/plugins/olPlugin.js +5 -6
  8. package/es/plugins/summaryPlugin.js +18 -0
  9. package/es/plugins/tablePlugin.js +1 -1
  10. package/es/plugins/ulPlugin.js +1 -1
  11. package/lib/plugins/blockquotePlugin.d.ts +9 -0
  12. package/lib/plugins/blockquotePlugin.js +25 -0
  13. package/lib/plugins/{ddPlugin.d.ts → detailsPlugin.d.ts} +2 -2
  14. package/lib/plugins/{ddPlugin.js → detailsPlugin.js} +6 -7
  15. package/lib/plugins/divPlugin.js +2 -1
  16. package/lib/plugins/{dtPlugin.d.ts → dlPlugin.d.ts} +1 -1
  17. package/lib/plugins/{dtPlugin.js → dlPlugin.js} +5 -5
  18. package/lib/plugins/embed/conceptEmbedPlugin.js +0 -1
  19. package/lib/plugins/index.js +9 -5
  20. package/lib/plugins/olPlugin.js +6 -7
  21. package/lib/plugins/summaryPlugin.d.ts +9 -0
  22. package/lib/plugins/summaryPlugin.js +25 -0
  23. package/lib/plugins/tablePlugin.js +2 -2
  24. package/lib/plugins/ulPlugin.js +2 -2
  25. package/package.json +4 -3
  26. package/src/plugins/blockquotePlugin.tsx +16 -0
  27. package/src/plugins/detailsPlugin.tsx +17 -0
  28. package/src/plugins/divPlugin.tsx +2 -1
  29. package/src/plugins/{dtPlugin.tsx → dlPlugin.tsx} +4 -4
  30. package/src/plugins/embed/conceptEmbedPlugin.tsx +1 -1
  31. package/src/plugins/index.ts +8 -4
  32. package/src/plugins/olPlugin.tsx +3 -6
  33. package/src/plugins/{ddPlugin.tsx → summaryPlugin.tsx} +4 -6
  34. package/src/plugins/tablePlugin.tsx +1 -1
  35. package/src/plugins/ulPlugin.tsx +1 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps, domToReact } from "html-react-parser";
10
+ import { BlockQuote } from "@ndla/primitives";
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export const blockquotePlugin = (node, opts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx(BlockQuote, {
15
+ ...props,
16
+ children: domToReact(node.children, opts)
17
+ });
18
+ };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2023-present, NDLA.
2
+ * Copyright (c) 2024-present, NDLA.
3
3
  *
4
4
  * This source code is licensed under the GPLv3 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,13 +7,12 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { DefinitionDescription } from "@ndla/ui";
10
+ import { ExpandableBox } from "@ndla/primitives";
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export const ddPlugin = (node, converterOpts, opts) => {
12
+ export const detailsPlugin = (node, converterOpts) => {
13
13
  const props = attributesToProps(node.attribs);
14
- return _jsx(DefinitionDescription, {
14
+ return _jsx(ExpandableBox, {
15
15
  ...props,
16
- lang: opts.articleLanguage,
17
16
  children: domToReact(node.children, converterOpts)
18
17
  });
19
18
  };
@@ -7,7 +7,8 @@
7
7
  */
8
8
 
9
9
  import { domToReact, attributesToProps } from "html-react-parser";
10
- import { FileList, RelatedArticleList, Grid, GridParallaxItem, FramedContent } from "@ndla/ui";
10
+ import { FramedContent } from "@ndla/primitives";
11
+ import { FileList, RelatedArticleList, Grid, GridParallaxItem } from "@ndla/ui";
11
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
12
13
  export const divPlugin = (node, opts) => {
13
14
  if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
@@ -7,11 +7,11 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { DefinitionTerm } from "@ndla/ui";
10
+ import { DefinitionList } from "@ndla/primitives";
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
- export const dtPlugin = (node, converterOpts, opts) => {
12
+ export const dlPlugin = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
14
- return _jsx(DefinitionTerm, {
14
+ return _jsx(DefinitionList, {
15
15
  ...props,
16
16
  lang: opts.articleLanguage,
17
17
  children: domToReact(node.children, converterOpts)
@@ -14,7 +14,6 @@ export const conceptEmbedPlugin = (element, _, opts) => {
14
14
  const data = JSON.parse(props["data-json"]);
15
15
  return _jsx(ConceptEmbed, {
16
16
  embed: data,
17
- fullWidth: true,
18
17
  lang: opts.articleLanguage,
19
18
  renderContext: opts.renderContext
20
19
  });
@@ -8,16 +8,18 @@
8
8
 
9
9
  import { anchorPlugin } from "./anchorPlugin";
10
10
  import { asidePlugin } from "./asidePlugin";
11
+ import { blockquotePlugin } from "./blockquotePlugin";
11
12
  import { copyParagraphPlugin } from "./copyParagraphPlugin";
12
- import { ddPlugin } from "./ddPlugin";
13
+ import { detailsPlugin } from "./detailsPlugin";
13
14
  import { divPlugin } from "./divPlugin";
14
- import { dtPlugin } from "./dtPlugin";
15
+ import { dlPlugin } from "./dlPlugin";
15
16
  import { h3Plugin } from "./h3Plugin";
16
17
  import { mathPlugin } from "./mathPlugin";
17
18
  import { navPlugin } from "./navPlugin";
18
19
  import { anchorPlugin as oembedAnchorPlugin } from "./oembed/anchorPlugin";
19
20
  import { olPlugin } from "./olPlugin";
20
21
  import { paragraphPlugin } from "./paragraphPlugin";
22
+ import { summaryPlugin } from "./summaryPlugin";
21
23
  import { tablePlugin } from "./tablePlugin";
22
24
  import { ulPlugin } from "./ulPlugin";
23
25
  export const basePlugins = {
@@ -30,10 +32,12 @@ export const basePlugins = {
30
32
  table: tablePlugin,
31
33
  aside: asidePlugin,
32
34
  ul: ulPlugin,
33
- dd: ddPlugin,
34
- dt: dtPlugin,
35
35
  nav: navPlugin,
36
- a: anchorPlugin
36
+ a: anchorPlugin,
37
+ summary: summaryPlugin,
38
+ details: detailsPlugin,
39
+ dl: dlPlugin,
40
+ blockquote: blockquotePlugin
37
41
  };
38
42
  export const oembedPlugins = {
39
43
  ...basePlugins,
@@ -7,17 +7,16 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { OrderedList } from "@ndla/ui";
10
+ import { OrderedList } from "@ndla/primitives";
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
12
  export const olPlugin = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
14
- const letterClass = node.attribs["data-type"] === "letters" ? "ol-list--roman" : false;
15
- const num = node.attribs.start;
16
- const numClass = num ? `ol-reset-${num}` : false;
17
- const classes = [node.attribs.class ?? false, letterClass, numClass].filter(c => !!c).join(" ");
14
+ const variantProp = node.attribs["data-type"] === "letters" ? {
15
+ variant: "letters"
16
+ } : {};
18
17
  return _jsx(OrderedList, {
19
18
  ...props,
20
- className: classes.length ? classes : undefined,
19
+ ...variantProp,
21
20
  lang: opts.articleLanguage,
22
21
  children: domToReact(node.children, converterOpts)
23
22
  });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { attributesToProps, domToReact } from "html-react-parser";
10
+ import { ExpandableBoxSummary } from "@ndla/primitives";
11
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
+ export const summaryPlugin = (node, converterOpts) => {
13
+ const props = attributesToProps(node.attribs);
14
+ return _jsx(ExpandableBoxSummary, {
15
+ ...props,
16
+ children: domToReact(node.children, converterOpts)
17
+ });
18
+ };
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { Table } from "@ndla/ui";
10
+ import { Table } from "@ndla/primitives";
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
12
  export const tablePlugin = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { attributesToProps, domToReact } from "html-react-parser";
10
- import { UnOrderedList } from "@ndla/ui";
10
+ import { UnOrderedList } from "@ndla/primitives";
11
11
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
12
12
  export const ulPlugin = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { PluginType } from "./types";
9
+ export declare const blockquotePlugin: PluginType;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.blockquotePlugin = void 0;
7
+ var _htmlReactParser = require("html-react-parser");
8
+ var _primitives = require("@ndla/primitives");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2024-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const blockquotePlugin = (node, opts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)(_primitives.BlockQuote, {
21
+ ...props,
22
+ children: (0, _htmlReactParser.domToReact)(node.children, opts)
23
+ });
24
+ };
25
+ exports.blockquotePlugin = blockquotePlugin;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Copyright (c) 2023-present, NDLA.
2
+ * Copyright (c) 2024-present, NDLA.
3
3
  *
4
4
  * This source code is licensed under the GPLv3 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  */
8
8
  import { PluginType } from "./types";
9
- export declare const ddPlugin: PluginType;
9
+ export declare const detailsPlugin: PluginType;
@@ -3,24 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ddPlugin = void 0;
6
+ exports.detailsPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _ui = require("@ndla/ui");
8
+ var _primitives = require("@ndla/primitives");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  /**
11
- * Copyright (c) 2023-present, NDLA.
11
+ * Copyright (c) 2024-present, NDLA.
12
12
  *
13
13
  * This source code is licensed under the GPLv3 license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  *
16
16
  */
17
17
 
18
- const ddPlugin = (node, converterOpts, opts) => {
18
+ const detailsPlugin = (node, converterOpts) => {
19
19
  const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- return (0, _jsxRuntime.jsx)(_ui.DefinitionDescription, {
20
+ return (0, _jsxRuntime.jsx)(_primitives.ExpandableBox, {
21
21
  ...props,
22
- lang: opts.articleLanguage,
23
22
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
24
23
  });
25
24
  };
26
- exports.ddPlugin = ddPlugin;
25
+ exports.detailsPlugin = detailsPlugin;
@@ -5,6 +5,7 @@ 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");
8
9
  var _ui = require("@ndla/ui");
9
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
11
  /**
@@ -17,7 +18,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
18
 
18
19
  const divPlugin = (node, opts) => {
19
20
  if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
20
- return (0, _jsxRuntime.jsx)(_ui.FramedContent, {
21
+ return (0, _jsxRuntime.jsx)(_primitives.FramedContent, {
21
22
  children: (0, _htmlReactParser.domToReact)(node.children, opts)
22
23
  });
23
24
  }
@@ -6,4 +6,4 @@
6
6
  *
7
7
  */
8
8
  import { PluginType } from "./types";
9
- export declare const dtPlugin: PluginType;
9
+ export declare const dlPlugin: PluginType;
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.dtPlugin = void 0;
6
+ exports.dlPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _ui = require("@ndla/ui");
8
+ var _primitives = require("@ndla/primitives");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  /**
11
11
  * Copyright (c) 2023-present, NDLA.
@@ -15,12 +15,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
15
15
  *
16
16
  */
17
17
 
18
- const dtPlugin = (node, converterOpts, opts) => {
18
+ const dlPlugin = (node, converterOpts, opts) => {
19
19
  const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- return (0, _jsxRuntime.jsx)(_ui.DefinitionTerm, {
20
+ return (0, _jsxRuntime.jsx)(_primitives.DefinitionList, {
21
21
  ...props,
22
22
  lang: opts.articleLanguage,
23
23
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
24
24
  });
25
25
  };
26
- exports.dtPlugin = dtPlugin;
26
+ exports.dlPlugin = dlPlugin;
@@ -20,7 +20,6 @@ const conceptEmbedPlugin = (element, _, opts) => {
20
20
  const data = JSON.parse(props["data-json"]);
21
21
  return (0, _jsxRuntime.jsx)(_ui.ConceptEmbed, {
22
22
  embed: data,
23
- fullWidth: true,
24
23
  lang: opts.articleLanguage,
25
24
  renderContext: opts.renderContext
26
25
  });
@@ -6,16 +6,18 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.oembedPlugins = exports.basePlugins = void 0;
7
7
  var _anchorPlugin = require("./anchorPlugin");
8
8
  var _asidePlugin = require("./asidePlugin");
9
+ var _blockquotePlugin = require("./blockquotePlugin");
9
10
  var _copyParagraphPlugin = require("./copyParagraphPlugin");
10
- var _ddPlugin = require("./ddPlugin");
11
+ var _detailsPlugin = require("./detailsPlugin");
11
12
  var _divPlugin = require("./divPlugin");
12
- var _dtPlugin = require("./dtPlugin");
13
+ var _dlPlugin = require("./dlPlugin");
13
14
  var _h3Plugin = require("./h3Plugin");
14
15
  var _mathPlugin = require("./mathPlugin");
15
16
  var _navPlugin = require("./navPlugin");
16
17
  var _anchorPlugin2 = require("./oembed/anchorPlugin");
17
18
  var _olPlugin = require("./olPlugin");
18
19
  var _paragraphPlugin = require("./paragraphPlugin");
20
+ var _summaryPlugin = require("./summaryPlugin");
19
21
  var _tablePlugin = require("./tablePlugin");
20
22
  var _ulPlugin = require("./ulPlugin");
21
23
  /**
@@ -36,10 +38,12 @@ const basePlugins = exports.basePlugins = {
36
38
  table: _tablePlugin.tablePlugin,
37
39
  aside: _asidePlugin.asidePlugin,
38
40
  ul: _ulPlugin.ulPlugin,
39
- dd: _ddPlugin.ddPlugin,
40
- dt: _dtPlugin.dtPlugin,
41
41
  nav: _navPlugin.navPlugin,
42
- a: _anchorPlugin.anchorPlugin
42
+ a: _anchorPlugin.anchorPlugin,
43
+ summary: _summaryPlugin.summaryPlugin,
44
+ details: _detailsPlugin.detailsPlugin,
45
+ dl: _dlPlugin.dlPlugin,
46
+ blockquote: _blockquotePlugin.blockquotePlugin
43
47
  };
44
48
  const oembedPlugins = exports.oembedPlugins = {
45
49
  ...basePlugins,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.olPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _ui = require("@ndla/ui");
8
+ var _primitives = require("@ndla/primitives");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  /**
11
11
  * Copyright (c) 2023-present, NDLA.
@@ -17,13 +17,12 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
17
 
18
18
  const olPlugin = (node, converterOpts, opts) => {
19
19
  const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- const letterClass = node.attribs["data-type"] === "letters" ? "ol-list--roman" : false;
21
- const num = node.attribs.start;
22
- const numClass = num ? `ol-reset-${num}` : false;
23
- const classes = [node.attribs.class ?? false, letterClass, numClass].filter(c => !!c).join(" ");
24
- return (0, _jsxRuntime.jsx)(_ui.OrderedList, {
20
+ const variantProp = node.attribs["data-type"] === "letters" ? {
21
+ variant: "letters"
22
+ } : {};
23
+ return (0, _jsxRuntime.jsx)(_primitives.OrderedList, {
25
24
  ...props,
26
- className: classes.length ? classes : undefined,
25
+ ...variantProp,
27
26
  lang: opts.articleLanguage,
28
27
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
29
28
  });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import { PluginType } from "./types";
9
+ export declare const summaryPlugin: PluginType;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.summaryPlugin = void 0;
7
+ var _htmlReactParser = require("html-react-parser");
8
+ var _primitives = require("@ndla/primitives");
9
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
+ /**
11
+ * Copyright (c) 2024-present, NDLA.
12
+ *
13
+ * This source code is licensed under the GPLv3 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ const summaryPlugin = (node, converterOpts) => {
19
+ const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
+ return (0, _jsxRuntime.jsx)(_primitives.ExpandableBoxSummary, {
21
+ ...props,
22
+ children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
23
+ });
24
+ };
25
+ exports.summaryPlugin = summaryPlugin;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.tablePlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _ui = require("@ndla/ui");
8
+ var _primitives = require("@ndla/primitives");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  /**
11
11
  * Copyright (c) 2023-present, NDLA.
@@ -17,7 +17,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
17
 
18
18
  const tablePlugin = (node, converterOpts, opts) => {
19
19
  const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- return (0, _jsxRuntime.jsx)(_ui.Table, {
20
+ return (0, _jsxRuntime.jsx)(_primitives.Table, {
21
21
  ...props,
22
22
  lang: opts.articleLanguage,
23
23
  children: (0, _htmlReactParser.domToReact)(node.children, converterOpts)
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ulPlugin = void 0;
7
7
  var _htmlReactParser = require("html-react-parser");
8
- var _ui = require("@ndla/ui");
8
+ var _primitives = require("@ndla/primitives");
9
9
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
10
  /**
11
11
  * Copyright (c) 2023-present, NDLA.
@@ -17,7 +17,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
17
17
 
18
18
  const ulPlugin = (node, converterOpts, opts) => {
19
19
  const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
20
- return (0, _jsxRuntime.jsx)(_ui.UnOrderedList, {
20
+ return (0, _jsxRuntime.jsx)(_primitives.UnOrderedList, {
21
21
  ...props,
22
22
  className: node.attribs.class,
23
23
  lang: opts.articleLanguage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
- "version": "9.0.13-alpha.0",
3
+ "version": "9.0.15-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,7 +31,8 @@
31
31
  "@ndla/types-embed": "^4.1.8"
32
32
  },
33
33
  "dependencies": {
34
- "@ndla/ui": "^55.0.13-alpha.0",
34
+ "@ndla/primitives": "^0.0.19",
35
+ "@ndla/ui": "^55.0.15-alpha.0",
35
36
  "html-react-parser": "^5.1.8"
36
37
  },
37
38
  "peerDependencies": {
@@ -46,5 +47,5 @@
46
47
  "publishConfig": {
47
48
  "access": "public"
48
49
  },
49
- "gitHead": "93dde6fe4aaca52642f8fa0a27f4acad359207cb"
50
+ "gitHead": "3675a902b9f44f5afb37c648038b8d90f1ccd7d0"
50
51
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
+ import { BlockQuote } from "@ndla/primitives";
11
+ import { PluginType } from "./types";
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>;
16
+ };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2024-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
+ import { ExpandableBox } from "@ndla/primitives";
11
+ import { PluginType } from "./types";
12
+
13
+ export const detailsPlugin: PluginType = (node, converterOpts) => {
14
+ const props = attributesToProps(node.attribs);
15
+
16
+ return <ExpandableBox {...props}>{domToReact(node.children as DOMNode[], converterOpts)}</ExpandableBox>;
17
+ };
@@ -7,7 +7,8 @@
7
7
  */
8
8
 
9
9
  import { domToReact, attributesToProps, Element, DOMNode } from "html-react-parser";
10
- import { FileList, RelatedArticleList, Grid, GridType, GridParallaxItem, FramedContent } from "@ndla/ui";
10
+ import { FramedContent } from "@ndla/primitives";
11
+ import { FileList, RelatedArticleList, Grid, GridType, GridParallaxItem } from "@ndla/ui";
11
12
  import { PluginType } from "./types";
12
13
 
13
14
  export const divPlugin: PluginType = (node, opts) => {
@@ -7,15 +7,15 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { DefinitionTerm } from "@ndla/ui";
10
+ import { DefinitionList } from "@ndla/primitives";
11
11
  import { PluginType } from "./types";
12
12
 
13
- export const dtPlugin: PluginType = (node, converterOpts, opts) => {
13
+ export const dlPlugin: PluginType = (node, converterOpts, opts) => {
14
14
  const props = attributesToProps(node.attribs);
15
15
 
16
16
  return (
17
- <DefinitionTerm {...props} lang={opts.articleLanguage}>
17
+ <DefinitionList {...props} lang={opts.articleLanguage}>
18
18
  {domToReact(node.children as DOMNode[], converterOpts)}
19
- </DefinitionTerm>
19
+ </DefinitionList>
20
20
  );
21
21
  };
@@ -14,5 +14,5 @@ import { PluginType } from "../types";
14
14
  export const conceptEmbedPlugin: PluginType = (element, _, opts) => {
15
15
  const props = attributesToProps(element.attribs);
16
16
  const data = JSON.parse(props["data-json"] as string) as ConceptMetaData;
17
- return <ConceptEmbed embed={data} fullWidth lang={opts.articleLanguage} renderContext={opts.renderContext} />;
17
+ return <ConceptEmbed embed={data} lang={opts.articleLanguage} renderContext={opts.renderContext} />;
18
18
  };
@@ -8,16 +8,18 @@
8
8
 
9
9
  import { anchorPlugin } from "./anchorPlugin";
10
10
  import { asidePlugin } from "./asidePlugin";
11
+ import { blockquotePlugin } from "./blockquotePlugin";
11
12
  import { copyParagraphPlugin } from "./copyParagraphPlugin";
12
- import { ddPlugin } from "./ddPlugin";
13
+ import { detailsPlugin } from "./detailsPlugin";
13
14
  import { divPlugin } from "./divPlugin";
14
- import { dtPlugin } from "./dtPlugin";
15
+ import { dlPlugin } from "./dlPlugin";
15
16
  import { h3Plugin } from "./h3Plugin";
16
17
  import { mathPlugin } from "./mathPlugin";
17
18
  import { navPlugin } from "./navPlugin";
18
19
  import { anchorPlugin as oembedAnchorPlugin } from "./oembed/anchorPlugin";
19
20
  import { olPlugin } from "./olPlugin";
20
21
  import { paragraphPlugin } from "./paragraphPlugin";
22
+ import { summaryPlugin } from "./summaryPlugin";
21
23
  import { tablePlugin } from "./tablePlugin";
22
24
  import { PluginType } from "./types";
23
25
  import { ulPlugin } from "./ulPlugin";
@@ -32,10 +34,12 @@ export const basePlugins: Record<string, PluginType> = {
32
34
  table: tablePlugin,
33
35
  aside: asidePlugin,
34
36
  ul: ulPlugin,
35
- dd: ddPlugin,
36
- dt: dtPlugin,
37
37
  nav: navPlugin,
38
38
  a: anchorPlugin,
39
+ summary: summaryPlugin,
40
+ details: detailsPlugin,
41
+ dl: dlPlugin,
42
+ blockquote: blockquotePlugin,
39
43
  };
40
44
 
41
45
  export const oembedPlugins: Record<string, PluginType> = {
@@ -7,17 +7,14 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { OrderedList } from "@ndla/ui";
10
+ import { OrderedList } from "@ndla/primitives";
11
11
  import { PluginType } from "./types";
12
12
  export const olPlugin: PluginType = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
14
- const letterClass = node.attribs["data-type"] === "letters" ? "ol-list--roman" : false;
15
- const num = node.attribs.start;
16
- const numClass = num ? `ol-reset-${num}` : false;
17
- const classes = [node.attribs.class ?? false, letterClass, numClass].filter((c): c is string => !!c).join(" ");
14
+ const variantProp = node.attribs["data-type"] === "letters" ? ({ variant: "letters" } as const) : {};
18
15
 
19
16
  return (
20
- <OrderedList {...props} className={classes.length ? classes : undefined} lang={opts.articleLanguage}>
17
+ <OrderedList {...props} {...variantProp} lang={opts.articleLanguage}>
21
18
  {domToReact(node.children as DOMNode[], converterOpts)}
22
19
  </OrderedList>
23
20
  );
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) 2023-present, NDLA.
2
+ * Copyright (c) 2024-present, NDLA.
3
3
  *
4
4
  * This source code is licensed under the GPLv3 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -7,15 +7,13 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { DefinitionDescription } from "@ndla/ui";
10
+ import { ExpandableBoxSummary } from "@ndla/primitives";
11
11
  import { PluginType } from "./types";
12
12
 
13
- export const ddPlugin: PluginType = (node, converterOpts, opts) => {
13
+ export const summaryPlugin: PluginType = (node, converterOpts) => {
14
14
  const props = attributesToProps(node.attribs);
15
15
 
16
16
  return (
17
- <DefinitionDescription {...props} lang={opts.articleLanguage}>
18
- {domToReact(node.children as DOMNode[], converterOpts)}
19
- </DefinitionDescription>
17
+ <ExpandableBoxSummary {...props}>{domToReact(node.children as DOMNode[], converterOpts)}</ExpandableBoxSummary>
20
18
  );
21
19
  };
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { Table } from "@ndla/ui";
10
+ import { Table } from "@ndla/primitives";
11
11
  import { PluginType } from "./types";
12
12
  export const tablePlugin: PluginType = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { DOMNode, attributesToProps, domToReact } from "html-react-parser";
10
- import { UnOrderedList } from "@ndla/ui";
10
+ import { UnOrderedList } from "@ndla/primitives";
11
11
  import { PluginType } from "./types";
12
12
  export const ulPlugin: PluginType = (node, converterOpts, opts) => {
13
13
  const props = attributesToProps(node.attribs);