@contentful/experiences-visual-editor-react 1.7.2-dev-20240613T0816-4d3b2da.0 → 1.8.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 +59 -16
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +59 -16
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -54815,7 +54815,7 @@ function getStyle$2(style, snapshot) {
|
|
|
54815
54815
|
transitionDuration: `0.001s`,
|
|
54816
54816
|
};
|
|
54817
54817
|
}
|
|
54818
|
-
const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, onMouseOver = () => null, coordinates, userIsDragging, style, wrapperProps, isContainer, blockId, isDragDisabled = false, placeholder,
|
|
54818
|
+
const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, onMouseOver = () => null, coordinates, userIsDragging, style, wrapperProps, isContainer, blockId, isDragDisabled = false, placeholder, displayName, ...rest }) => {
|
|
54819
54819
|
const ref = reactExports.useRef(null);
|
|
54820
54820
|
const setDomRect = useDraggedItemStore((state) => state.setDomRect);
|
|
54821
54821
|
const isHoveredComponent = useDraggedItemStore((state) => state.hoveredComponentId === id);
|
|
@@ -54843,7 +54843,7 @@ const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSe
|
|
|
54843
54843
|
e.stopPropagation();
|
|
54844
54844
|
setDomRect(e.currentTarget.getBoundingClientRect());
|
|
54845
54845
|
}, onMouseOver: onMouseOver, onClick: onClick },
|
|
54846
|
-
React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: displayName ||
|
|
54846
|
+
React.createElement(Tooltip, { id: id, coordinates: coordinates, isAssemblyBlock: isAssemblyBlock, isContainer: isContainer, label: displayName || 'No label specified' }),
|
|
54847
54847
|
React.createElement(Placeholder, { ...placeholder, id: id }),
|
|
54848
54848
|
children))));
|
|
54849
54849
|
};
|
|
@@ -55209,9 +55209,12 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
55209
55209
|
node,
|
|
55210
55210
|
renderDropzone,
|
|
55211
55211
|
...omit$1(props, stylesToRemove, ['cfHyperlink', 'cfOpenInNewTab', 'cfSsrClassName']),
|
|
55212
|
-
...(definition
|
|
55212
|
+
...(definition?.children ? { children: renderDropzone(node) } : {}),
|
|
55213
|
+
};
|
|
55214
|
+
return {
|
|
55215
|
+
componentProps,
|
|
55216
|
+
wrapperProps,
|
|
55213
55217
|
};
|
|
55214
|
-
return { componentProps, wrapperProps };
|
|
55215
55218
|
};
|
|
55216
55219
|
const addExtraDropzonePadding = (padding) => padding
|
|
55217
55220
|
.split(' ')
|
|
@@ -55988,7 +55991,8 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
|
|
|
55988
55991
|
});
|
|
55989
55992
|
}
|
|
55990
55993
|
if (!registration) {
|
|
55991
|
-
|
|
55994
|
+
console.warn(`Component registration not found for component with id: "${node.data.blockId}". The component might of been removed. To proceed, remove the component manually from the layers tab.`);
|
|
55995
|
+
return undefined;
|
|
55992
55996
|
}
|
|
55993
55997
|
return registration;
|
|
55994
55998
|
}, [node]);
|
|
@@ -55998,24 +56002,40 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
|
|
|
55998
56002
|
areEntitiesFetched,
|
|
55999
56003
|
resolveDesignValue,
|
|
56000
56004
|
renderDropzone,
|
|
56001
|
-
definition: componentRegistration
|
|
56005
|
+
definition: componentRegistration?.definition,
|
|
56002
56006
|
userIsDragging,
|
|
56003
56007
|
slotId,
|
|
56004
56008
|
});
|
|
56005
56009
|
// Only pass editor props to built-in components
|
|
56006
56010
|
const { editorMode, renderDropzone: _renderDropzone, ...otherComponentProps } = componentProps;
|
|
56007
|
-
const
|
|
56008
|
-
|
|
56009
|
-
|
|
56010
|
-
|
|
56011
|
-
|
|
56012
|
-
|
|
56011
|
+
const createElementToRender = (componentRegistration) => {
|
|
56012
|
+
if (builtInComponents.includes(node.data.blockId || '')) {
|
|
56013
|
+
// eslint-disable-next-line react/display-name
|
|
56014
|
+
return (dragProps) => React.createElement(componentRegistration.component, {
|
|
56015
|
+
...dragProps,
|
|
56016
|
+
...componentProps,
|
|
56017
|
+
});
|
|
56018
|
+
}
|
|
56019
|
+
if (node.type === ASSEMBLY_NODE_TYPE) {
|
|
56020
|
+
// Assembly.tsx requires renderDropzone and editorMode as well
|
|
56021
|
+
// eslint-disable-next-line react/display-name
|
|
56022
|
+
return () => React.createElement(componentRegistration.component, componentProps);
|
|
56023
|
+
}
|
|
56024
|
+
return function createComponentWrappedInErrorBoundary() {
|
|
56025
|
+
const elementToWrap = React.createElement(componentRegistration.component, otherComponentProps);
|
|
56026
|
+
return React.createElement(ImportedComponentErrorBoundary, null, elementToWrap);
|
|
56027
|
+
};
|
|
56028
|
+
};
|
|
56029
|
+
const elementToRender = componentRegistration
|
|
56030
|
+
? createElementToRender(componentRegistration)
|
|
56031
|
+
: null;
|
|
56013
56032
|
return {
|
|
56033
|
+
isComponentMissing: !componentRegistration,
|
|
56014
56034
|
node,
|
|
56015
56035
|
componentId,
|
|
56016
56036
|
elementToRender,
|
|
56017
56037
|
wrapperProps,
|
|
56018
|
-
definition: componentRegistration
|
|
56038
|
+
definition: componentRegistration?.definition,
|
|
56019
56039
|
};
|
|
56020
56040
|
};
|
|
56021
56041
|
|
|
@@ -57293,11 +57313,22 @@ const Hitboxes = ({ zoneId, parentZoneId, isEmptyZone }) => {
|
|
|
57293
57313
|
return reactDomExports.createPortal(ActiveHitboxes, hitboxContainer);
|
|
57294
57314
|
};
|
|
57295
57315
|
|
|
57316
|
+
const MissingComponentPlacehoder = ({ blockId }) => {
|
|
57317
|
+
return (React.createElement("div", { style: {
|
|
57318
|
+
border: '1px solid red',
|
|
57319
|
+
width: '100%',
|
|
57320
|
+
height: '100%',
|
|
57321
|
+
} },
|
|
57322
|
+
"Missing component '",
|
|
57323
|
+
blockId,
|
|
57324
|
+
"'"));
|
|
57325
|
+
};
|
|
57326
|
+
|
|
57296
57327
|
const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, index, zoneId, userIsDragging, placeholder, }) => {
|
|
57297
57328
|
const { slotId } = parseZoneId(zoneId);
|
|
57298
57329
|
const setSelectedNodeId = useEditorStore((state) => state.setSelectedNodeId);
|
|
57299
57330
|
const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
|
|
57300
|
-
const { node, wrapperProps, definition, elementToRender } = useComponent({
|
|
57331
|
+
const { node, wrapperProps, definition, elementToRender, isComponentMissing } = useComponent({
|
|
57301
57332
|
node: rawNode,
|
|
57302
57333
|
resolveDesignValue,
|
|
57303
57334
|
renderDropzone,
|
|
@@ -57340,10 +57371,14 @@ const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, index,
|
|
|
57340
57371
|
nodeId: node.data.id,
|
|
57341
57372
|
});
|
|
57342
57373
|
};
|
|
57374
|
+
if (isComponentMissing || !definition || !elementToRender) {
|
|
57375
|
+
return (React.createElement(DraggableComponent, { placeholder: placeholder, id: node.data.id, index: index, isAssemblyBlock: isAssembly || isAssemblyBlock, isDragDisabled: false, isSelected: selectedNodeId === node.data.id, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, onMouseOver: onMouseOver, displayName: displayName || definition?.name },
|
|
57376
|
+
React.createElement(MissingComponentPlacehoder, { blockId: node.data.blockId })));
|
|
57377
|
+
}
|
|
57343
57378
|
if (isSingleColumn) {
|
|
57344
57379
|
return (React.createElement(DraggableChildComponent, { elementToRender: elementToRender, id: node.data.id, index: index, isAssemblyBlock: isAssembly || isAssemblyBlock, isDragDisabled: true, isSelected: selectedNodeId === node.data.id, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, onMouseOver: onMouseOver, definition: definition, displayName: displayName }));
|
|
57345
57380
|
}
|
|
57346
|
-
return (React.createElement(DraggableComponent, { placeholder: placeholder,
|
|
57381
|
+
return (React.createElement(DraggableComponent, { placeholder: placeholder, id: node.data.id, index: index, isAssemblyBlock: isAssembly || isAssemblyBlock, isDragDisabled: isAssemblyBlock || isSlotComponent, isSelected: selectedNodeId === node.data.id, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, onMouseOver: onMouseOver, displayName: displayName },
|
|
57347
57382
|
elementToRender(),
|
|
57348
57383
|
isStructureComponent && userIsDragging && (React.createElement(Hitboxes, { parentZoneId: zoneId, zoneId: node.data.id, isEmptyZone: isEmptyZone }))));
|
|
57349
57384
|
};
|
|
@@ -57406,7 +57441,7 @@ function getStyle$1(style = {}, snapshot) {
|
|
|
57406
57441
|
}
|
|
57407
57442
|
const EditorBlockClone = ({ node: rawNode, resolveDesignValue, snapshot, provided, renderDropzone, }) => {
|
|
57408
57443
|
const userIsDragging = useDraggedItemStore((state) => state.isDraggingOnCanvas);
|
|
57409
|
-
const { node, wrapperProps, elementToRender } = useComponent({
|
|
57444
|
+
const { isComponentMissing, node, wrapperProps, elementToRender } = useComponent({
|
|
57410
57445
|
node: rawNode,
|
|
57411
57446
|
resolveDesignValue,
|
|
57412
57447
|
renderDropzone,
|
|
@@ -57414,6 +57449,14 @@ const EditorBlockClone = ({ node: rawNode, resolveDesignValue, snapshot, provide
|
|
|
57414
57449
|
});
|
|
57415
57450
|
const isAssemblyBlock = node.type === ASSEMBLY_BLOCK_NODE_TYPE;
|
|
57416
57451
|
const isSingleColumn = node.data.blockId === CONTENTFUL_COMPONENTS.singleColumn.id;
|
|
57452
|
+
if (isComponentMissing || !elementToRender) {
|
|
57453
|
+
// !elementToRender is for typescript
|
|
57454
|
+
return (React.createElement("div", { ref: provided?.innerRef, "data-ctfl-dragging-element": true, ...wrapperProps, ...provided?.draggableProps, ...provided?.dragHandleProps, className: classNames(styles$3.DraggableComponent, wrapperProps.className, styles$3.DraggableClone, {
|
|
57455
|
+
[styles$3.isAssemblyBlock]: isAssemblyBlock,
|
|
57456
|
+
[styles$3.isDragging]: snapshot?.isDragging,
|
|
57457
|
+
}), style: getStyle$1(provided?.draggableProps.style, snapshot) },
|
|
57458
|
+
React.createElement(MissingComponentPlacehoder, { blockId: node.data.blockId })));
|
|
57459
|
+
}
|
|
57417
57460
|
if (isSingleColumn) {
|
|
57418
57461
|
return elementToRender();
|
|
57419
57462
|
}
|