@contentful/experiences-visual-editor-react 1.0.3 → 1.0.4-beta.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 -2
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +21 -2
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -38428,6 +38428,11 @@ const getOptimizedImageAsset = (file, sizes, quality = '100%', format) => {
|
|
|
38428
38428
|
|
|
38429
38429
|
const transformMedia = (asset, variables, resolveDesignValue, variableName, path) => {
|
|
38430
38430
|
let value;
|
|
38431
|
+
// If it is not a deep path and not pointing to the file of the asset,
|
|
38432
|
+
// it is just pointing to a normal field and therefore we just resolve the value as normal field
|
|
38433
|
+
if (!isDeepPath(path) && !lastPathNamedSegmentEq(path, 'file')) {
|
|
38434
|
+
return getBoundValue(asset, path);
|
|
38435
|
+
}
|
|
38431
38436
|
//TODO: this will be better served by injectable type transformers instead of if statement
|
|
38432
38437
|
if (variableName === 'cfImageAsset') {
|
|
38433
38438
|
const optionsVariableName = 'cfImageOptions';
|
|
@@ -38466,8 +38471,7 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
38466
38471
|
}
|
|
38467
38472
|
return;
|
|
38468
38473
|
}
|
|
38469
|
-
|
|
38470
|
-
return getBoundValue(asset, path);
|
|
38474
|
+
return asset.fields.file?.url;
|
|
38471
38475
|
};
|
|
38472
38476
|
|
|
38473
38477
|
const transformBoundContentValue = (variables, entityStore, binding, resolveDesignValue, variableName, variableDefinition, path) => {
|
|
@@ -38476,6 +38480,10 @@ const transformBoundContentValue = (variables, entityStore, binding, resolveDesi
|
|
|
38476
38480
|
return;
|
|
38477
38481
|
switch (variableDefinition.type) {
|
|
38478
38482
|
case 'Media':
|
|
38483
|
+
// If we bound a normal entry field to the media veriable we just return the bound value
|
|
38484
|
+
if (entityOrAsset.sys.type === 'Entry') {
|
|
38485
|
+
return getBoundValue(entityOrAsset, path);
|
|
38486
|
+
}
|
|
38479
38487
|
return transformMedia(entityOrAsset, variables, resolveDesignValue, variableName, path);
|
|
38480
38488
|
case 'RichText':
|
|
38481
38489
|
return transformRichText(entityOrAsset, path);
|
|
@@ -39073,6 +39081,17 @@ const chunkSegments = (segments, { startNextChunkOnElementEqualTo }) => {
|
|
|
39073
39081
|
chunks.push(currentChunk);
|
|
39074
39082
|
return chunks.filter(excludeEmptyChunks);
|
|
39075
39083
|
};
|
|
39084
|
+
const lastPathNamedSegmentEq = (path, expectedName) => {
|
|
39085
|
+
// `/key123/fields/featureImage/~locale/fields/file/~locale`
|
|
39086
|
+
// ['', 'key123', 'fields', 'featureImage', '~locale', 'fields', 'file', '~locale']
|
|
39087
|
+
const segments = path.split('/');
|
|
39088
|
+
if (segments.length < 2) {
|
|
39089
|
+
console.warn(`[experiences-sdk-react] Attempting to check whether last named segment of the path (${path}) equals to '${expectedName}', but the path doesn't have enough segments.`);
|
|
39090
|
+
return false;
|
|
39091
|
+
}
|
|
39092
|
+
const secondLast = segments[segments.length - 2]; // skipping trailing '~locale'
|
|
39093
|
+
return secondLast === expectedName;
|
|
39094
|
+
};
|
|
39076
39095
|
|
|
39077
39096
|
const sendMessage = (eventType, data) => {
|
|
39078
39097
|
if (typeof window === 'undefined') {
|