@contentful/experiences-visual-editor-react 1.40.0-alpha-20250604T0813-1f6e699.0 → 1.40.0-alpha-20250626T1127-cab6b9d.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 +12 -8
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +12 -8
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -45577,6 +45577,10 @@ const findOutermostCoordinates = (first, second) => {
|
|
|
45577
45577
|
left: Math.min(first.left, second.left),
|
|
45578
45578
|
};
|
|
45579
45579
|
};
|
|
45580
|
+
const isElementHidden = (rect) => {
|
|
45581
|
+
/** if the rect has no size and position, its element is not rendered in the DOM */
|
|
45582
|
+
return rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
|
|
45583
|
+
};
|
|
45580
45584
|
const getElementCoordinates = (element) => {
|
|
45581
45585
|
const rect = element.getBoundingClientRect();
|
|
45582
45586
|
/**
|
|
@@ -49562,6 +49566,9 @@ const collectNodeCoordinates = (node, nodeToCoordinatesMap) => {
|
|
|
49562
49566
|
const selectedElement = document.querySelector(`[data-cf-node-id="${node.data.id}"]`);
|
|
49563
49567
|
if (selectedElement) {
|
|
49564
49568
|
const rect = getElementCoordinates(selectedElement);
|
|
49569
|
+
if (isElementHidden(rect)) {
|
|
49570
|
+
return;
|
|
49571
|
+
}
|
|
49565
49572
|
nodeToCoordinatesMap[node.data.id] = {
|
|
49566
49573
|
coordinates: {
|
|
49567
49574
|
x: rect.x + window.scrollX,
|
|
@@ -49598,7 +49605,7 @@ const waitForAllImagesToBeLoaded = () => {
|
|
|
49598
49605
|
}));
|
|
49599
49606
|
};
|
|
49600
49607
|
|
|
49601
|
-
const useCanvasGeometryUpdates = ({ tree
|
|
49608
|
+
const useCanvasGeometryUpdates = ({ tree }) => {
|
|
49602
49609
|
const debouncedUpdateGeometry = reactExports.useMemo(() => debounce((tree, sourceEvent) => {
|
|
49603
49610
|
// When the DOM changed, we still need to wait for the next frame to ensure that
|
|
49604
49611
|
// rendering is complete (e.g. this is required when deleting a node).
|
|
@@ -49625,22 +49632,19 @@ const useCanvasGeometryUpdates = ({ tree, rootContainerRef, }) => {
|
|
|
49625
49632
|
}, [debouncedUpdateGeometry]);
|
|
49626
49633
|
// Handling DOM mutations
|
|
49627
49634
|
reactExports.useEffect(() => {
|
|
49628
|
-
if (!rootContainerRef.current)
|
|
49629
|
-
return;
|
|
49630
49635
|
const observer = new MutationObserver(() => debouncedUpdateGeometry(treeRef.current, 'mutation'));
|
|
49631
|
-
observer.observe(
|
|
49636
|
+
observer.observe(document.documentElement, {
|
|
49632
49637
|
childList: true,
|
|
49633
49638
|
subtree: true,
|
|
49634
49639
|
attributes: true,
|
|
49635
49640
|
});
|
|
49636
49641
|
return () => observer.disconnect();
|
|
49637
|
-
}, [debouncedUpdateGeometry
|
|
49642
|
+
}, [debouncedUpdateGeometry]);
|
|
49638
49643
|
};
|
|
49639
49644
|
|
|
49640
49645
|
const RootRenderer = () => {
|
|
49641
|
-
const rootContainerRef = reactExports.useRef(null);
|
|
49642
49646
|
const tree = useTreeStore((state) => state.tree);
|
|
49643
|
-
useCanvasGeometryUpdates({ tree
|
|
49647
|
+
useCanvasGeometryUpdates({ tree });
|
|
49644
49648
|
useEditorSubscriber();
|
|
49645
49649
|
const breakpoints = useTreeStore((state) => state.breakpoints);
|
|
49646
49650
|
const { resolveDesignValue } = useBreakpoints(breakpoints);
|
|
@@ -49649,7 +49653,7 @@ const RootRenderer = () => {
|
|
|
49649
49653
|
const rootBlockId = tree.root.data.blockId ?? ROOT_ID;
|
|
49650
49654
|
const wrappingPatternIds = rootBlockId !== ROOT_ID ? new Set([rootBlockId]) : new Set();
|
|
49651
49655
|
return (React$1.createElement(React$1.Fragment, null,
|
|
49652
|
-
React$1.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer
|
|
49656
|
+
React$1.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer }, !tree.root.children.length ? (React$1.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React$1.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds })))))));
|
|
49653
49657
|
};
|
|
49654
49658
|
|
|
49655
49659
|
const useInitializeEditor = () => {
|