@contentful/experiences-visual-editor-react 1.8.0 → 1.8.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.js CHANGED
@@ -29,8 +29,8 @@ const INCOMING_EVENTS$1 = {
29
29
  UpdatedEntity: 'updatedEntity',
30
30
  AssembliesAdded: 'assembliesAdded',
31
31
  AssembliesRegistered: 'assembliesRegistered',
32
- InitEditor: 'initEditor',
33
32
  MouseMove: 'mouseMove',
33
+ RequestedEntities: 'REQUESTED_ENTITIES',
34
34
  };
35
35
  const CONTENTFUL_COMPONENTS$1 = {
36
36
  section: {
@@ -1953,7 +1953,6 @@ const OUTGOING_EVENTS = {
1953
1953
  Connected: 'connected',
1954
1954
  DesignTokens: 'registerDesignTokens',
1955
1955
  RegisteredBreakpoints: 'registeredBreakpoints',
1956
- HoveredSection: 'hoveredSection',
1957
1956
  MouseMove: 'mouseMove',
1958
1957
  NewHoveredElement: 'newHoveredElement',
1959
1958
  ComponentSelected: 'componentSelected',
@@ -1964,13 +1963,13 @@ const OUTGOING_EVENTS = {
1964
1963
  ComponentMoved: 'componentMoved',
1965
1964
  CanvasReload: 'canvasReload',
1966
1965
  UpdateSelectedComponentCoordinates: 'updateSelectedComponentCoordinates',
1967
- UpdateHoveredComponentCoordinates: 'updateHoveredComponentCoordinates',
1968
1966
  CanvasScroll: 'canvasScrolling',
1969
1967
  CanvasError: 'canvasError',
1970
1968
  ComponentMoveStarted: 'componentMoveStarted',
1971
1969
  ComponentMoveEnded: 'componentMoveEnded',
1972
1970
  OutsideCanvasClick: 'outsideCanvasClick',
1973
1971
  SDKFeatures: 'sdkFeatures',
1972
+ RequestEntities: 'REQUEST_ENTITIES',
1974
1973
  };
1975
1974
  const INCOMING_EVENTS = {
1976
1975
  RequestEditorMode: 'requestEditorMode',
@@ -1986,8 +1985,8 @@ const INCOMING_EVENTS = {
1986
1985
  UpdatedEntity: 'updatedEntity',
1987
1986
  AssembliesAdded: 'assembliesAdded',
1988
1987
  AssembliesRegistered: 'assembliesRegistered',
1989
- InitEditor: 'initEditor',
1990
1988
  MouseMove: 'mouseMove',
1989
+ RequestedEntities: 'REQUESTED_ENTITIES',
1991
1990
  };
1992
1991
  const INTERNAL_EVENTS = {
1993
1992
  ComponentsRegistered: 'cfComponentsRegistered',
@@ -2495,8 +2494,8 @@ const sendSelectedComponentCoordinates = (instanceId) => {
2495
2494
  selectedNodeCoordinates: getElementCoordinates(selectedElement),
2496
2495
  selectedAssemblyChildCoordinates: selectedAssemblyChild
2497
2496
  ? getElementCoordinates(selectedAssemblyChild)
2498
- : null,
2499
- parentCoordinates: parent ? getElementCoordinates(parent) : null,
2497
+ : undefined,
2498
+ parentCoordinates: parent ? getElementCoordinates(parent) : undefined,
2500
2499
  });
2501
2500
  };
2502
2501
  const childImage = selectedElement.querySelector('img');
@@ -4112,7 +4111,7 @@ function useEditorSubscriber() {
4112
4111
  // TODO: As we have disabled the useEffect, we can remove these states
4113
4112
  const [, /* isFetchingEntities */ setFetchingEntities] = useState(false);
4114
4113
  const reloadApp = () => {
4115
- sendMessage(OUTGOING_EVENTS.CanvasReload, {});
4114
+ sendMessage(OUTGOING_EVENTS.CanvasReload, undefined);
4116
4115
  // Wait a moment to ensure that the message was sent
4117
4116
  setTimeout(() => {
4118
4117
  // Received a hot reload message from webpack dev server -> reload the canvas
@@ -4120,7 +4119,7 @@ function useEditorSubscriber() {
4120
4119
  }, 50);
4121
4120
  };
4122
4121
  useEffect(() => {
4123
- sendMessage(OUTGOING_EVENTS.RequestComponentTreeUpdate);
4122
+ sendMessage(OUTGOING_EVENTS.RequestComponentTreeUpdate, undefined);
4124
4123
  }, []);
4125
4124
  /**
4126
4125
  * Fills up entityStore with entities from newDataSource and from the tree.
@@ -4217,10 +4216,9 @@ function useEditorSubscriber() {
4217
4216
  return;
4218
4217
  }
4219
4218
  console.debug(`[experiences-sdk-react::onMessage] Received message [${eventData.eventType}]`, eventData);
4220
- const { payload } = eventData;
4221
4219
  switch (eventData.eventType) {
4222
4220
  case INCOMING_EVENTS.ExperienceUpdated: {
4223
- const { tree, locale, changedNode, changedValueType, assemblies, } = payload;
4221
+ const { tree, locale, changedNode, changedValueType, assemblies } = eventData.payload;
4224
4222
  // Make sure to first store the assemblies before setting the tree and thus triggering a rerender
4225
4223
  if (assemblies) {
4226
4224
  setAssemblies(assemblies);
@@ -4264,7 +4262,7 @@ function useEditorSubscriber() {
4264
4262
  break;
4265
4263
  }
4266
4264
  case INCOMING_EVENTS.AssembliesRegistered: {
4267
- const { assemblies } = payload;
4265
+ const { assemblies } = eventData.payload;
4268
4266
  assemblies.forEach((definition) => {
4269
4267
  addComponentRegistration({
4270
4268
  component: Assembly,
@@ -4274,7 +4272,7 @@ function useEditorSubscriber() {
4274
4272
  break;
4275
4273
  }
4276
4274
  case INCOMING_EVENTS.AssembliesAdded: {
4277
- const { assembly, assemblyDefinition, } = payload;
4275
+ const { assembly, assemblyDefinition, } = eventData.payload;
4278
4276
  entityStore.updateEntity(assembly);
4279
4277
  // Using a Map here to avoid setting state and rerending all existing assemblies when a new assembly is added
4280
4278
  // TODO: Figure out if we can extend this love to data source and unbound values. Maybe that'll solve the blink
@@ -4291,19 +4289,19 @@ function useEditorSubscriber() {
4291
4289
  break;
4292
4290
  }
4293
4291
  case INCOMING_EVENTS.CanvasResized: {
4294
- const { selectedNodeId } = payload;
4292
+ const { selectedNodeId } = eventData.payload;
4295
4293
  if (selectedNodeId) {
4296
4294
  sendSelectedComponentCoordinates(selectedNodeId);
4297
4295
  }
4298
4296
  break;
4299
4297
  }
4300
4298
  case INCOMING_EVENTS.HoverComponent: {
4301
- const { hoveredNodeId } = payload;
4299
+ const { hoveredNodeId } = eventData.payload;
4302
4300
  setHoveredComponentId(hoveredNodeId);
4303
4301
  break;
4304
4302
  }
4305
4303
  case INCOMING_EVENTS.ComponentDraggingChanged: {
4306
- const { isDragging } = payload;
4304
+ const { isDragging } = eventData.payload;
4307
4305
  if (!isDragging) {
4308
4306
  setComponentId('');
4309
4307
  setDraggingOnCanvas(false);
@@ -4312,7 +4310,7 @@ function useEditorSubscriber() {
4312
4310
  break;
4313
4311
  }
4314
4312
  case INCOMING_EVENTS.UpdatedEntity: {
4315
- const { entity: updatedEntity, shouldRerender } = payload;
4313
+ const { entity: updatedEntity, shouldRerender } = eventData.payload;
4316
4314
  if (updatedEntity) {
4317
4315
  const storedEntity = entityStore.entities.find((entity) => entity.sys.id === updatedEntity.sys.id);
4318
4316
  const didEntityChange = storedEntity?.sys.version !== updatedEntity.sys.version;
@@ -4335,8 +4333,9 @@ function useEditorSubscriber() {
4335
4333
  break;
4336
4334
  }
4337
4335
  case INCOMING_EVENTS.ComponentDragStarted: {
4336
+ const { id } = eventData.payload;
4338
4337
  SimulateDnD$1.setupDrag();
4339
- setComponentId(payload.id || '');
4338
+ setComponentId(id || '');
4340
4339
  setDraggingOnCanvas(true);
4341
4340
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
4342
4341
  nodeId: '',
@@ -4350,13 +4349,13 @@ function useEditorSubscriber() {
4350
4349
  break;
4351
4350
  }
4352
4351
  case INCOMING_EVENTS.SelectComponent: {
4353
- const { selectedNodeId: nodeId } = payload;
4352
+ const { selectedNodeId: nodeId } = eventData.payload;
4354
4353
  setSelectedNodeId(nodeId);
4355
4354
  sendSelectedComponentCoordinates(nodeId);
4356
4355
  break;
4357
4356
  }
4358
4357
  case INCOMING_EVENTS.MouseMove: {
4359
- const { mouseX, mouseY } = payload;
4358
+ const { mouseX, mouseY } = eventData.payload;
4360
4359
  setMousePosition(mouseX, mouseY);
4361
4360
  if (SimulateDnD$1.isDraggingOnParent && !SimulateDnD$1.isDragging) {
4362
4361
  SimulateDnD$1.startDrag(mouseX, mouseY);
@@ -4367,7 +4366,7 @@ function useEditorSubscriber() {
4367
4366
  break;
4368
4367
  }
4369
4368
  case INCOMING_EVENTS.ComponentMoveEnded: {
4370
- const { mouseX, mouseY } = payload;
4369
+ const { mouseX, mouseY } = eventData.payload;
4371
4370
  SimulateDnD$1.endDrag(mouseX, mouseY);
4372
4371
  break;
4373
4372
  }
@@ -4615,7 +4614,7 @@ const DNDProvider = ({ children }) => {
4615
4614
  nodeId: '',
4616
4615
  });
4617
4616
  if (source.droppableId !== COMPONENT_LIST_ID) {
4618
- sendMessage(OUTGOING_EVENTS.ComponentMoveStarted);
4617
+ sendMessage(OUTGOING_EVENTS.ComponentMoveStarted, undefined);
4619
4618
  }
4620
4619
  };
4621
4620
  const beforeCapture = ({ draggableId }) => {
@@ -4635,7 +4634,7 @@ const DNDProvider = ({ children }) => {
4635
4634
  if (!dropResult.destination) {
4636
4635
  if (!draggedItem?.destination) {
4637
4636
  // User cancel drag
4638
- sendMessage(OUTGOING_EVENTS.ComponentDragCanceled);
4637
+ sendMessage(OUTGOING_EVENTS.ComponentDragCanceled, undefined);
4639
4638
  //select the previously selected node if drag was canceled
4640
4639
  if (prevSelectedNodeId.current) {
4641
4640
  setSelectedNodeId(prevSelectedNodeId.current);
@@ -4658,7 +4657,7 @@ const DNDProvider = ({ children }) => {
4658
4657
  }
4659
4658
  // If a node was previously selected prior to dragging, re-select it
4660
4659
  setSelectedNodeId(dropResult.draggableId);
4661
- sendMessage(OUTGOING_EVENTS.ComponentMoveEnded);
4660
+ sendMessage(OUTGOING_EVENTS.ComponentMoveEnded, undefined);
4662
4661
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
4663
4662
  nodeId: dropResult.draggableId,
4664
4663
  });
@@ -4694,7 +4693,7 @@ const RootRenderer = ({ onChange }) => {
4694
4693
  outsideCanvasClick: true,
4695
4694
  });
4696
4695
  sendMessage(OUTGOING_EVENTS.ComponentSelected, {
4697
- selectedId: '',
4696
+ nodeId: '',
4698
4697
  });
4699
4698
  setSelectedNodeId('');
4700
4699
  }, [setSelectedNodeId]);