@contentful/experiences-visual-editor-react 1.37.1 → 1.37.2-dev-20250515T1505-4c9ed48.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
@@ -1365,6 +1365,7 @@ const transformVisibility = (value) => {
1365
1365
  // Don't explicitly set anything when visible to not overwrite values like `grid` or `flex`.
1366
1366
  return {};
1367
1367
  };
1368
+ // TODO: Remove in next major version v2 since the change is 17 months old
1368
1369
  // Keep this for backwards compatibility - deleting this would be a breaking change
1369
1370
  // because existing components on a users experience will have the width value as fill
1370
1371
  // rather than 100%
@@ -1890,6 +1891,23 @@ const transformBoundContentValue = (variables, entityStore, binding, resolveDesi
1890
1891
  }
1891
1892
  };
1892
1893
 
1894
+ function treeVisit(initialNode, onNode) {
1895
+ // returns last used index
1896
+ const _treeVisit = (currentNode, currentIndex, currentDepth) => {
1897
+ // Copy children in case of onNode removing it as we pass the node by reference
1898
+ const children = [...currentNode.children];
1899
+ onNode(currentNode, currentIndex, currentDepth);
1900
+ let nextAvailableIndex = currentIndex + 1;
1901
+ const lastUsedIndex = currentIndex;
1902
+ for (const child of children) {
1903
+ const lastUsedIndex = _treeVisit(child, nextAvailableIndex, currentDepth + 1);
1904
+ nextAvailableIndex = lastUsedIndex + 1;
1905
+ }
1906
+ return lastUsedIndex;
1907
+ };
1908
+ _treeVisit(initialNode, 0, 0);
1909
+ }
1910
+
1893
1911
  const getDataFromTree = (tree) => {
1894
1912
  let dataSource = {};
1895
1913
  let unboundValues = {};
@@ -2389,23 +2407,6 @@ var VisualEditorMode$1;
2389
2407
  VisualEditorMode["InjectScript"] = "injectScript";
2390
2408
  })(VisualEditorMode$1 || (VisualEditorMode$1 = {}));
2391
2409
 
