@contentful/experiences-core 1.28.0-dev-20250103T2247-b6bc301.0 → 1.28.0-dev-20250108T2237-ba7ba90.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 +21 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2027,21 +2027,31 @@ const transformRichText = (entryOrAsset, entityStore, path) => {
|
|
|
2027
2027
|
};
|
|
2028
2028
|
}
|
|
2029
2029
|
if (typeof value === 'object' && value.nodeType === BLOCKS.DOCUMENT) {
|
|
2030
|
-
//resolve any
|
|
2030
|
+
// resolve any links to assets/entries/hyperlinks
|
|
2031
2031
|
const richTextDocument = value;
|
|
2032
|
-
richTextDocument
|
|
2033
|
-
|
|
2034
|
-
node.data.target.sys.type === 'Link') {
|
|
2035
|
-
const entity = entityStore.getEntityFromLink(node.data.target);
|
|
2036
|
-
if (entity) {
|
|
2037
|
-
node.data.target = entity;
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
});
|
|
2041
|
-
return value;
|
|
2032
|
+
resolveLinks(richTextDocument, entityStore);
|
|
2033
|
+
return richTextDocument;
|
|
2042
2034
|
}
|
|
2043
2035
|
return undefined;
|
|
2044
2036
|
};
|
|
2037
|
+
const isLinkTarget = (node) => {
|
|
2038
|
+
return node?.data?.target?.sys?.type === 'Link';
|
|
2039
|
+
};
|
|
2040
|
+
const resolveLinks = (node, entityStore) => {
|
|
2041
|
+
if (!node)
|
|
2042
|
+
return;
|
|
2043
|
+
// Resolve link if current node has one
|
|
2044
|
+
if (isLinkTarget(node)) {
|
|
2045
|
+
const entity = entityStore.getEntityFromLink(node.data.target);
|
|
2046
|
+
if (entity) {
|
|
2047
|
+
node.data.target = entity;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
// Process content array if it exists
|
|
2051
|
+
if ('content' in node && Array.isArray(node.content)) {
|
|
2052
|
+
node.content.forEach((childNode) => resolveLinks(childNode, entityStore));
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2045
2055
|
|
|
2046
2056
|
function getOptimizedImageUrl(url, width, quality, format) {
|
|
2047
2057
|
if (url.startsWith('//')) {
|