@contentful/experiences-visual-editor-react 3.3.1-dev-20250825T0713-34ae1b3.0 → 3.4.0-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 +66 -15
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +66 -15
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -44475,6 +44475,18 @@ var CodeNames$1;
|
|
|
44475
44475
|
CodeNames["Custom"] = "custom";
|
|
44476
44476
|
})(CodeNames$1 || (CodeNames$1 = {}));
|
|
44477
44477
|
|
|
44478
|
+
const sdkOptionsRegistry = {};
|
|
44479
|
+
/**
|
|
44480
|
+
* Used inside defineComponents to forward registry arguments to this registry
|
|
44481
|
+
* of SDK options.
|
|
44482
|
+
*/
|
|
44483
|
+
const defineSdkOptions = (options) => {
|
|
44484
|
+
Object.assign(sdkOptionsRegistry, options);
|
|
44485
|
+
};
|
|
44486
|
+
const getSdkOptions = () => {
|
|
44487
|
+
return { ...sdkOptionsRegistry };
|
|
44488
|
+
};
|
|
44489
|
+
|
|
44478
44490
|
const MEDIA_QUERY_REGEXP = /(<|>)(\d{1,})(px|cm|mm|in|pt|pc)$/;
|
|
44479
44491
|
const toCSSMediaQuery = ({ query }) => {
|
|
44480
44492
|
if (query === '*')
|
|
@@ -45059,6 +45071,20 @@ const transformBackgroundImage = (cfBackgroundImageUrl, cfBackgroundImageOptions
|
|
|
45059
45071
|
backgroundSize: matchBackgroundSize(cfBackgroundImageOptions?.scaling),
|
|
45060
45072
|
};
|
|
45061
45073
|
};
|
|
45074
|
+
const transformTextAlign = (value) => {
|
|
45075
|
+
if (!value)
|
|
45076
|
+
return undefined;
|
|
45077
|
+
const sdkOptions = getSdkOptions();
|
|
45078
|
+
// New behavior: translate left/right to start/end
|
|
45079
|
+
// Customer can opt-out by activating this global option toggle
|
|
45080
|
+
if (!sdkOptions.__disableTextAlignmentTransform) {
|
|
45081
|
+
if (value === 'left')
|
|
45082
|
+
return 'start';
|
|
45083
|
+
if (value === 'right')
|
|
45084
|
+
return 'end';
|
|
45085
|
+
}
|
|
45086
|
+
return value;
|
|
45087
|
+
};
|
|
45062
45088
|
|
|
45063
45089
|
const toCSSAttribute = (key) => {
|
|
45064
45090
|
let val = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
@@ -45136,7 +45162,7 @@ const buildCfStyles = (values) => {
|
|
|
45136
45162
|
lineHeight: values.cfLineHeight,
|
|
45137
45163
|
letterSpacing: values.cfLetterSpacing,
|
|
45138
45164
|
color: values.cfTextColor,
|
|
45139
|
-
textAlign: values.cfTextAlign,
|
|
45165
|
+
textAlign: transformTextAlign(values.cfTextAlign),
|
|
45140
45166
|
textTransform: values.cfTextTransform,
|
|
45141
45167
|
objectFit: values.cfImageOptions?.objectFit,
|
|
45142
45168
|
objectPosition: values.cfImageOptions?.objectPosition,
|
|
@@ -45615,6 +45641,27 @@ const tryParseMessage = (event) => {
|
|
|
45615
45641
|
return eventData;
|
|
45616
45642
|
};
|
|
45617
45643
|
|
|
45644
|
+
const splitDirectAndSlotChildren = (allChildNodes, componentDefinition) => {
|
|
45645
|
+
// Bridge difference between editor and delivery mode
|
|
45646
|
+
const getSlotId = (child) => {
|
|
45647
|
+
if ('data' in child)
|
|
45648
|
+
return child.data.slotId;
|
|
45649
|
+
return child.slotId;
|
|
45650
|
+
};
|
|
45651
|
+
const slotNodesMap = {};
|
|
45652
|
+
for (const slotId in componentDefinition.slots) {
|
|
45653
|
+
// We only allow one component per slot (container). This is just safer to not render components twice or not at all
|
|
45654
|
+
const nodes = allChildNodes.filter((child) => getSlotId(child) === slotId);
|
|
45655
|
+
slotNodesMap[slotId] = nodes.length ? nodes : null;
|
|
45656
|
+
}
|
|
45657
|
+
const directChildNodes = allChildNodes.filter((child) => getSlotId(child) === undefined);
|
|
45658
|
+
if (!componentDefinition.children || !directChildNodes.length) {
|
|
45659
|
+
// If there are no children allowed in the component or no children added, render as undefined
|
|
45660
|
+
return { slotNodesMap, directChildNodes: undefined };
|
|
45661
|
+
}
|
|
45662
|
+
return { slotNodesMap, directChildNodes };
|
|
45663
|
+
};
|
|
45664
|
+
|
|
45618
45665
|
const sendMessage = (eventType, data) => {
|
|
45619
45666
|
if (typeof window === 'undefined') {
|
|
45620
45667
|
return;
|
|
@@ -47389,12 +47436,14 @@ const useEditorStore = create((set, get) => ({
|
|
|
47389
47436
|
}
|
|
47390
47437
|
set({ locale });
|
|
47391
47438
|
},
|
|
47392
|
-
initializeEditor({ componentRegistry: initialRegistry, designTokens, initialLocale }) {
|
|
47439
|
+
initializeEditor({ componentRegistry: initialRegistry, designTokens, sdkOptions, initialLocale, }) {
|
|
47393
47440
|
initialRegistry.forEach((registration) => {
|
|
47394
47441
|
componentRegistry.set(registration.definition.id, registration);
|
|
47395
47442
|
});
|
|
47396
47443
|
// Re-register the design tokens with the Visual Editor's instance of the experiences-core package
|
|
47397
47444
|
defineDesignTokens(designTokens);
|
|
47445
|
+
// Same copy over from one instance to the other is necessary for the sdk options
|
|
47446
|
+
defineSdkOptions(sdkOptions);
|
|
47398
47447
|
set({ locale: initialLocale });
|
|
47399
47448
|
},
|
|
47400
47449
|
}));
|
|
@@ -50301,18 +50350,19 @@ function EditorBlock({ node, resolveDesignValue, wrappingPatternIds: parentWrapp
|
|
|
50301
50350
|
if (isRootAssemblyNode && node.data.blockId && parentWrappingPatternIds.has(node.data.blockId)) {
|
|
50302
50351
|
return React$1.createElement(CircularDependencyErrorPlaceholder, { wrappingPatternIds: wrappingPatternIds });
|
|
50303
50352
|
}
|
|
50304
|
-
const
|
|
50305
|
-
|
|
50306
|
-
|
|
50307
|
-
|
|
50308
|
-
|
|
50309
|
-
|
|
50310
|
-
|
|
50311
|
-
|
|
50312
|
-
|
|
50313
|
-
|
|
50314
|
-
|
|
50315
|
-
|
|
50353
|
+
const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(node.children, componentRegistration.definition);
|
|
50354
|
+
const renderChildNode = (childNode) => (React$1.createElement(EditorBlock, { key: childNode.data.id, node: childNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }));
|
|
50355
|
+
const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce((acc, [slotId, nodes]) => {
|
|
50356
|
+
if (nodes?.length) {
|
|
50357
|
+
acc[slotId] = React$1.createElement(React$1.Fragment, null, nodes.map((slotChildNode) => renderChildNode(slotChildNode)));
|
|
50358
|
+
}
|
|
50359
|
+
else {
|
|
50360
|
+
acc[slotId] = React$1.createElement("div", { className: styles$1.emptySlot });
|
|
50361
|
+
}
|
|
50362
|
+
return acc;
|
|
50363
|
+
}, {});
|
|
50364
|
+
const renderedChildren = directChildNodes?.map((childNode) => renderChildNode(childNode));
|
|
50365
|
+
return (React$1.createElement(RegistrationComponent, { node: node, resolveDesignValue: resolveDesignValue, componentRegistration: componentRegistration, slotNodes: renderedSlotNodesMap, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }, renderedChildren));
|
|
50316
50366
|
}
|
|
50317
50367
|
const RegistrationComponent = ({ node, resolveDesignValue, componentRegistration, slotNodes, children, entityStore, areEntitiesFetched, }) => {
|
|
50318
50368
|
const { componentProps } = useComponentProps({
|
|
@@ -50545,11 +50595,12 @@ const useInitializeEditor = (inMemoryEntitiesStore) => {
|
|
|
50545
50595
|
const onVisualEditorInitialize = (event) => {
|
|
50546
50596
|
if (!event.detail)
|
|
50547
50597
|
return;
|
|
50548
|
-
const { componentRegistry, designTokens, locale: initialLocale, entities } = event.detail;
|
|
50598
|
+
const { componentRegistry, designTokens, sdkOptions, locale: initialLocale, entities, } = event.detail;
|
|
50549
50599
|
initializeEditor({
|
|
50550
50600
|
initialLocale,
|
|
50551
50601
|
componentRegistry,
|
|
50552
50602
|
designTokens,
|
|
50603
|
+
sdkOptions,
|
|
50553
50604
|
});
|
|
50554
50605
|
// if entities is set to [], then everything will still work as EntityStore will
|
|
50555
50606
|
// request entities on demand via ▲REQUEST_ENTITY
|