@contentful/experiences-visual-editor-react 1.41.0-beta.0 → 1.41.0-dev-20250612T0852-ddef0ff.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 +25 -39
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +25 -39
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1842,43 +1842,20 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1842
1842
|
return asset.fields.file?.url;
|
|
1843
1843
|
};
|
|
1844
1844
|
|
|
1845
|
-
const isAsset = (value) => {
|
|
1846
|
-
return (null !== value &&
|
|
1847
|
-
typeof value === 'object' &&
|
|
1848
|
-
'sys' in value &&
|
|
1849
|
-
value.sys?.type === 'Asset');
|
|
1850
|
-
};
|
|
1851
|
-
const isEntry = (value) => {
|
|
1852
|
-
return (null !== value &&
|
|
1853
|
-
typeof value === 'object' &&
|
|
1854
|
-
'sys' in value &&
|
|
1855
|
-
value.sys?.type === 'Entry');
|
|
1856
|
-
};
|
|
1857
|
-
|
|
1858
1845
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
1859
|
-
if (
|
|
1846
|
+
if (entryOrAsset.sys.type === 'Asset') {
|
|
1860
1847
|
return entryOrAsset;
|
|
1861
1848
|
}
|
|
1862
|
-
else if (!isEntry(entryOrAsset)) {
|
|
1863
|
-
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
1864
|
-
}
|
|
1865
1849
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
1866
|
-
|
|
1867
|
-
if (isAsset(value) || isEntry(value)) {
|
|
1868
|
-
// In some cases, reference fields are already resolved
|
|
1869
|
-
resolvedEntity = value;
|
|
1870
|
-
}
|
|
1871
|
-
else if (value?.sys.type === 'Link') {
|
|
1872
|
-
// Look up the reference in the entity store
|
|
1873
|
-
resolvedEntity = entityStore.getEntityFromLink(value);
|
|
1874
|
-
if (!resolvedEntity) {
|
|
1875
|
-
return;
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
else {
|
|
1850
|
+
if (value?.sys.type !== 'Link') {
|
|
1879
1851
|
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
1880
1852
|
return;
|
|
1881
1853
|
}
|
|
1854
|
+
//Look up the reference in the entity store
|
|
1855
|
+
const resolvedEntity = entityStore.getEntityFromLink(value);
|
|
1856
|
+
if (!resolvedEntity) {
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1882
1859
|
//resolve any embedded links - we currently only support 2 levels deep
|
|
1883
1860
|
const fields = resolvedEntity.fields || {};
|
|
1884
1861
|
Object.entries(fields).forEach(([fieldKey, field]) => {
|
|
@@ -2131,13 +2108,10 @@ class EntityStoreBase {
|
|
|
2131
2108
|
}
|
|
2132
2109
|
entity = resolvedEntity;
|
|
2133
2110
|
}
|
|
2134
|
-
else
|
|
2111
|
+
else {
|
|
2135
2112
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
2136
2113
|
entity = linkOrEntryOrAsset;
|
|
2137
2114
|
}
|
|
2138
|
-
else {
|
|
2139
|
-
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
2140
|
-
}
|
|
2141
2115
|
return entity;
|
|
2142
2116
|
}
|
|
2143
2117
|
/**
|
|
@@ -2183,14 +2157,14 @@ class EntityStoreBase {
|
|
|
2183
2157
|
};
|
|
2184
2158
|
}
|
|
2185
2159
|
addEntity(entity) {
|
|
2186
|
-
if (isAsset(entity)) {
|
|
2160
|
+
if (this.isAsset(entity)) {
|
|
2187
2161
|
this.assetMap.set(entity.sys.id, entity);
|
|
2188
2162
|
}
|
|
2189
|
-
else if (isEntry(entity)) {
|
|
2163
|
+
else if (this.isEntry(entity)) {
|
|
2190
2164
|
this.entryMap.set(entity.sys.id, entity);
|
|
2191
2165
|
}
|
|
2192
2166
|
else {
|
|
2193
|
-
|
|
2167
|
+
console.warn('Attempted to add an entity that is neither Asset nor Entry:', entity);
|
|
2194
2168
|
}
|
|
2195
2169
|
}
|
|
2196
2170
|
async fetchAsset(id) {
|
|
@@ -2260,7 +2234,7 @@ class EntityStoreBase {
|
|
|
2260
2234
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
2261
2235
|
entityToResolveFieldsFrom = entity; // we move up
|
|
2262
2236
|
}
|
|
2263
|
-
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
2237
|
+
else if (this.isAsset(fieldValue) || this.isEntry(fieldValue)) {
|
|
2264
2238
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
2265
2239
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
2266
2240
|
}
|
|
@@ -2296,6 +2270,18 @@ class EntityStoreBase {
|
|
|
2296
2270
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
2297
2271
|
return leafEntity;
|
|
2298
2272
|
}
|
|
2273
|
+
isAsset(value) {
|
|
2274
|
+
return (null !== value &&
|
|
2275
|
+
typeof value === 'object' &&
|
|
2276
|
+
'sys' in value &&
|
|
2277
|
+
value.sys?.type === 'Asset');
|
|
2278
|
+
}
|
|
2279
|
+
isEntry(value) {
|
|
2280
|
+
return (null !== value &&
|
|
2281
|
+
typeof value === 'object' &&
|
|
2282
|
+
'sys' in value &&
|
|
2283
|
+
value.sys?.type === 'Entry');
|
|
2284
|
+
}
|
|
2299
2285
|
getEntity(type, id) {
|
|
2300
2286
|
if (type === 'Asset') {
|
|
2301
2287
|
return this.assetMap.get(id);
|
|
@@ -5521,7 +5507,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5521
5507
|
return false;
|
|
5522
5508
|
}
|
|
5523
5509
|
const { cfWrapColumns } = parentNode.data.props;
|
|
5524
|
-
if (cfWrapColumns
|
|
5510
|
+
if (cfWrapColumns.type !== 'DesignValue') {
|
|
5525
5511
|
return false;
|
|
5526
5512
|
}
|
|
5527
5513
|
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint);
|