@contentful/experiences-core 1.27.0-prerelease-20241213T0010-0475c78.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -21
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2024,31 +2024,21 @@ const transformRichText = (entryOrAsset, entityStore, path) => {
|
|
|
2024
2024
|
};
|
|
2025
2025
|
}
|
|
2026
2026
|
if (typeof value === 'object' && value.nodeType === BLOCKS.DOCUMENT) {
|
|
2027
|
-
//
|
|
2027
|
+
//resolve any embedded links - we currently only support resolving embedded in the first entry
|
|
2028
2028
|
const richTextDocument = value;
|
|
2029
|
-
|
|
2030
|
-
|
|
2029
|
+
richTextDocument.content.forEach((node) => {
|
|
2030
|
+
if ((node.nodeType === BLOCKS.EMBEDDED_ENTRY || node.nodeType === BLOCKS.EMBEDDED_ASSET) &&
|
|
2031
|
+
node.data.target.sys.type === 'Link') {
|
|
2032
|
+
const entity = entityStore.getEntityFromLink(node.data.target);
|
|
2033
|
+
if (entity) {
|
|
2034
|
+
node.data.target = entity;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
return value;
|
|
2031
2039
|
}
|
|
2032
2040
|
return undefined;
|
|
2033
2041
|
};
|
|
2034
|
-
const isLinkTarget = (node) => {
|
|
2035
|
-
return node?.data?.target?.sys?.type === 'Link';
|
|
2036
|
-
};
|
|
2037
|
-
const resolveLinks = (node, entityStore) => {
|
|
2038
|
-
if (!node)
|
|
2039
|
-
return;
|
|
2040
|
-
// Resolve link if current node has one
|
|
2041
|
-
if (isLinkTarget(node)) {
|
|
2042
|
-
const entity = entityStore.getEntityFromLink(node.data.target);
|
|
2043
|
-
if (entity) {
|
|
2044
|
-
node.data.target = entity;
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
// Process content array if it exists
|
|
2048
|
-
if ('content' in node && Array.isArray(node.content)) {
|
|
2049
|
-
node.content.forEach((childNode) => resolveLinks(childNode, entityStore));
|
|
2050
|
-
}
|
|
2051
|
-
};
|
|
2052
2042
|
|
|
2053
2043
|
function getOptimizedImageUrl(url, width, quality, format) {
|
|
2054
2044
|
if (url.startsWith('//')) {
|