@contentful/experiences-visual-editor-react 3.2.1-dev-20250818T1739-df3d95e.0 → 3.2.1-dev-20250820T1011-7f01669.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 CHANGED
@@ -131,7 +131,6 @@ const CF_STYLE_ATTRIBUTES = [
131
131
  'cfTextUnderline',
132
132
  ];
133
133
  const EMPTY_CONTAINER_SIZE$1 = '80px';
134
- const DEFAULT_IMAGE_WIDTH = '500px';
135
134
  var PostMessageMethods$3;
136
135
  (function (PostMessageMethods) {
137
136
  PostMessageMethods["REQUEST_ENTITIES"] = "REQUEST_ENTITIES";
@@ -353,9 +352,9 @@ const optionalBuiltInStyles = {
353
352
  type: 'Object',
354
353
  group: 'style',
355
354
  defaultValue: {
356
- width: DEFAULT_IMAGE_WIDTH,
355
+ width: '100%',
357
356
  height: '100%',
358
- targetSize: DEFAULT_IMAGE_WIDTH,
357
+ targetSize: 'unset',
359
358
  },
360
359
  },
361
360
  cfBackgroundColor: {
@@ -4895,7 +4894,7 @@ const sendCanvasGeometryUpdatedMessage = async (tree, sourceEvent) => {
4895
4894
  const rootRect = document.documentElement.getBoundingClientRect();
4896
4895
  const bodyRect = document.body.getBoundingClientRect();
4897
4896
  const width = Math.max(document.documentElement.offsetWidth, rootRect.width, bodyRect.width);
4898
- const height = Math.max(document.documentElement.offsetHeight, rootRect.height, bodyRect.height);
4897
+ const height = Math.max(document.documentElement.offsetHeight, rootRect.height, bodyRect.height, measureBodyContentHeight());
4899
4898
  sendMessage(OUTGOING_EVENTS.CanvasGeometryUpdated, {
4900
4899
  size: {
4901
4900
  width,
@@ -4943,6 +4942,31 @@ function waitForImageToBeLoaded(imageNode) {
4943
4942
  imageNode.addEventListener('error', handleImageLoad);
4944
4943
  });
4945
4944
  }
4945
+ // calculates the content height by finding the deepest node in the first 2 levels of the body
4946
+ function measureBodyContentHeight(depth = 2, node = document.body) {
4947
+ if (depth <= 0)
4948
+ return 0;
4949
+ let height = 0;
4950
+ for (const element of node.children) {
4951
+ const rect = element.getBoundingClientRect();
4952
+ const style = window.getComputedStyle(element);
4953
+ const isHidden = (rect.width === 0 && rect.height === 0) ||
4954
+ style.display === 'none' ||
4955
+ style.visibility === 'hidden';
4956
+ // ignore relative positioned elements that are anchored to the bottom,
4957
+ // as this can cause infinite height
4958
+ const isBottomAnchored = (style.position === 'fixed' ||
4959
+ style.position === 'absolute' ||
4960
+ style.position === 'relative' ||
4961
+ style.position === 'sticky') &&
4962
+ parseFloat(style.bottom) < 0;
4963
+ if (isHidden || isBottomAnchored) {
4964
+ continue;
4965
+ }
4966
+ height = Math.max(height, Math.ceil(rect.bottom), measureBodyContentHeight(depth - 1, element));
4967
+ }
4968
+ return height;
4969
+ }
4946
4970
 
4947
4971
  const useCanvasGeometryUpdates = ({ tree, canvasMode }) => {
4948
4972
  const debouncedUpdateGeometry = useMemo(() => debounce((tree, sourceEvent) => {