react-datocms 7.2.0 → 7.2.2
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/dist/cjs/Image/index.js +3 -3
- package/dist/cjs/Image/index.js.map +1 -1
- package/dist/cjs/SRCImage/index.js +2 -2
- package/dist/cjs/SRCImage/index.js.map +1 -1
- package/dist/cjs/StructuredText/index.js +4 -4
- package/dist/cjs/StructuredText/index.js.map +1 -1
- package/dist/esm/Image/index.js +3 -3
- package/dist/esm/Image/index.js.map +1 -1
- package/dist/esm/SRCImage/index.js +2 -2
- package/dist/esm/SRCImage/index.js.map +1 -1
- package/dist/esm/StructuredText/index.js +4 -4
- package/dist/esm/StructuredText/index.js.map +1 -1
- package/dist/types/Image/index.d.ts +8 -1
- package/dist/types/SRCImage/index.d.ts +9 -2
- package/dist/types/StructuredText/index.d.ts +7 -7
- package/package.json +3 -3
- package/src/Image/__tests__/__snapshots__/index.test.tsx.snap +20 -0
- package/src/Image/index.tsx +11 -1
- package/src/SRCImage/__tests__/__snapshots__/index.test.tsx.snap +7 -0
- package/src/SRCImage/index.tsx +10 -1
- package/src/StructuredText/__tests__/__snapshots__/index.test.tsx.snap +2 -0
- package/src/StructuredText/__tests__/index.test.tsx +89 -86
- package/src/StructuredText/index.tsx +34 -15
package/dist/cjs/Image/index.js
CHANGED
|
@@ -35,7 +35,7 @@ const imageShowStrategy = ({ priority, loaded }) => {
|
|
|
35
35
|
}
|
|
36
36
|
return true;
|
|
37
37
|
};
|
|
38
|
-
exports.Image = (0, react_2.forwardRef)(({ className, fadeInDuration = 500, intersectionTreshold, intersectionThreshold, intersectionMargin, pictureClassName, imgClassName, style, pictureStyle, imgStyle, layout = 'intrinsic', objectFit, objectPosition, data, onLoad, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], placeholderClassName, placeholderStyle, }, ref) => {
|
|
38
|
+
exports.Image = (0, react_2.forwardRef)(({ className, fadeInDuration = 500, intersectionTreshold, intersectionThreshold, intersectionMargin, pictureClassName, imgClassName, style, pictureStyle, imgStyle, layout = 'intrinsic', objectFit, objectPosition, data, onLoad, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], placeholderClassName, placeholderStyle, referrerPolicy = 'no-referrer-when-downgrade', }, ref) => {
|
|
39
39
|
var _a, _b, _c, _d, _e;
|
|
40
40
|
const imageRef = (0, react_2.useRef)(null);
|
|
41
41
|
const [loaded, handleLoad] = (0, utils_js_2.useImageLoad)(imageRef, onLoad);
|
|
@@ -78,7 +78,7 @@ exports.Image = (0, react_2.forwardRef)(({ className, fadeInDuration = 500, inte
|
|
|
78
78
|
data.src && (
|
|
79
79
|
// biome-ignore lint/a11y/useAltText: We do support the `alt` attribute
|
|
80
80
|
react_1.default.createElement("img", Object.assign({ ref: imageRef, src: data.src, alt: (_b = data.alt) !== null && _b !== void 0 ? _b : '', title: (_c = data.title) !== null && _c !== void 0 ? _c : undefined, onLoad: handleLoad }, (0, utils_js_1.priorityProp)(priority ? 'high' : undefined), { className: imgClassName, style: Object.assign(Object.assign(Object.assign({ opacity: showImage ? 1 : 0, transition }, utils_js_2.absolutePositioning), { objectFit,
|
|
81
|
-
objectPosition }), imgStyle) }))))),
|
|
81
|
+
objectPosition }), imgStyle), referrerPolicy: referrerPolicy }))))),
|
|
82
82
|
react_1.default.createElement("noscript", null,
|
|
83
83
|
react_1.default.createElement("picture", { className: pictureClassName, style: pictureStyle },
|
|
84
84
|
webpSource,
|
|
@@ -86,6 +86,6 @@ exports.Image = (0, react_2.forwardRef)(({ className, fadeInDuration = 500, inte
|
|
|
86
86
|
data.src && (
|
|
87
87
|
// biome-ignore lint/a11y/useAltText: We do support the `alt` attribute
|
|
88
88
|
react_1.default.createElement("img", Object.assign({ src: data.src, alt: (_d = data.alt) !== null && _d !== void 0 ? _d : '', title: (_e = data.title) !== null && _e !== void 0 ? _e : undefined, className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, utils_js_2.absolutePositioning), { objectFit,
|
|
89
|
-
objectPosition }), imgStyle), loading: priority ? undefined : 'lazy' }, (0, utils_js_1.priorityProp)(priority ? 'high' : undefined))))))));
|
|
89
|
+
objectPosition }), imgStyle), loading: priority ? undefined : 'lazy' }, (0, utils_js_1.priorityProp)(priority ? 'high' : undefined), { referrerPolicy: referrerPolicy })))))));
|
|
90
90
|
});
|
|
91
91
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Image/index.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AAEb,uDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Image/index.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;AAEb,uDAAuD;AACvD,kDAA2D;AAC3D,iCAA+D;AAC/D,mDAI8B;AAC9B,iDAA2C;AAC3C,yCAOoB;AA8GpB,MAAM,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAS,EAAE,EAAE;IAC/D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,0CAA+B,EAAE,CAAC;QACpC,OAAO,MAAM,IAAI,MAAM,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAS,EAAE,EAAE;IACxD,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,0CAA+B,EAAE,CAAC;QACpC,OAAO,M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AG,mCAAI,EAAE,EACnB,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,SAAS,EAC9B,MAAM,EAAE,UAAU,IACd,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAC/C,SAAS,EAAE,YAAY,EACvB,KAAK,8CACH,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC1B,UAAU,IACP,8BAAmB,KACtB,SAAS;oBACT,cAAc,KACX,QAAQ,GAEb,cAAc,EAAE,cAAc,IAC9B,CACH,CACO,CACX;QACD;YACE,2CAAS,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY;gBACtD,UAAU;gBACV,aAAa;gBACb,IAAI,CAAC,GAAG,IAAI;gBACX,uEAAuE;gBACvE,qDACE,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,EAAE,EACnB,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,SAAS,EAC9B,SAAS,EAAE,YAAY,EACvB,KAAK,gDACA,8BAAmB,KACtB,SAAS;wBACT,cAAc,KACX,QAAQ,GAEb,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAClC,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAC/C,cAAc,EAAE,cAAc,IAC9B,CACH,CACO,CACD,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -7,7 +7,7 @@ exports.SRCImage = void 0;
|
|
|
7
7
|
// biome-ignore lint/style/useImportType: wrong warning
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const utils_js_1 = require("./utils.js");
|
|
10
|
-
function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], }) {
|
|
10
|
+
function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], referrerPolicy = 'no-referrer-when-downgrade', }) {
|
|
11
11
|
var _a, _b, _c, _d;
|
|
12
12
|
const webpSource = (0, utils_js_1.buildWebpSource)(data, sizes);
|
|
13
13
|
const regularSource = (0, utils_js_1.buildRegularSource)(data, sizes, srcSetCandidates);
|
|
@@ -38,7 +38,7 @@ function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data
|
|
|
38
38
|
regularSource,
|
|
39
39
|
data.src && (
|
|
40
40
|
// biome-ignore lint/a11y/useAltText: We do with alt the best we can
|
|
41
|
-
react_1.default.createElement("img", Object.assign({ src: data.src, alt: (_c = data.alt) !== null && _c !== void 0 ? _c : '', title: (_d = data.title) !== null && _d !== void 0 ? _d : undefined }, loadingBehaviourProps, { className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, placeholderStyle), sizingStyle), imgStyle) })))));
|
|
41
|
+
react_1.default.createElement("img", Object.assign({ src: data.src, alt: (_c = data.alt) !== null && _c !== void 0 ? _c : '', title: (_d = data.title) !== null && _d !== void 0 ? _d : undefined }, loadingBehaviourProps, { className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, placeholderStyle), sizingStyle), imgStyle), referrerPolicy: referrerPolicy })))));
|
|
42
42
|
}
|
|
43
43
|
exports.SRCImage = SRCImage;
|
|
44
44
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SRCImage/index.tsx"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SRCImage/index.tsx"],"names":[],"mappings":";;;;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AAE;QACnC,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,GAAG,KAAK,IAAI;QACtB,MAAM,EAAE,MAAM;KACf,CAAC;IAEF,MAAM,qBAAqB,GAAG,QAAQ;QACpC,CAAC,CAAC,IAAA,uBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7C,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,2CAAS,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY;QACtD,UAAU;QACV,aAAa;QACb,IAAI,CAAC,GAAG,IAAI;QACX,oEAAoE;QACpE,qDACE,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,MAAA,IAAI,CAAC,GAAG,mCAAI,EAAE,EACnB,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,SAAS,IAC1B,qBAAqB,IACzB,SAAS,EAAE,YAAY,EACvB,KAAK,gDACA,gBAAgB,GAChB,WAAW,GACX,QAAQ,GAEb,cAAc,EAAE,cAAc,IAC9B,CACH,CACO,CACX,CAAC;AACJ,CAAC;AAlED,4BAkEC"}
|
|
@@ -105,12 +105,12 @@ function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBl
|
|
|
105
105
|
if (!renderInlineBlock) {
|
|
106
106
|
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'inlineBlock' node, but no 'renderInlineBlock' prop is specified!`, node);
|
|
107
107
|
}
|
|
108
|
-
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.
|
|
109
|
-
throw new datocms_structured_text_utils_1.RenderError(`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.
|
|
108
|
+
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.inlineBlocks)) {
|
|
109
|
+
throw new datocms_structured_text_utils_1.RenderError(`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.inlineBlocks is not present!`, node);
|
|
110
110
|
}
|
|
111
|
-
const item = data.
|
|
111
|
+
const item = data.inlineBlocks.find((item) => item.id === node.item);
|
|
112
112
|
if (!item) {
|
|
113
|
-
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.
|
|
113
|
+
throw new datocms_structured_text_utils_1.RenderError(`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.inlineBlocks!`, node);
|
|
114
114
|
}
|
|
115
115
|
return appendKeyToValidElement(renderInlineBlock({ record: item }), key);
|
|
116
116
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAQuD;AAkB9B,+FApBvB,8DAAc,OAoBuB;AAA9B,+FAnBP,8DAAc,OAmBO;AAGI,2FAtBzB,8DAAc,OAsBqB;AApBrC,iFAcuC;AAGE,4FAfvC,2CAAW,OAeuC;AAFpD,+CAA+E;AAgBlE,QAAA,cAAc,GAAG;IAC5B,UAAU,EAAE,eAAK,CAAC,aAAgD;IAClE,cAAc,EAAE,CACd,QAA+B,EAC/B,GAAW,EACI,EAAE,CAAC,8BAAC,eAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,IAAG,QAAQ,CAAkB;IACzE,UAAU,EAAE,CAAC,IAAY,EAAE,GAAW,EAAiB,EAAE,CAAC,IAAI;CAC/D,CAAC;AAEF,SAAgB,uBAAuB,CACrC,OAA4B,EAC5B,GAAW;IAEX,IAAI,IAAA,sBAAc,EAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,IAAA,oBAAY,EAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACj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
|
@@ -29,7 +29,7 @@ const imageShowStrategy = ({ priority, loaded }) => {
|
|
|
29
29
|
}
|
|
30
30
|
return true;
|
|
31
31
|
};
|
|
32
|
-
export const Image = forwardRef(({ className, fadeInDuration = 500, intersectionTreshold, intersectionThreshold, intersectionMargin, pictureClassName, imgClassName, style, pictureStyle, imgStyle, layout = 'intrinsic', objectFit, objectPosition, data, onLoad, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], placeholderClassName, placeholderStyle, }, ref) => {
|
|
32
|
+
export const Image = forwardRef(({ className, fadeInDuration = 500, intersectionTreshold, intersectionThreshold, intersectionMargin, pictureClassName, imgClassName, style, pictureStyle, imgStyle, layout = 'intrinsic', objectFit, objectPosition, data, onLoad, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], placeholderClassName, placeholderStyle, referrerPolicy = 'no-referrer-when-downgrade', }, ref) => {
|
|
33
33
|
var _a, _b, _c, _d, _e;
|
|
34
34
|
const imageRef = useRef(null);
|
|
35
35
|
const [loaded, handleLoad] = useImageLoad(imageRef, onLoad);
|
|
@@ -72,7 +72,7 @@ export const Image = forwardRef(({ className, fadeInDuration = 500, intersection
|
|
|
72
72
|
data.src && (
|
|
73
73
|
// biome-ignore lint/a11y/useAltText: We do support the `alt` attribute
|
|
74
74
|
React.createElement("img", Object.assign({ ref: imageRef, src: data.src, alt: (_b = data.alt) !== null && _b !== void 0 ? _b : '', title: (_c = data.title) !== null && _c !== void 0 ? _c : undefined, onLoad: handleLoad }, priorityProp(priority ? 'high' : undefined), { className: imgClassName, style: Object.assign(Object.assign(Object.assign({ opacity: showImage ? 1 : 0, transition }, absolutePositioning), { objectFit,
|
|
75
|
-
objectPosition }), imgStyle) }))))),
|
|
75
|
+
objectPosition }), imgStyle), referrerPolicy: referrerPolicy }))))),
|
|
76
76
|
React.createElement("noscript", null,
|
|
77
77
|
React.createElement("picture", { className: pictureClassName, style: pictureStyle },
|
|
78
78
|
webpSource,
|
|
@@ -80,6 +80,6 @@ export const Image = forwardRef(({ className, fadeInDuration = 500, intersection
|
|
|
80
80
|
data.src && (
|
|
81
81
|
// biome-ignore lint/a11y/useAltText: We do support the `alt` attribute
|
|
82
82
|
React.createElement("img", Object.assign({ src: data.src, alt: (_d = data.alt) !== null && _d !== void 0 ? _d : '', title: (_e = data.title) !== null && _e !== void 0 ? _e : undefined, className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, absolutePositioning), { objectFit,
|
|
83
|
-
objectPosition }), imgStyle), loading: priority ? undefined : 'lazy' }, priorityProp(priority ? 'high' : undefined))))))));
|
|
83
|
+
objectPosition }), imgStyle), loading: priority ? undefined : 'lazy' }, priorityProp(priority ? 'high' : undefined), { referrerPolicy: referrerPolicy })))))));
|
|
84
84
|
});
|
|
85
85
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Image/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,uDAAuD;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Image/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,uDAAuD;AACvD,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAsB,UAAU,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACL,mBAAmB,EACnB,+BAA+B,EAC/B,KAAK,EACL,aAAa,EACb,YAAY,EACZ,YAAY,GACb,MAAM,YAAY,CAAC;AA8GpB,MAAM,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAS,EAA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,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAClC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAC/C,cAAc,EAAE,cAAc,IAC9B,CACH,CACO,CACD,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// biome-ignore lint/style/useImportType: wrong warning
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { buildRegularSource, buildWebpSource, priorityProp } from './utils.js';
|
|
4
|
-
export function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], }) {
|
|
4
|
+
export function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder = true, priority = false, sizes, srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4], referrerPolicy = 'no-referrer-when-downgrade', }) {
|
|
5
5
|
var _a, _b, _c, _d;
|
|
6
6
|
const webpSource = buildWebpSource(data, sizes);
|
|
7
7
|
const regularSource = buildRegularSource(data, sizes, srcSetCandidates);
|
|
@@ -32,6 +32,6 @@ export function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyl
|
|
|
32
32
|
regularSource,
|
|
33
33
|
data.src && (
|
|
34
34
|
// biome-ignore lint/a11y/useAltText: We do with alt the best we can
|
|
35
|
-
React.createElement("img", Object.assign({ src: data.src, alt: (_c = data.alt) !== null && _c !== void 0 ? _c : '', title: (_d = data.title) !== null && _d !== void 0 ? _d : undefined }, loadingBehaviourProps, { className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, placeholderStyle), sizingStyle), imgStyle) })))));
|
|
35
|
+
React.createElement("img", Object.assign({ src: data.src, alt: (_c = data.alt) !== null && _c !== void 0 ? _c : '', title: (_d = data.title) !== null && _d !== void 0 ? _d : undefined }, loadingBehaviourProps, { className: imgClassName, style: Object.assign(Object.assign(Object.assign({}, placeholderStyle), sizingStyle), imgStyle), referrerPolicy: referrerPolicy })))));
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SRCImage/index.tsx"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/SRCImage/index.tsx"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA4C/E,MAAM,UAAU,QAAQ,CAAC,EACvB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,cAAc,GAAG,IAAI,EACrB,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,gBAAgB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrD,cAAc,GAAG,4BAA4B,GAC3B;;IAClB,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAExE,MAAM,gBAAgB,GACpB,cAAc,IAAI,IAAI,CAAC,MAAM;QAC3B,CAAC,CAAC;YACE,eAAe,EAAE,QAAQ,IAAI,CAAC,MAAM,IAAI;YACxC,cAAc,EAAE,OAAO;YACvB,gBAAgB,EAAE,WAAW;YAC7B,kBAAkB,EAAE,SAAS;YAC7B,KAAK,EAAE,aAAa;SACrB;QACH,CAAC,CAAC,cAAc,IAAI,IAAI,CAAC,O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77
|
if (!renderInlineBlock) {
|
|
78
78
|
throw new RenderError(`The Structured Text document contains an 'inlineBlock' node, but no 'renderInlineBlock' prop is specified!`, node);
|
|
79
79
|
}
|
|
80
|
-
if (!(isStructuredText(data) && data.
|
|
81
|
-
throw new RenderError(`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.
|
|
80
|
+
if (!(isStructuredText(data) && data.inlineBlocks)) {
|
|
81
|
+
throw new RenderError(`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.inlineBlocks is not present!`, node);
|
|
82
82
|
}
|
|
83
|
-
const item = data.
|
|
83
|
+
const item = data.inlineBlocks.find((item) => item.id === node.item);
|
|
84
84
|
if (!item) {
|
|
85
|
-
throw new RenderError(`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.
|
|
85
|
+
throw new RenderError(`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.inlineBlocks!`, node);
|
|
86
86
|
}
|
|
87
87
|
return appendKeyToValidElement(renderInlineBlock({ record: item }), key);
|
|
88
88
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,sBAAsB,EACtB,MAAM,EACN,cAAc,EACd,cAAc,GACf,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAEL,WAAW,EAOX,OAAO,EACP,aAAa,EACb,YAAY,EACZ,UAAU,EACV,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;AAEvD,aAAa;AACb,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,CAAC;AAWxC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAA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AC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;gBAErE,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,WAAW,CACnB,iGAAiG,IAAI,CAAC,IAAI,4BAA4B,EACtI,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,OAAO,uBAAuB,CAC5B,iBAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EACnC,GAAG,CACJ,CAAC;YACJ,CAAC,CAAC;YACF,GAAG,CAAC,eAAe,IAAI,WAAW,IAAI,EAAE,CAAC;SAC1C;KACF,CAAC,CAAC;IAEH,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,0CAAG,MAAM,CAAI,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributeReferrerPolicy } from 'react';
|
|
2
2
|
import { type CSSProperties } from 'react';
|
|
3
3
|
type Maybe<T> = T | null;
|
|
4
4
|
export type ResponsiveImageType = {
|
|
@@ -91,6 +91,13 @@ export type ImagePropTypes = {
|
|
|
91
91
|
* Default candidate multipliers are [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
|
|
92
92
|
**/
|
|
93
93
|
srcSetCandidates?: number[];
|
|
94
|
+
/**
|
|
95
|
+
* Defines which referrer is sent when fetching the image
|
|
96
|
+
* Read more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy
|
|
97
|
+
*
|
|
98
|
+
* Defaults to `no-referrer-when-downgrade` to give more useful stats in DatoCMS Project Usages
|
|
99
|
+
**/
|
|
100
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy;
|
|
94
101
|
};
|
|
95
102
|
export declare const Image: React.ForwardRefExoticComponent<ImagePropTypes & React.RefAttributes<HTMLDivElement>>;
|
|
96
103
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributeReferrerPolicy } from 'react';
|
|
2
2
|
import type { ResponsiveImageType } from '../Image';
|
|
3
3
|
export type SRCImagePropTypes = {
|
|
4
4
|
/** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */
|
|
@@ -33,5 +33,12 @@ export type SRCImagePropTypes = {
|
|
|
33
33
|
* Default candidate multipliers are [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
|
|
34
34
|
**/
|
|
35
35
|
srcSetCandidates?: number[];
|
|
36
|
+
/**
|
|
37
|
+
* Defines which referrer is sent when fetching the image
|
|
38
|
+
* Read more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy
|
|
39
|
+
*
|
|
40
|
+
* Defaults to `no-referrer-when-downgrade` to give more useful stats in DatoCMS Project Usages
|
|
41
|
+
**/
|
|
42
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy;
|
|
36
43
|
};
|
|
37
|
-
export declare function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder, priority, sizes, srcSetCandidates, }: SRCImagePropTypes): JSX.Element;
|
|
44
|
+
export declare function SRCImage({ pictureClassName, pictureStyle, imgClassName, imgStyle, data, usePlaceholder, priority, sizes, srcSetCandidates, referrerPolicy, }: SRCImagePropTypes): JSX.Element;
|
|
@@ -25,21 +25,21 @@ export type RenderRecordLinkContext<R extends StructuredTextGraphQlResponseRecor
|
|
|
25
25
|
export type RenderBlockContext<R extends StructuredTextGraphQlResponseRecord> = {
|
|
26
26
|
record: R;
|
|
27
27
|
};
|
|
28
|
-
export type StructuredTextPropTypes<
|
|
28
|
+
export type StructuredTextPropTypes<BlockRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord, LinkRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord, InlineBlockRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord> = {
|
|
29
29
|
/** The actual field value you get from DatoCMS **/
|
|
30
|
-
data: StructuredTextGraphQlResponse<
|
|
30
|
+
data: StructuredTextGraphQlResponse<BlockRecord, LinkRecord, InlineBlockRecord> | StructuredTextDocument | Node | null | undefined;
|
|
31
31
|
/** A set of additional rules to convert nodes to JSX **/
|
|
32
32
|
customNodeRules?: RenderRule<H, T, F>[];
|
|
33
33
|
/** A set of additional rules to convert marks to JSX **/
|
|
34
34
|
customMarkRules?: RenderMarkRule<H, T, F>[];
|
|
35
35
|
/** Fuction that converts an 'inlineItem' node into React **/
|
|
36
|
-
renderInlineRecord?: (context: RenderInlineRecordContext<
|
|
36
|
+
renderInlineRecord?: (context: RenderInlineRecordContext<LinkRecord>) => ReactElement | null;
|
|
37
37
|
/** Fuction that converts an 'itemLink' node into React **/
|
|
38
|
-
renderLinkToRecord?: (context: RenderRecordLinkContext<
|
|
38
|
+
renderLinkToRecord?: (context: RenderRecordLinkContext<LinkRecord>) => ReactElement | null;
|
|
39
39
|
/** Fuction that converts a 'block' node into React **/
|
|
40
|
-
renderBlock?: (context: RenderBlockContext<
|
|
40
|
+
renderBlock?: (context: RenderBlockContext<BlockRecord>) => ReactElement | null;
|
|
41
41
|
/** Fuction that converts an 'inlineBlock' node into React **/
|
|
42
|
-
renderInlineBlock?: (context: RenderBlockContext<
|
|
42
|
+
renderInlineBlock?: (context: RenderBlockContext<InlineBlockRecord>) => ReactElement | null;
|
|
43
43
|
/** Function that converts 'link' and 'itemLink' `meta` into HTML props */
|
|
44
44
|
metaTransformer?: TransformMetaFn;
|
|
45
45
|
/** Fuction that converts a simple string text into React **/
|
|
@@ -51,4 +51,4 @@ export type StructuredTextPropTypes<R1 extends StructuredTextGraphQlResponseReco
|
|
|
51
51
|
/** @deprecated use customNodeRules **/
|
|
52
52
|
customRules?: RenderRule<H, T, F>[];
|
|
53
53
|
};
|
|
54
|
-
export declare function StructuredText<
|
|
54
|
+
export declare function StructuredText<BlockRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord, LinkRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord, InlineBlockRecord extends StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord>({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderInlineBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }: StructuredTextPropTypes<BlockRecord, LinkRecord, InlineBlockRecord>): ReactElement | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-datocms",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.2",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=8.0.0"
|
|
6
6
|
},
|
|
@@ -135,8 +135,8 @@
|
|
|
135
135
|
"dependencies": {
|
|
136
136
|
"@mux/mux-player-react": "*",
|
|
137
137
|
"datocms-listen": "^0.1.9",
|
|
138
|
-
"datocms-structured-text-generic-html-renderer": "^
|
|
139
|
-
"datocms-structured-text-utils": "^
|
|
138
|
+
"datocms-structured-text-generic-html-renderer": "^5.0.0",
|
|
139
|
+
"datocms-structured-text-utils": "^5.0.0",
|
|
140
140
|
"react-intersection-observer": "^9.4.3",
|
|
141
141
|
"react-string-replace": "^1.1.0",
|
|
142
142
|
"use-deep-compare-effect": "^1.6.1"
|
|
@@ -61,6 +61,7 @@ exports[`Image explicit sizes renders correctly 1`] = `
|
|
|
61
61
|
<img
|
|
62
62
|
alt=""
|
|
63
63
|
onLoad={[Function]}
|
|
64
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
64
65
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
65
66
|
style={
|
|
66
67
|
{
|
|
@@ -205,6 +206,7 @@ exports[`Image layout=fill visible image loaded shows the image 1`] = `
|
|
|
205
206
|
<img
|
|
206
207
|
alt="DatoCMS swag"
|
|
207
208
|
onLoad={[Function]}
|
|
209
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
208
210
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
209
211
|
style={
|
|
210
212
|
{
|
|
@@ -285,6 +287,7 @@ exports[`Image layout=fill visible renders the image (minimal data) 1`] = `
|
|
|
285
287
|
<img
|
|
286
288
|
alt=""
|
|
287
289
|
onLoad={[Function]}
|
|
290
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
288
291
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
289
292
|
style={
|
|
290
293
|
{
|
|
@@ -364,6 +367,7 @@ exports[`Image layout=fill visible renders the image (relative URL) 1`] = `
|
|
|
364
367
|
<img
|
|
365
368
|
alt=""
|
|
366
369
|
onLoad={[Function]}
|
|
370
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
367
371
|
src="/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
368
372
|
style={
|
|
369
373
|
{
|
|
@@ -449,6 +453,7 @@ exports[`Image layout=fill visible renders the image 1`] = `
|
|
|
449
453
|
<img
|
|
450
454
|
alt="DatoCMS swag"
|
|
451
455
|
onLoad={[Function]}
|
|
456
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
452
457
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
453
458
|
style={
|
|
454
459
|
{
|
|
@@ -606,6 +611,7 @@ exports[`Image layout=fixed visible image loaded shows the image 1`] = `
|
|
|
606
611
|
<img
|
|
607
612
|
alt="DatoCMS swag"
|
|
608
613
|
onLoad={[Function]}
|
|
614
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
609
615
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
610
616
|
style={
|
|
611
617
|
{
|
|
@@ -692,6 +698,7 @@ exports[`Image layout=fixed visible renders the image (minimal data) 1`] = `
|
|
|
692
698
|
<img
|
|
693
699
|
alt=""
|
|
694
700
|
onLoad={[Function]}
|
|
701
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
695
702
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
696
703
|
style={
|
|
697
704
|
{
|
|
@@ -777,6 +784,7 @@ exports[`Image layout=fixed visible renders the image (relative URL) 1`] = `
|
|
|
777
784
|
<img
|
|
778
785
|
alt=""
|
|
779
786
|
onLoad={[Function]}
|
|
787
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
780
788
|
src="/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
781
789
|
style={
|
|
782
790
|
{
|
|
@@ -868,6 +876,7 @@ exports[`Image layout=fixed visible renders the image 1`] = `
|
|
|
868
876
|
<img
|
|
869
877
|
alt="DatoCMS swag"
|
|
870
878
|
onLoad={[Function]}
|
|
879
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
871
880
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
872
881
|
style={
|
|
873
882
|
{
|
|
@@ -1027,6 +1036,7 @@ exports[`Image layout=intrinsic visible image loaded shows the image 1`] = `
|
|
|
1027
1036
|
<img
|
|
1028
1037
|
alt="DatoCMS swag"
|
|
1029
1038
|
onLoad={[Function]}
|
|
1039
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1030
1040
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1031
1041
|
style={
|
|
1032
1042
|
{
|
|
@@ -1114,6 +1124,7 @@ exports[`Image layout=intrinsic visible renders the image (minimal data) 1`] = `
|
|
|
1114
1124
|
<img
|
|
1115
1125
|
alt=""
|
|
1116
1126
|
onLoad={[Function]}
|
|
1127
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1117
1128
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1118
1129
|
style={
|
|
1119
1130
|
{
|
|
@@ -1200,6 +1211,7 @@ exports[`Image layout=intrinsic visible renders the image (relative URL) 1`] = `
|
|
|
1200
1211
|
<img
|
|
1201
1212
|
alt=""
|
|
1202
1213
|
onLoad={[Function]}
|
|
1214
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1203
1215
|
src="/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1204
1216
|
style={
|
|
1205
1217
|
{
|
|
@@ -1292,6 +1304,7 @@ exports[`Image layout=intrinsic visible renders the image 1`] = `
|
|
|
1292
1304
|
<img
|
|
1293
1305
|
alt="DatoCMS swag"
|
|
1294
1306
|
onLoad={[Function]}
|
|
1307
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1295
1308
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1296
1309
|
style={
|
|
1297
1310
|
{
|
|
@@ -1449,6 +1462,7 @@ exports[`Image layout=responsive visible image loaded shows the image 1`] = `
|
|
|
1449
1462
|
<img
|
|
1450
1463
|
alt="DatoCMS swag"
|
|
1451
1464
|
onLoad={[Function]}
|
|
1465
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1452
1466
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1453
1467
|
style={
|
|
1454
1468
|
{
|
|
@@ -1535,6 +1549,7 @@ exports[`Image layout=responsive visible renders the image (minimal data) 1`] =
|
|
|
1535
1549
|
<img
|
|
1536
1550
|
alt=""
|
|
1537
1551
|
onLoad={[Function]}
|
|
1552
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1538
1553
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1539
1554
|
style={
|
|
1540
1555
|
{
|
|
@@ -1620,6 +1635,7 @@ exports[`Image layout=responsive visible renders the image (relative URL) 1`] =
|
|
|
1620
1635
|
<img
|
|
1621
1636
|
alt=""
|
|
1622
1637
|
onLoad={[Function]}
|
|
1638
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1623
1639
|
src="/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1624
1640
|
style={
|
|
1625
1641
|
{
|
|
@@ -1711,6 +1727,7 @@ exports[`Image layout=responsive visible renders the image 1`] = `
|
|
|
1711
1727
|
<img
|
|
1712
1728
|
alt="DatoCMS swag"
|
|
1713
1729
|
onLoad={[Function]}
|
|
1730
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1714
1731
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1715
1732
|
style={
|
|
1716
1733
|
{
|
|
@@ -1834,6 +1851,7 @@ exports[`Image passing className and/or style renders correctly 1`] = `
|
|
|
1834
1851
|
alt=""
|
|
1835
1852
|
className="img-class-name"
|
|
1836
1853
|
onLoad={[Function]}
|
|
1854
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1837
1855
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1838
1856
|
style={
|
|
1839
1857
|
{
|
|
@@ -1928,6 +1946,7 @@ exports[`Image priority=true renders correctly 1`] = `
|
|
|
1928
1946
|
alt=""
|
|
1929
1947
|
fetchpriority="high"
|
|
1930
1948
|
onLoad={[Function]}
|
|
1949
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1931
1950
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1932
1951
|
style={
|
|
1933
1952
|
{
|
|
@@ -1993,6 +2012,7 @@ exports[`Image usePlaceholder=false renders correctly 1`] = `
|
|
|
1993
2012
|
<img
|
|
1994
2013
|
alt=""
|
|
1995
2014
|
onLoad={[Function]}
|
|
2015
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
1996
2016
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
1997
2017
|
style={
|
|
1998
2018
|
{
|
package/src/Image/index.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
// biome-ignore lint/style/useImportType: wrong warning
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { HTMLAttributeReferrerPolicy } from 'react';
|
|
5
5
|
import { type CSSProperties, forwardRef, useRef } from 'react';
|
|
6
6
|
import {
|
|
7
7
|
buildRegularSource,
|
|
@@ -111,6 +111,13 @@ export type ImagePropTypes = {
|
|
|
111
111
|
* Default candidate multipliers are [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
|
|
112
112
|
**/
|
|
113
113
|
srcSetCandidates?: number[];
|
|
114
|
+
/**
|
|
115
|
+
* Defines which referrer is sent when fetching the image
|
|
116
|
+
* Read more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy
|
|
117
|
+
*
|
|
118
|
+
* Defaults to `no-referrer-when-downgrade` to give more useful stats in DatoCMS Project Usages
|
|
119
|
+
**/
|
|
120
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy;
|
|
114
121
|
};
|
|
115
122
|
|
|
116
123
|
type State = {
|
|
@@ -175,6 +182,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
|
|
|
175
182
|
srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4],
|
|
176
183
|
placeholderClassName,
|
|
177
184
|
placeholderStyle,
|
|
185
|
+
referrerPolicy = 'no-referrer-when-downgrade',
|
|
178
186
|
},
|
|
179
187
|
ref,
|
|
180
188
|
) => {
|
|
@@ -300,6 +308,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
|
|
|
300
308
|
objectPosition,
|
|
301
309
|
...imgStyle,
|
|
302
310
|
}}
|
|
311
|
+
referrerPolicy={referrerPolicy}
|
|
303
312
|
/>
|
|
304
313
|
)}
|
|
305
314
|
</picture>
|
|
@@ -323,6 +332,7 @@ export const Image = forwardRef<HTMLDivElement, ImagePropTypes>(
|
|
|
323
332
|
}}
|
|
324
333
|
loading={priority ? undefined : 'lazy'}
|
|
325
334
|
{...priorityProp(priority ? 'high' : undefined)}
|
|
335
|
+
referrerPolicy={referrerPolicy}
|
|
326
336
|
/>
|
|
327
337
|
)}
|
|
328
338
|
</picture>
|
|
@@ -20,6 +20,7 @@ exports[`Image explicit sizes renders correctly 1`] = `
|
|
|
20
20
|
<img
|
|
21
21
|
alt=""
|
|
22
22
|
loading="lazy"
|
|
23
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
23
24
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
24
25
|
style={
|
|
25
26
|
{
|
|
@@ -63,6 +64,7 @@ exports[`Image full data renders correctly 1`] = `
|
|
|
63
64
|
<img
|
|
64
65
|
alt="DatoCMS swag"
|
|
65
66
|
loading="lazy"
|
|
67
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
66
68
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
67
69
|
style={
|
|
68
70
|
{
|
|
@@ -101,6 +103,7 @@ exports[`Image minimal data renders correctly 1`] = `
|
|
|
101
103
|
<img
|
|
102
104
|
alt=""
|
|
103
105
|
loading="lazy"
|
|
106
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
104
107
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
105
108
|
style={
|
|
106
109
|
{
|
|
@@ -138,6 +141,7 @@ exports[`Image minimalDataWithRelativeUrl renders correctly 1`] = `
|
|
|
138
141
|
<img
|
|
139
142
|
alt=""
|
|
140
143
|
loading="lazy"
|
|
144
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
141
145
|
src="/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
142
146
|
style={
|
|
143
147
|
{
|
|
@@ -195,6 +199,7 @@ exports[`Image passing className and/or style renders correctly 1`] = `
|
|
|
195
199
|
alt=""
|
|
196
200
|
className="class-name"
|
|
197
201
|
loading="lazy"
|
|
202
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
198
203
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
199
204
|
style={
|
|
200
205
|
{
|
|
@@ -234,6 +239,7 @@ exports[`Image priority=true renders correctly 1`] = `
|
|
|
234
239
|
<img
|
|
235
240
|
alt=""
|
|
236
241
|
fetchpriority="high"
|
|
242
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
237
243
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
238
244
|
style={
|
|
239
245
|
{
|
|
@@ -272,6 +278,7 @@ exports[`Image usePlaceholder=false renders correctly 1`] = `
|
|
|
272
278
|
<img
|
|
273
279
|
alt=""
|
|
274
280
|
loading="lazy"
|
|
281
|
+
referrerPolicy="no-referrer-when-downgrade"
|
|
275
282
|
src="https://www.datocms-assets.com/205/image.png?ar=16%3A9&fit=crop&w=750"
|
|
276
283
|
style={
|
|
277
284
|
{
|
package/src/SRCImage/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// biome-ignore lint/style/useImportType: wrong warning
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { HTMLAttributeReferrerPolicy } from 'react';
|
|
3
3
|
import type { ResponsiveImageType } from '../Image';
|
|
4
4
|
import { buildRegularSource, buildWebpSource, priorityProp } from './utils.js';
|
|
5
5
|
|
|
@@ -36,6 +36,13 @@ export type SRCImagePropTypes = {
|
|
|
36
36
|
* Default candidate multipliers are [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
|
|
37
37
|
**/
|
|
38
38
|
srcSetCandidates?: number[];
|
|
39
|
+
/**
|
|
40
|
+
* Defines which referrer is sent when fetching the image
|
|
41
|
+
* Read more: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#referrerpolicy
|
|
42
|
+
*
|
|
43
|
+
* Defaults to `no-referrer-when-downgrade` to give more useful stats in DatoCMS Project Usages
|
|
44
|
+
**/
|
|
45
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy;
|
|
39
46
|
};
|
|
40
47
|
|
|
41
48
|
export function SRCImage({
|
|
@@ -48,6 +55,7 @@ export function SRCImage({
|
|
|
48
55
|
priority = false,
|
|
49
56
|
sizes,
|
|
50
57
|
srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4],
|
|
58
|
+
referrerPolicy = 'no-referrer-when-downgrade',
|
|
51
59
|
}: SRCImagePropTypes) {
|
|
52
60
|
const webpSource = buildWebpSource(data, sizes);
|
|
53
61
|
const regularSource = buildRegularSource(data, sizes, srcSetCandidates);
|
|
@@ -98,6 +106,7 @@ export function SRCImage({
|
|
|
98
106
|
...sizingStyle,
|
|
99
107
|
...imgStyle,
|
|
100
108
|
}}
|
|
109
|
+
referrerPolicy={referrerPolicy}
|
|
101
110
|
/>
|
|
102
111
|
)}
|
|
103
112
|
</picture>
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { renderMarkRule } from
|
|
2
|
-
import { isHeading } from
|
|
3
|
-
import { mount, render, shallow } from
|
|
4
|
-
import * as React from
|
|
1
|
+
import { renderMarkRule } from 'datocms-structured-text-generic-html-renderer';
|
|
2
|
+
import { isHeading } from 'datocms-structured-text-utils';
|
|
3
|
+
import { mount, render, shallow } from 'enzyme';
|
|
4
|
+
import * as React from 'react';
|
|
5
5
|
import {
|
|
6
6
|
RenderError,
|
|
7
7
|
StructuredText,
|
|
8
8
|
type StructuredTextDocument,
|
|
9
9
|
type StructuredTextGraphQlResponse,
|
|
10
10
|
renderNodeRule,
|
|
11
|
-
} from
|
|
11
|
+
} from '../index.js';
|
|
12
12
|
|
|
13
|
-
describe(
|
|
14
|
-
describe(
|
|
15
|
-
it(
|
|
13
|
+
describe('StructuredText', () => {
|
|
14
|
+
describe('with no value', () => {
|
|
15
|
+
it('renders null', () => {
|
|
16
16
|
const wrapper = mount(<StructuredText data={null} />);
|
|
17
17
|
expect(wrapper).toMatchSnapshot();
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
describe(
|
|
21
|
+
describe('simple dast /2', () => {
|
|
22
22
|
const structuredText: StructuredTextDocument = {
|
|
23
|
-
schema:
|
|
23
|
+
schema: 'dast',
|
|
24
24
|
document: {
|
|
25
|
-
type:
|
|
25
|
+
type: 'root',
|
|
26
26
|
children: [
|
|
27
27
|
{
|
|
28
|
-
type:
|
|
28
|
+
type: 'heading',
|
|
29
29
|
level: 1,
|
|
30
30
|
children: [
|
|
31
31
|
{
|
|
32
|
-
type:
|
|
33
|
-
value:
|
|
32
|
+
type: 'span',
|
|
33
|
+
value: 'This\nis a ',
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
type:
|
|
37
|
-
marks: [
|
|
38
|
-
value:
|
|
36
|
+
type: 'span',
|
|
37
|
+
marks: ['strong'],
|
|
38
|
+
value: 'title',
|
|
39
39
|
},
|
|
40
40
|
],
|
|
41
41
|
},
|
|
@@ -43,49 +43,49 @@ describe("StructuredText", () => {
|
|
|
43
43
|
},
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
describe(
|
|
47
|
-
it(
|
|
46
|
+
describe('with default rules', () => {
|
|
47
|
+
it('renders the document', () => {
|
|
48
48
|
const wrapper = mount(<StructuredText data={structuredText} />);
|
|
49
49
|
expect(wrapper).toMatchSnapshot();
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
describe(
|
|
54
|
-
it(
|
|
53
|
+
describe('with custom mark rules', () => {
|
|
54
|
+
it('renders the document', () => {
|
|
55
55
|
const wrapper = mount(
|
|
56
56
|
<StructuredText
|
|
57
57
|
data={structuredText}
|
|
58
58
|
customMarkRules={[
|
|
59
|
-
renderMarkRule(
|
|
59
|
+
renderMarkRule('strong', ({ children, key }) => (
|
|
60
60
|
<b key={key}>{children}</b>
|
|
61
61
|
)),
|
|
62
62
|
]}
|
|
63
|
-
|
|
63
|
+
/>,
|
|
64
64
|
);
|
|
65
65
|
expect(wrapper).toMatchSnapshot();
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
describe(
|
|
70
|
+
describe('simple dast with no links/blocks', () => {
|
|
71
71
|
const structuredText: StructuredTextGraphQlResponse = {
|
|
72
72
|
value: {
|
|
73
|
-
schema:
|
|
73
|
+
schema: 'dast',
|
|
74
74
|
document: {
|
|
75
|
-
type:
|
|
75
|
+
type: 'root',
|
|
76
76
|
children: [
|
|
77
77
|
{
|
|
78
|
-
type:
|
|
78
|
+
type: 'heading',
|
|
79
79
|
level: 1,
|
|
80
80
|
children: [
|
|
81
81
|
{
|
|
82
|
-
type:
|
|
83
|
-
value:
|
|
82
|
+
type: 'span',
|
|
83
|
+
value: 'This\nis a ',
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
|
-
type:
|
|
87
|
-
marks: [
|
|
88
|
-
value:
|
|
86
|
+
type: 'span',
|
|
87
|
+
marks: ['strong'],
|
|
88
|
+
value: 'title',
|
|
89
89
|
},
|
|
90
90
|
],
|
|
91
91
|
},
|
|
@@ -94,22 +94,22 @@ describe("StructuredText", () => {
|
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
describe(
|
|
98
|
-
it(
|
|
97
|
+
describe('with default rules', () => {
|
|
98
|
+
it('renders the document', () => {
|
|
99
99
|
const wrapper = mount(<StructuredText data={structuredText} />);
|
|
100
100
|
expect(wrapper).toMatchSnapshot();
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
-
describe(
|
|
105
|
-
it(
|
|
104
|
+
describe('with custom rules', () => {
|
|
105
|
+
it('renders the document', () => {
|
|
106
106
|
const wrapper = mount(
|
|
107
107
|
<StructuredText
|
|
108
108
|
data={structuredText}
|
|
109
109
|
renderText={(text, key) => {
|
|
110
110
|
return (
|
|
111
111
|
<React.Fragment key={key}>
|
|
112
|
-
{text.replace(/This/,
|
|
112
|
+
{text.replace(/This/, 'That')}
|
|
113
113
|
</React.Fragment>
|
|
114
114
|
);
|
|
115
115
|
}}
|
|
@@ -118,113 +118,116 @@ describe("StructuredText", () => {
|
|
|
118
118
|
isHeading,
|
|
119
119
|
({ adapter: { renderNode }, node, children, key }) => {
|
|
120
120
|
return renderNode(`h${node.level + 1}`, { key }, children);
|
|
121
|
-
}
|
|
121
|
+
},
|
|
122
122
|
),
|
|
123
123
|
]}
|
|
124
|
-
|
|
124
|
+
/>,
|
|
125
125
|
);
|
|
126
126
|
expect(wrapper).toMatchSnapshot();
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
describe(
|
|
131
|
+
describe('with links/blocks', () => {
|
|
132
132
|
type QuoteRecord = {
|
|
133
133
|
id: string;
|
|
134
|
-
__typename:
|
|
134
|
+
__typename: 'QuoteRecord';
|
|
135
135
|
quote: string;
|
|
136
136
|
author: string;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
type MentionRecord = {
|
|
140
140
|
id: string;
|
|
141
|
-
__typename:
|
|
141
|
+
__typename: 'MentionRecord';
|
|
142
142
|
name: string;
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
type DocPageRecord = {
|
|
146
146
|
id: string;
|
|
147
|
-
__typename:
|
|
147
|
+
__typename: 'DocPageRecord';
|
|
148
148
|
slug: string;
|
|
149
149
|
title: string;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
152
|
const structuredText: StructuredTextGraphQlResponse<
|
|
153
|
-
QuoteRecord
|
|
154
|
-
DocPageRecord
|
|
153
|
+
QuoteRecord,
|
|
154
|
+
DocPageRecord,
|
|
155
|
+
MentionRecord
|
|
155
156
|
> = {
|
|
156
157
|
value: {
|
|
157
|
-
schema:
|
|
158
|
+
schema: 'dast',
|
|
158
159
|
document: {
|
|
159
|
-
type:
|
|
160
|
+
type: 'root',
|
|
160
161
|
children: [
|
|
161
162
|
{
|
|
162
|
-
type:
|
|
163
|
+
type: 'heading',
|
|
163
164
|
level: 1,
|
|
164
165
|
children: [
|
|
165
166
|
{
|
|
166
|
-
type:
|
|
167
|
-
value:
|
|
167
|
+
type: 'span',
|
|
168
|
+
value: 'This is a',
|
|
168
169
|
},
|
|
169
170
|
{
|
|
170
|
-
type:
|
|
171
|
-
marks: [
|
|
172
|
-
value:
|
|
171
|
+
type: 'span',
|
|
172
|
+
marks: ['highlight'],
|
|
173
|
+
value: 'title',
|
|
173
174
|
},
|
|
174
175
|
{
|
|
175
|
-
type:
|
|
176
|
-
item:
|
|
176
|
+
type: 'inlineItem',
|
|
177
|
+
item: '123',
|
|
177
178
|
},
|
|
178
179
|
{
|
|
179
|
-
type:
|
|
180
|
-
item:
|
|
181
|
-
meta: [{ id:
|
|
182
|
-
children: [{ type:
|
|
180
|
+
type: 'itemLink',
|
|
181
|
+
item: '123',
|
|
182
|
+
meta: [{ id: 'target', value: '_blank' }],
|
|
183
|
+
children: [{ type: 'span', value: 'here!' }],
|
|
183
184
|
},
|
|
184
185
|
{
|
|
185
|
-
type:
|
|
186
|
-
item:
|
|
186
|
+
type: 'inlineBlock',
|
|
187
|
+
item: '789',
|
|
187
188
|
},
|
|
188
189
|
],
|
|
189
190
|
},
|
|
190
191
|
{
|
|
191
|
-
type:
|
|
192
|
-
item:
|
|
192
|
+
type: 'block',
|
|
193
|
+
item: '456',
|
|
193
194
|
},
|
|
194
195
|
],
|
|
195
196
|
},
|
|
196
197
|
},
|
|
197
198
|
blocks: [
|
|
198
199
|
{
|
|
199
|
-
id:
|
|
200
|
-
__typename:
|
|
201
|
-
quote:
|
|
202
|
-
author:
|
|
200
|
+
id: '456',
|
|
201
|
+
__typename: 'QuoteRecord',
|
|
202
|
+
quote: 'Foo bar.',
|
|
203
|
+
author: 'Mark Smith',
|
|
203
204
|
},
|
|
205
|
+
],
|
|
206
|
+
inlineBlocks: [
|
|
204
207
|
{
|
|
205
|
-
id:
|
|
206
|
-
__typename:
|
|
207
|
-
name:
|
|
208
|
+
id: '789',
|
|
209
|
+
__typename: 'MentionRecord',
|
|
210
|
+
name: 'Jane Doe',
|
|
208
211
|
},
|
|
209
212
|
],
|
|
210
213
|
links: [
|
|
211
214
|
{
|
|
212
|
-
id:
|
|
213
|
-
__typename:
|
|
214
|
-
title:
|
|
215
|
-
slug:
|
|
215
|
+
id: '123',
|
|
216
|
+
__typename: 'DocPageRecord',
|
|
217
|
+
title: 'How to code',
|
|
218
|
+
slug: 'how-to-code',
|
|
216
219
|
},
|
|
217
220
|
],
|
|
218
221
|
};
|
|
219
222
|
|
|
220
|
-
describe(
|
|
221
|
-
it(
|
|
223
|
+
describe('with default rules', () => {
|
|
224
|
+
it('renders the document', () => {
|
|
222
225
|
const wrapper = mount(
|
|
223
226
|
<StructuredText
|
|
224
227
|
data={structuredText}
|
|
225
228
|
renderInlineRecord={({ record }) => {
|
|
226
229
|
switch (record.__typename) {
|
|
227
|
-
case
|
|
230
|
+
case 'DocPageRecord':
|
|
228
231
|
return <a href={`/docs/${record.slug}`}>{record.title}</a>;
|
|
229
232
|
default:
|
|
230
233
|
return null;
|
|
@@ -232,7 +235,7 @@ describe("StructuredText", () => {
|
|
|
232
235
|
}}
|
|
233
236
|
renderLinkToRecord={({ record, children, transformedMeta }) => {
|
|
234
237
|
switch (record.__typename) {
|
|
235
|
-
case
|
|
238
|
+
case 'DocPageRecord':
|
|
236
239
|
return (
|
|
237
240
|
<a {...transformedMeta} href={`/docs/${record.slug}`}>
|
|
238
241
|
{children}
|
|
@@ -244,7 +247,7 @@ describe("StructuredText", () => {
|
|
|
244
247
|
}}
|
|
245
248
|
renderBlock={({ record }) => {
|
|
246
249
|
switch (record.__typename) {
|
|
247
|
-
case
|
|
250
|
+
case 'QuoteRecord':
|
|
248
251
|
return (
|
|
249
252
|
<figure>
|
|
250
253
|
<blockquote>{record.quote}</blockquote>
|
|
@@ -257,28 +260,28 @@ describe("StructuredText", () => {
|
|
|
257
260
|
}}
|
|
258
261
|
renderInlineBlock={({ record }) => {
|
|
259
262
|
switch (record.__typename) {
|
|
260
|
-
case
|
|
263
|
+
case 'MentionRecord':
|
|
261
264
|
return <em>{record.name}</em>;
|
|
262
265
|
default:
|
|
263
266
|
return null;
|
|
264
267
|
}
|
|
265
268
|
}}
|
|
266
|
-
|
|
269
|
+
/>,
|
|
267
270
|
);
|
|
268
271
|
expect(wrapper).toMatchSnapshot();
|
|
269
272
|
});
|
|
270
273
|
});
|
|
271
274
|
|
|
272
|
-
describe(
|
|
273
|
-
it(
|
|
275
|
+
describe('with missing renderInlineRecord prop', () => {
|
|
276
|
+
it('raises an error', () => {
|
|
274
277
|
expect(() => {
|
|
275
278
|
shallow(<StructuredText data={structuredText} />);
|
|
276
279
|
}).toThrow(RenderError);
|
|
277
280
|
});
|
|
278
281
|
});
|
|
279
282
|
|
|
280
|
-
describe(
|
|
281
|
-
it(
|
|
283
|
+
describe('with missing record', () => {
|
|
284
|
+
it('raises an error', () => {
|
|
282
285
|
expect(() => {
|
|
283
286
|
shallow(
|
|
284
287
|
<StructuredText
|
|
@@ -286,7 +289,7 @@ describe("StructuredText", () => {
|
|
|
286
289
|
renderInlineRecord={() => {
|
|
287
290
|
return null;
|
|
288
291
|
}}
|
|
289
|
-
|
|
292
|
+
/>,
|
|
290
293
|
);
|
|
291
294
|
}).toThrow(RenderError);
|
|
292
295
|
});
|
|
@@ -81,12 +81,16 @@ export type RenderBlockContext<R extends StructuredTextGraphQlResponseRecord> =
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export type StructuredTextPropTypes<
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
BlockRecord extends
|
|
85
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
86
|
+
LinkRecord extends
|
|
87
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
88
|
+
InlineBlockRecord extends
|
|
89
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
86
90
|
> = {
|
|
87
91
|
/** The actual field value you get from DatoCMS **/
|
|
88
92
|
data:
|
|
89
|
-
| StructuredTextGraphQlResponse<
|
|
93
|
+
| StructuredTextGraphQlResponse<BlockRecord, LinkRecord, InlineBlockRecord>
|
|
90
94
|
| StructuredTextDocument
|
|
91
95
|
| Node
|
|
92
96
|
| null
|
|
@@ -97,16 +101,20 @@ export type StructuredTextPropTypes<
|
|
|
97
101
|
customMarkRules?: RenderMarkRule<H, T, F>[];
|
|
98
102
|
/** Fuction that converts an 'inlineItem' node into React **/
|
|
99
103
|
renderInlineRecord?: (
|
|
100
|
-
context: RenderInlineRecordContext<
|
|
104
|
+
context: RenderInlineRecordContext<LinkRecord>,
|
|
101
105
|
) => ReactElement | null;
|
|
102
106
|
/** Fuction that converts an 'itemLink' node into React **/
|
|
103
107
|
renderLinkToRecord?: (
|
|
104
|
-
context: RenderRecordLinkContext<
|
|
108
|
+
context: RenderRecordLinkContext<LinkRecord>,
|
|
105
109
|
) => ReactElement | null;
|
|
106
110
|
/** Fuction that converts a 'block' node into React **/
|
|
107
|
-
renderBlock?: (
|
|
111
|
+
renderBlock?: (
|
|
112
|
+
context: RenderBlockContext<BlockRecord>,
|
|
113
|
+
) => ReactElement | null;
|
|
108
114
|
/** Fuction that converts an 'inlineBlock' node into React **/
|
|
109
|
-
renderInlineBlock?: (
|
|
115
|
+
renderInlineBlock?: (
|
|
116
|
+
context: RenderBlockContext<InlineBlockRecord>,
|
|
117
|
+
) => ReactElement | null;
|
|
110
118
|
/** Function that converts 'link' and 'itemLink' `meta` into HTML props */
|
|
111
119
|
metaTransformer?: TransformMetaFn;
|
|
112
120
|
/** Fuction that converts a simple string text into React **/
|
|
@@ -120,8 +128,12 @@ export type StructuredTextPropTypes<
|
|
|
120
128
|
};
|
|
121
129
|
|
|
122
130
|
export function StructuredText<
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
BlockRecord extends
|
|
132
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
133
|
+
LinkRecord extends
|
|
134
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
135
|
+
InlineBlockRecord extends
|
|
136
|
+
StructuredTextGraphQlResponseRecord = StructuredTextGraphQlResponseRecord,
|
|
125
137
|
>({
|
|
126
138
|
data,
|
|
127
139
|
renderInlineRecord,
|
|
@@ -135,7 +147,11 @@ export function StructuredText<
|
|
|
135
147
|
customRules,
|
|
136
148
|
customNodeRules,
|
|
137
149
|
metaTransformer,
|
|
138
|
-
}: StructuredTextPropTypes<
|
|
150
|
+
}: StructuredTextPropTypes<
|
|
151
|
+
BlockRecord,
|
|
152
|
+
LinkRecord,
|
|
153
|
+
InlineBlockRecord
|
|
154
|
+
>): ReactElement | null {
|
|
139
155
|
const result = render(data, {
|
|
140
156
|
adapter: {
|
|
141
157
|
renderText: renderText || defaultAdapter.renderText,
|
|
@@ -246,23 +262,26 @@ export function StructuredText<
|
|
|
246
262
|
);
|
|
247
263
|
}
|
|
248
264
|
|
|
249
|
-
if (!(isStructuredText(data) && data.
|
|
265
|
+
if (!(isStructuredText(data) && data.inlineBlocks)) {
|
|
250
266
|
throw new RenderError(
|
|
251
|
-
`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.
|
|
267
|
+
`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.inlineBlocks is not present!`,
|
|
252
268
|
node,
|
|
253
269
|
);
|
|
254
270
|
}
|
|
255
271
|
|
|
256
|
-
const item = data.
|
|
272
|
+
const item = data.inlineBlocks.find((item) => item.id === node.item);
|
|
257
273
|
|
|
258
274
|
if (!item) {
|
|
259
275
|
throw new RenderError(
|
|
260
|
-
`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.
|
|
276
|
+
`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.inlineBlocks!`,
|
|
261
277
|
node,
|
|
262
278
|
);
|
|
263
279
|
}
|
|
264
280
|
|
|
265
|
-
return appendKeyToValidElement(
|
|
281
|
+
return appendKeyToValidElement(
|
|
282
|
+
renderInlineBlock({ record: item }),
|
|
283
|
+
key,
|
|
284
|
+
);
|
|
266
285
|
}),
|
|
267
286
|
...(customNodeRules || customRules || []),
|
|
268
287
|
],
|