@contentful/experiences-visual-editor-react 3.5.0-dev-20250902T0640-ab0b512.0 → 3.6.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
@@ -4917,6 +4917,31 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
4917
4917
  styles: componentStyles,
4918
4918
  nodeId: node.data.id,
4919
4919
  });
4920
+ // Allows custom components to render differently in the editor. This needs to be activated
4921
+ // through registry options as the component has to be aware of this prop to not cause any React warnings.
4922
+ const editorProps = useMemo(() => {
4923
+ const editorProps = {};
4924
+ if (options?.enableEditorProperties?.isEditorMode) {
4925
+ editorProps.isEditorMode = true;
4926
+ }
4927
+ if (options?.enableEditorProperties?.isEmpty) {
4928
+ editorProps.isEmpty = node.children.length === 0;
4929
+ }
4930
+ if (options?.enableEditorProperties?.nodeBlockId) {
4931
+ editorProps.nodeBlockId = node.data.blockId;
4932
+ }
4933
+ if (options?.enableCustomEditorView) {
4934
+ editorProps.isInExpEditorMode = true;
4935
+ }
4936
+ return editorProps;
4937
+ }, [
4938
+ node.children.length,
4939
+ node.data.blockId,
4940
+ options?.enableEditorProperties?.isEditorMode,
4941
+ options?.enableEditorProperties?.isEmpty,
4942
+ options?.enableEditorProperties?.nodeBlockId,
4943
+ options?.enableCustomEditorView,
4944
+ ]);
4920
4945
  const componentProps = useMemo(() => {
4921
4946
  const sharedProps = {
4922
4947
  'data-cf-node-id': node.data.id,
@@ -4925,22 +4950,12 @@ const useComponentProps = ({ node, entityStore, areEntitiesFetched, resolveDesig
4925
4950
  className: props.cfSsrClassName ?? cfCsrClassName,
4926
4951
  };
4927
4952
  return {
4928
- ...sharedProps,
4929
- // Allows custom components to render differently in the editor. This needs to be activated
4930
- // through options as the component has to be aware of this prop to not cause any React warnings.
4931
- ...(options?.enableCustomEditorView ? { isInExpEditorMode: true } : {}),
4932
- ...(options?.editorProperties?.isEditorMode ? { isEditorMode: true } : {}),
4933
- ...(options?.editorProperties?.node ? { node } : {}),
4934
4953
  ...sanitizeNodeProps(props),
4954
+ // Add those at last to not let them get overwritten by custom properties
4955
+ ...editorProps,
4956
+ ...sharedProps,
4935
4957
  };
4936
- }, [
4937
- cfCsrClassName,
4938
- node,
4939
- options?.editorProperties?.isEditorMode,
4940
- options?.editorProperties?.node,
4941
- options?.enableCustomEditorView,
4942
- props,
4943
- ]);
4958
+ }, [cfCsrClassName, editorProps, node, props]);
4944
4959
  return { componentProps };
4945
4960
  };
4946
4961
 
@@ -4982,7 +4997,9 @@ const RegistrationComponent = ({ node, resolveDesignValue, componentRegistration
4982
4997
  entityStore,
4983
4998
  areEntitiesFetched,
4984
4999
  });
4985
- return React.createElement(ImportedComponentErrorBoundary, { componentId: node.data.blockId }, React.createElement(componentRegistration.component, { ...componentProps, ...slotNodes }, children));
5000
+ return React.createElement(ImportedComponentErrorBoundary, { componentId: node.data.blockId }, React.createElement(componentRegistration.component, { ...componentProps, ...slotNodes },
5001
+ // If there are no children, a custom property called `children` can be passed through to the custom component
5002
+ ...(children ?? [])));
4986
5003
  };
4987
5004
 
4988
5005
  var css_248z$1 = ".EmptyCanvasMessage-module_empty-canvas-container__7K-0l {\n height: 200px;\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: center;\n flex-direction: row;\n transition: all 0.2s;\n color: var(--exp-builder-gray400);\n font-size: var(--exp-builder-font-size-l);\n font-family: var(--exp-builder-font-stack-primary);\n outline: 2px dashed var(--exp-builder-gray400);\n outline-offset: -2px;\n}\n\n.EmptyCanvasMessage-module_empty-canvas-icon__EztFr rect {\n fill: var(--exp-builder-gray400);\n}\n\n.EmptyCanvasMessage-module_empty-canvas-label__cbIrR {\n margin-left: var(--exp-builder-spacing-s);\n}\n";