@ndla/article-converter 10.0.159-alpha.0 → 10.0.160-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.
@@ -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 parsedBackground = parseBackground(background);
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: parsedBackground
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, type ContactBlockBackground } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport function isBackground(background?: string): background is ContactBlockBackground {\n return (contactBlockBackgrounds as readonly string[]).includes(background ?? \"\");\n}\nconst parseBackground = (background: string | undefined): ContactBlockBackground | undefined => {\n if (isBackground(background)) return background;\n};\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 parsedBackground = parseBackground(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={parsedBackground}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,aAAa,YAA2D;AACtF,QAAQ,wBAA8C,SAAS,cAAc,GAAG;;AAElF,MAAM,mBAAmB,eAAuE;AAC9F,KAAI,aAAa,WAAW,CAAE,QAAO;;AAGvC,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,mBAAmB,gBAAgB,WAAW;AAEpD,QACE,oBAAC;EACC,OAAO,UAAU,WAAW,YAAY,UAAU,KAAK,QAAQ;EAC/D,UAAU;EACG;EACN;EACG;EACJ;EACN,MAAM,KAAK;EACX,iBAAiB;GACjB"}
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"}
@@ -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 parsedBackground = parseBackground(background);
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: parsedBackground
27
+ backgroundColor: validBackground
34
28
  });
35
29
  };
36
30
 
@@ -1 +1 @@
1
- {"version":3,"file":"contactBlockEmbedPlugin.js","names":["contactBlockBackgrounds","contactBlockEmbedPlugin: PluginType","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, type ContactBlockBackground } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport function isBackground(background?: string): background is ContactBlockBackground {\n return (contactBlockBackgrounds as readonly string[]).includes(background ?? \"\");\n}\nconst parseBackground = (background: string | undefined): ContactBlockBackground | undefined => {\n if (isBackground(background)) return background;\n};\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 parsedBackground = parseBackground(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={parsedBackground}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,aAAa,YAA2D;AACtF,QAAQA,kCAA8C,SAAS,cAAc,GAAG;;AAElF,MAAM,mBAAmB,eAAuE;AAC9F,KAAI,aAAa,WAAW,CAAE,QAAO;;AAGvC,MAAaC,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,mBAAmB,gBAAgB,WAAW;AAEpD,QACE,2CAACC;EACC,OAAO,UAAU,WAAW,YAAY,UAAU,KAAK,QAAQ;EAC/D,UAAU;EACG;EACN;EACG;EACJ;EACN,MAAM,KAAK;EACX,iBAAiB;GACjB"}
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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ndla/article-converter",
3
3
  "type": "module",
4
- "version": "10.0.159-alpha.0",
4
+ "version": "10.0.160-alpha.0",
5
5
  "description": "Transforms NDLA articles into extended html versions",
6
6
  "license": "GPL-3.0",
7
7
  "exports": {
@@ -37,7 +37,7 @@
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.155-alpha.0",
40
+ "@ndla/ui": "^56.0.156-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": "a4a2fbf2afb8cdcb083a3e3a93bbbae3eee718d6"
53
+ "gitHead": "5a949912b848631d194d74fec102e8fe5657f194"
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, type ContactBlockBackground } from "@ndla/ui";
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 parsedBackground = parseBackground(background);
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={parsedBackground}
29
+ backgroundColor={validBackground}
37
30
  />
38
31
  );
39
32
  };