2392
- function treeVisit$1(initialNode, onNode) {
2393
- // returns last used index
2394
- const _treeVisit = (currentNode, currentIndex, currentDepth) => {
2395
- // Copy children in case of onNode removing it as we pass the node by reference
2396
- const children = [...currentNode.children];
2397
- onNode(currentNode, currentIndex, currentDepth);
2398
- let nextAvailableIndex = currentIndex + 1;
2399
- const lastUsedIndex = currentIndex;
2400
- for (const child of children) {
2401
- const lastUsedIndex = _treeVisit(child, nextAvailableIndex, currentDepth + 1);
2402
- nextAvailableIndex = lastUsedIndex + 1;
2403
- }
2404
- return lastUsedIndex;
2405
- };
2406
- _treeVisit(initialNode, 0, 0);
2407
- }
2408
-
2409
2410
  class DeepReference {
2410
2411
  constructor({ path, dataSource }) {
2411
2412
  const { key, field, referentField } = parseDataSourcePathWithL1DeepBindings(path);
@@ -2443,7 +2444,7 @@ class DeepReference {
2443
2444
  }
2444
2445
  function gatherDeepReferencesFromTree(startingNode, dataSource) {
2445
2446
  const deepReferences = [];
2446
- treeVisit$1(startingNode, (node) => {
2447
+ treeVisit(startingNode, (node) => {
2447
2448
  if (!node.data.props)
2448
2449
  return;
2449
2450
  for (const [, variableMapping] of Object.entries(node.data.props)) {
@@ -2953,26 +2954,6 @@ function getTreeDiffs(tree1, tree2, originalTree) {
2953
2954
  return differences.filter((diff) => diff);
2954
2955
  }
2955
2956
 
2956
- /**
2957
- * @deprecated in favor of one in 'core' package
2958
- */
2959
- function treeVisit(initialNode, onNode) {
2960
- // returns last used index
2961
- const _treeVisit = (currentNode, currentIndex, currentDepth) => {
2962
- // Copy children in case of onNode removing it as we pass the node by reference
2963
- const children = [...currentNode.children];
2964
- onNode(currentNode, currentIndex, currentDepth);
2965
- let nextAvailableIndex = currentIndex + 1;
2966
- const lastUsedIndex = currentIndex;
2967
- for (const child of children) {
2968
- const lastUsedIndex = _treeVisit(child, nextAvailableIndex, currentDepth + 1);
2969
- nextAvailableIndex = lastUsedIndex + 1;
2970
- }
2971
- return lastUsedIndex;
2972
- };
2973
- _treeVisit(initialNode, 0, 0);
2974
- }
2975
-
2976
2957
  const useTreeStore = create((set, get) => ({
2977
2958
  tree: {
2978
2959
  root: {
@@ -3228,8 +3209,6 @@ const useEditorStore = create((set, get) => ({
3228
3209
  dataSource: {},
3229
3210
  hyperLinkPattern: undefined,
3230
3211
  unboundValues: {},
3231
- isDragging: false,
3232
- dragItem: '',
3233
3212
  selectedNodeId: null,
3234
3213
  locale: null,
3235
3214
  setHyperLinkPattern: (pattern) => {
@@ -3298,7 +3277,7 @@ styleInject(css_248z$5);
3298
3277
  var css_248z$4 = ".cf-text {\n white-space: pre-line;\n}\n\n.cf-text-link .cf-text {\n margin: 0;\n}\n";
3299
3278
  styleInject(css_248z$4);
3300
3279
 
3301
- var css_248z$3 = "@import url(https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,400;0,500;0,600;1,400;1,600&display=swap);\n\n:root {\n /* All sizing comments based of 16px base body font size */\n\n /* color */\n --cf-color-white: #fff;\n --cf-color-black: #000;\n --cf-color-gray100: #f7f9fa;\n --cf-color-gray400: #aec1cc;\n --cf-color-gray400-rgb: 174, 193, 204;\n\n /* spacing */\n --cf-spacing-0: 0rem; /* 0px */\n --cf-spacing-1: 0.125rem; /* 2px */\n --cf-spacing-2: 0.25rem; /* 4px */\n --cf-spacing-3: 0.375rem; /* 6px */\n --cf-spacing-4: 0.5rem; /* 8px */\n --cf-spacing-5: 0.625rem; /* 10px */\n --cf-spacing-6: 0.75rem; /* 12px */\n --cf-spacing-7: 0.875rem; /* 14px */\n --cf-spacing-8: 1rem; /* 16px */\n --cf-spacing-9: 1.25rem; /* 20px */\n --cf-spacing-10: 1.5rem; /* 24px */\n --cf-spacing-11: 1.75rem; /* 28px */\n --cf-spacing-12: 2rem; /* 32px */\n --cf-spacing-13: 2.25rem; /* 36px */\n\n /* font-size */\n --cf-text-xs: 0.75rem; /* 12px */\n --cf-text-sm: 0.875rem; /* 14px */\n --cf-text-base: 1rem; /* 16px */\n --cf-text-lg: 1.125rem; /* 18px */\n --cf-text-xl: 1.25rem; /* 20px */\n --cf-text-2xl: 1.5rem; /* 24px */\n --cf-text-3xl: 2rem; /* 32px */\n --cf-text-4xl: 2.75rem; /* 44px */\n\n /* font-weight */\n --cf-font-light: 300;\n --cf-font-normal: 400;\n --cf-font-medium: 500;\n --cf-font-semibold: 600;\n --cf-font-bold: 700;\n --cf-font-extra-bold: 800;\n --cf-font-black: 900;\n\n /* border-radius */\n --cf-border-radius-none: 0px; /* none */\n --cf-border-radius-sm: 0.125rem; /* 2px */\n --cf-border-radius: 0.25rem; /* 4px */\n --cf-border-radius-md: 0.375rem; /* 6px */\n --cf-border-radius-lg: 0.5rem; /* 8px */\n --cf-border-radius-xl: 0.75rem; /* 12px */\n --cf-border-radius-2xl: 1rem; /* 16px */\n --cf-border-radius-3xl: 1.5rem; /* 24px */\n --cf-border-radius-full: 9999px; /* full */\n\n /* font-family */\n --cf-font-family-sans: Archivo, Helvetica, Arial, sans-serif;\n --cf-font-family-serif: Georgia, Cambria, Times New Roman, Times, serif;\n\n /* max widths */\n --cf-max-width-full: 100%;\n\n /* component specific colors */\n --cf-button-bg: var(--cf-color-black);\n --cf-button-color: var(--cf-color-white);\n --cf-text-color: var(--cf-color-black);\n}\n\nimg.cf-placeholder-image {\n background-color: var(--cf-color-gray100);\n outline-offset: -2px;\n outline: 2px solid rgba(var(--cf-color-gray400-rgb), 0.5);\n}\n\nsvg.cf-placeholder-icon {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n height: var(--cf-text-3xl);\n width: var(--cf-text-3xl);\n max-height: 100%;\n max-width: 100%;\n}\n\nsvg.cf-placeholder-icon path {\n fill: var(--cf-color-gray400);\n}\n";
3280
+ var css_248z$3 = "@import url(https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,400;0,500;0,600;1,400;1,600&display=swap);\n\n:root {\n /* All sizing comments based of 16px base body font size */\n\n /* color */\n --cf-color-white: #fff;\n --cf-color-black: #000;\n --cf-color-gray100: #f7f9fa;\n --cf-color-gray400: #aec1cc;\n --cf-color-gray400-rgb: 174, 193, 204;\n\n /* spacing */\n --cf-spacing-0: 0rem; /* 0px */\n --cf-spacing-1: 0.125rem; /* 2px */\n --cf-spacing-2: 0.25rem; /* 4px */\n --cf-spacing-3: 0.375rem; /* 6px */\n --cf-spacing-4: 0.5rem; /* 8px */\n --cf-spacing-5: 0.625rem; /* 10px */\n --cf-spacing-6: 0.75rem; /* 12px */\n --cf-spacing-7: 0.875rem; /* 14px */\n --cf-spacing-8: 1rem; /* 16px */\n --cf-spacing-9: 1.25rem; /* 20px */\n --cf-spacing-10: 1.5rem; /* 24px */\n --cf-spacing-11: 1.75rem; /* 28px */\n --cf-spacing-12: 2rem; /* 32px */\n --cf-spacing-13: 2.25rem; /* 36px */\n\n /* font-size */\n --cf-text-xs: 0.75rem; /* 12px */\n --cf-text-sm: 0.875rem; /* 14px */\n --cf-text-base: 1rem; /* 16px */\n --cf-text-lg: 1.125rem; /* 18px */\n --cf-text-xl: 1.25rem; /* 20px */\n --cf-text-2xl: 1.5rem; /* 24px */\n --cf-text-3xl: 2rem; /* 32px */\n --cf-text-4xl: 2.75rem; /* 44px */\n\n /* font-weight */\n --cf-font-light: 300;\n --cf-font-normal: 400;\n --cf-font-medium: 500;\n --cf-font-semibold: 600;\n --cf-font-bold: 700;\n --cf-font-extra-bold: 800;\n --cf-font-black: 900;\n\n /* border-radius */\n --cf-border-radius-none: 0px; /* none */\n --cf-border-radius-sm: 0.125rem; /* 2px */\n --cf-border-radius: 0.25rem; /* 4px */\n --cf-border-radius-md: 0.375rem; /* 6px */\n --cf-border-radius-lg: 0.5rem; /* 8px */\n --cf-border-radius-xl: 0.75rem; /* 12px */\n --cf-border-radius-2xl: 1rem; /* 16px */\n --cf-border-radius-3xl: 1.5rem; /* 24px */\n --cf-border-radius-full: 9999px; /* full */\n\n /* font-family */\n --cf-font-family-sans: Archivo, Helvetica, Arial, sans-serif;\n --cf-font-family-serif: Georgia, Cambria, Times New Roman, Times, serif;\n\n /* max widths */\n --cf-max-width-full: 100%;\n\n /* component specific colors */\n --cf-button-bg: var(--cf-color-black);\n --cf-button-color: var(--cf-color-white);\n --cf-text-color: var(--cf-color-black);\n}\n\ndiv.cf-placeholder-wrapper {\n /* Required for the absolute positioned icon to render in the center */\n position: relative;\n}\n\nimg.cf-placeholder-image {\n background-color: var(--cf-color-gray100);\n outline-offset: -2px;\n outline: 2px solid rgba(var(--cf-color-gray400-rgb), 0.5);\n width: 100%;\n height: 100%;\n}\n\nsvg.cf-placeholder-icon {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n height: var(--cf-text-3xl);\n width: var(--cf-text-3xl);\n max-height: 100%;\n max-width: 100%;\n}\n\nsvg.cf-placeholder-icon path {\n fill: var(--cf-color-gray400);\n}\n";
3302
3281
  styleInject(css_248z$3);
3303
3282
 
3304
3283
  /**
@@ -5405,29 +5384,23 @@ const Tooltip = ({ coordinates, id, label, isAssemblyBlock, isContainer, isSelec
5405
5384
  function useSingleColumn(node, resolveDesignValue) {
5406
5385
  const tree = useTreeStore((store) => store.tree);
5407
5386
  const isSingleColumn = node.data.blockId === CONTENTFUL_COMPONENTS$1.singleColumn.id;
5408
- const { isWrapped, wrapColumnsCount } = useMemo(() => {
5409
- let isWrapped = false;
5410
- let wrapColumnsCount = 0;
5387
+ const isWrapped = useMemo(() => {
5411
5388
  if (!node.parentId || !isSingleColumn) {
5412
- return { isWrapped, wrapColumnsCount };
5389
+ return false;
5413
5390
  }
5414
5391
  const parentNode = getItem({ id: node.parentId }, tree);
5415
5392
  if (!parentNode || parentNode.data.blockId !== CONTENTFUL_COMPONENTS$1.columns.id) {
5416
- return { isWrapped, wrapColumnsCount };
5417
- }
5418
- const { cfWrapColumns, cfWrapColumnsCount } = parentNode.data.props;
5419
- if (cfWrapColumns.type === 'DesignValue') {
5420
- isWrapped = resolveDesignValue(cfWrapColumns.valuesByBreakpoint, 'cfWrapColumns');
5393
+ return false;
5421
5394
  }
5422
- if (cfWrapColumnsCount.type === 'DesignValue') {
5423
- wrapColumnsCount = resolveDesignValue(cfWrapColumnsCount.valuesByBreakpoint, 'cfWrapColumnsCount');
5395
+ const { cfWrapColumns } = parentNode.data.props;
5396
+ if (cfWrapColumns.type !== 'DesignValue') {
5397
+ return false;
5424
5398
  }
5425
- return { isWrapped, wrapColumnsCount };
5399
+ return resolveDesignValue(cfWrapColumns.valuesByBreakpoint, 'cfWrapColumns');
5426
5400
  }, [tree, node, isSingleColumn, resolveDesignValue]);
5427
5401
  return {
5428
5402
  isSingleColumn,
5429
5403
  isWrapped,
5430
- wrapColumnsCount,
5431
5404
  };
5432
5405
  }
5433
5406
 
@@ -5920,7 +5893,7 @@ const VisualEditorRoot = ({ experience }) => {
5920
5893
  }
5921
5894
  SimulateDnD$1.updateDrag(e.clientX, e.clientY);
5922
5895
  sendMessage(OUTGOING_EVENTS.MouseMove, {
5923
- clientX: e.pageX,
5896
+ clientX: e.pageX - window.scrollX,
5924
5897
  clientY: e.pageY - window.scrollY,
5925
5898
  });
5926
5899
  };
@@ -5928,8 +5901,7 @@ const VisualEditorRoot = ({ experience }) => {
5928
5901
  return () => {
5929
5902
  document.removeEventListener('mousemove', onMouseMove);
5930
5903
  };
5931
- // eslint-disable-next-line react-hooks/exhaustive-deps
5932
- }, []);
5904
+ }, [setHoveringZone, setMousePosition]);
5933
5905
  if (!initialized)
5934
5906
  return null;
5935
5907
  return React.createElement(RootRenderer, null);