@ndla/article-converter 10.0.179-alpha.0 → 10.0.181-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/anchorPlugin.mjs +7 -0
- package/es/plugins/anchorPlugin.mjs.map +1 -1
- package/lib/plugins/anchorPlugin.js +7 -0
- package/lib/plugins/anchorPlugin.js.map +1 -1
- package/lib/plugins/types.d.ts +1 -1
- package/package.json +5 -5
- package/src/plugins/anchorPlugin.tsx +1 -1
- package/src/plugins/types.ts +1 -1
|
@@ -4,6 +4,13 @@ import { jsx } from "react/jsx-runtime";
|
|
|
4
4
|
import { SafeLink } from "@ndla/safelink";
|
|
5
5
|
|
|
6
6
|
//#region src/plugins/anchorPlugin.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2023-present, NDLA.
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
7
14
|
const anchorPlugin = (node, opts, { path, isOembed }) => {
|
|
8
15
|
const props = attributesToProps(node.attribs);
|
|
9
16
|
const href = getPossiblyRelativeUrl(props.href, path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorPlugin.mjs","names":[],"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
|
|
1
|
+
{"version":3,"file":"anchorPlugin.mjs","names":[],"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 { SafeLink } from \"@ndla/safelink\";\nimport { getPossiblyRelativeUrl } from \"@ndla/ui\";\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport type { AnchorHTMLAttributes } from \"react\";\nimport { type PluginType } from \"./types\";\n\nexport const anchorPlugin: PluginType = (node, opts, { path, isOembed }) => {\n const props = attributesToProps(node.attribs);\n const href = getPossiblyRelativeUrl(props.href as string, path);\n\n const oembedProps: AnchorHTMLAttributes<HTMLAnchorElement> = isOembed ? { target: \"_blank\", rel: \"noreferrer\" } : {};\n\n return (\n <SafeLink {...props} to={href} {...oembedProps} target=\"\">\n {domToReact(node.children as DOMNode[], opts)}\n </SafeLink>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,gBAA4B,MAAM,MAAM,EAAE,MAAM,eAAe;CAC1E,MAAM,QAAQ,kBAAkB,KAAK,QAAQ;CAC7C,MAAM,OAAO,uBAAuB,MAAM,MAAgB,KAAK;CAE/D,MAAM,cAAuD,WAAW;EAAE,QAAQ;EAAU,KAAK;EAAc,GAAG,EAAE;AAEpH,QACE,oBAAC;EAAS,GAAI;EAAO,IAAI;EAAM,GAAI;EAAa,QAAO;YACpD,WAAW,KAAK,UAAuB,KAAK;GACpC"}
|
|
@@ -5,6 +5,13 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
5
5
|
let _ndla_safelink = require("@ndla/safelink");
|
|
6
6
|
|
|
7
7
|
//#region src/plugins/anchorPlugin.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2023-present, NDLA.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
8
15
|
const anchorPlugin = (node, opts, { path, isOembed }) => {
|
|
9
16
|
const props = (0, html_react_parser.attributesToProps)(node.attribs);
|
|
10
17
|
const href = (0, _ndla_ui.getPossiblyRelativeUrl)(props.href, path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchorPlugin.js","names":["SafeLink"],"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
|
|
1
|
+
{"version":3,"file":"anchorPlugin.js","names":["SafeLink"],"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 { SafeLink } from \"@ndla/safelink\";\nimport { getPossiblyRelativeUrl } from \"@ndla/ui\";\nimport { type DOMNode, attributesToProps, domToReact } from \"html-react-parser\";\nimport type { AnchorHTMLAttributes } from \"react\";\nimport { type PluginType } from \"./types\";\n\nexport const anchorPlugin: PluginType = (node, opts, { path, isOembed }) => {\n const props = attributesToProps(node.attribs);\n const href = getPossiblyRelativeUrl(props.href as string, path);\n\n const oembedProps: AnchorHTMLAttributes<HTMLAnchorElement> = isOembed ? { target: \"_blank\", rel: \"noreferrer\" } : {};\n\n return (\n <SafeLink {...props} to={href} {...oembedProps} target=\"\">\n {domToReact(node.children as DOMNode[], opts)}\n </SafeLink>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAa,gBAA4B,MAAM,MAAM,EAAE,MAAM,eAAe;CAC1E,MAAM,iDAA0B,KAAK,QAAQ;CAC7C,MAAM,4CAA8B,MAAM,MAAgB,KAAK;CAE/D,MAAM,cAAuD,WAAW;EAAE,QAAQ;EAAU,KAAK;EAAc,GAAG,EAAE;AAEpH,QACE,2CAACA;EAAS,GAAI;EAAO,IAAI;EAAM,GAAI;EAAa,QAAO;8CACzC,KAAK,UAAuB,KAAK;GACpC"}
|
package/lib/plugins/types.d.ts
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
import type { RenderContext, CanonicalUrlFuncs } from "@ndla/ui";
|
|
9
|
-
import type { ReactElement } from "react";
|
|
10
9
|
import { Element, type HTMLReactParserOptions } from "html-react-parser";
|
|
10
|
+
import type { ReactElement } from "react";
|
|
11
11
|
export interface TransformOptions {
|
|
12
12
|
isOembed?: boolean;
|
|
13
13
|
subject?: string;
|
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.181-alpha.0",
|
|
5
5
|
"description": "Transforms NDLA articles into extended html versions",
|
|
6
6
|
"license": "GPL-3.0",
|
|
7
7
|
"exports": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"@ndla/types-embed": "^5.0.21-alpha.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ndla/primitives": "^1.0.
|
|
39
|
-
"@ndla/safelink": "^7.0.
|
|
40
|
-
"@ndla/ui": "^56.0.
|
|
38
|
+
"@ndla/primitives": "^1.0.123-alpha.0",
|
|
39
|
+
"@ndla/safelink": "^7.0.126-alpha.0",
|
|
40
|
+
"@ndla/ui": "^56.0.177-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": "5a5db230dd4f95c573df293e0701a4962495c4d5"
|
|
54
54
|
}
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import type { AnchorHTMLAttributes } from "react";
|
|
10
9
|
import { SafeLink } from "@ndla/safelink";
|
|
11
10
|
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
12
11
|
import { type DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
12
|
+
import type { AnchorHTMLAttributes } from "react";
|
|
13
13
|
import { type PluginType } from "./types";
|
|
14
14
|
|
|
15
15
|
export const anchorPlugin: PluginType = (node, opts, { path, isOembed }) => {
|
package/src/plugins/types.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { RenderContext, CanonicalUrlFuncs } from "@ndla/ui";
|
|
10
|
-
import type { ReactElement } from "react";
|
|
11
10
|
import { Element, type HTMLReactParserOptions } from "html-react-parser";
|
|
11
|
+
import type { ReactElement } from "react";
|
|
12
12
|
|
|
13
13
|
export interface TransformOptions {
|
|
14
14
|
isOembed?: boolean;
|