@contentful/experiences-visual-editor-react 3.1.0-dev-20250807T0841-78e6af6.0 → 3.1.1-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/index.d.ts +3 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +21 -10
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { EntityStore, InMemoryEntitiesStore } from '@contentful/experiences-core';
|
|
3
|
+
import { StudioCanvasMode } from '@contentful/experiences-core/constants';
|
|
3
4
|
import { Experience } from '@contentful/experiences-core/types';
|
|
4
5
|
|
|
5
|
-
declare const VisualEditorRoot: ({ experience, inMemoryEntitiesStore, }: {
|
|
6
|
+
declare const VisualEditorRoot: ({ experience, inMemoryEntitiesStore, canvasMode, }: {
|
|
6
7
|
experience?: Experience<EntityStore>;
|
|
7
8
|
inMemoryEntitiesStore?: InMemoryEntitiesStore;
|
|
9
|
+
canvasMode?: StudioCanvasMode;
|
|
8
10
|
}) => React.JSX.Element | null;
|
|
9
11
|
|
|
10
12
|
export { VisualEditorRoot as default };
|
package/dist/index.js
CHANGED
|
@@ -4398,8 +4398,13 @@ function useEditorSubscriber(inMemoryEntitiesStore) {
|
|
|
4398
4398
|
case INCOMING_EVENTS.RequestEditorMode: {
|
|
4399
4399
|
break;
|
|
4400
4400
|
}
|
|
4401
|
-
default:
|
|
4402
|
-
|
|
4401
|
+
default: {
|
|
4402
|
+
const knownEvents = Object.values(INCOMING_EVENTS);
|
|
4403
|
+
const isDeprecatedMessage = knownEvents.includes(eventData.eventType);
|
|
4404
|
+
if (!isDeprecatedMessage) {
|
|
4405
|
+
console.error(`[experiences-sdk-react::onMessage] Logic error, unsupported eventType: [${eventData.eventType}]`);
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4403
4408
|
}
|
|
4404
4409
|
};
|
|
4405
4410
|
window.addEventListener('message', onMessage);
|
|
@@ -4815,10 +4820,14 @@ const EmptyCanvasMessage = () => {
|
|
|
4815
4820
|
const sendCanvasGeometryUpdatedMessage = async (tree, sourceEvent) => {
|
|
4816
4821
|
const nodeToCoordinatesMap = {};
|
|
4817
4822
|
collectNodeCoordinates(tree.root, nodeToCoordinatesMap);
|
|
4823
|
+
const rootRect = document.documentElement.getBoundingClientRect();
|
|
4824
|
+
const bodyRect = document.body.getBoundingClientRect();
|
|
4825
|
+
const width = Math.max(document.documentElement.offsetWidth, rootRect.width, bodyRect.width);
|
|
4826
|
+
const height = Math.max(document.documentElement.offsetHeight, rootRect.height, bodyRect.height);
|
|
4818
4827
|
sendMessage(OUTGOING_EVENTS.CanvasGeometryUpdated, {
|
|
4819
4828
|
size: {
|
|
4820
|
-
width
|
|
4821
|
-
height
|
|
4829
|
+
width,
|
|
4830
|
+
height,
|
|
4822
4831
|
},
|
|
4823
4832
|
nodes: nodeToCoordinatesMap,
|
|
4824
4833
|
sourceEvent,
|
|
@@ -4863,7 +4872,7 @@ function waitForImageToBeLoaded(imageNode) {
|
|
|
4863
4872
|
});
|
|
4864
4873
|
}
|
|
4865
4874
|
|
|
4866
|
-
const useCanvasGeometryUpdates = ({ tree }) => {
|
|
4875
|
+
const useCanvasGeometryUpdates = ({ tree, canvasMode }) => {
|
|
4867
4876
|
const debouncedUpdateGeometry = useMemo(() => debounce((tree, sourceEvent) => {
|
|
4868
4877
|
// When the DOM changed, we still need to wait for the next frame to ensure that
|
|
4869
4878
|
// rendering is complete (e.g. this is required when deleting a node).
|
|
@@ -4934,6 +4943,8 @@ const useCanvasGeometryUpdates = ({ tree }) => {
|
|
|
4934
4943
|
}, [allImages, loadedImages, debouncedUpdateGeometry]);
|
|
4935
4944
|
// Delegate scrolling to the canvas
|
|
4936
4945
|
useEffect(() => {
|
|
4946
|
+
if (canvasMode !== StudioCanvasMode$2.EDITOR)
|
|
4947
|
+
return;
|
|
4937
4948
|
const onWheel = (e) => {
|
|
4938
4949
|
e.preventDefault();
|
|
4939
4950
|
sendMessage(OUTGOING_EVENTS.CanvasPan, {
|
|
@@ -4947,13 +4958,13 @@ const useCanvasGeometryUpdates = ({ tree }) => {
|
|
|
4947
4958
|
};
|
|
4948
4959
|
document.addEventListener('wheel', onWheel, { passive: false });
|
|
4949
4960
|
return () => document.removeEventListener('wheel', onWheel);
|
|
4950
|
-
}, []);
|
|
4961
|
+
}, [canvasMode]);
|
|
4951
4962
|
};
|
|
4952
4963
|
|
|
4953
|
-
const RootRenderer = ({ inMemoryEntitiesStore }) => {
|
|
4964
|
+
const RootRenderer = ({ inMemoryEntitiesStore, canvasMode }) => {
|
|
4954
4965
|
useEditorSubscriber(inMemoryEntitiesStore);
|
|
4955
4966
|
const tree = useTreeStore((state) => state.tree);
|
|
4956
|
-
useCanvasGeometryUpdates({ tree });
|
|
4967
|
+
useCanvasGeometryUpdates({ tree, canvasMode });
|
|
4957
4968
|
const breakpoints = useTreeStore((state) => state.breakpoints);
|
|
4958
4969
|
const { resolveDesignValue } = useBreakpoints(breakpoints);
|
|
4959
4970
|
// If the root blockId is defined but not the default string, it is the entry ID
|
|
@@ -5002,7 +5013,7 @@ const useInitializeEditor = (inMemoryEntitiesStore) => {
|
|
|
5002
5013
|
return initialized;
|
|
5003
5014
|
};
|
|
5004
5015
|
|
|
5005
|
-
const VisualEditorRoot = ({ experience, inMemoryEntitiesStore: inMemoryEntitiesStore$1 = inMemoryEntitiesStore, }) => {
|
|
5016
|
+
const VisualEditorRoot = ({ experience, inMemoryEntitiesStore: inMemoryEntitiesStore$1 = inMemoryEntitiesStore, canvasMode, }) => {
|
|
5006
5017
|
const initialized = useInitializeEditor(inMemoryEntitiesStore$1);
|
|
5007
5018
|
const setHyperLinkPattern = useEditorStore((state) => state.setHyperLinkPattern);
|
|
5008
5019
|
useEffect(() => {
|
|
@@ -5012,7 +5023,7 @@ const VisualEditorRoot = ({ experience, inMemoryEntitiesStore: inMemoryEntitiesS
|
|
|
5012
5023
|
}, [experience?.hyperlinkPattern, setHyperLinkPattern]);
|
|
5013
5024
|
if (!initialized)
|
|
5014
5025
|
return null;
|
|
5015
|
-
return React.createElement(RootRenderer, { inMemoryEntitiesStore: inMemoryEntitiesStore$1 });
|
|
5026
|
+
return React.createElement(RootRenderer, { inMemoryEntitiesStore: inMemoryEntitiesStore$1, canvasMode: canvasMode });
|
|
5016
5027
|
};
|
|
5017
5028
|
|
|
5018
5029
|
export { VisualEditorRoot as default };
|