@contentful/experiences-visual-editor-react 1.40.0-alpha-20250604T0813-1f6e699.0 → 1.40.0-alpha-20250604T1545-078bcac.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
@@ -4228,7 +4228,7 @@ const waitForAllImagesToBeLoaded = () => {
4228
4228
  }));
4229
4229
  };
4230
4230
 
4231
- const useCanvasGeometryUpdates = ({ tree, rootContainerRef, }) => {
4231
+ const useCanvasGeometryUpdates = ({ tree }) => {
4232
4232
  const debouncedUpdateGeometry = useMemo(() => debounce((tree, sourceEvent) => {
4233
4233
  // When the DOM changed, we still need to wait for the next frame to ensure that
4234
4234
  // rendering is complete (e.g. this is required when deleting a node).
@@ -4255,22 +4255,19 @@ const useCanvasGeometryUpdates = ({ tree, rootContainerRef, }) => {
4255
4255
  }, [debouncedUpdateGeometry]);
4256
4256
  // Handling DOM mutations
4257
4257
  useEffect(() => {
4258
- if (!rootContainerRef.current)
4259
- return;
4260
4258
  const observer = new MutationObserver(() => debouncedUpdateGeometry(treeRef.current, 'mutation'));
4261
- observer.observe(rootContainerRef.current, {
4259
+ observer.observe(document.documentElement, {
4262
4260
  childList: true,
4263
4261
  subtree: true,
4264
4262
  attributes: true,
4265
4263
  });
4266
4264
  return () => observer.disconnect();
4267
- }, [debouncedUpdateGeometry, rootContainerRef]);
4265
+ }, [debouncedUpdateGeometry]);
4268
4266
  };
4269
4267
 
4270
4268
  const RootRenderer = () => {
4271
- const rootContainerRef = useRef(null);
4272
4269
  const tree = useTreeStore((state) => state.tree);
4273
- useCanvasGeometryUpdates({ tree, rootContainerRef });
4270
+ useCanvasGeometryUpdates({ tree });
4274
4271
  useEditorSubscriber();
4275
4272
  const breakpoints = useTreeStore((state) => state.breakpoints);
4276
4273
  const { resolveDesignValue } = useBreakpoints(breakpoints);
@@ -4279,7 +4276,7 @@ const RootRenderer = () => {
4279
4276
  const rootBlockId = tree.root.data.blockId ?? ROOT_ID;
4280
4277
  const wrappingPatternIds = rootBlockId !== ROOT_ID ? new Set([rootBlockId]) : new Set();
4281
4278
  return (React.createElement(React.Fragment, null,
4282
- React.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer, ref: rootContainerRef }, !tree.root.children.length ? (React.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds })))))));
4279
+ React.createElement("div", { "data-ctfl-root": true, className: styles$2.rootContainer }, !tree.root.children.length ? (React.createElement(EmptyCanvasMessage, null)) : (tree.root.children.map((topLevelChildNode) => (React.createElement(EditorBlock, { key: topLevelChildNode.data.id, node: topLevelChildNode, resolveDesignValue: resolveDesignValue, wrappingPatternIds: wrappingPatternIds })))))));
4283
4280
  };
4284
4281
 
4285
4282
  const useInitializeEditor = () => {