@contentful/experiences-visual-editor-react 1.0.8 → 1.0.9-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/renderApp.js CHANGED
@@ -50016,8 +50016,8 @@ var classnames = {exports: {}};
50016
50016
  var classnamesExports = classnames.exports;
50017
50017
  var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
50018
50018
 
50019
- var css_248z$8 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n box-sizing: border-box;\n display: flex;\n}\n\n.styles-module_DraggableComponent__m5-dA:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n outline-offset: -2px;\n outline: 2px solid transparent;\n z-index: 1;\n pointer-events: none;\n}\n\n.styles-module_DraggableClone__X8zTA:before {\n outline: 2px solid var(--exp-builder-blue500);\n}\n\n.styles-module_DraggableClone__X8zTA,\n.styles-module_DraggableClone__X8zTA * {\n pointer-events: none !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:not(.styles-module_userIsDragging__lqbjG) :not(.styles-module_DraggableComponent__m5-dA) {\n pointer-events: none;\n}\n\n.styles-module_isDragging__WHjPU {\n overflow: hidden;\n}\n\n.styles-module_isSelected__BzICQ:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_overlay__r4th9 {\n position: absolute;\n display: flex;\n align-items: center;\n min-width: max-content;\n height: 24px;\n z-index: 1;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 14px;\n font-weight: 500;\n background-color: var(--exp-builder-gray500);\n color: var(--exp-builder-color-white);\n border-radius: 0 0 2px 0;\n padding: 4px 12px 4px 12px;\n transition: opacity 0.2s;\n opacity: 0;\n text-wrap: nowrap;\n}\n\n.styles-module_overlayContainer__eiX-5 {\n opacity: 0;\n}\n\n.styles-module_overlayAssembly__tOzZU {\n background-color: var(--exp-builder-purple600);\n}\n\n.styles-module_userIsDragging__lqbjG > .styles-module_overlay__r4th9,\n.styles-module_userIsDragging__lqbjG > .styles-module_overlayContainer__eiX-5 {\n opacity: 0 !important;\n}\n\n.styles-module_userIsDragging__lqbjG:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)) > .styles-module_overlay__r4th9 {\n opacity: 1;\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:before,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id]:before {\n outline: 2px dashed var(--exp-builder-gray500);\n}\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(div[data-rfd-draggable-id]:hover)):before {\n outline: 2px solid var(--exp-builder-gray500);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:before,\n.styles-module_isAssemblyBlock__Y3Avk:hover div[data-rfd-draggable-id]:before,\n.styles-module_DraggableComponent__m5-dA:hover div[data-rfd-draggable-id][data-cf-node-block-type^='assembly']:before {\n outline: 2px dashed var(--exp-builder-purple600);\n}\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:not(:has(div[data-rfd-draggable-id]:hover)):before {\n outline: 2px solid var(--exp-builder-purple600);\n}\n";
50020
- var styles$3 = {"DraggableComponent":"styles-module_DraggableComponent__m5-dA","DraggableClone":"styles-module_DraggableClone__X8zTA","userIsDragging":"styles-module_userIsDragging__lqbjG","isDragging":"styles-module_isDragging__WHjPU","isSelected":"styles-module_isSelected__BzICQ","overlay":"styles-module_overlay__r4th9","overlayContainer":"styles-module_overlayContainer__eiX-5","overlayAssembly":"styles-module_overlayAssembly__tOzZU","isAssemblyBlock":"styles-module_isAssemblyBlock__Y3Avk"};
50019
+ var css_248z$8 = ".styles-module_DraggableComponent__m5-dA {\n pointer-events: all;\n position: relative;\n transition: outline 0.2s;\n cursor: grab;\n box-sizing: border-box;\n display: flex;\n}\n\n.styles-module_DraggableComponent__m5-dA:before {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n outline-offset: -2px;\n outline: 2px solid transparent;\n z-index: 1;\n pointer-events: none;\n}\n\n.styles-module_DraggableClone__X8zTA:before {\n outline: 2px solid var(--exp-builder-blue500);\n}\n\n.styles-module_DraggableClone__X8zTA,\n.styles-module_DraggableClone__X8zTA * {\n pointer-events: none !important;\n}\n\n.styles-module_DraggableComponent__m5-dA:not(.styles-module_userIsDragging__lqbjG) :not(.styles-module_DraggableComponent__m5-dA) {\n pointer-events: none;\n}\n\n.styles-module_isDragging__WHjPU {\n overflow: hidden;\n}\n\n.styles-module_isSelected__BzICQ:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_overlay__r4th9 {\n position: absolute;\n display: flex;\n align-items: center;\n min-width: max-content;\n height: 24px;\n z-index: 2;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 14px;\n font-weight: 500;\n background-color: var(--exp-builder-gray500);\n color: var(--exp-builder-color-white);\n padding: 4px 12px 4px 12px;\n transition: opacity 0.1s;\n opacity: 0;\n text-wrap: nowrap;\n}\n\n.styles-module_overlayContainer__eiX-5 {\n opacity: 0;\n}\n\n.styles-module_overlayAssembly__tOzZU {\n background-color: var(--exp-builder-purple600);\n}\n\n.styles-module_userIsDragging__lqbjG > .styles-module_overlay__r4th9,\n.styles-module_userIsDragging__lqbjG > .styles-module_overlayContainer__eiX-5 {\n opacity: 0 !important;\n}\n\n.styles-module_userIsDragging__lqbjG:before {\n outline: 2px solid transparent !important;\n}\n\n.styles-module_isHoveringComponent__RSeDG > .styles-module_overlay__r4th9,\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(.styles-module_DraggableComponent__m5-dA:hover)) > .styles-module_overlay__r4th9 {\n opacity: 1;\n}\n\n/* hovering related component in layers tab */\n\n.styles-module_DraggableComponent__m5-dA:has(.styles-module_isHoveringComponent__RSeDG):not(.styles-module_isAssemblyBlock__Y3Avk):before,\n.styles-module_DraggableComponent__m5-dA:has(.styles-module_isHoveringComponent__RSeDG):not(.styles-module_isAssemblyBlock__Y3Avk) .styles-module_DraggableComponent__m5-dA:not(.styles-module_isHoveringComponent__RSeDG):not(.styles-module_isAssemblyBlock__Y3Avk):before,\n.styles-module_isHoveringComponent__RSeDG:not(.styles-module_isAssemblyBlock__Y3Avk) .styles-module_DraggableComponent__m5-dA:not(.styles-module_isAssemblyBlock__Y3Avk):before,\n\n.styles-module_DraggableComponent__m5-dA:hover:before,\n.styles-module_DraggableComponent__m5-dA:hover .styles-module_DraggableComponent__m5-dA:before {\n outline: 2px dashed var(--exp-builder-gray500);\n}\n\n/* hovering component in layers tab */\n\n.styles-module_isHoveringComponent__RSeDG:not(.styles-module_isAssemblyBlock__Y3Avk):before,\n\n.styles-module_DraggableComponent__m5-dA:hover:not(:has(.styles-module_DraggableComponent__m5-dA:hover)):before {\n outline: 2px solid var(--exp-builder-gray500);\n}\n\n/* hovering related pattern in layers tab */\n\n.styles-module_isAssemblyBlock__Y3Avk:has(.styles-module_isHoveringComponent__RSeDG):before,\n.styles-module_isAssemblyBlock__Y3Avk:has(.styles-module_isHoveringComponent__RSeDG) .styles-module_isAssemblyBlock__Y3Avk:not(.styles-module_isHoveringComponent__RSeDG):before,\n.styles-module_isHoveringComponent__RSeDG .styles-module_isAssemblyBlock__Y3Avk:before,\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:before,\n.styles-module_isAssemblyBlock__Y3Avk:hover .styles-module_DraggableComponent__m5-dA:before,\n.styles-module_DraggableComponent__m5-dA:hover .styles-module_isAssemblyBlock__Y3Avk:before {\n outline: 2px dashed var(--exp-builder-purple600);\n}\n\n/* hovering pattern in layers tab */\n\n.styles-module_isAssemblyBlock__Y3Avk.styles-module_isHoveringComponent__RSeDG:before,\n\n.styles-module_isAssemblyBlock__Y3Avk:hover:not(:has(.styles-module_DraggableComponent__m5-dA:hover)):before {\n outline: 2px solid var(--exp-builder-purple600);\n}\n";
50020
+ var styles$3 = {"DraggableComponent":"styles-module_DraggableComponent__m5-dA","DraggableClone":"styles-module_DraggableClone__X8zTA","userIsDragging":"styles-module_userIsDragging__lqbjG","isDragging":"styles-module_isDragging__WHjPU","isSelected":"styles-module_isSelected__BzICQ","overlay":"styles-module_overlay__r4th9","overlayContainer":"styles-module_overlayContainer__eiX-5","overlayAssembly":"styles-module_overlayAssembly__tOzZU","isHoveringComponent":"styles-module_isHoveringComponent__RSeDG","isAssemblyBlock":"styles-module_isAssemblyBlock__Y3Avk"};
50021
50021
  styleInject(css_248z$8);
50022
50022
 
50023
50023
  const SCROLL_STATES = {
@@ -50313,6 +50313,7 @@ const create = (createState) => createState ? createImpl(createState) : createIm
50313
50313
 
50314
50314
  const useDraggedItemStore = create((set) => ({
50315
50315
  draggedItem: undefined,
50316
+ hoveredComponentId: undefined,
50316
50317
  domRect: undefined,
50317
50318
  componentId: '',
50318
50319
  isDraggingOnCanvas: false,
@@ -50323,6 +50324,9 @@ const useDraggedItemStore = create((set) => ({
50323
50324
  setComponentId(id) {
50324
50325
  set({ componentId: id });
50325
50326
  },
50327
+ setHoveredComponentId(id) {
50328
+ set({ hoveredComponentId: id });
50329
+ },
50326
50330
  updateItem: (item) => {
50327
50331
  set({ draggedItem: item });
50328
50332
  },
@@ -50573,6 +50577,7 @@ function getStyle$2(style, snapshot) {
50573
50577
  const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, coordinates, userIsDragging, style, wrapperProps, isContainer, blockId, isDragDisabled = false, placeholder, definition, ...rest }) => {
50574
50578
  const ref = reactExports.useRef(null);
50575
50579
  const setDomRect = useDraggedItemStore((state) => state.setDomRect);
50580
+ const isHoveredComponent = useDraggedItemStore((state) => state.hoveredComponentId === id);
50576
50581
  useDraggablePosition({
50577
50582
  draggableId: id,
50578
50583
  draggableRef: ref,
@@ -50586,6 +50591,7 @@ const DraggableComponent = ({ children, id, index, isAssemblyBlock = false, isSe
50586
50591
  [styles$3.isDragging]: snapshot.isDragging,
50587
50592
  [styles$3.isSelected]: isSelected,
50588
50593
  [styles$3.userIsDragging]: userIsDragging,
50594
+ [styles$3.isHoveringComponent]: isHoveredComponent,
50589
50595
  }), style: {
50590
50596
  ...style,
50591
50597
  ...getStyle$2(provided.draggableProps.style, snapshot),
@@ -51764,6 +51770,7 @@ const useComponent = ({ node: rawNode, resolveDesignValue, renderDropzone, userI
51764
51770
  */
51765
51771
  const DraggableChildComponent = (props) => {
51766
51772
  const { elementToRender, id, index, isAssemblyBlock = false, isSelected = false, onClick = () => null, coordinates, userIsDragging, style, isContainer, blockId, isDragDisabled = false, wrapperProps, definition, } = props;
51773
+ const isHoveredComponent = useDraggedItemStore((state) => state.hoveredComponentId === id);
51767
51774
  return (React.createElement(PublicDraggable, { key: id, draggableId: id, index: index, isDragDisabled: isDragDisabled }, (provided, snapshot) => elementToRender({
51768
51775
  ['data-ctfl-draggable-id']: id,
51769
51776
  ['data-test-id']: `draggable-${blockId}`,
@@ -51775,6 +51782,7 @@ const DraggableChildComponent = (props) => {
51775
51782
  [styles$3.isDragging]: snapshot.isDragging,
51776
51783
  [styles$3.isSelected]: isSelected,
51777
51784
  [styles$3.userIsDragging]: userIsDragging,
51785
+ [styles$3.isHoveringComponent]: isHoveredComponent,
51778
51786
  }),
51779
51787
  dragHandleProps: provided.dragHandleProps,
51780
51788
  style: {
@@ -53035,10 +53043,10 @@ const EditorBlock = ({ node: rawNode, resolveDesignValue, renderDropzone, index,
53035
53043
  };
53036
53044
  if (node.data.blockId === CONTENTFUL_COMPONENTS.singleColumn.id) {
53037
53045
  return (React.createElement(React.Fragment, null,
53038
- React.createElement(DraggableChildComponent, { elementToRender: elementToRender, id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isSingleColumn, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, definition: definition }),
53046
+ React.createElement(DraggableChildComponent, { elementToRender: elementToRender, id: componentId, index: index, isAssemblyBlock: isAssembly || isAssemblyBlock, isDragDisabled: isSingleColumn, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick, definition: definition }),
53039
53047
  isStructureComponent && !isSingleColumn && userIsDragging && (React.createElement(Hitboxes, { parentZoneId: zoneId, zoneId: componentId, isEmptyZone: isEmptyZone }))));
53040
53048
  }
53041
- return (React.createElement(DraggableComponent, { placeholder: placeholder, definition: definition, id: componentId, index: index, isAssemblyBlock: isAssemblyBlock, isDragDisabled: isAssemblyBlock, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick },
53049
+ return (React.createElement(DraggableComponent, { placeholder: placeholder, definition: definition, id: componentId, index: index, isAssemblyBlock: isAssembly || isAssemblyBlock, isDragDisabled: isAssemblyBlock, isSelected: selectedNodeId === componentId, userIsDragging: userIsDragging, isContainer: isContainer, blockId: node.data.blockId, coordinates: coordinates, wrapperProps: wrapperProps, onClick: onClick },
53042
53050
  elementToRender(),
53043
53051
  isStructureComponent && !isSingleColumn && userIsDragging && (React.createElement(Hitboxes, { parentZoneId: zoneId, zoneId: componentId, isEmptyZone: isEmptyZone }))));
53044
53052
  };
@@ -53137,8 +53145,8 @@ function DropzoneClone({ node, zoneId, resolveDesignValue, className, WrapperCom
53137
53145
  function Dropzone({ node, zoneId, resolveDesignValue, className, WrapperComponent = 'div', ...rest }) {
53138
53146
  const userIsDragging = useDraggedItemStore((state) => state.isDraggingOnCanvas);
53139
53147
  const draggedItem = useDraggedItemStore((state) => state.draggedItem);
53140
- const newComponentId = useDraggedItemStore((state) => state.componentId);
53141
- const hoveringZone = useZoneStore((state) => state.hoveringZone);
53148
+ const isDraggingNewComponent = useDraggedItemStore((state) => Boolean(state.componentId));
53149
+ const isHoveringZone = useZoneStore((state) => state.hoveringZone === zoneId);
53142
53150
  const tree = useTreeStore((state) => state.tree);
53143
53151
  const content = node?.children || tree.root?.children || [];
53144
53152
  const direction = useDropzoneDirection({ resolveDesignValue, node, zoneId });
@@ -53148,8 +53156,6 @@ function Dropzone({ node, zoneId, resolveDesignValue, className, WrapperComponen
53148
53156
  return;
53149
53157
  return getItem({ id: draggedItem.draggableId }, tree)?.data.blockId;
53150
53158
  }, [draggedItem, tree]);
53151
- const isDraggingNewComponent = !!newComponentId;
53152
- const isHoveringZone = hoveringZone === zoneId;
53153
53159
  const isRootZone = zoneId === ROOT_ID;
53154
53160
  const isDestination = draggedDestinationId === zoneId;
53155
53161
  const isEmptyCanvas = isRootZone && !content.length;
@@ -53289,173 +53295,6 @@ const useBreakpoints = (breakpoints) => {
53289
53295
  return { resolveDesignValue };
53290
53296
  };
53291
53297
 
53292
- class MouseOverHandler {
53293
- constructor() {
53294
- this.currentHoveredElementId = null;
53295
- this.getMargins = (element) => {
53296
- if (typeof window === 'undefined')
53297
- return undefined;
53298
- const styles = window.getComputedStyle(element);
53299
- const top = parseInt(styles.marginTop);
53300
- const bottom = parseInt(styles.marginBottom);
53301
- const left = parseInt(styles.marginLeft);
53302
- const right = parseInt(styles.marginRight);
53303
- return { top, bottom, left, right };
53304
- };
53305
- this.getFullCoordinates = (element) => {
53306
- const validChildren = Array.from(element.children).filter((child) => child instanceof HTMLElement && child.dataset.cfNodeBlockType === 'block');
53307
- const { left, top, width, height } = this.getBoundingClientRect(element);
53308
- const margins = this.getMargins(element);
53309
- const childrenCoordinates = validChildren.map((child) => {
53310
- const { left, top, width, height } = this.getBoundingClientRect(child);
53311
- return { left, top, width, height, margins };
53312
- });
53313
- return {
53314
- left,
53315
- top,
53316
- width,
53317
- height,
53318
- margins,
53319
- childrenCoordinates,
53320
- };
53321
- };
53322
- this.getClosestComponentInformation = (element) => {
53323
- let target = element;
53324
- // If the target is outside on the root or anywhere else on the iframes body
53325
- if (target?.id === 'VisualEditorRoot' || target?.tagName === 'BODY') {
53326
- const rootElement = document.getElementById('VisualEditorRoot');
53327
- const hoveredRootElement = {
53328
- nodeId: 'root',
53329
- blockType: 'root',
53330
- blockId: 'root',
53331
- };
53332
- return [rootElement, hoveredRootElement];
53333
- }
53334
- // Find the closest contentful container or direct parent that is a contentful container
53335
- while (target) {
53336
- if (
53337
- // is itself a section?
53338
- target.dataset.cfNodeId ||
53339
- // Or a direct child of a section
53340
- (target.parentElement && target.parentElement.dataset.cfNodeBlockId === 'ContentfulSection')) {
53341
- const sectionId = target.dataset.cfNodeId;
53342
- const sectionBlockId = target.dataset.cfNodeBlockId;
53343
- const sectionBlockType = target.dataset.cfNodeBlockType;
53344
- const hoveredElement = {
53345
- nodeId: sectionId,
53346
- blockId: sectionBlockId,
53347
- blockType: sectionBlockType,
53348
- };
53349
- return [target, hoveredElement];
53350
- }
53351
- target = target.parentElement;
53352
- }
53353
- };
53354
- this.getNewlyHoveredElement = (element) => {
53355
- let parentElement = null;
53356
- let parentSectionIndex = -1;
53357
- const [hoveredElement, hoveredInfo] = this.getClosestComponentInformation(element) || [
53358
- null,
53359
- null,
53360
- ];
53361
- if (!hoveredElement)
53362
- return;
53363
- // if hovered element is already hovered and the information is already sent
53364
- // ignore the rest and don't proceed.
53365
- if (hoveredInfo.nodeId === this.currentHoveredElementId)
53366
- return;
53367
- let parentHTMLElement = hoveredElement?.parentElement || null;
53368
- while (parentHTMLElement) {
53369
- const parentIsRoot = parentHTMLElement.id === 'VisualEditorRoot';
53370
- if (parentHTMLElement.dataset.cfNodeId || parentIsRoot) {
53371
- parentElement = {
53372
- nodeId: parentIsRoot ? 'root' : parentHTMLElement.dataset.cfNodeId,
53373
- blockType: parentHTMLElement.dataset.cfNodeBlockType,
53374
- blockId: parentHTMLElement.dataset.cfNodeBlockId,
53375
- };
53376
- const parentChildrenElements = parentHTMLElement.children;
53377
- parentSectionIndex = Array.from(parentChildrenElements).findIndex((child) => child === hoveredElement);
53378
- break;
53379
- }
53380
- parentHTMLElement = parentHTMLElement.parentElement;
53381
- }
53382
- const coordinates = this.getFullCoordinates(hoveredElement);
53383
- return { coordinates, hoveredElement: hoveredInfo, parentElement, parentSectionIndex };
53384
- };
53385
- this.handleMouseMove = (target) => {
53386
- const hoveredElementInfo = this.getNewlyHoveredElement(target);
53387
- if (!hoveredElementInfo) {
53388
- return;
53389
- }
53390
- const { coordinates, hoveredElement, parentElement, parentSectionIndex } = hoveredElementInfo;
53391
- this.currentHoveredElementId = hoveredElementInfo.hoveredElement.nodeId || null;
53392
- sendMessage(OUTGOING_EVENTS.NewHoveredElement, {
53393
- hoveredElement,
53394
- parentElement,
53395
- parentSectionIndex,
53396
- coordinates,
53397
- });
53398
- };
53399
- this.onMouseMove = (event) => {
53400
- const target = event.target;
53401
- this.handleMouseMove(target);
53402
- };
53403
- this.onMouseLeave = () => {
53404
- this.currentHoveredElementId = null;
53405
- };
53406
- }
53407
- getBoundingClientRect(element) {
53408
- const isAssembly = element.getAttribute('data-cf-node-block-type') === ASSEMBLY_NODE_TYPE;
53409
- if (!isAssembly) {
53410
- return element.getBoundingClientRect();
53411
- }
53412
- else {
53413
- // As we use `display: contents` for assemblies, there is no real "block"
53414
- // in the DOM and thus the browser fails to calculate the bounding rect.
53415
- // Instead, we calculate it for each child and add it up:
53416
- if (!element.firstElementChild) {
53417
- return { left: 0, top: 0, width: 0, height: 0 };
53418
- }
53419
- const firstChildRect = element.firstElementChild.getBoundingClientRect();
53420
- let fullHeight = firstChildRect.height;
53421
- let nextChild = element.firstElementChild.nextElementSibling;
53422
- while (nextChild) {
53423
- const nextChildRect = nextChild.getBoundingClientRect();
53424
- fullHeight += nextChildRect.height;
53425
- nextChild = nextChild.nextElementSibling;
53426
- }
53427
- // The root of a assembly positions its first level containers vertically.
53428
- // So we just need to add up the height and use the remaining properties from the first child.
53429
- return {
53430
- left: firstChildRect.left,
53431
- top: firstChildRect.top,
53432
- width: firstChildRect.width,
53433
- height: fullHeight,
53434
- };
53435
- }
53436
- }
53437
- attachEvent() {
53438
- document.addEventListener('mousemove', this.onMouseMove);
53439
- document.addEventListener('mouseout', this.onMouseLeave);
53440
- }
53441
- detachEvent() {
53442
- document.removeEventListener('mousemove', this.onMouseMove);
53443
- document.removeEventListener('mouseout', this.onMouseLeave);
53444
- }
53445
- }
53446
-
53447
- /**
53448
- * This function gets the element co-ordinates of a specified component in the DOM and its parent
53449
- * and sends the DOM Rect to the client app
53450
- */
53451
- const sendHoveredComponentCoordinates = (instanceId) => {
53452
- const selectedElement = instanceId
53453
- ? document.querySelector(`[data-cf-node-id="${instanceId}"]`)
53454
- : undefined;
53455
- const mouseOverHandler = new MouseOverHandler();
53456
- mouseOverHandler.handleMouseMove(selectedElement || null);
53457
- };
53458
-
53459
53298
  class DragState {
53460
53299
  constructor() {
53461
53300
  this.isDragStartedOnParent = false;
@@ -53542,6 +53381,7 @@ function useEditorSubscriber() {
53542
53381
  const selectedNodeId = useEditorStore((state) => state.selectedNodeId);
53543
53382
  const resetEntityStore = useEntityStore((state) => state.resetEntityStore);
53544
53383
  const setComponentId = useDraggedItemStore((state) => state.setComponentId);
53384
+ const setHoveredComponentId = useDraggedItemStore((state) => state.setHoveredComponentId);
53545
53385
  const setDraggingOnCanvas = useDraggedItemStore((state) => state.setDraggingOnCanvas);
53546
53386
  const setMousePosition = useDraggedItemStore((state) => state.setMousePosition);
53547
53387
  const setScrollY = useDraggedItemStore((state) => state.setScrollY);
@@ -53735,7 +53575,7 @@ function useEditorSubscriber() {
53735
53575
  }
53736
53576
  case INCOMING_EVENTS.HoverComponent: {
53737
53577
  const { hoveredNodeId } = payload;
53738
- sendHoveredComponentCoordinates(hoveredNodeId);
53578
+ setHoveredComponentId(hoveredNodeId);
53739
53579
  break;
53740
53580
  }
53741
53581
  case INCOMING_EVENTS.ComponentDraggingChanged: {
@@ -53831,6 +53671,7 @@ function useEditorSubscriber() {
53831
53671
  updateNodesByUpdatedEntity,
53832
53672
  setMousePosition,
53833
53673
  resetEntityStore,
53674
+ setHoveredComponentId,
53834
53675
  ]);
53835
53676
  /*
53836
53677
  * Handles on scroll business
@@ -54166,12 +54007,17 @@ const RootRenderer = ({ onChange }) => {
54166
54007
  useEditorSubscriber();
54167
54008
  const dragItem = useDraggedItemStore((state) => state.componentId);
54168
54009
  const userIsDragging = useDraggedItemStore((state) => state.isDraggingOnCanvas);
54010
+ const setHoveredComponentId = useDraggedItemStore((state) => state.setHoveredComponentId);
54169
54011
  const breakpoints = useTreeStore((state) => state.breakpoints);
54170
54012
  const setSelectedNodeId = useEditorStore((state) => state.setSelectedNodeId);
54171
54013
  const containerRef = reactExports.useRef(null);
54172
54014
  const { resolveDesignValue } = useBreakpoints(breakpoints);
54173
54015
  const [containerStyles, setContainerStyles] = reactExports.useState({});
54174
54016
  const tree = useTreeStore((state) => state.tree);
54017
+ const handleMouseOver = reactExports.useCallback(() => {
54018
+ // Remove hover state set by UI when mouse is over canvas
54019
+ setHoveredComponentId();
54020
+ }, [setHoveredComponentId]);
54175
54021
  const handleClickOutside = reactExports.useCallback((e) => {
54176
54022
  const element = e.target;
54177
54023
  const isRoot = element.getAttribute('data-ctfl-zone-id') === ROOT_ID;
@@ -54220,6 +54066,12 @@ const RootRenderer = ({ onChange }) => {
54220
54066
  if (onChange)
54221
54067
  onChange(tree);
54222
54068
  }, [tree, onChange]);
54069
+ reactExports.useEffect(() => {
54070
+ window.addEventListener('mouseover', handleMouseOver);
54071
+ return () => {
54072
+ window.removeEventListener('mouseover', handleMouseOver);
54073
+ };
54074
+ }, [handleMouseOver]);
54223
54075
  reactExports.useEffect(() => {
54224
54076
  document.addEventListener('click', handleClickOutside);
54225
54077
  return () => {