@contentful/experiences-visual-editor-react 1.0.6 → 1.0.7-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 +37 -37
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +37 -37
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -38106,6 +38106,9 @@ const tryParseMessage = (event) => {
|
|
|
38106
38106
|
return eventData;
|
|
38107
38107
|
};
|
|
38108
38108
|
|
|
38109
|
+
// Keep this for backwards compatilibity - deleting this would be a breaking change
|
|
38110
|
+
// because existing components on a users experience will have the width value as fill
|
|
38111
|
+
// rather than 100%
|
|
38109
38112
|
const transformFill = (value) => (value === 'fill' ? '100%' : value);
|
|
38110
38113
|
const transformGridColumn = (span) => {
|
|
38111
38114
|
if (!span) {
|
|
@@ -38276,7 +38279,7 @@ const buildCfStyles = ({ cfHorizontalAlignment, cfVerticalAlignment, cfFlexDirec
|
|
|
38276
38279
|
};
|
|
38277
38280
|
/**
|
|
38278
38281
|
* Container/section default behavior:
|
|
38279
|
-
* Default height => height: EMPTY_CONTAINER_HEIGHT
|
|
38282
|
+
* Default height => height: EMPTY_CONTAINER_HEIGHT
|
|
38280
38283
|
* If a container component has children => height: 'fit-content'
|
|
38281
38284
|
*/
|
|
38282
38285
|
const calculateNodeDefaultHeight = ({ blockId, children, value, }) => {
|
|
@@ -38402,7 +38405,7 @@ const getOptimizedBackgroundImageAsset = (file, widthStyle, quality = '100%', fo
|
|
|
38402
38405
|
};
|
|
38403
38406
|
|
|
38404
38407
|
const MAX_WIDTH_ALLOWED = 4000;
|
|
38405
|
-
const getOptimizedImageAsset = (file, sizes, quality = '100%', format) => {
|
|
38408
|
+
const getOptimizedImageAsset = ({ file, sizes, loading, quality = '100%', format, }) => {
|
|
38406
38409
|
const qualityNumber = Number(quality.replace('%', ''));
|
|
38407
38410
|
if (!validateParams(file, qualityNumber, format)) ;
|
|
38408
38411
|
const url = file.url;
|
|
@@ -38422,6 +38425,7 @@ const getOptimizedImageAsset = (file, sizes, quality = '100%', format) => {
|
|
|
38422
38425
|
srcSet,
|
|
38423
38426
|
sizes,
|
|
38424
38427
|
file,
|
|
38428
|
+
loading,
|
|
38425
38429
|
};
|
|
38426
38430
|
return optimizedImageAsset;
|
|
38427
38431
|
};
|
|
@@ -38444,7 +38448,13 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
38444
38448
|
return;
|
|
38445
38449
|
}
|
|
38446
38450
|
try {
|
|
38447
|
-
value = getOptimizedImageAsset(
|
|
38451
|
+
value = getOptimizedImageAsset({
|
|
38452
|
+
file: asset.fields.file,
|
|
38453
|
+
loading: options.loading,
|
|
38454
|
+
sizes: options.targetSize,
|
|
38455
|
+
quality: options.quality,
|
|
38456
|
+
format: options.format,
|
|
38457
|
+
});
|
|
38448
38458
|
return value;
|
|
38449
38459
|
}
|
|
38450
38460
|
catch (error) {
|
|
@@ -38587,7 +38597,7 @@ const builtInStyles = {
|
|
|
38587
38597
|
type: 'Text',
|
|
38588
38598
|
group: 'style',
|
|
38589
38599
|
description: 'The width of the section',
|
|
38590
|
-
defaultValue: '
|
|
38600
|
+
defaultValue: '100%',
|
|
38591
38601
|
},
|
|
38592
38602
|
cfHeight: {
|
|
38593
38603
|
displayName: 'Height',
|
|
@@ -50532,7 +50542,8 @@ function useDraggablePosition({ draggableId, draggableRef, position }) {
|
|
|
50532
50542
|
const draggingId = useDraggedItemStore((state) => state.onBeforeCaptureId);
|
|
50533
50543
|
const preDragDomRect = useDraggedItemStore((state) => state.domRect);
|
|
50534
50544
|
reactExports.useEffect(() => {
|
|
50535
|
-
const el = draggableRef?.current
|
|
50545
|
+
const el = draggableRef?.current ??
|
|
50546
|
+
document.querySelector(`[${CTFL_DRAGGING_ELEMENT}][data-cf-node-id="${draggableId}"]`);
|
|
50536
50547
|
if (!isDraggingOnCanvas || draggingId !== draggableId || !el) {
|
|
50537
50548
|
return;
|
|
50538
50549
|
}
|
|
@@ -50906,7 +50917,6 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
50906
50917
|
}),
|
|
50907
50918
|
...(userIsDragging &&
|
|
50908
50919
|
isContentfulStructureComponent(node?.data.blockId) &&
|
|
50909
|
-
node?.data.blockId !== CONTENTFUL_COMPONENTS.divider.id &&
|
|
50910
50920
|
node?.data.blockId !== CONTENTFUL_COMPONENTS.columns.id && {
|
|
50911
50921
|
padding: addExtraDropzonePadding(componentStyles.padding?.toString() || '0 0 0 0'),
|
|
50912
50922
|
}),
|
|
@@ -50934,13 +50944,7 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
|
|
|
50934
50944
|
};
|
|
50935
50945
|
const addExtraDropzonePadding = (padding) => padding
|
|
50936
50946
|
.split(' ')
|
|
50937
|
-
.map((value) => {
|
|
50938
|
-
if (value.endsWith('px')) {
|
|
50939
|
-
const parsedValue = parseInt(value.replace(/px$/, ''), 10);
|
|
50940
|
-
return (parsedValue < DRAG_PADDING ? DRAG_PADDING : parsedValue) + 'px';
|
|
50941
|
-
}
|
|
50942
|
-
return `${DRAG_PADDING}px`;
|
|
50943
|
-
})
|
|
50947
|
+
.map((value) => parseFloat(value) === 0 ? `${DRAG_PADDING}px` : `calc(${value} + ${DRAG_PADDING}px)`)
|
|
50944
50948
|
.join(' ');
|
|
50945
50949
|
|
|
50946
50950
|
var richTextReactRenderer_es5 = {};
|
|
@@ -52908,7 +52912,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect, scrollY, offsetRect, }
|
|
|
52908
52912
|
return {
|
|
52909
52913
|
width: WIDTH,
|
|
52910
52914
|
height: height - HEIGHT,
|
|
52911
|
-
left: right + offsetWidth
|
|
52915
|
+
left: right + offsetWidth + calcOffsetDepth(zoneDepth) - WIDTH / 2,
|
|
52912
52916
|
top: top + HEIGHT / 2 - scrollY,
|
|
52913
52917
|
zIndex: 100 + zoneDepth,
|
|
52914
52918
|
};
|
|
@@ -52932,7 +52936,7 @@ const getHitboxStyles = ({ direction, zoneDepth, domRect, scrollY, offsetRect, }
|
|
|
52932
52936
|
return {
|
|
52933
52937
|
width: width - DRAGGABLE_WIDTH * 2,
|
|
52934
52938
|
height,
|
|
52935
|
-
left: left +
|
|
52939
|
+
left: left + DRAGGABLE_WIDTH,
|
|
52936
52940
|
top: top - scrollY,
|
|
52937
52941
|
zIndex: 1000 + zoneDepth,
|
|
52938
52942
|
};
|
|
@@ -52947,35 +52951,26 @@ const Hitboxes = ({ zoneId, parentZoneId, isEmptyZone }) => {
|
|
|
52947
52951
|
const isDraggingOnCanvas = useDraggedItemStore((state) => state.isDraggingOnCanvas);
|
|
52948
52952
|
const scrollY = useDraggedItemStore((state) => state.scrollY);
|
|
52949
52953
|
const zoneDepth = reactExports.useMemo(() => getItemDepthFromNode({ id: parentZoneId }, tree.root), [tree, parentZoneId]);
|
|
52950
|
-
const
|
|
52951
|
-
const
|
|
52954
|
+
const zones = useZoneStore((state) => state.zones);
|
|
52955
|
+
const hoveringZone = useZoneStore((state) => state.hoveringZone);
|
|
52952
52956
|
const isHoveringZone = hoveringZone === zoneId;
|
|
52953
|
-
reactExports.useEffect(() => {
|
|
52954
|
-
/**
|
|
52955
|
-
* A bit hacky but we need to wait a very small amount
|
|
52956
|
-
* of time to fetch the dom getBoundingClientRect once a
|
|
52957
|
-
* drag starts because we need pre-drag styles like padding
|
|
52958
|
-
* applied before we calculate positions of hitboxes
|
|
52959
|
-
*/
|
|
52960
|
-
setTimeout(() => {
|
|
52961
|
-
setFetchDomRect(Date.now());
|
|
52962
|
-
}, 50);
|
|
52963
|
-
}, [isDraggingOnCanvas]);
|
|
52964
52957
|
const hitboxContainer = reactExports.useMemo(() => {
|
|
52965
52958
|
return document.querySelector('[data-ctfl-hitboxes]');
|
|
52966
52959
|
}, []);
|
|
52967
52960
|
const domRect = reactExports.useMemo(() => {
|
|
52961
|
+
if (!isDraggingOnCanvas)
|
|
52962
|
+
return;
|
|
52968
52963
|
return document.querySelector(`[${CTFL_ZONE_ID}="${zoneId}"]`)?.getBoundingClientRect();
|
|
52969
52964
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52970
|
-
}, [zoneId,
|
|
52965
|
+
}, [zoneId, isDraggingOnCanvas]);
|
|
52971
52966
|
// Use the size of the cloned dragging element to offset the position of the hitboxes
|
|
52972
52967
|
// So that when dragging causes a dropzone to expand, the hitboxes will be in the correct position
|
|
52973
52968
|
const offsetRect = reactExports.useMemo(() => {
|
|
52974
|
-
if (isEmptyZone || !isHoveringZone)
|
|
52969
|
+
if (!isDraggingOnCanvas || isEmptyZone || !isHoveringZone)
|
|
52975
52970
|
return;
|
|
52976
52971
|
return document.querySelector(`[${CTFL_DRAGGING_ELEMENT}]`)?.getBoundingClientRect();
|
|
52977
52972
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52978
|
-
}, [isEmptyZone, isHoveringZone,
|
|
52973
|
+
}, [isEmptyZone, isHoveringZone, isDraggingOnCanvas]);
|
|
52979
52974
|
const zoneDirection = zones[parentZoneId]?.direction || 'vertical';
|
|
52980
52975
|
const isVertical = zoneDirection === 'vertical';
|
|
52981
52976
|
const isRoot = parentZoneId === ROOT_ID;
|
|
@@ -54048,7 +54043,7 @@ function useCanvasInteractions() {
|
|
|
54048
54043
|
return { onAddComponent, onMoveComponent };
|
|
54049
54044
|
}
|
|
54050
54045
|
|
|
54051
|
-
const TestDNDContainer = ({ onDragEnd, onBeforeDragStart, onDragUpdate, children, }) => {
|
|
54046
|
+
const TestDNDContainer = ({ onDragEnd, onBeforeDragStart, onDragStart, onDragUpdate, children, }) => {
|
|
54052
54047
|
const handleDragStart = (event) => {
|
|
54053
54048
|
const draggedItem = event.nativeEvent;
|
|
54054
54049
|
const start = {
|
|
@@ -54058,6 +54053,7 @@ const TestDNDContainer = ({ onDragEnd, onBeforeDragStart, onDragUpdate, children
|
|
|
54058
54053
|
source: draggedItem.source,
|
|
54059
54054
|
};
|
|
54060
54055
|
onBeforeDragStart(start);
|
|
54056
|
+
onDragStart(start, {});
|
|
54061
54057
|
};
|
|
54062
54058
|
const handleDrag = (event) => {
|
|
54063
54059
|
const draggedItem = event.nativeEvent;
|
|
@@ -54097,10 +54093,12 @@ const DNDProvider = ({ children }) => {
|
|
|
54097
54093
|
const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
|
|
54098
54094
|
const prevSelectedNodeId = reactExports.useRef(null);
|
|
54099
54095
|
const isTestRun = typeof window !== 'undefined' && Object.prototype.hasOwnProperty.call(window, 'Cypress');
|
|
54100
|
-
const
|
|
54096
|
+
const beforeDragStart = ({ source }) => {
|
|
54101
54097
|
prevSelectedNodeId.current = selectedNodeId;
|
|
54102
|
-
//Unselect the current node when dragging and remove the outline
|
|
54098
|
+
// Unselect the current node when dragging and remove the outline
|
|
54103
54099
|
setSelectedNodeId('');
|
|
54100
|
+
// Set dragging state here to make sure that DnD capture phase has completed
|
|
54101
|
+
setDraggingOnCanvas(true);
|
|
54104
54102
|
sendMessage(OUTGOING_EVENTS.ComponentSelected, {
|
|
54105
54103
|
nodeId: '',
|
|
54106
54104
|
});
|
|
@@ -54109,16 +54107,18 @@ const DNDProvider = ({ children }) => {
|
|
|
54109
54107
|
}
|
|
54110
54108
|
};
|
|
54111
54109
|
const beforeCapture = ({ draggableId }) => {
|
|
54112
|
-
setDraggingOnCanvas(true);
|
|
54113
54110
|
setOnBeforeCaptureId(draggableId);
|
|
54114
54111
|
};
|
|
54112
|
+
const dragStart = (start) => {
|
|
54113
|
+
updateItem(start);
|
|
54114
|
+
};
|
|
54115
54115
|
const dragUpdate = (update) => {
|
|
54116
54116
|
updateItem(update);
|
|
54117
54117
|
};
|
|
54118
54118
|
const dragEnd = (dropResult) => {
|
|
54119
54119
|
setDraggingOnCanvas(false);
|
|
54120
54120
|
setOnBeforeCaptureId('');
|
|
54121
|
-
updateItem(
|
|
54121
|
+
updateItem();
|
|
54122
54122
|
SimulateDnD$1.reset();
|
|
54123
54123
|
if (!dropResult.destination) {
|
|
54124
54124
|
if (!draggedItem?.destination) {
|
|
@@ -54151,7 +54151,7 @@ const DNDProvider = ({ children }) => {
|
|
|
54151
54151
|
nodeId: dropResult.draggableId,
|
|
54152
54152
|
});
|
|
54153
54153
|
};
|
|
54154
|
-
return (React.createElement(DragDropContext, { onBeforeCapture: beforeCapture, onDragUpdate: dragUpdate, onBeforeDragStart: dragStart, onDragEnd: dragEnd }, isTestRun ? (React.createElement(TestDNDContainer, { onDragEnd: dragEnd, onBeforeDragStart: dragStart, onDragUpdate: dragUpdate }, children)) : (children)));
|
|
54154
|
+
return (React.createElement(DragDropContext, { onBeforeCapture: beforeCapture, onDragUpdate: dragUpdate, onBeforeDragStart: beforeDragStart, onDragStart: dragStart, onDragEnd: dragEnd }, isTestRun ? (React.createElement(TestDNDContainer, { onDragEnd: dragEnd, onBeforeDragStart: beforeDragStart, onDragStart: dragStart, onDragUpdate: dragUpdate }, children)) : (children)));
|
|
54155
54155
|
};
|
|
54156
54156
|
|
|
54157
54157
|
const RootRenderer = ({ onChange }) => {
|