@contentful/experiences-visual-editor-react 3.3.1-dev-20250825T1222-bc8206a.0 → 3.4.0-dev-20250825T1512-8bcc4b9.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
@@ -1011,6 +1011,18 @@ var CodeNames$1;
1011
1011
  CodeNames["Custom"] = "custom";
1012
1012
  })(CodeNames$1 || (CodeNames$1 = {}));
1013
1013
 
1014
+ const sdkOptionsRegistry = {};
1015
+ /**
1016
+ * Used inside defineComponents to forward registry arguments to this registry
1017
+ * of SDK options.
1018
+ */
1019
+ const defineSdkOptions = (options) => {
1020
+ Object.assign(sdkOptionsRegistry, options);
1021
+ };
1022
+ const getSdkOptions = () => {
1023
+ return { ...sdkOptionsRegistry };
1024
+ };
1025
+
1014
1026
  const MEDIA_QUERY_REGEXP = /(<|>)(\d{1,})(px|cm|mm|in|pt|pc)$/;
1015
1027
  const toCSSMediaQuery = ({ query }) => {
1016
1028
  if (query === '*')
@@ -1595,6 +1607,20 @@ const transformBackgroundImage = (cfBackgroundImageUrl, cfBackgroundImageOptions
1595
1607
  backgroundSize: matchBackgroundSize(cfBackgroundImageOptions?.scaling),
1596
1608
  };
1597
1609
  };
1610
+ const transformTextAlign = (value) => {
1611
+ if (!value)
1612
+ return undefined;
1613
+ const sdkOptions = getSdkOptions();
1614
+ // New behavior: translate left/right to start/end
1615
+ // Customer can opt-out by activating this global option toggle
1616
+ if (!sdkOptions.__disableTextAlignmentTransform) {
1617
+ if (value === 'left')
1618
+ return 'start';
1619
+ if (value === 'right')
1620
+ return 'end';
1621
+ }
1622
+ return value;
1623
+ };
1598
1624
 
1599
1625
  const toCSSAttribute = (key) => {
1600
1626
  let val = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
@@ -1672,7 +1698,7 @@ const buildCfStyles = (values) => {
1672
1698
  lineHeight: values.cfLineHeight,
1673
1699
  letterSpacing: values.cfLetterSpacing,
1674
1700
  color: values.cfTextColor,
1675
- textAlign: values.cfTextAlign,
1701
+ textAlign: transformTextAlign(values.cfTextAlign),
1676
1702
  textTransform: values.cfTextTransform,
1677
1703
  objectFit: values.cfImageOptions?.objectFit,
1678
1704
  objectPosition: values.cfImageOptions?.objectPosition,
@@ -3240,12 +3266,14 @@ const useEditorStore = create((set, get) => ({
3240
3266
  }
3241
3267
  set({ locale });
3242
3268
  },
3243
- initializeEditor({ componentRegistry: initialRegistry, designTokens, initialLocale }) {
3269
+ initializeEditor({ componentRegistry: initialRegistry, designTokens, sdkOptions, initialLocale, }) {
3244
3270
  initialRegistry.forEach((registration) => {
3245
3271
  componentRegistry.set(registration.definition.id, registration);
3246
3272
  });
3247
3273
  // Re-register the design tokens with the Visual Editor's instance of the experiences-core package
3248
3274
  defineDesignTokens(designTokens);
3275
+ // Same copy over from one instance to the other is necessary for the sdk options
3276
+ defineSdkOptions(sdkOptions);
3249
3277
  set({ locale: initialLocale });
3250
3278
  },
3251
3279
  }));
@@ -5171,11 +5199,12 @@ const useInitializeEditor = (inMemoryEntitiesStore) => {
5171
5199
  const onVisualEditorInitialize = (event) => {
5172
5200
  if (!event.detail)
5173
5201
  return;
5174
- const { componentRegistry, designTokens, locale: initialLocale, entities } = event.detail;
5202
+ const { componentRegistry, designTokens, sdkOptions, locale: initialLocale, entities, } = event.detail;
5175
5203
  initializeEditor({
5176
5204
  initialLocale,
5177
5205
  componentRegistry,
5178
5206
  designTokens,
5207
+ sdkOptions,
5179
5208
  });
5180
5209
  // if entities is set to [], then everything will still work as EntityStore will
5181
5210
  // request entities on demand via ▲REQUEST_ENTITY