@ndla/article-converter 10.0.126-alpha.0 → 10.0.128-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/extractEmbedMeta.js +17 -32
- package/es/extractEmbedMeta.js.map +1 -0
- package/es/index.js +3 -9
- package/es/plugins/anchorPlugin.js +17 -22
- package/es/plugins/anchorPlugin.js.map +1 -0
- package/es/plugins/asidePlugin.js +11 -17
- package/es/plugins/asidePlugin.js.map +1 -0
- package/es/plugins/blockquotePlugin.js +16 -24
- package/es/plugins/blockquotePlugin.js.map +1 -0
- package/es/plugins/copyParagraphPlugin.js +16 -20
- package/es/plugins/copyParagraphPlugin.js.map +1 -0
- package/es/plugins/detailsPlugin.js +14 -16
- package/es/plugins/detailsPlugin.js.map +1 -0
- package/es/plugins/divPlugin.js +50 -66
- package/es/plugins/divPlugin.js.map +1 -0
- package/es/plugins/dlPlugin.js +15 -17
- package/es/plugins/dlPlugin.js.map +1 -0
- package/es/plugins/embed/KeyFigureEmbedPlugin.js +20 -26
- package/es/plugins/embed/KeyFigureEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/audioEmbedPlugin.js +15 -17
- package/es/plugins/embed/audioEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/brightcoveEmbedPlugin.js +16 -18
- package/es/plugins/embed/brightcoveEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/campaignBlockPlugin.js +26 -28
- package/es/plugins/embed/campaignBlockPlugin.js.map +1 -0
- package/es/plugins/embed/codeEmbedPlugin.js +12 -16
- package/es/plugins/embed/codeEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/conceptEmbedPlugin.js +17 -19
- package/es/plugins/embed/conceptEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/contactBlockEmbedPlugin.js +27 -36
- package/es/plugins/embed/contactBlockEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/contentLinkEmbedPlugin.js +16 -21
- package/es/plugins/embed/contentLinkEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/copyrightEmbedPlugin.js +15 -17
- package/es/plugins/embed/copyrightEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/externalEmbedPlugin.js +12 -16
- package/es/plugins/embed/externalEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/fileEmbedPlugin.js +23 -32
- package/es/plugins/embed/fileEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/footnoteEmbedPlugin.js +12 -16
- package/es/plugins/embed/footnoteEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/h5pEmbedPlugin.js +12 -16
- package/es/plugins/embed/h5pEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/iframeEmbedPlugin.js +12 -16
- package/es/plugins/embed/iframeEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/imageEmbedPlugin.js +17 -19
- package/es/plugins/embed/imageEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/index.js +47 -49
- package/es/plugins/embed/index.js.map +1 -0
- package/es/plugins/embed/linkBlockEmbedPlugin.js +16 -18
- package/es/plugins/embed/linkBlockEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/pitchEmbedPlugin.js +23 -30
- package/es/plugins/embed/pitchEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/relatedContentEmbedPlugin.js +16 -18
- package/es/plugins/embed/relatedContentEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/symbolEmbedPlugin.js +10 -14
- package/es/plugins/embed/symbolEmbedPlugin.js.map +1 -0
- package/es/plugins/embed/uuDisclaimerEmbedPlugin.js +19 -25
- package/es/plugins/embed/uuDisclaimerEmbedPlugin.js.map +1 -0
- package/es/plugins/h3Plugin.js +15 -17
- package/es/plugins/h3Plugin.js.map +1 -0
- package/es/plugins/index.js +41 -43
- package/es/plugins/index.js.map +1 -0
- package/es/plugins/mathPlugin.js +14 -22
- package/es/plugins/mathPlugin.js.map +1 -0
- package/es/plugins/navPlugin.js +17 -19
- package/es/plugins/navPlugin.js.map +1 -0
- package/es/plugins/oembed/anchorPlugin.js +19 -24
- package/es/plugins/oembed/anchorPlugin.js.map +1 -0
- package/es/plugins/olPlugin.js +17 -21
- package/es/plugins/olPlugin.js.map +1 -0
- package/es/plugins/paragraphPlugin.js +15 -17
- package/es/plugins/paragraphPlugin.js.map +1 -0
- package/es/plugins/summaryPlugin.js +14 -16
- package/es/plugins/summaryPlugin.js.map +1 -0
- package/es/plugins/tablePlugin.js +15 -17
- package/es/plugins/tablePlugin.js.map +1 -0
- package/es/plugins/ulPlugin.js +16 -18
- package/es/plugins/ulPlugin.js.map +1 -0
- package/es/transform.js +22 -34
- package/es/transform.js.map +1 -0
- package/lib/_virtual/rolldown_runtime.js +30 -0
- package/lib/extractEmbedMeta.js +18 -39
- package/lib/extractEmbedMeta.js.map +1 -0
- package/lib/index.js +5 -26
- package/lib/plugins/anchorPlugin.js +18 -29
- package/lib/plugins/anchorPlugin.js.map +1 -0
- package/lib/plugins/asidePlugin.js +11 -23
- package/lib/plugins/asidePlugin.js.map +1 -0
- package/lib/plugins/blockquotePlugin.js +17 -31
- package/lib/plugins/blockquotePlugin.js.map +1 -0
- package/lib/plugins/copyParagraphPlugin.js +16 -26
- package/lib/plugins/copyParagraphPlugin.js.map +1 -0
- package/lib/plugins/detailsPlugin.js +14 -22
- package/lib/plugins/detailsPlugin.js.map +1 -0
- package/lib/plugins/divPlugin.js +50 -72
- package/lib/plugins/divPlugin.js.map +1 -0
- package/lib/plugins/dlPlugin.js +15 -23
- package/lib/plugins/dlPlugin.js.map +1 -0
- package/lib/plugins/embed/KeyFigureEmbedPlugin.js +21 -33
- package/lib/plugins/embed/KeyFigureEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/audioEmbedPlugin.js +15 -23
- package/lib/plugins/embed/audioEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/brightcoveEmbedPlugin.js +16 -24
- package/lib/plugins/embed/brightcoveEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/campaignBlockPlugin.js +26 -34
- package/lib/plugins/embed/campaignBlockPlugin.js.map +1 -0
- package/lib/plugins/embed/codeEmbedPlugin.js +13 -23
- package/lib/plugins/embed/codeEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/conceptEmbedPlugin.js +17 -25
- package/lib/plugins/embed/conceptEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/contactBlockEmbedPlugin.js +26 -42
- package/lib/plugins/embed/contactBlockEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/contentLinkEmbedPlugin.js +17 -28
- package/lib/plugins/embed/contentLinkEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/copyrightEmbedPlugin.js +15 -23
- package/lib/plugins/embed/copyrightEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/externalEmbedPlugin.js +13 -23
- package/lib/plugins/embed/externalEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/fileEmbedPlugin.js +23 -38
- package/lib/plugins/embed/fileEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/footnoteEmbedPlugin.js +13 -23
- package/lib/plugins/embed/footnoteEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/h5pEmbedPlugin.js +13 -23
- package/lib/plugins/embed/h5pEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/iframeEmbedPlugin.js +13 -23
- package/lib/plugins/embed/iframeEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/imageEmbedPlugin.js +17 -25
- package/lib/plugins/embed/imageEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/index.js +46 -54
- package/lib/plugins/embed/index.js.map +1 -0
- package/lib/plugins/embed/linkBlockEmbedPlugin.js +16 -24
- package/lib/plugins/embed/linkBlockEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/pitchEmbedPlugin.js +23 -36
- package/lib/plugins/embed/pitchEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/relatedContentEmbedPlugin.js +16 -24
- package/lib/plugins/embed/relatedContentEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/symbolEmbedPlugin.js +9 -19
- package/lib/plugins/embed/symbolEmbedPlugin.js.map +1 -0
- package/lib/plugins/embed/uuDisclaimerEmbedPlugin.js +19 -32
- package/lib/plugins/embed/uuDisclaimerEmbedPlugin.js.map +1 -0
- package/lib/plugins/h3Plugin.js +14 -22
- package/lib/plugins/h3Plugin.js.map +1 -0
- package/lib/plugins/index.js +42 -49
- package/lib/plugins/index.js.map +1 -0
- package/lib/plugins/mathPlugin.js +14 -28
- package/lib/plugins/mathPlugin.js.map +1 -0
- package/lib/plugins/navPlugin.js +17 -25
- package/lib/plugins/navPlugin.js.map +1 -0
- package/lib/plugins/oembed/anchorPlugin.js +20 -31
- package/lib/plugins/oembed/anchorPlugin.js.map +1 -0
- package/lib/plugins/olPlugin.js +17 -27
- package/lib/plugins/olPlugin.js.map +1 -0
- package/lib/plugins/paragraphPlugin.js +14 -22
- package/lib/plugins/paragraphPlugin.js.map +1 -0
- package/lib/plugins/summaryPlugin.js +14 -22
- package/lib/plugins/summaryPlugin.js.map +1 -0
- package/lib/plugins/tablePlugin.js +15 -23
- package/lib/plugins/tablePlugin.js.map +1 -0
- package/lib/plugins/ulPlugin.js +16 -24
- package/lib/plugins/ulPlugin.js.map +1 -0
- package/lib/transform.js +24 -42
- package/lib/transform.js.map +1 -0
- package/package.json +7 -6
- package/es/plugins/types.js +0 -1
- package/lib/plugins/types.js +0 -5
package/es/extractEmbedMeta.js
CHANGED
|
@@ -1,35 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import parse from "html-react-parser";
|
|
10
|
-
const extractEmbedMeta = embed => {
|
|
11
|
-
const node = parse(embed);
|
|
12
|
-
if (typeof node === "string" || Array.isArray(node) || node.type !== "ndlaembed" || !node.props["data-json"]) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
return JSON.parse(node.props["data-json"]);
|
|
16
|
-
};
|
|
17
|
-
export const extractEmbedMetas = embed => {
|
|
18
|
-
const nodes = parse(embed);
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
else if (!Array.isArray(nodes) && nodes.type === "ndlaembed" && !!nodes.props["data-json"]) {
|
|
26
|
-
return [JSON.parse(nodes.props["data-json"])];
|
|
27
|
-
}
|
|
28
|
-
// There are multiple embeds in the string
|
|
29
|
-
else if (Array.isArray(nodes) && nodes.length && nodes.every(n => n.type === "ndlaembed" && !!n.props["data-json"])) {
|
|
30
|
-
return nodes.map(n => JSON.parse(n.props["data-json"]));
|
|
31
|
-
} else {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
3
|
+
//#region src/extractEmbedMeta.ts
|
|
4
|
+
const extractEmbedMeta = (embed) => {
|
|
5
|
+
const node = parse(embed);
|
|
6
|
+
if (typeof node === "string" || Array.isArray(node) || node.type !== "ndlaembed" || !node.props["data-json"]) return;
|
|
7
|
+
return JSON.parse(node.props["data-json"]);
|
|
34
8
|
};
|
|
35
|
-
|
|
9
|
+
const extractEmbedMetas = (embed) => {
|
|
10
|
+
const nodes = parse(embed);
|
|
11
|
+
if (typeof nodes === "string") return [];
|
|
12
|
+
else if (!Array.isArray(nodes) && nodes.type === "ndlaembed" && !!nodes.props["data-json"]) return [JSON.parse(nodes.props["data-json"])];
|
|
13
|
+
else if (Array.isArray(nodes) && nodes.length && nodes.every((n) => n.type === "ndlaembed" && !!n.props["data-json"])) return nodes.map((n) => JSON.parse(n.props["data-json"]));
|
|
14
|
+
else return [];
|
|
15
|
+
};
|
|
16
|
+
var extractEmbedMeta_default = extractEmbedMeta;
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { extractEmbedMeta_default, extractEmbedMetas };
|
|
20
|
+
//# sourceMappingURL=extractEmbedMeta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractEmbedMeta.js","names":["embed: string"],"sources":["../src/extractEmbedMeta.ts"],"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 parse from \"html-react-parser\";\nimport { type EmbedMetaData } from \"@ndla/types-embed\";\n\nconst extractEmbedMeta = (embed: string): EmbedMetaData | undefined => {\n const node = parse(embed);\n if (typeof node === \"string\" || Array.isArray(node) || node.type !== \"ndlaembed\" || !node.props[\"data-json\"]) {\n return;\n }\n\n return JSON.parse(node.props[\"data-json\"]) as EmbedMetaData;\n};\n\nexport const extractEmbedMetas = (embed: string): EmbedMetaData[] => {\n const nodes = parse(embed);\n\n // There are no embeds in the string\n if (typeof nodes === \"string\") {\n return [];\n }\n // There is only one embed in the string\n else if (!Array.isArray(nodes) && nodes.type === \"ndlaembed\" && !!nodes.props[\"data-json\"]) {\n return [JSON.parse(nodes.props[\"data-json\"]) as EmbedMetaData];\n }\n // There are multiple embeds in the string\n else if (\n Array.isArray(nodes) &&\n nodes.length &&\n nodes.every((n) => n.type === \"ndlaembed\" && !!n.props[\"data-json\"])\n ) {\n return nodes.map((n) => JSON.parse(n.props[\"data-json\"]) as EmbedMetaData);\n } else {\n return [];\n }\n};\n\nexport default extractEmbedMeta;\n"],"mappings":";;;AAWA,MAAM,mBAAmB,CAACA,UAA6C;CACrE,MAAM,OAAO,MAAM,MAAM;AACzB,YAAW,SAAS,YAAY,MAAM,QAAQ,KAAK,IAAI,KAAK,SAAS,gBAAgB,KAAK,MAAM,aAC9F;AAGF,QAAO,KAAK,MAAM,KAAK,MAAM,aAAa;AAC3C;AAED,MAAa,oBAAoB,CAACA,UAAmC;CACnE,MAAM,QAAQ,MAAM,MAAM;AAG1B,YAAW,UAAU,SACnB,QAAO,CAAE;WAGD,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,iBAAiB,MAAM,MAAM,aAC5E,QAAO,CAAC,KAAK,MAAM,MAAM,MAAM,aAAa,AAAkB;UAI9D,MAAM,QAAQ,MAAM,IACpB,MAAM,UACN,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,MAAM,aAAa,CAEpE,QAAO,MAAM,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE,MAAM,aAAa,CAAkB;KAE1E,QAAO,CAAE;AAEZ;AAED,+BAAe"}
|
package/es/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
*/
|
|
1
|
+
import { transform_default } from "./transform.js";
|
|
2
|
+
import { extractEmbedMeta_default, extractEmbedMetas } from "./extractEmbedMeta.js";
|
|
8
3
|
|
|
9
|
-
export {
|
|
10
|
-
export { default as extractEmbedMeta, extractEmbedMetas } from "./extractEmbedMeta";
|
|
4
|
+
export { extractEmbedMeta_default as extractEmbedMeta, extractEmbedMetas, transform_default as transform };
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { attributesToProps, domToReact } from "html-react-parser";
|
|
10
|
-
import { SafeLink } from "@ndla/safelink";
|
|
11
2
|
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
3
|
+
import { SafeLink } from "@ndla/safelink";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/plugins/anchorPlugin.tsx
|
|
7
|
+
const anchorPlugin = (node, opts, { path }) => {
|
|
8
|
+
const props = attributesToProps(node.attribs);
|
|
9
|
+
const href = getPossiblyRelativeUrl(props.href, path);
|
|
10
|
+
return /* @__PURE__ */ jsx(SafeLink, {
|
|
11
|
+
...props,
|
|
12
|
+
to: href,
|
|
13
|
+
children: domToReact(node.children, opts)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { anchorPlugin };
|
|
19
|
+
//# sourceMappingURL=anchorPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchorPlugin.js","names":["anchorPlugin: PluginType"],"sources":["../../src/plugins/anchorPlugin.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 { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { SafeLink } from \"@ndla/safelink\";\nimport { getPossiblyRelativeUrl } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const anchorPlugin: PluginType = (node, opts, { path }) => {\n const props = attributesToProps(node.attribs);\n const href = getPossiblyRelativeUrl(props.href as string, path);\n\n return (\n <SafeLink {...props} to={href}>\n {domToReact(node.children as DOMNode[], opts)}\n </SafeLink>\n );\n};\n"],"mappings":";;;;;;AAaA,MAAaA,eAA2B,CAAC,MAAM,MAAM,EAAE,MAAM,KAAK;CAChE,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;CAC7C,MAAM,OAAO,uBAAuB,MAAM,MAAgB,KAAK;AAE/D,wBACE,IAAC;EAAS,GAAI;EAAO,IAAI;YACtB,WAAW,KAAK,UAAuB,KAAK;GACpC;AAEd"}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { domToReact } from "html-react-parser";
|
|
10
2
|
import { FactBox } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/asidePlugin.tsx
|
|
6
|
+
const asidePlugin = (node, opts) => {
|
|
7
|
+
if (node.attribs["data-type"] === "factAside") return /* @__PURE__ */ jsx(FactBox, { children: domToReact(node.children, opts) });
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { asidePlugin };
|
|
13
|
+
//# sourceMappingURL=asidePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asidePlugin.js","names":["asidePlugin: PluginType"],"sources":["../../src/plugins/asidePlugin.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 { type DOMNode, domToReact } from \"html-react-parser\";\nimport { FactBox } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\nexport const asidePlugin: PluginType = (node, opts) => {\n if (node.attribs[\"data-type\"] === \"factAside\") {\n return <FactBox>{domToReact(node.children as DOMNode[], opts)}</FactBox>;\n }\n return null;\n};\n"],"mappings":";;;;;AAWA,MAAaA,cAA0B,CAAC,MAAM,SAAS;AACrD,KAAI,KAAK,QAAQ,iBAAiB,YAChC,wBAAO,IAAC,qBAAS,WAAW,KAAK,UAAuB,KAAK,GAAW;AAE1E,QAAO;AACR"}
|
|
@@ -1,26 +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
1
|
import { attributesToProps, domToReact } from "html-react-parser";
|
|
10
2
|
import { ContentTypeBlockQuote } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/blockquotePlugin.tsx
|
|
6
|
+
const blockquotePlugin = (node, opts, { contentType }) => {
|
|
7
|
+
const { "data-variant": variant,...props } = attributesToProps(node.attribs);
|
|
8
|
+
return /* @__PURE__ */ jsx(ContentTypeBlockQuote, {
|
|
9
|
+
...props,
|
|
10
|
+
variant,
|
|
11
|
+
contentType,
|
|
12
|
+
children: domToReact(node.children, opts)
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { blockquotePlugin };
|
|
18
|
+
//# sourceMappingURL=blockquotePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockquotePlugin.js","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 { ContentTypeBlockQuote, type ContentTypeBlockQuoteVariant } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const blockquotePlugin: PluginType = (node, opts, { contentType }) => {\n const { \"data-variant\": variant, ...props } = attributesToProps(node.attribs);\n return (\n <ContentTypeBlockQuote\n {...props}\n variant={variant as ContentTypeBlockQuoteVariant | undefined}\n contentType={contentType}\n >\n {domToReact(node.children as DOMNode[], opts)}\n </ContentTypeBlockQuote>\n );\n};\n"],"mappings":";;;;;AAYA,MAAaA,mBAA+B,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK;CAC3E,MAAM,EAAE,gBAAgB,QAAS,GAAG,OAAO,GAAG,kBAAkB,KAAK,QAAQ;AAC7E,wBACE,IAAC;EACC,GAAI;EACK;EACI;YAEZ,WAAW,KAAK,UAAuB,KAAK;GACvB;AAE3B"}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { domToReact } from "html-react-parser";
|
|
10
2
|
import { CopyParagraphButton } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/copyParagraphPlugin.tsx
|
|
6
|
+
const copyParagraphPlugin = (node, converterOpts, opts) => {
|
|
7
|
+
const parent = node.parent;
|
|
8
|
+
if (parent?.name === "section" || parent?.name === "div" && Object.keys(parent.attribs ?? {}).length === 0 || parent?.name === "ndlaembed" && parent.attribs["data-resource"] === "uu-disclaimer") return /* @__PURE__ */ jsx(CopyParagraphButton, {
|
|
9
|
+
copyText: node.attribs["data-text"],
|
|
10
|
+
lang: opts.articleLanguage,
|
|
11
|
+
children: domToReact(node.children, converterOpts)
|
|
12
|
+
});
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { copyParagraphPlugin };
|
|
18
|
+
//# sourceMappingURL=copyParagraphPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyParagraphPlugin.js","names":["copyParagraphPlugin: PluginType"],"sources":["../../src/plugins/copyParagraphPlugin.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 { type DOMNode, Element, domToReact } from \"html-react-parser\";\nimport { CopyParagraphButton } from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\nexport const copyParagraphPlugin: PluginType = (node, converterOpts, opts) => {\n const parent = node.parent as Element | undefined;\n if (\n parent?.name === \"section\" ||\n (parent?.name === \"div\" && Object.keys(parent.attribs ?? {}).length === 0) ||\n (parent?.name === \"ndlaembed\" && parent.attribs[\"data-resource\"] === \"uu-disclaimer\")\n ) {\n return (\n <CopyParagraphButton copyText={node.attribs[\"data-text\"]} lang={opts.articleLanguage}>\n {domToReact(node.children as DOMNode[], converterOpts)}\n </CopyParagraphButton>\n );\n }\n return null;\n};\n"],"mappings":";;;;;AAWA,MAAaA,sBAAkC,CAAC,MAAM,eAAe,SAAS;CAC5E,MAAM,SAAS,KAAK;AACpB,KACE,QAAQ,SAAS,aAChB,QAAQ,SAAS,SAAS,OAAO,KAAK,OAAO,WAAW,CAAE,EAAC,CAAC,WAAW,KACvE,QAAQ,SAAS,eAAe,OAAO,QAAQ,qBAAqB,gBAErE,wBACE,IAAC;EAAoB,UAAU,KAAK,QAAQ;EAAc,MAAM,KAAK;YAClE,WAAW,KAAK,UAAuB,cAAc;GAClC;AAG1B,QAAO;AACR"}
|
|
@@ -1,18 +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
1
|
import { attributesToProps, domToReact } from "html-react-parser";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
3
|
import { ExpandableBox } from "@ndla/primitives";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/detailsPlugin.tsx
|
|
6
|
+
const detailsPlugin = (node, converterOpts) => {
|
|
7
|
+
const props = attributesToProps(node.attribs);
|
|
8
|
+
return /* @__PURE__ */ jsx(ExpandableBox, {
|
|
9
|
+
...props,
|
|
10
|
+
children: domToReact(node.children, converterOpts)
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { detailsPlugin };
|
|
16
|
+
//# sourceMappingURL=detailsPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detailsPlugin.js","names":["detailsPlugin: PluginType"],"sources":["../../src/plugins/detailsPlugin.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 { ExpandableBox } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const detailsPlugin: PluginType = (node, converterOpts) => {\n const props = attributesToProps(node.attribs);\n\n return <ExpandableBox {...props}>{domToReact(node.children as DOMNode[], converterOpts)}</ExpandableBox>;\n};\n"],"mappings":";;;;;AAYA,MAAaA,gBAA4B,CAAC,MAAM,kBAAkB;CAChE,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;AAE7C,wBAAO,IAAC;EAAc,GAAI;YAAQ,WAAW,KAAK,UAAuB,cAAc;GAAiB;AACzG"}
|
package/es/plugins/divPlugin.js
CHANGED
|
@@ -1,67 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
*/
|
|
1
|
+
import { attributesToProps, domToReact } from "html-react-parser";
|
|
2
|
+
import { ContentTypeFramedContent, FileListEmbed, Grid, GridParallaxItem, RelatedArticleList } from "@ndla/ui";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
background: background,
|
|
57
|
-
...props,
|
|
58
|
-
children: domToReact(node.children, opts)
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (node.attribs["data-parallax-cell"] === "true" && node.children.length) {
|
|
62
|
-
return /*#__PURE__*/_jsx(GridParallaxItem, {
|
|
63
|
-
children: domToReact(node.children, opts)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
};
|
|
5
|
+
//#region src/plugins/divPlugin.tsx
|
|
6
|
+
const divPlugin = (node, opts, { contentType }) => {
|
|
7
|
+
if (node.attribs["data-type"] === "framed-content" || node.attribs.class === "c-bodybox") {
|
|
8
|
+
const { "data-variant": variant,...props } = attributesToProps(node.attribs);
|
|
9
|
+
return /* @__PURE__ */ jsx(ContentTypeFramedContent, {
|
|
10
|
+
contentType,
|
|
11
|
+
variant,
|
|
12
|
+
...props,
|
|
13
|
+
children: domToReact(node.children, opts)
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
if (node.attribs["data-type"] === "related-content" && node.children.length) {
|
|
17
|
+
const props = attributesToProps(node.attribs);
|
|
18
|
+
return /* @__PURE__ */ jsx(RelatedArticleList, {
|
|
19
|
+
...props,
|
|
20
|
+
children: domToReact(node.children, opts)
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (node.attribs["data-type"] === "file" && node.childNodes.length) {
|
|
24
|
+
const elements = node.childNodes.filter((c) => c.type === "tag" && c.name === "ndlaembed" && c.attribs["data-resource"] === "file");
|
|
25
|
+
const [pdfs, files] = elements.reduce((acc, el) => {
|
|
26
|
+
const arr = el.attribs["data-type"] === "pdf" && el.attribs["data-display"] === "block" ? acc[0] : acc[1];
|
|
27
|
+
arr.push(el);
|
|
28
|
+
return acc;
|
|
29
|
+
}, [[], []]);
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [files.length ? /* @__PURE__ */ jsx(FileListEmbed, { children: domToReact(files, opts) }) : void 0, domToReact(pdfs, opts)] });
|
|
31
|
+
}
|
|
32
|
+
if (node.attribs["data-type"] === "grid" && node.children.length > 0) {
|
|
33
|
+
const props = attributesToProps(node.attribs);
|
|
34
|
+
const columns = props["data-columns"];
|
|
35
|
+
const border = props["data-border"];
|
|
36
|
+
const background = props["data-background"];
|
|
37
|
+
return /* @__PURE__ */ jsx(Grid, {
|
|
38
|
+
border,
|
|
39
|
+
columns,
|
|
40
|
+
background,
|
|
41
|
+
...props,
|
|
42
|
+
children: domToReact(node.children, opts)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (node.attribs["data-parallax-cell"] === "true" && node.children.length) return /* @__PURE__ */ jsx(GridParallaxItem, { children: domToReact(node.children, opts) });
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { divPlugin };
|
|
51
|
+
//# sourceMappingURL=divPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"divPlugin.js","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 {\n FileListEmbed,\n RelatedArticleList,\n Grid,\n type GridType,\n GridParallaxItem,\n ContentTypeFramedContent,\n type ContentTypeFramedContentVariant,\n} from \"@ndla/ui\";\nimport { type PluginType } from \"./types\";\n\nexport const divPlugin: PluginType = (node, opts, { contentType }) => {\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 <ContentTypeFramedContent\n contentType={contentType}\n variant={variant as ContentTypeFramedContentVariant | undefined}\n {...props}\n >\n {domToReact(node.children as DOMNode[], opts)}\n </ContentTypeFramedContent>\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":";;;;;AAoBA,MAAaA,YAAwB,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK;AACpE,KAAI,KAAK,QAAQ,iBAAiB,oBAAoB,KAAK,QAAQ,UAAU,aAAa;EACxF,MAAM,EAAE,gBAAgB,QAAS,GAAG,OAAO,GAAG,kBAAkB,KAAK,QAAQ;AAC7E,yBACE,IAAC;GACc;GACJ;GACT,GAAI;aAEH,WAAW,KAAK,UAAuB,KAAK;IACpB;CAE9B;AACD,KAAI,KAAK,QAAQ,iBAAiB,qBAAqB,KAAK,SAAS,QAAQ;EAC3E,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;AAE7C,yBACE,IAAC;GAAmB,GAAI;aAErB,WAAW,KAAK,UAAU,KAAK;IACb;CAExB;AACD,KAAI,KAAK,QAAQ,iBAAiB,UAAU,KAAK,WAAW,QAAQ;EAClE,MAAM,WAAW,KAAK,WAAW,OAC/B,CAAC,MAAoB,EAAE,SAAS,SAAS,EAAE,SAAS,eAAe,EAAE,QAAQ,qBAAqB,OACnG;EACD,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,OAC7B,CAAC,KAAK,OAAO;GACX,MAAM,MAAM,GAAG,QAAQ,iBAAiB,SAAS,GAAG,QAAQ,oBAAoB,UAAU,IAAI,KAAK,IAAI;AACvG,OAAI,KAAK,GAAG;AACZ,UAAO;EACR,GACD,CAAC,CAAE,GAAE,CAAE,CAAC,EACT;AAED,yBACE,4BACG,MAAM,yBAAS,IAAC,2BAAe,WAAW,OAAO,KAAK,GAAiB,WACvE,WAAW,MAAM,KAAK,IACtB;CAEN;AACD,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,yBACE,IAAC;GAAa;GAAiB;GAAqB;GAAY,GAAI;aAEjE,WAAW,KAAK,UAAU,KAAK;IAC3B;CAEV;AACD,KAAI,KAAK,QAAQ,0BAA0B,UAAU,KAAK,SAAS,OACjE,wBAAO,IAAC,8BAAkB,WAAW,KAAK,UAAuB,KAAK,GAAoB;AAE5F,QAAO;AACR"}
|
package/es/plugins/dlPlugin.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { attributesToProps, domToReact } from "html-react-parser";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
3
|
import { DefinitionList } from "@ndla/primitives";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/dlPlugin.tsx
|
|
6
|
+
const dlPlugin = (node, converterOpts, opts) => {
|
|
7
|
+
const props = attributesToProps(node.attribs);
|
|
8
|
+
return /* @__PURE__ */ jsx(DefinitionList, {
|
|
9
|
+
...props,
|
|
10
|
+
lang: opts.articleLanguage,
|
|
11
|
+
children: domToReact(node.children, converterOpts)
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { dlPlugin };
|
|
17
|
+
//# sourceMappingURL=dlPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlPlugin.js","names":["dlPlugin: PluginType"],"sources":["../../src/plugins/dlPlugin.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 { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport { DefinitionList } from \"@ndla/primitives\";\nimport { type PluginType } from \"./types\";\n\nexport const dlPlugin: PluginType = (node, converterOpts, opts) => {\n const props = attributesToProps(node.attribs);\n\n return (\n <DefinitionList {...props} lang={opts.articleLanguage}>\n {domToReact(node.children as DOMNode[], converterOpts)}\n </DefinitionList>\n );\n};\n"],"mappings":";;;;;AAYA,MAAaA,WAAuB,CAAC,MAAM,eAAe,SAAS;CACjE,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;AAE7C,wBACE,IAAC;EAAe,GAAI;EAAO,MAAM,KAAK;YACnC,WAAW,KAAK,UAAuB,cAAc;GACvC;AAEpB"}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { attributesToProps } from "html-react-parser";
|
|
10
2
|
import { KeyFigure } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/embed/KeyFigureEmbedPlugin.tsx
|
|
6
|
+
const keyFigureEmbedPlugin = (element) => {
|
|
7
|
+
const props = attributesToProps(element.attribs);
|
|
8
|
+
const data = JSON.parse(props["data-json"]);
|
|
9
|
+
const { title, subtitle, alt } = data.embedData;
|
|
10
|
+
return /* @__PURE__ */ jsx(KeyFigure, {
|
|
11
|
+
title,
|
|
12
|
+
subtitle,
|
|
13
|
+
image: data.status === "success" && data.data.metaImage ? {
|
|
14
|
+
src: data.data.metaImage.image.imageUrl,
|
|
15
|
+
alt: alt === void 0 ? "" : alt
|
|
16
|
+
} : void 0
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { keyFigureEmbedPlugin };
|
|
22
|
+
//# sourceMappingURL=KeyFigureEmbedPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeyFigureEmbedPlugin.js","names":["keyFigureEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/KeyFigureEmbedPlugin.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 KeyFigureMetaData } from \"@ndla/types-embed\";\nimport { KeyFigure } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const keyFigureEmbedPlugin: PluginType = (element) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as KeyFigureMetaData;\n const { title, subtitle, alt } = data.embedData;\n return (\n <KeyFigure\n title={title}\n subtitle={subtitle}\n image={\n data.status === \"success\" && data.data.metaImage\n ? {\n src: data.data.metaImage.image.imageUrl,\n alt: alt === undefined ? \"\" : alt,\n }\n : undefined\n }\n />\n );\n};\n"],"mappings":";;;;;AAaA,MAAaA,uBAAmC,CAAC,YAAY;CAC3D,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;CACrD,MAAM,EAAE,OAAO,UAAU,KAAK,GAAG,KAAK;AACtC,wBACE,IAAC;EACQ;EACG;EACV,OACE,KAAK,WAAW,aAAa,KAAK,KAAK,YACnC;GACE,KAAK,KAAK,KAAK,UAAU,MAAM;GAC/B,KAAK,iBAAoB,KAAK;EAC/B;GAGP;AAEL"}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { attributesToProps } from "html-react-parser";
|
|
10
2
|
import { AudioEmbed } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/embed/audioEmbedPlugin.tsx
|
|
6
|
+
const audioEmbedPlugin = (element, _, opts) => {
|
|
7
|
+
const props = attributesToProps(element.attribs);
|
|
8
|
+
const data = JSON.parse(props["data-json"]);
|
|
9
|
+
return /* @__PURE__ */ jsx(AudioEmbed, {
|
|
10
|
+
embed: data,
|
|
11
|
+
lang: opts.articleLanguage
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { audioEmbedPlugin };
|
|
17
|
+
//# sourceMappingURL=audioEmbedPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioEmbedPlugin.js","names":["audioEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/audioEmbedPlugin.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 AudioMetaData } from \"@ndla/types-embed\";\nimport { AudioEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const audioEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as AudioMetaData;\n return <AudioEmbed embed={data} lang={opts.articleLanguage} />;\n};\n"],"mappings":";;;;;AAaA,MAAaA,mBAA+B,CAAC,SAAS,GAAG,SAAS;CAChE,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBAAO,IAAC;EAAW,OAAO;EAAM,MAAM,KAAK;GAAmB;AAC/D"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2023-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
1
|
import { attributesToProps } from "html-react-parser";
|
|
10
2
|
import { BrightcoveEmbed } from "@ndla/ui";
|
|
11
|
-
import { jsx
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/embed/brightcoveEmbedPlugin.tsx
|
|
6
|
+
const brightcoveEmbedPlugin = (element, _, opts) => {
|
|
7
|
+
const props = attributesToProps(element.attribs);
|
|
8
|
+
const data = JSON.parse(props["data-json"]);
|
|
9
|
+
return /* @__PURE__ */ jsx(BrightcoveEmbed, {
|
|
10
|
+
embed: data,
|
|
11
|
+
renderContext: opts.renderContext,
|
|
12
|
+
lang: opts.articleLanguage
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { brightcoveEmbedPlugin };
|
|
18
|
+
//# sourceMappingURL=brightcoveEmbedPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brightcoveEmbedPlugin.js","names":["brightcoveEmbedPlugin: PluginType"],"sources":["../../../src/plugins/embed/brightcoveEmbedPlugin.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 BrightcoveMetaData } from \"@ndla/types-embed\";\nimport { BrightcoveEmbed } from \"@ndla/ui\";\nimport { type PluginType } from \"../types\";\n\nexport const brightcoveEmbedPlugin: PluginType = (element, _, opts) => {\n const props = attributesToProps(element.attribs);\n const data = JSON.parse(props[\"data-json\"] as string) as BrightcoveMetaData;\n return <BrightcoveEmbed embed={data} renderContext={opts.renderContext} lang={opts.articleLanguage} />;\n};\n"],"mappings":";;;;;AAaA,MAAaA,wBAAoC,CAAC,SAAS,GAAG,SAAS;CACrE,MAAM,QAAQ,kBAAkB,QAAQ,QAAQ;CAChD,MAAM,OAAO,KAAK,MAAM,MAAM,aAAuB;AACrD,wBAAO,IAAC;EAAgB,OAAO;EAAM,eAAe,KAAK;EAAe,MAAM,KAAK;GAAmB;AACvG"}
|