@contentful/experiences-visual-editor-react 3.3.1-dev-20250825T0658-5f2fae7.0 → 3.3.1-dev-20250825T1222-bc8206a.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 +34 -12
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +34 -12
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -45615,6 +45615,27 @@ const tryParseMessage = (event) => {
|
|
|
45615
45615
|
return eventData;
|
|
45616
45616
|
};
|
|
45617
45617
|
|
|
45618
|
+
const splitDirectAndSlotChildren = (allChildNodes, componentDefinition) => {
|
|
45619
|
+
// Bridge difference between editor and delivery mode
|
|
45620
|
+
const getSlotId = (child) => {
|
|
45621
|
+
if ('data' in child)
|
|
45622
|
+
return child.data.slotId;
|
|
45623
|
+
return child.slotId;
|
|
45624
|
+
};
|
|
45625
|
+
const slotNodesMap = {};
|
|
45626
|
+
for (const slotId in componentDefinition.slots) {
|
|
45627
|
+
// We only allow one component per slot (container). This is just safer to not render components twice or not at all
|
|
45628
|
+
const nodes = allChildNodes.filter((child) => getSlotId(child) === slotId);
|
|
45629
|
+
slotNodesMap[slotId] = nodes.length ? nodes : null;
|
|
45630
|
+
}
|
|
45631
|
+
const directChildNodes = allChildNodes.filter((child) => getSlotId(child) === undefined);
|
|
45632
|
+
if (!componentDefinition.children || !directChildNodes.length) {
|
|
45633
|
+
// If there are no children allowed in the component or no children added, render as undefined
|
|
45634
|
+
return { slotNodesMap, directChildNodes: undefined };
|
|
45635
|
+
}
|
|
45636
|
+
return { slotNodesMap, directChildNodes };
|
|
45637
|
+
};
|
|
45638
|
+
|
|
45618
45639
|
const sendMessage = (eventType, data) => {
|
|
45619
45640
|
if (typeof window === 'undefined') {
|
|
45620
45641
|
return;
|
|
@@ -50301,18 +50322,19 @@ function EditorBlock({ node, resolveDesignValue, wrappingPatternIds: parentWrapp
|
|
|
50301
50322
|
if (isRootAssemblyNode && node.data.blockId && parentWrappingPatternIds.has(node.data.blockId)) {
|
|
50302
50323
|
return React$1.createElement(CircularDependencyErrorPlaceholder, { wrappingPatternIds: wrappingPatternIds });
|
|
50303
50324
|
}
|
|
50304
|
-
const
|
|
50305
|
-
|
|
50306
|
-
|
|
50307
|
-
|
|
50308
|
-
|
|
50309
|
-
|
|
50310
|
-
|
|
50311
|
-
|
|
50312
|
-
|
|
50313
|
-
|
|
50314
|
-
|
|
50315
|
-
|
|
50325
|
+
const { slotNodesMap, directChildNodes } = splitDirectAndSlotChildren(node.children, componentRegistration.definition);
|
|
50326
|
+
const renderChildNode = (childNode) => (React$1.createElement(EditorBlock, { key: childNode.data.id, node: childNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }));
|
|
50327
|
+
const renderedSlotNodesMap = Object.entries(slotNodesMap).reduce((acc, [slotId, nodes]) => {
|
|
50328
|
+
if (nodes?.length) {
|
|
50329
|
+
acc[slotId] = React$1.createElement(React$1.Fragment, null, nodes.map((slotChildNode) => renderChildNode(slotChildNode)));
|
|
50330
|
+
}
|
|
50331
|
+
else {
|
|
50332
|
+
acc[slotId] = React$1.createElement("div", { className: styles$1.emptySlot });
|
|
50333
|
+
}
|
|
50334
|
+
return acc;
|
|
50335
|
+
}, {});
|
|
50336
|
+
const renderedChildren = directChildNodes?.map((childNode) => renderChildNode(childNode));
|
|
50337
|
+
return (React$1.createElement(RegistrationComponent, { node: node, resolveDesignValue: resolveDesignValue, componentRegistration: componentRegistration, slotNodes: renderedSlotNodesMap, entityStore: entityStore, areEntitiesFetched: areEntitiesFetched }, renderedChildren));
|
|
50316
50338
|
}
|
|
50317
50339
|
const RegistrationComponent = ({ node, resolveDesignValue, componentRegistration, slotNodes, children, entityStore, areEntitiesFetched, }) => {
|
|
50318
50340
|
const { componentProps } = useComponentProps({
|