@ndla/article-converter 10.0.159-alpha.0 → 10.0.161-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.
- package/es/plugins/blockquotePlugin.mjs +1 -1
- package/es/plugins/blockquotePlugin.mjs.map +1 -1
- package/es/plugins/divPlugin.mjs +1 -1
- package/es/plugins/divPlugin.mjs.map +1 -1
- package/es/plugins/embed/contactBlockEmbedPlugin.mjs +2 -8
- package/es/plugins/embed/contactBlockEmbedPlugin.mjs.map +1 -1
- package/es/plugins/mathPlugin.mjs +1 -1
- package/es/plugins/mathPlugin.mjs.map +1 -1
- package/lib/_virtual/rolldown_runtime.js +10 -6
- package/lib/plugins/blockquotePlugin.js +1 -1
- package/lib/plugins/blockquotePlugin.js.map +1 -1
- package/lib/plugins/divPlugin.js +1 -1
- package/lib/plugins/divPlugin.js.map +1 -1
- package/lib/plugins/embed/contactBlockEmbedPlugin.d.ts +0 -2
- package/lib/plugins/embed/contactBlockEmbedPlugin.js +2 -8
- package/lib/plugins/embed/contactBlockEmbedPlugin.js.map +1 -1
- package/lib/plugins/mathPlugin.js +1 -1
- package/lib/plugins/mathPlugin.js.map +1 -1
- package/package.json +5 -5
- package/src/plugins/embed/contactBlockEmbedPlugin.tsx +3 -10
|
@@ -11,7 +11,7 @@ import { BlockQuote } from "@ndla/primitives";
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
const blockquotePlugin = (node, opts) => {
|
|
14
|
-
const { "data-variant": variant
|
|
14
|
+
const { "data-variant": variant, ...props } = attributesToProps(node.attribs);
|
|
15
15
|
return /* @__PURE__ */ jsx(BlockQuote, {
|
|
16
16
|
...props,
|
|
17
17
|
variant: variant === "colored" ? "brand1" : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockquotePlugin.mjs","names":["blockquotePlugin: PluginType"],"sources":["../../src/plugins/blockquotePlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { BlockQuote } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const blockquotePlugin: PluginType = (node, opts) => {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <BlockQuote {...props} variant={variant === \"colored\" ? \"brand1\" : undefined}>\n {domToReact(node.children as DOMNode[], opts)}\n </BlockQuote>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAaA,oBAAgC,MAAM,SAAS;CAC1D,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"blockquotePlugin.mjs","names":["blockquotePlugin: PluginType"],"sources":["../../src/plugins/blockquotePlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { BlockQuote } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const blockquotePlugin: PluginType = (node, opts) => {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <BlockQuote {...props} variant={variant === \"colored\" ? \"brand1\" : undefined}>\n {domToReact(node.children as DOMNode[], opts)}\n </BlockQuote>\n );\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAaA,oBAAgC,MAAM,SAAS;CAC1D,MAAM,EAAE,gBAAgB,SAAS,GAAG,UAAU,kBAAkB,KAAK,QAAQ;AAC7E,QACE,oBAAC;EAAW,GAAI;EAAO,SAAS,YAAY,YAAY,WAAW;YAChE,WAAW,KAAK,UAAuB,KAAK;GAClC"}
|
package/es/plugins/divPlugin.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { FramedContent } from "@ndla/primitives";
|
|
|
13
13
|
*/
|
|
14
14
|
const divPlugin = (node, opts) => {
|
|
15
15
|
if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
|
|
16
|
-
const { "data-variant": variant
|
|
16
|
+
const { "data-variant": variant, ...props } = attributesToProps(node.attribs);
|
|
17
17
|
return /* @__PURE__ */ jsx(FramedContent, {
|
|
18
18
|
colorTheme: variant === "colored" ? "brand1" : void 0,
|
|
19
19
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"divPlugin.mjs","names":["divPlugin: PluginType"],"sources":["../../src/plugins/divPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { domToReact, attributesToProps, Element, type DOMNode } from \"html-react-parser\";\nimport { FramedContent } from \"@ndla/primitives\";\nimport { FileListEmbed, RelatedArticleList, Grid, type GridType, GridParallaxItem } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const divPlugin: PluginType = (node, opts) => {\n if (node.attribs[\"data-type\"] === \"framed-content\" || node.attribs.class === \"c-bodybox\") {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <FramedContent colorTheme={variant === \"colored\" ? \"brand1\" : undefined} {...props}>\n {domToReact(node.children as DOMNode[], opts)}\n </FramedContent>\n );\n }\n if (node.attribs[\"data-type\"] === \"related-content\" && node.children.length) {\n const props = attributesToProps(node.attribs);\n\n return (\n <RelatedArticleList {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </RelatedArticleList>\n );\n }\n if (node.attribs[\"data-type\"] === \"file\" && node.childNodes.length) {\n const elements = node.childNodes.filter(\n (c): c is Element => c.type === \"tag\" && c.name === \"ndlaembed\" && c.attribs[\"data-resource\"] === \"file\",\n );\n const [pdfs, files] = elements.reduce<[Element[], Element[]]>(\n (acc, el) => {\n const arr = el.attribs[\"data-type\"] === \"pdf\" && el.attribs[\"data-display\"] === \"block\" ? acc[0] : acc[1];\n arr.push(el);\n return acc;\n },\n [[], []],\n );\n\n return (\n <>\n {files.length ? <FileListEmbed>{domToReact(files, opts)}</FileListEmbed> : undefined}\n {domToReact(pdfs, opts)}\n </>\n );\n }\n if (node.attribs[\"data-type\"] === \"grid\" && node.children.length > 0) {\n const props = attributesToProps(node.attribs);\n const columns = props[\"data-columns\"] as GridType[\"columns\"];\n const border = props[\"data-border\"] as GridType[\"border\"];\n const background = props[\"data-background\"] as GridType[\"background\"];\n return (\n <Grid border={border} columns={columns} background={background} {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </Grid>\n );\n }\n if (node.attribs[\"data-parallax-cell\"] === \"true\" && node.children.length) {\n return <GridParallaxItem>{domToReact(node.children as DOMNode[], opts)}</GridParallaxItem>;\n }\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAaA,aAAyB,MAAM,SAAS;AACnD,KAAI,KAAK,QAAQ,iBAAiB,oBAAoB,KAAK,QAAQ,UAAU,aAAa;EACxF,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"divPlugin.mjs","names":["divPlugin: PluginType"],"sources":["../../src/plugins/divPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { domToReact, attributesToProps, Element, type DOMNode } from \"html-react-parser\";\nimport { FramedContent } from \"@ndla/primitives\";\nimport { FileListEmbed, RelatedArticleList, Grid, type GridType, GridParallaxItem } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const divPlugin: PluginType = (node, opts) => {\n if (node.attribs[\"data-type\"] === \"framed-content\" || node.attribs.class === \"c-bodybox\") {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <FramedContent colorTheme={variant === \"colored\" ? \"brand1\" : undefined} {...props}>\n {domToReact(node.children as DOMNode[], opts)}\n </FramedContent>\n );\n }\n if (node.attribs[\"data-type\"] === \"related-content\" && node.children.length) {\n const props = attributesToProps(node.attribs);\n\n return (\n <RelatedArticleList {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </RelatedArticleList>\n );\n }\n if (node.attribs[\"data-type\"] === \"file\" && node.childNodes.length) {\n const elements = node.childNodes.filter(\n (c): c is Element => c.type === \"tag\" && c.name === \"ndlaembed\" && c.attribs[\"data-resource\"] === \"file\",\n );\n const [pdfs, files] = elements.reduce<[Element[], Element[]]>(\n (acc, el) => {\n const arr = el.attribs[\"data-type\"] === \"pdf\" && el.attribs[\"data-display\"] === \"block\" ? acc[0] : acc[1];\n arr.push(el);\n return acc;\n },\n [[], []],\n );\n\n return (\n <>\n {files.length ? <FileListEmbed>{domToReact(files, opts)}</FileListEmbed> : undefined}\n {domToReact(pdfs, opts)}\n </>\n );\n }\n if (node.attribs[\"data-type\"] === \"grid\" && node.children.length > 0) {\n const props = attributesToProps(node.attribs);\n const columns = props[\"data-columns\"] as GridType[\"columns\"];\n const border = props[\"data-border\"] as GridType[\"border\"];\n const background = props[\"data-background\"] as GridType[\"background\"];\n return (\n <Grid border={border} columns={columns} background={background} {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </Grid>\n );\n }\n if (node.attribs[\"data-parallax-cell\"] === \"true\" && node.children.length) {\n return <GridParallaxItem>{domToReact(node.children as DOMNode[], opts)}</GridParallaxItem>;\n }\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAaA,aAAyB,MAAM,SAAS;AACnD,KAAI,KAAK,QAAQ,iBAAiB,oBAAoB,KAAK,QAAQ,UAAU,aAAa;EACxF,MAAM,EAAE,gBAAgB,SAAS,GAAG,UAAU,kBAAkB,KAAK,QAAQ;AAC7E,SACE,oBAAC;GAAc,YAAY,YAAY,YAAY,WAAW;GAAW,GAAI;aAC1E,WAAW,KAAK,UAAuB,KAAK;IAC/B;;AAGpB,KAAI,KAAK,QAAQ,iBAAiB,qBAAqB,KAAK,SAAS,OAGnE,QACE,oBAAC;EAAmB,GAHR,kBAAkB,KAAK,QAAQ;YAKxC,WAAW,KAAK,UAAU,KAAK;GACb;AAGzB,KAAI,KAAK,QAAQ,iBAAiB,UAAU,KAAK,WAAW,QAAQ;EAIlE,MAAM,CAAC,MAAM,SAHI,KAAK,WAAW,QAC9B,MAAoB,EAAE,SAAS,SAAS,EAAE,SAAS,eAAe,EAAE,QAAQ,qBAAqB,OACnG,CAC8B,QAC5B,KAAK,OAAO;AAEX,IADY,GAAG,QAAQ,iBAAiB,SAAS,GAAG,QAAQ,oBAAoB,UAAU,IAAI,KAAK,IAAI,IACnG,KAAK,GAAG;AACZ,UAAO;KAET,CAAC,EAAE,EAAE,EAAE,CAAC,CACT;AAED,SACE,4CACG,MAAM,SAAS,oBAAC,2BAAe,WAAW,OAAO,KAAK,GAAiB,GAAG,QAC1E,WAAW,MAAM,KAAK,IACtB;;AAGP,KAAI,KAAK,QAAQ,iBAAiB,UAAU,KAAK,SAAS,SAAS,GAAG;EACpE,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;EAC7C,MAAM,UAAU,MAAM;EACtB,MAAM,SAAS,MAAM;EACrB,MAAM,aAAa,MAAM;AACzB,SACE,oBAAC;GAAa;GAAiB;GAAqB;GAAY,GAAI;aAEjE,WAAW,KAAK,UAAU,KAAK;IAC3B;;AAGX,KAAI,KAAK,QAAQ,0BAA0B,UAAU,KAAK,SAAS,OACjE,QAAO,oBAAC,8BAAkB,WAAW,KAAK,UAAuB,KAAK,GAAoB;AAE5F,QAAO"}
|
|
@@ -10,17 +10,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
function isBackground(background) {
|
|
14
|
-
return contactBlockBackgrounds.includes(background ?? "");
|
|
15
|
-
}
|
|
16
|
-
const parseBackground = (background) => {
|
|
17
|
-
if (isBackground(background)) return background;
|
|
18
|
-
};
|
|
19
13
|
const contactBlockEmbedPlugin = (element, _, opts) => {
|
|
20
14
|
const props = attributesToProps(element.attribs);
|
|
21
15
|
const embedData = JSON.parse(props["data-json"]);
|
|
22
16
|
const { name, email, description, background, jobTitle, alt } = embedData.embedData;
|
|
23
|
-
const
|
|
17
|
+
const validBackground = contactBlockBackgrounds.find((bg) => bg === background);
|
|
24
18
|
return /* @__PURE__ */ jsx(ContactBlock, {
|
|
25
19
|
image: embedData.status === "success" ? embedData.data.image : void 0,
|
|
26
20
|
embedAlt: alt,
|
|
@@ -29,7 +23,7 @@ const contactBlockEmbedPlugin = (element, _, opts) => {
|
|
|
29
23
|
jobTitle,
|
|
30
24
|
name,
|
|
31
25
|
lang: opts.articleLanguage,
|
|
32
|
-
backgroundColor:
|
|
26
|
+
backgroundColor: validBackground
|
|
33
27
|
});
|
|
34
28
|
};
|
|
35
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactBlockEmbedPlugin.mjs","names":["contactBlockEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/contactBlockEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type ContactBlockMetaData } from \"@ndla/types-embed\";\nimport { ContactBlock, contactBlockBackgrounds
|
|
1
|
+
{"version":3,"file":"contactBlockEmbedPlugin.mjs","names":["contactBlockEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/contactBlockEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type ContactBlockMetaData } from \"@ndla/types-embed\";\nimport { ContactBlock, contactBlockBackgrounds } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const embedData = JSON.parse(props[\"data-json\"] as string) as ContactBlockMetaData;\n const { name, email, description, background, jobTitle, alt } = embedData.embedData;\n const validBackground = contactBlockBackgrounds.find((bg) => bg === background);\n\n return (\n <ContactBlock\n image={embedData.status === \"success\" ? embedData.data.image : undefined}\n embedAlt={alt}\n description={description}\n email={email}\n jobTitle={jobTitle}\n name={name}\n lang={opts.articleLanguage}\n backgroundColor={validBackground}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;AAaA,MAAaA,2BAAuC,SAAS,GAAG,SAAS;CACvE,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,YAAY,KAAK,MAAM,MAAM,aAAuB;CAC1D,MAAM,EAAE,MAAM,OAAO,aAAa,YAAY,UAAU,QAAQ,UAAU;CAC1E,MAAM,kBAAkB,wBAAwB,MAAM,OAAO,OAAO,WAAW;AAE/E,QACE,oBAAC;EACC,OAAO,UAAU,WAAW,YAAY,UAAU,KAAK,QAAQ;EAC/D,UAAU;EACG;EACN;EACG;EACJ;EACN,MAAM,KAAK;EACX,iBAAiB;GACjB"}
|
|
@@ -10,7 +10,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
const mathPlugin = (node) => {
|
|
13
|
-
const { "data-math": mathContent
|
|
13
|
+
const { "data-math": mathContent, ...props } = attributesToProps(node.attribs);
|
|
14
14
|
return /* @__PURE__ */ jsx("math", {
|
|
15
15
|
xmlns: "http://www.w3.org/1998/Math/MathML",
|
|
16
16
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathPlugin.mjs","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAaA,cAA0B,SAAS;CAC9C,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"mathPlugin.mjs","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;;;;;;;;AAUA,MAAaA,cAA0B,SAAS;CAC9C,MAAM,EAAE,aAAa,aAAa,GAAG,UAAU,kBAAkB,KAAK,QAAQ;AAC9E,QAEE,oBAAC;EAAK,OAAM;EAAqC,GAAI;EAAO,yBAAyB,EAAE,QAAQ,aAAa;GAAI"}
|
|
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
@@ -12,7 +12,7 @@ let __ndla_primitives = require("@ndla/primitives");
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
const blockquotePlugin = (node, opts) => {
|
|
15
|
-
const { "data-variant": variant
|
|
15
|
+
const { "data-variant": variant, ...props } = (0, html_react_parser.attributesToProps)(node.attribs);
|
|
16
16
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.BlockQuote, {
|
|
17
17
|
...props,
|
|
18
18
|
variant: variant === "colored" ? "brand1" : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blockquotePlugin.js","names":["blockquotePlugin: PluginType","BlockQuote"],"sources":["../../src/plugins/blockquotePlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { BlockQuote } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const blockquotePlugin: PluginType = (node, opts) => {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <BlockQuote {...props} variant={variant === \"colored\" ? \"brand1\" : undefined}>\n {domToReact(node.children as DOMNode[], opts)}\n </BlockQuote>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAaA,oBAAgC,MAAM,SAAS;CAC1D,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"blockquotePlugin.js","names":["blockquotePlugin: PluginType","BlockQuote"],"sources":["../../src/plugins/blockquotePlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2024-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { BlockQuote } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const blockquotePlugin: PluginType = (node, opts) => {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <BlockQuote {...props} variant={variant === \"colored\" ? \"brand1\" : undefined}>\n {domToReact(node.children as DOMNode[], opts)}\n </BlockQuote>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAaA,oBAAgC,MAAM,SAAS;CAC1D,MAAM,EAAE,gBAAgB,SAAS,GAAG,mDAA4B,KAAK,QAAQ;AAC7E,QACE,2CAACC;EAAW,GAAI;EAAO,SAAS,YAAY,YAAY,WAAW;8CACrD,KAAK,UAAuB,KAAK;GAClC"}
|
package/lib/plugins/divPlugin.js
CHANGED
|
@@ -14,7 +14,7 @@ let __ndla_primitives = require("@ndla/primitives");
|
|
|
14
14
|
*/
|
|
15
15
|
const divPlugin = (node, opts) => {
|
|
16
16
|
if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
|
|
17
|
-
const { "data-variant": variant
|
|
17
|
+
const { "data-variant": variant, ...props } = (0, html_react_parser.attributesToProps)(node.attribs);
|
|
18
18
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_primitives.FramedContent, {
|
|
19
19
|
colorTheme: variant === "colored" ? "brand1" : void 0,
|
|
20
20
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"divPlugin.js","names":["divPlugin: PluginType","FramedContent","RelatedArticleList","FileListEmbed","Grid","GridParallaxItem"],"sources":["../../src/plugins/divPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { domToReact, attributesToProps, Element, type DOMNode } from \"html-react-parser\";\nimport { FramedContent } from \"@ndla/primitives\";\nimport { FileListEmbed, RelatedArticleList, Grid, type GridType, GridParallaxItem } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const divPlugin: PluginType = (node, opts) => {\n if (node.attribs[\"data-type\"] === \"framed-content\" || node.attribs.class === \"c-bodybox\") {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <FramedContent colorTheme={variant === \"colored\" ? \"brand1\" : undefined} {...props}>\n {domToReact(node.children as DOMNode[], opts)}\n </FramedContent>\n );\n }\n if (node.attribs[\"data-type\"] === \"related-content\" && node.children.length) {\n const props = attributesToProps(node.attribs);\n\n return (\n <RelatedArticleList {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </RelatedArticleList>\n );\n }\n if (node.attribs[\"data-type\"] === \"file\" && node.childNodes.length) {\n const elements = node.childNodes.filter(\n (c): c is Element => c.type === \"tag\" && c.name === \"ndlaembed\" && c.attribs[\"data-resource\"] === \"file\",\n );\n const [pdfs, files] = elements.reduce<[Element[], Element[]]>(\n (acc, el) => {\n const arr = el.attribs[\"data-type\"] === \"pdf\" && el.attribs[\"data-display\"] === \"block\" ? acc[0] : acc[1];\n arr.push(el);\n return acc;\n },\n [[], []],\n );\n\n return (\n <>\n {files.length ? <FileListEmbed>{domToReact(files, opts)}</FileListEmbed> : undefined}\n {domToReact(pdfs, opts)}\n </>\n );\n }\n if (node.attribs[\"data-type\"] === \"grid\" && node.children.length > 0) {\n const props = attributesToProps(node.attribs);\n const columns = props[\"data-columns\"] as GridType[\"columns\"];\n const border = props[\"data-border\"] as GridType[\"border\"];\n const background = props[\"data-background\"] as GridType[\"background\"];\n return (\n <Grid border={border} columns={columns} background={background} {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </Grid>\n );\n }\n if (node.attribs[\"data-parallax-cell\"] === \"true\" && node.children.length) {\n return <GridParallaxItem>{domToReact(node.children as DOMNode[], opts)}</GridParallaxItem>;\n }\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAaA,aAAyB,MAAM,SAAS;AACnD,KAAI,KAAK,QAAQ,iBAAiB,oBAAoB,KAAK,QAAQ,UAAU,aAAa;EACxF,MAAM,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"divPlugin.js","names":["divPlugin: PluginType","FramedContent","RelatedArticleList","FileListEmbed","Grid","GridParallaxItem"],"sources":["../../src/plugins/divPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { domToReact, attributesToProps, Element, type DOMNode } from \"html-react-parser\";\nimport { FramedContent } from \"@ndla/primitives\";\nimport { FileListEmbed, RelatedArticleList, Grid, type GridType, GridParallaxItem } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const divPlugin: PluginType = (node, opts) => {\n if (node.attribs[\"data-type\"] === \"framed-content\" || node.attribs.class === \"c-bodybox\") {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <FramedContent colorTheme={variant === \"colored\" ? \"brand1\" : undefined} {...props}>\n {domToReact(node.children as DOMNode[], opts)}\n </FramedContent>\n );\n }\n if (node.attribs[\"data-type\"] === \"related-content\" && node.children.length) {\n const props = attributesToProps(node.attribs);\n\n return (\n <RelatedArticleList {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </RelatedArticleList>\n );\n }\n if (node.attribs[\"data-type\"] === \"file\" && node.childNodes.length) {\n const elements = node.childNodes.filter(\n (c): c is Element => c.type === \"tag\" && c.name === \"ndlaembed\" && c.attribs[\"data-resource\"] === \"file\",\n );\n const [pdfs, files] = elements.reduce<[Element[], Element[]]>(\n (acc, el) => {\n const arr = el.attribs[\"data-type\"] === \"pdf\" && el.attribs[\"data-display\"] === \"block\" ? acc[0] : acc[1];\n arr.push(el);\n return acc;\n },\n [[], []],\n );\n\n return (\n <>\n {files.length ? <FileListEmbed>{domToReact(files, opts)}</FileListEmbed> : undefined}\n {domToReact(pdfs, opts)}\n </>\n );\n }\n if (node.attribs[\"data-type\"] === \"grid\" && node.children.length > 0) {\n const props = attributesToProps(node.attribs);\n const columns = props[\"data-columns\"] as GridType[\"columns\"];\n const border = props[\"data-border\"] as GridType[\"border\"];\n const background = props[\"data-background\"] as GridType[\"background\"];\n return (\n <Grid border={border} columns={columns} background={background} {...props}>\n {/* @ts-expect-error - This works, the types just won't match entirely */}\n {domToReact(node.children, opts)}\n </Grid>\n );\n }\n if (node.attribs[\"data-parallax-cell\"] === \"true\" && node.children.length) {\n return <GridParallaxItem>{domToReact(node.children as DOMNode[], opts)}</GridParallaxItem>;\n }\n return null;\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAaA,aAAyB,MAAM,SAAS;AACnD,KAAI,KAAK,QAAQ,iBAAiB,oBAAoB,KAAK,QAAQ,UAAU,aAAa;EACxF,MAAM,EAAE,gBAAgB,SAAS,GAAG,mDAA4B,KAAK,QAAQ;AAC7E,SACE,2CAACC;GAAc,YAAY,YAAY,YAAY,WAAW;GAAW,GAAI;+CAC/D,KAAK,UAAuB,KAAK;IAC/B;;AAGpB,KAAI,KAAK,QAAQ,iBAAiB,qBAAqB,KAAK,SAAS,OAGnE,QACE,2CAACC;EAAmB,4CAHU,KAAK,QAAQ;8CAK7B,KAAK,UAAU,KAAK;GACb;AAGzB,KAAI,KAAK,QAAQ,iBAAiB,UAAU,KAAK,WAAW,QAAQ;EAIlE,MAAM,CAAC,MAAM,SAHI,KAAK,WAAW,QAC9B,MAAoB,EAAE,SAAS,SAAS,EAAE,SAAS,eAAe,EAAE,QAAQ,qBAAqB,OACnG,CAC8B,QAC5B,KAAK,OAAO;AAEX,IADY,GAAG,QAAQ,iBAAiB,SAAS,GAAG,QAAQ,oBAAoB,UAAU,IAAI,KAAK,IAAI,IACnG,KAAK,GAAG;AACZ,UAAO;KAET,CAAC,EAAE,EAAE,EAAE,CAAC,CACT;AAED,SACE,qFACG,MAAM,SAAS,2CAACC,uEAA0B,OAAO,KAAK,GAAiB,GAAG,0CAC/D,MAAM,KAAK,IACtB;;AAGP,KAAI,KAAK,QAAQ,iBAAiB,UAAU,KAAK,SAAS,SAAS,GAAG;EACpE,MAAM,iDAA0B,KAAK,QAAQ;EAC7C,MAAM,UAAU,MAAM;EACtB,MAAM,SAAS,MAAM;EACrB,MAAM,aAAa,MAAM;AACzB,SACE,2CAACC;GAAa;GAAiB;GAAqB;GAAY,GAAI;+CAEtD,KAAK,UAAU,KAAK;IAC3B;;AAGX,KAAI,KAAK,QAAQ,0BAA0B,UAAU,KAAK,SAAS,OACjE,QAAO,2CAACC,0EAA6B,KAAK,UAAuB,KAAK,GAAoB;AAE5F,QAAO"}
|
|
@@ -5,7 +5,5 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { type ContactBlockBackground } from "@ndla/ui";
|
|
9
8
|
import { type PluginType } from "../types";
|
|
10
|
-
export declare function isBackground(background?: string): background is ContactBlockBackground;
|
|
11
9
|
export declare const contactBlockEmbedPlugin: PluginType;
|
|
@@ -11,17 +11,11 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
11
11
|
* LICENSE file in the root directory of this source tree.
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
|
-
function isBackground(background) {
|
|
15
|
-
return __ndla_ui.contactBlockBackgrounds.includes(background ?? "");
|
|
16
|
-
}
|
|
17
|
-
const parseBackground = (background) => {
|
|
18
|
-
if (isBackground(background)) return background;
|
|
19
|
-
};
|
|
20
14
|
const contactBlockEmbedPlugin = (element, _, opts) => {
|
|
21
15
|
const props = (0, html_react_parser.attributesToProps)(element.attribs);
|
|
22
16
|
const embedData = JSON.parse(props["data-json"]);
|
|
23
17
|
const { name, email, description, background, jobTitle, alt } = embedData.embedData;
|
|
24
|
-
const
|
|
18
|
+
const validBackground = __ndla_ui.contactBlockBackgrounds.find((bg) => bg === background);
|
|
25
19
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__ndla_ui.ContactBlock, {
|
|
26
20
|
image: embedData.status === "success" ? embedData.data.image : void 0,
|
|
27
21
|
embedAlt: alt,
|
|
@@ -30,7 +24,7 @@ const contactBlockEmbedPlugin = (element, _, opts) => {
|
|
|
30
24
|
jobTitle,
|
|
31
25
|
name,
|
|
32
26
|
lang: opts.articleLanguage,
|
|
33
|
-
backgroundColor:
|
|
27
|
+
backgroundColor: validBackground
|
|
34
28
|
});
|
|
35
29
|
};
|
|
36
30
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contactBlockEmbedPlugin.js","names":["
|
|
1
|
+
{"version":3,"file":"contactBlockEmbedPlugin.js","names":["contactBlockEmbedPlugin: PluginType","contactBlockBackgrounds","ContactBlock"],"sources":["../../../src/plugins/embed/contactBlockEmbedPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type ContactBlockMetaData } from \"@ndla/types-embed\";\nimport { ContactBlock, contactBlockBackgrounds } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const embedData = JSON.parse(props[\"data-json\"] as string) as ContactBlockMetaData;\n const { name, email, description, background, jobTitle, alt } = embedData.embedData;\n const validBackground = contactBlockBackgrounds.find((bg) => bg === background);\n\n return (\n <ContactBlock\n image={embedData.status === \"success\" ? embedData.data.image : undefined}\n embedAlt={alt}\n description={description}\n email={email}\n jobTitle={jobTitle}\n name={name}\n lang={opts.articleLanguage}\n backgroundColor={validBackground}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAaA,2BAAuC,SAAS,GAAG,SAAS;CACvE,MAAM,iDAA0B,QAAQ,QAAQ;CAChD,MAAM,YAAY,KAAK,MAAM,MAAM,aAAuB;CAC1D,MAAM,EAAE,MAAM,OAAO,aAAa,YAAY,UAAU,QAAQ,UAAU;CAC1E,MAAM,kBAAkBC,kCAAwB,MAAM,OAAO,OAAO,WAAW;AAE/E,QACE,2CAACC;EACC,OAAO,UAAU,WAAW,YAAY,UAAU,KAAK,QAAQ;EAC/D,UAAU;EACG;EACN;EACG;EACJ;EACN,MAAM,KAAK;EACX,iBAAiB;GACjB"}
|
|
@@ -11,7 +11,7 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
const mathPlugin = (node) => {
|
|
14
|
-
const { "data-math": mathContent
|
|
14
|
+
const { "data-math": mathContent, ...props } = (0, html_react_parser.attributesToProps)(node.attribs);
|
|
15
15
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("math", {
|
|
16
16
|
xmlns: "http://www.w3.org/1998/Math/MathML",
|
|
17
17
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAaA,cAA0B,SAAS;CAC9C,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"mathPlugin.js","names":["mathPlugin: PluginType"],"sources":["../../src/plugins/mathPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) 2023-present, NDLA.\n *\n * This source code is licensed under the GPLv3 license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { attributesToProps } from \"html-react-parser\";\nimport { type PluginType } from \"./types\";\nexport const mathPlugin: PluginType = (node) => {\n const { \"data-math\": mathContent, ...props } = attributesToProps(node.attribs);\n return (\n // @ts-expect-error - math is a valid tag\n <math xmlns=\"http://www.w3.org/1998/Math/MathML\" {...props} dangerouslySetInnerHTML={{ __html: mathContent }} />\n );\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAaA,cAA0B,SAAS;CAC9C,MAAM,EAAE,aAAa,aAAa,GAAG,mDAA4B,KAAK,QAAQ;AAC9E,QAEE,2CAAC;EAAK,OAAM;EAAqC,GAAI;EAAO,yBAAyB,EAAE,QAAQ,aAAa;GAAI"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.0.
|
|
4
|
+
"version": "10.0.161-alpha.0",
|
|
5
5
|
"description": "Transforms NDLA articles into extended html versions",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"exports": {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"src"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@ndla/types-backend": "^1.0.
|
|
35
|
-
"@ndla/types-embed": "^5.0.
|
|
34
|
+
"@ndla/types-backend": "^1.0.82",
|
|
35
|
+
"@ndla/types-embed": "^5.0.18-alpha.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ndla/primitives": "^1.0.109-alpha.0",
|
|
39
39
|
"@ndla/safelink": "^7.0.112-alpha.0",
|
|
40
|
-
"@ndla/ui": "^56.0.
|
|
40
|
+
"@ndla/ui": "^56.0.157-alpha.0",
|
|
41
41
|
"html-react-parser": "^5.2.8"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f640957c55acc5c10e4b6f495e4ffc3390557649"
|
|
54
54
|
}
|
|
@@ -8,21 +8,14 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps } from "html-react-parser";
|
|
10
10
|
import { type ContactBlockMetaData } from "@ndla/types-embed";
|
|
11
|
-
import { ContactBlock, contactBlockBackgrounds
|
|
11
|
+
import { ContactBlock, contactBlockBackgrounds } from "@ndla/ui";
|
|
12
12
|
import { type PluginType } from "../types";
|
|
13
13
|
|
|
14
|
-
export function isBackground(background?: string): background is ContactBlockBackground {
|
|
15
|
-
return (contactBlockBackgrounds as readonly string[]).includes(background ?? "");
|
|
16
|
-
}
|
|
17
|
-
const parseBackground = (background: string | undefined): ContactBlockBackground | undefined => {
|
|
18
|
-
if (isBackground(background)) return background;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
14
|
export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
|
|
22
15
|
const props = attributesToProps(element.attribs);
|
|
23
16
|
const embedData = JSON.parse(props["data-json"] as string) as ContactBlockMetaData;
|
|
24
17
|
const { name, email, description, background, jobTitle, alt } = embedData.embedData;
|
|
25
|
-
const
|
|
18
|
+
const validBackground = contactBlockBackgrounds.find((bg) => bg === background);
|
|
26
19
|
|
|
27
20
|
return (
|
|
28
21
|
<ContactBlock
|
|
@@ -33,7 +26,7 @@ export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
|
|
|
33
26
|
jobTitle={jobTitle}
|
|
34
27
|
name={name}
|
|
35
28
|
lang={opts.articleLanguage}
|
|
36
|
-
backgroundColor={
|
|
29
|
+
backgroundColor={validBackground}
|
|
37
30
|
/>
|
|
38
31
|
);
|
|
39
32
|
};
|