react-datocms 7.1.0 → 7.2.1
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/README.md +33 -14
- 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 +14 -1
- 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 +15 -2
- 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 +3 -1
- 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 +15 -0
- package/src/StructuredText/__tests__/index.test.tsx +24 -1
- package/src/StructuredText/index.tsx +33 -0
package/README.md
CHANGED
|
@@ -52,26 +52,45 @@ npm run start
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
54
|
# What is DatoCMS?
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
<a href="https://www.datocms.com/"><img src="https://www.datocms.com/images/full_logo.svg" height="60" alt="DatoCMS - The Headless CMS for the Modern Web"></a>
|
|
56
57
|
|
|
57
58
|
[DatoCMS](https://www.datocms.com/) is the REST & GraphQL Headless CMS for the modern web.
|
|
58
59
|
|
|
59
|
-
Trusted by over 25,000 enterprise businesses,
|
|
60
|
+
Trusted by over 25,000 enterprise businesses, agencies, and individuals across the world, DatoCMS users create online content at scale from a central hub and distribute it via API. We ❤️ our [developers](https://www.datocms.com/team/best-cms-for-developers), [content editors](https://www.datocms.com/team/content-creators) and [marketers](https://www.datocms.com/team/cms-digital-marketing)!
|
|
61
|
+
|
|
62
|
+
**Why DatoCMS?**
|
|
63
|
+
|
|
64
|
+
- **API-First Architecture**: Built for both REST and GraphQL, enabling flexible content delivery
|
|
65
|
+
- **Just Enough Features**: We believe in keeping things simple, and giving you [the right feature-set tools](https://www.datocms.com/features) to get the job done
|
|
66
|
+
- **Developer Experience**: First-class TypeScript support with powerful developer tools
|
|
67
|
+
|
|
68
|
+
**Getting Started:**
|
|
69
|
+
|
|
70
|
+
- ⚡️ [Create Free Account](https://dashboard.datocms.com/signup) - Get started with DatoCMS in minutes
|
|
71
|
+
- 🔖 [Documentation](https://www.datocms.com/docs) - Comprehensive guides and API references
|
|
72
|
+
- ⚙️ [Community Support](https://community.datocms.com/) - Get help from our team and community
|
|
73
|
+
- 🆕 [Changelog](https://www.datocms.com/product-updates) - Latest features and improvements
|
|
74
|
+
|
|
75
|
+
**Official Libraries:**
|
|
76
|
+
|
|
77
|
+
- [**Content Delivery Client**](https://github.com/datocms/cda-client) - TypeScript GraphQL client for content fetching
|
|
78
|
+
- [**REST API Clients**](https://github.com/datocms/js-rest-api-clients) - Node.js/Browser clients for content management
|
|
79
|
+
- [**CLI Tools**](https://github.com/datocms/cli) - Command-line utilities for schema migrations (includes [Contentful](https://github.com/datocms/cli/tree/main/packages/cli-plugin-contentful) and [WordPress](https://github.com/datocms/cli/tree/main/packages/cli-plugin-wordpress) importers)
|
|
80
|
+
|
|
81
|
+
**Official Framework Integrations**
|
|
60
82
|
|
|
61
|
-
|
|
83
|
+
Helpers to manage SEO, images, video and Structured Text coming from your DatoCMS projects:
|
|
62
84
|
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
85
|
+
- [**React Components**](https://github.com/datocms/react-datocms)
|
|
86
|
+
- [**Vue Components**](https://github.com/datocms/vue-datocms)
|
|
87
|
+
- [**Svelte Components**](https://github.com/datocms/datocms-svelte)
|
|
88
|
+
- [**Astro Components**](https://github.com/datocms/astro-datocms)
|
|
67
89
|
|
|
68
|
-
**
|
|
69
|
-
- [datocms/react-datocms](https://github.com/datocms/react-datocms): React helper components for images, Structured Text rendering, and more
|
|
70
|
-
- [datocms/js-rest-api-clients](https://github.com/datocms/js-rest-api-clients): Node and browser JavaScript clients for updating and administering your content. For frontend fetches, we recommend using our [GraphQL Content Delivery API](https://www.datocms.com/docs/content-delivery-api) instead.
|
|
71
|
-
- [datocms/cli](https://github.com/datocms/cli): Command-line interface that includes our [Contentful importer](https://github.com/datocms/cli/tree/main/packages/cli-plugin-contentful) and [Wordpress importer](https://github.com/datocms/cli/tree/main/packages/cli-plugin-wordpress)
|
|
72
|
-
- [datocms/plugins](https://github.com/datocms/plugins): Example plugins we've made that extend the editor/admin dashboard
|
|
73
|
-
- [DatoCMS Starters](https://www.datocms.com/marketplace/starters) has examples for various Javascript frontend frameworks
|
|
90
|
+
**Additional Resources:**
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
- [**Plugin Examples**](https://github.com/datocms/plugins) - Example plugins we've made that extend the editor/admin dashboard
|
|
93
|
+
- [**Starter Projects**](https://www.datocms.com/marketplace/starters) - Example website implementations for popular frameworks
|
|
94
|
+
- [**All Public Repositories**](https://github.com/orgs/datocms/repositories?q=&type=public&language=&sort=stargazers)
|
|
76
95
|
|
|
77
96
|
<!--datocms-autoinclude-footer end-->
|
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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|
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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AG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E,MAAM,WAAW,GAAG;QAClB,WAAW,EAAE,GAAG,KAAK,MAAM,MAAM,EAAE;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"}
|
|
@@ -43,7 +43,7 @@ function appendKeyToValidElement(element, key) {
|
|
|
43
43
|
return element;
|
|
44
44
|
}
|
|
45
45
|
exports.appendKeyToValidElement = appendKeyToValidElement;
|
|
46
|
-
function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }) {
|
|
46
|
+
function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderInlineBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }) {
|
|
47
47
|
const result = (0, datocms_structured_text_generic_html_renderer_1.render)(data, {
|
|
48
48
|
adapter: {
|
|
49
49
|
renderText: renderText || exports.defaultAdapter.renderText,
|
|
@@ -101,6 +101,19 @@ function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBl
|
|
|
101
101
|
}
|
|
102
102
|
return appendKeyToValidElement(renderBlock({ record: item }), key);
|
|
103
103
|
}),
|
|
104
|
+
(0, datocms_structured_text_generic_html_renderer_1.renderNodeRule)(datocms_structured_text_utils_1.isInlineBlock, ({ node, key }) => {
|
|
105
|
+
if (!renderInlineBlock) {
|
|
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
|
+
}
|
|
108
|
+
if (!((0, datocms_structured_text_utils_1.isStructuredText)(data) && data.blocks)) {
|
|
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.blocks is not present!`, node);
|
|
110
|
+
}
|
|
111
|
+
const item = data.blocks.find((item) => item.id === node.item);
|
|
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.blocks!`, node);
|
|
114
|
+
}
|
|
115
|
+
return appendKeyToValidElement(renderInlineBlock({ record: item }), key);
|
|
116
|
+
}),
|
|
104
117
|
...(customNodeRules || customRules || []),
|
|
105
118
|
],
|
|
106
119
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAQuD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/StructuredText/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iHAQuD;AAkB9B,+FApBvB,8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E,CAAC,CAAC;YACF,IAAA,8DAAc,EAAC,6CAAa,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC9C,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,MAAM,IAAI,2CAAW,CACnB,4GAA4G,EAC5G,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC,CAAC,IAAA,gDAAgB,EAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,2CAAW,CACnB,iJAAiJ,EACjJ,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE/D,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,2CAAW,CACnB,iGAAiG,IAAI,CAAC,IAAI,sBAAsB,EAChI,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,8DAAG,MAAM,CAAI,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC;AA7JD,wCA6JC"}
|
package/dist/esm/Image/index.js
CHANGED
|
@@ -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,EAAE,EAAE;IAC/D,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,+BAA+B,EAA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,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,OAAO;YAC9B,CAAC,CAAC,EAAE,eAAe,EAAE,MAAA,IAAI,CAAC,OAAO,mCAAI,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE;YACtE,CAAC,CAAC,SAAS,CAAC;IAElB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAEvB,MAAM,MAAM,GACV,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7E,MAAM,WAAW,GAAG;QAClB,WAAW,EAAE,GAAG,KAAK,MAAM,MAAM,EAAE;QACnC,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,GAAG,KAAK,IAAI;QACtB,MAAM,EAAE,MAAM;KACf,CAAC;IAEF,MAAM,qBAAqB,GAAG,QAAQ;QACpC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;QAC7C,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAExB,OAAO,CACL,iCAAS,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY;QACtD,UAAU;QACV,aAAa;QACb,IAAI,CAAC,GAAG,IAAI;QACX,oEAAoE;QACpE,2CACE,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defaultMetaTransformer, render, renderMarkRule, renderNodeRule, } from 'datocms-structured-text-generic-html-renderer';
|
|
2
|
-
import { RenderError, isBlock, isInlineItem, isItemLink, isStructuredText, } from 'datocms-structured-text-utils';
|
|
2
|
+
import { RenderError, isBlock, isInlineBlock, isInlineItem, isItemLink, isStructuredText, } from 'datocms-structured-text-utils';
|
|
3
3
|
import React, { cloneElement, isValidElement } from 'react';
|
|
4
4
|
export { renderNodeRule, renderMarkRule, RenderError };
|
|
5
5
|
// deprecated
|
|
@@ -15,7 +15,7 @@ export function appendKeyToValidElement(element, key) {
|
|
|
15
15
|
}
|
|
16
16
|
return element;
|
|
17
17
|
}
|
|
18
|
-
export function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }) {
|
|
18
|
+
export function StructuredText({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderInlineBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }) {
|
|
19
19
|
const result = render(data, {
|
|
20
20
|
adapter: {
|
|
21
21
|
renderText: renderText || defaultAdapter.renderText,
|
|
@@ -73,6 +73,19 @@ export function StructuredText({ data, renderInlineRecord, renderLinkToRecord, r
|
|
|
73
73
|
}
|
|
74
74
|
return appendKeyToValidElement(renderBlock({ record: item }), key);
|
|
75
75
|
}),
|
|
76
|
+
renderNodeRule(isInlineBlock, ({ node, key }) => {
|
|
77
|
+
if (!renderInlineBlock) {
|
|
78
|
+
throw new RenderError(`The Structured Text document contains an 'inlineBlock' node, but no 'renderInlineBlock' prop is specified!`, node);
|
|
79
|
+
}
|
|
80
|
+
if (!(isStructuredText(data) && data.blocks)) {
|
|
81
|
+
throw new RenderError(`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.blocks is not present!`, node);
|
|
82
|
+
}
|
|
83
|
+
const item = data.blocks.find((item) => item.id === node.item);
|
|
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.blocks!`, node);
|
|
86
|
+
}
|
|
87
|
+
return appendKeyToValidElement(renderInlineBlock({ record: item }), key);
|
|
88
|
+
}),
|
|
76
89
|
...(customNodeRules || customRules || []),
|
|
77
90
|
],
|
|
78
91
|
});
|
|
@@ -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,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,UAAU,EAAE,KAAK,CAAC,aAAgD;IAClE,cAAc,EAAE,CACd,QAA+B,EAC/B,GAAW,EACI,EAAE,CAAC,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,IAAG,QAAQ,CAAkB;IACzE,UAAU,EAAE,CAAC,IAAY,EAAE,GAAW,EAAiB,EAAE,CAAC,IAAI;CAC/D,CAAC;AAEF,MAAM,UAAU,uBAAuB,CACrC,OAA4B,EAC5B,GAAW;IAEX,IAAI,cAAc,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,YAAY,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;
|
|
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,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AC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;YACrE,CAAC,CAAC;YACF,cAAc,CAAC,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC9C,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBACvB,MAAM,IAAI,WAAW,CACnB,4GAA4G,EAC5G,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,IAAI,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,WAAW,CACnB,iJAAiJ,EACjJ,IAAI,CACL,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE/D,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,WAAW,CACnB,iGAAiG,IAAI,CAAC,IAAI,sBAAsB,EAChI,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;
|
|
@@ -38,6 +38,8 @@ export type StructuredTextPropTypes<R1 extends StructuredTextGraphQlResponseReco
|
|
|
38
38
|
renderLinkToRecord?: (context: RenderRecordLinkContext<R2>) => ReactElement | null;
|
|
39
39
|
/** Fuction that converts a 'block' node into React **/
|
|
40
40
|
renderBlock?: (context: RenderBlockContext<R1>) => ReactElement | null;
|
|
41
|
+
/** Fuction that converts an 'inlineBlock' node into React **/
|
|
42
|
+
renderInlineBlock?: (context: RenderBlockContext<R1>) => ReactElement | null;
|
|
41
43
|
/** Function that converts 'link' and 'itemLink' `meta` into HTML props */
|
|
42
44
|
metaTransformer?: TransformMetaFn;
|
|
43
45
|
/** Fuction that converts a simple string text into React **/
|
|
@@ -49,4 +51,4 @@ export type StructuredTextPropTypes<R1 extends StructuredTextGraphQlResponseReco
|
|
|
49
51
|
/** @deprecated use customNodeRules **/
|
|
50
52
|
customRules?: RenderRule<H, T, F>[];
|
|
51
53
|
};
|
|
52
|
-
export declare function StructuredText<R1 extends StructuredTextGraphQlResponseRecord, R2 extends StructuredTextGraphQlResponseRecord = R1>({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }: StructuredTextPropTypes<R1, R2>): ReactElement | null;
|
|
54
|
+
export declare function StructuredText<R1 extends StructuredTextGraphQlResponseRecord, R2 extends StructuredTextGraphQlResponseRecord = R1>({ data, renderInlineRecord, renderLinkToRecord, renderBlock, renderInlineBlock, renderText, renderNode, renderFragment, customMarkRules, customRules, customNodeRules, metaTransformer, }: StructuredTextPropTypes<R1, R2>): ReactElement | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-datocms",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.2.1",
|
|
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": "^4.
|
|
139
|
-
"datocms-structured-text-utils": "^4.
|
|
138
|
+
"datocms-structured-text-generic-html-renderer": "^4.1.2",
|
|
139
|
+
"datocms-structured-text-utils": "^4.1.2",
|
|
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>
|
|
@@ -224,6 +224,11 @@ exports[`StructuredText with links/blocks with default rules renders the documen
|
|
|
224
224
|
"id": "456",
|
|
225
225
|
"quote": "Foo bar.",
|
|
226
226
|
},
|
|
227
|
+
{
|
|
228
|
+
"__typename": "MentionRecord",
|
|
229
|
+
"id": "789",
|
|
230
|
+
"name": "Jane Doe",
|
|
231
|
+
},
|
|
227
232
|
],
|
|
228
233
|
"links": [
|
|
229
234
|
{
|
|
@@ -269,6 +274,10 @@ exports[`StructuredText with links/blocks with default rules renders the documen
|
|
|
269
274
|
],
|
|
270
275
|
"type": "itemLink",
|
|
271
276
|
},
|
|
277
|
+
{
|
|
278
|
+
"item": "789",
|
|
279
|
+
"type": "inlineBlock",
|
|
280
|
+
},
|
|
272
281
|
],
|
|
273
282
|
"level": 1,
|
|
274
283
|
"type": "heading",
|
|
@@ -285,6 +294,7 @@ exports[`StructuredText with links/blocks with default rules renders the documen
|
|
|
285
294
|
}
|
|
286
295
|
}
|
|
287
296
|
renderBlock={[Function]}
|
|
297
|
+
renderInlineBlock={[Function]}
|
|
288
298
|
renderInlineRecord={[Function]}
|
|
289
299
|
renderLinkToRecord={[Function]}
|
|
290
300
|
>
|
|
@@ -310,6 +320,11 @@ exports[`StructuredText with links/blocks with default rules renders the documen
|
|
|
310
320
|
>
|
|
311
321
|
here!
|
|
312
322
|
</a>
|
|
323
|
+
<em
|
|
324
|
+
key="t-4"
|
|
325
|
+
>
|
|
326
|
+
Jane Doe
|
|
327
|
+
</em>
|
|
313
328
|
</h1>
|
|
314
329
|
<figure
|
|
315
330
|
key="t-1"
|
|
@@ -136,6 +136,12 @@ describe('StructuredText', () => {
|
|
|
136
136
|
author: string;
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
+
type MentionRecord = {
|
|
140
|
+
id: string;
|
|
141
|
+
__typename: 'MentionRecord';
|
|
142
|
+
name: string;
|
|
143
|
+
};
|
|
144
|
+
|
|
139
145
|
type DocPageRecord = {
|
|
140
146
|
id: string;
|
|
141
147
|
__typename: 'DocPageRecord';
|
|
@@ -144,7 +150,7 @@ describe('StructuredText', () => {
|
|
|
144
150
|
};
|
|
145
151
|
|
|
146
152
|
const structuredText: StructuredTextGraphQlResponse<
|
|
147
|
-
QuoteRecord,
|
|
153
|
+
QuoteRecord | MentionRecord,
|
|
148
154
|
DocPageRecord
|
|
149
155
|
> = {
|
|
150
156
|
value: {
|
|
@@ -175,6 +181,10 @@ describe('StructuredText', () => {
|
|
|
175
181
|
meta: [{ id: 'target', value: '_blank' }],
|
|
176
182
|
children: [{ type: 'span', value: 'here!' }],
|
|
177
183
|
},
|
|
184
|
+
{
|
|
185
|
+
type: 'inlineBlock',
|
|
186
|
+
item: '789',
|
|
187
|
+
},
|
|
178
188
|
],
|
|
179
189
|
},
|
|
180
190
|
{
|
|
@@ -191,6 +201,11 @@ describe('StructuredText', () => {
|
|
|
191
201
|
quote: 'Foo bar.',
|
|
192
202
|
author: 'Mark Smith',
|
|
193
203
|
},
|
|
204
|
+
{
|
|
205
|
+
id: '789',
|
|
206
|
+
__typename: 'MentionRecord',
|
|
207
|
+
name: 'Jane Doe',
|
|
208
|
+
},
|
|
194
209
|
],
|
|
195
210
|
links: [
|
|
196
211
|
{
|
|
@@ -240,6 +255,14 @@ describe('StructuredText', () => {
|
|
|
240
255
|
return null;
|
|
241
256
|
}
|
|
242
257
|
}}
|
|
258
|
+
renderInlineBlock={({ record }) => {
|
|
259
|
+
switch (record.__typename) {
|
|
260
|
+
case 'MentionRecord':
|
|
261
|
+
return <em>{record.name}</em>;
|
|
262
|
+
default:
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
}}
|
|
243
266
|
/>,
|
|
244
267
|
);
|
|
245
268
|
expect(wrapper).toMatchSnapshot();
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type Record as StructuredTextGraphQlResponseRecord,
|
|
18
18
|
type TypesafeStructuredText as TypesafeStructuredTextGraphQlResponse,
|
|
19
19
|
isBlock,
|
|
20
|
+
isInlineBlock,
|
|
20
21
|
isInlineItem,
|
|
21
22
|
isItemLink,
|
|
22
23
|
isStructuredText,
|
|
@@ -104,6 +105,8 @@ export type StructuredTextPropTypes<
|
|
|
104
105
|
) => ReactElement | null;
|
|
105
106
|
/** Fuction that converts a 'block' node into React **/
|
|
106
107
|
renderBlock?: (context: RenderBlockContext<R1>) => ReactElement | null;
|
|
108
|
+
/** Fuction that converts an 'inlineBlock' node into React **/
|
|
109
|
+
renderInlineBlock?: (context: RenderBlockContext<R1>) => ReactElement | null;
|
|
107
110
|
/** Function that converts 'link' and 'itemLink' `meta` into HTML props */
|
|
108
111
|
metaTransformer?: TransformMetaFn;
|
|
109
112
|
/** Fuction that converts a simple string text into React **/
|
|
@@ -124,6 +127,7 @@ export function StructuredText<
|
|
|
124
127
|
renderInlineRecord,
|
|
125
128
|
renderLinkToRecord,
|
|
126
129
|
renderBlock,
|
|
130
|
+
renderInlineBlock,
|
|
127
131
|
renderText,
|
|
128
132
|
renderNode,
|
|
129
133
|
renderFragment,
|
|
@@ -234,6 +238,35 @@ export function StructuredText<
|
|
|
234
238
|
|
|
235
239
|
return appendKeyToValidElement(renderBlock({ record: item }), key);
|
|
236
240
|
}),
|
|
241
|
+
renderNodeRule(isInlineBlock, ({ node, key }) => {
|
|
242
|
+
if (!renderInlineBlock) {
|
|
243
|
+
throw new RenderError(
|
|
244
|
+
`The Structured Text document contains an 'inlineBlock' node, but no 'renderInlineBlock' prop is specified!`,
|
|
245
|
+
node,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (!(isStructuredText(data) && data.blocks)) {
|
|
250
|
+
throw new RenderError(
|
|
251
|
+
`The document contains an 'inlineBlock' node, but the passed data prop is not a Structured Text GraphQL response, or data.blocks is not present!`,
|
|
252
|
+
node,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const item = data.blocks.find((item) => item.id === node.item);
|
|
257
|
+
|
|
258
|
+
if (!item) {
|
|
259
|
+
throw new RenderError(
|
|
260
|
+
`The Structured Text document contains an 'inlineBlock' node, but cannot find a record with ID ${node.item} inside data.blocks!`,
|
|
261
|
+
node,
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return appendKeyToValidElement(
|
|
266
|
+
renderInlineBlock({ record: item }),
|
|
267
|
+
key,
|
|
268
|
+
);
|
|
269
|
+
}),
|
|
237
270
|
...(customNodeRules || customRules || []),
|
|
238
271
|
],
|
|
239
272
|
});
|