@ndla/article-converter 10.0.115-alpha.0 → 10.0.117-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.
|
@@ -8,17 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
import { attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { SafeLink } from "@ndla/safelink";
|
|
11
|
-
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { getPossiblyRelativeUrl, TargetBlankIcon } from "@ndla/ui";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
export const anchorPlugin = (node, opts, _ref) => {
|
|
14
14
|
let {
|
|
15
15
|
path
|
|
16
16
|
} = _ref;
|
|
17
17
|
const props = attributesToProps(node.attribs);
|
|
18
18
|
const href = getPossiblyRelativeUrl(props.href, path);
|
|
19
|
-
|
|
19
|
+
const icon = props.target === "_blank" ? /*#__PURE__*/_jsx(TargetBlankIcon, {}) : "";
|
|
20
|
+
return /*#__PURE__*/_jsxs(SafeLink, {
|
|
20
21
|
...props,
|
|
21
22
|
to: href,
|
|
22
|
-
children: domToReact(node.children, opts)
|
|
23
|
+
children: [domToReact(node.children, opts), icon]
|
|
23
24
|
});
|
|
24
25
|
};
|
|
@@ -22,10 +22,11 @@ const anchorPlugin = (node, opts, _ref) => {
|
|
|
22
22
|
} = _ref;
|
|
23
23
|
const props = (0, _htmlReactParser.attributesToProps)(node.attribs);
|
|
24
24
|
const href = (0, _ui.getPossiblyRelativeUrl)(props.href, path);
|
|
25
|
-
|
|
25
|
+
const icon = props.target === "_blank" ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ui.TargetBlankIcon, {}) : "";
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_safelink.SafeLink, {
|
|
26
27
|
...props,
|
|
27
28
|
to: href,
|
|
28
|
-
children: (0, _htmlReactParser.domToReact)(node.children, opts)
|
|
29
|
+
children: [(0, _htmlReactParser.domToReact)(node.children, opts), icon]
|
|
29
30
|
});
|
|
30
31
|
};
|
|
31
32
|
exports.anchorPlugin = anchorPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.117-alpha.0",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ndla/primitives": "^1.0.85-alpha.0",
|
|
35
|
-
"@ndla/ui": "^56.0.
|
|
35
|
+
"@ndla/ui": "^56.0.114-alpha.0",
|
|
36
36
|
"html-react-parser": "^5.1.19"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c69b83767d021c8f907b54b2a81c60db9d07ae73"
|
|
49
49
|
}
|
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
import { type DOMNode, attributesToProps, domToReact } from "html-react-parser";
|
|
10
10
|
import { SafeLink } from "@ndla/safelink";
|
|
11
|
-
import { getPossiblyRelativeUrl } from "@ndla/ui";
|
|
11
|
+
import { getPossiblyRelativeUrl, TargetBlankIcon } from "@ndla/ui";
|
|
12
12
|
import { type PluginType } from "./types";
|
|
13
13
|
|
|
14
14
|
export const anchorPlugin: PluginType = (node, opts, { path }) => {
|
|
15
15
|
const props = attributesToProps(node.attribs);
|
|
16
16
|
const href = getPossiblyRelativeUrl(props.href as string, path);
|
|
17
|
+
const icon = props.target === "_blank" ? <TargetBlankIcon /> : "";
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
20
|
<SafeLink {...props} to={href}>
|
|
20
21
|
{domToReact(node.children as DOMNode[], opts)}
|
|
22
|
+
{icon}
|
|
21
23
|
</SafeLink>
|
|
22
24
|
);
|
|
23
25
|
};
|