@sitecore-jss/sitecore-jss-nextjs 21.2.0-canary.32 → 21.2.0-canary.34
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.
|
@@ -44,7 +44,7 @@ const router_1 = require("next/router");
|
|
|
44
44
|
const sitecore_jss_react_1 = require("@sitecore-jss/sitecore-jss-react");
|
|
45
45
|
const prefetched = {};
|
|
46
46
|
const RichText = (props) => {
|
|
47
|
-
const { internalLinksSelector = 'a[href^="/"]' } = props, rest = __rest(props, ["internalLinksSelector"]);
|
|
47
|
+
const { internalLinksSelector = 'a[href^="/"]', prefetchLinks = true } = props, rest = __rest(props, ["internalLinksSelector", "prefetchLinks"]);
|
|
48
48
|
const hasText = props.field && props.field.value;
|
|
49
49
|
const isEditing = props.editable && props.field && props.field.editable;
|
|
50
50
|
const router = (0, router_1.useRouter)();
|
|
@@ -69,13 +69,13 @@ const RichText = (props) => {
|
|
|
69
69
|
if (!internalLinks || !internalLinks.length)
|
|
70
70
|
return;
|
|
71
71
|
internalLinks.forEach((link) => {
|
|
72
|
-
if (link.target
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
link.addEventListener('click', routeHandler, false);
|
|
72
|
+
if (link.target === '_blank')
|
|
73
|
+
return;
|
|
74
|
+
if (prefetchLinks && !prefetched[link.pathname]) {
|
|
75
|
+
router.prefetch(link.pathname, undefined, { locale: false });
|
|
76
|
+
prefetched[link.pathname] = true;
|
|
78
77
|
}
|
|
78
|
+
link.addEventListener('click', routeHandler, false);
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
return react_1.default.createElement(sitecore_jss_react_1.RichText, Object.assign({ ref: richTextRef }, rest));
|
|
@@ -15,7 +15,7 @@ import { useRouter } from 'next/router';
|
|
|
15
15
|
import { RichText as ReactRichText, RichTextPropTypes, } from '@sitecore-jss/sitecore-jss-react';
|
|
16
16
|
const prefetched = {};
|
|
17
17
|
export const RichText = (props) => {
|
|
18
|
-
const { internalLinksSelector = 'a[href^="/"]' } = props, rest = __rest(props, ["internalLinksSelector"]);
|
|
18
|
+
const { internalLinksSelector = 'a[href^="/"]', prefetchLinks = true } = props, rest = __rest(props, ["internalLinksSelector", "prefetchLinks"]);
|
|
19
19
|
const hasText = props.field && props.field.value;
|
|
20
20
|
const isEditing = props.editable && props.field && props.field.editable;
|
|
21
21
|
const router = useRouter();
|
|
@@ -40,13 +40,13 @@ export const RichText = (props) => {
|
|
|
40
40
|
if (!internalLinks || !internalLinks.length)
|
|
41
41
|
return;
|
|
42
42
|
internalLinks.forEach((link) => {
|
|
43
|
-
if (link.target
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
link.addEventListener('click', routeHandler, false);
|
|
43
|
+
if (link.target === '_blank')
|
|
44
|
+
return;
|
|
45
|
+
if (prefetchLinks && !prefetched[link.pathname]) {
|
|
46
|
+
router.prefetch(link.pathname, undefined, { locale: false });
|
|
47
|
+
prefetched[link.pathname] = true;
|
|
49
48
|
}
|
|
49
|
+
link.addEventListener('click', routeHandler, false);
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
return React.createElement(ReactRichText, Object.assign({ ref: richTextRef }, rest));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-nextjs",
|
|
3
|
-
"version": "21.2.0-canary.
|
|
3
|
+
"version": "21.2.0-canary.34",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"react-dom": "^18.2.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@sitecore-jss/sitecore-jss": "^21.2.0-canary.
|
|
74
|
-
"@sitecore-jss/sitecore-jss-dev-tools": "^21.2.0-canary.
|
|
75
|
-
"@sitecore-jss/sitecore-jss-react": "^21.2.0-canary.
|
|
73
|
+
"@sitecore-jss/sitecore-jss": "^21.2.0-canary.34",
|
|
74
|
+
"@sitecore-jss/sitecore-jss-dev-tools": "^21.2.0-canary.34",
|
|
75
|
+
"@sitecore-jss/sitecore-jss-react": "^21.2.0-canary.34",
|
|
76
76
|
"node-html-parser": "^6.1.4",
|
|
77
77
|
"prop-types": "^15.8.1",
|
|
78
78
|
"regex-parser": "^2.2.11",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"description": "",
|
|
82
82
|
"types": "types/index.d.ts",
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "e73944adcc1dee36014b734eaa6bea2d3c68b437",
|
|
84
84
|
"files": [
|
|
85
85
|
"dist",
|
|
86
86
|
"types",
|
|
@@ -6,6 +6,12 @@ export type RichTextProps = ReactRichTextProps & {
|
|
|
6
6
|
* @default 'a[href^="/"]'
|
|
7
7
|
*/
|
|
8
8
|
internalLinksSelector?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Controls the prefetch of internal links. This can be beneficial if you have RichText fields
|
|
11
|
+
* with large numbers of internal links in them.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
prefetchLinks?: boolean;
|
|
9
15
|
};
|
|
10
16
|
export declare const RichText: {
|
|
11
17
|
(props: RichTextProps): JSX.Element;
|