@contentful/experiences-visual-editor-react 1.40.0-alpha-20250604T1545-078bcac.0 → 1.40.0-alpha-20250702T0805-d0f2745.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
@@ -1433,6 +1433,10 @@ const findOutermostCoordinates = (first, second) => {
1433
1433
  left: Math.min(first.left, second.left),
1434
1434
  };
1435
1435
  };
1436
+ const isElementHidden = (rect) => {
1437
+ /** if the rect has no size and position, its element is not rendered in the DOM */
1438
+ return rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0;
1439
+ };
1436
1440
  const getElementCoordinates = (element) => {
1437
1441
  const rect = element.getBoundingClientRect();
1438
1442
  /**
@@ -1664,7 +1668,14 @@ function buildTemplate({ template, context, }) {
1664
1668
 
1665
1669
  const stylesToKeep = ['cfImageAsset'];
1666
1670
  const stylesToRemove = CF_STYLE_ATTRIBUTES.filter((style) => !stylesToKeep.includes(style));
1667
- const propsToRemove = ['cfHyperlink', 'cfOpenInNewTab', 'cfSsrClassName'];
1671
+ // cfWrapColumns & cfWrapColumnsCount are no real style attributes as they are handled on the editor side
1672
+ const propsToRemove = [
1673
+ 'cfHyperlink',
1674
+ 'cfOpenInNewTab',
1675
+ 'cfSsrClassName',
1676
+ 'cfWrapColumns',
1677
+ 'cfWrapColumnsCount',
1678
+ ];
1668
1679
  const sanitizeNodeProps = (nodeProps) => {
1669
1680
  return omit(nodeProps, stylesToRemove, propsToRemove);
1670
1681
  };
@@ -4192,6 +4203,9 @@ const collectNodeCoordinates = (node, nodeToCoordinatesMap) => {
4192
4203
  const selectedElement = document.querySelector(`[data-cf-node-id="${node.data.id}"]`);
4193
4204
  if (selectedElement) {
4194
4205
  const rect = getElementCoordinates(selectedElement);
4206
+ if (isElementHidden(rect)) {
4207
+ return;
4208
+ }
4195
4209
  nodeToCoordinatesMap[node.data.id] = {
4196
4210
  coordinates: {
4197
4211
  x: rect.x + window.scrollX,