@se-studio/contentful-rest-api 1.0.26 → 1.0.27

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 CHANGED
@@ -34,6 +34,8 @@ interface BaseMediaFields {
34
34
  hideControls?: EntryFieldTypes.Boolean;
35
35
  horizontalPosition?: EntryFieldTypes.Symbol<'Left' | 'Middle' | 'Right'>;
36
36
  width?: EntryFieldTypes.Integer;
37
+ mask?: EntryFieldTypes.Symbol<'Circle' | 'Pill' | 'Rounded diamond' | 'Rounded rectangle' | 'Rounded square'>;
38
+ maskImage?: EntryFieldTypes.AssetLink;
37
39
  }
38
40
  type BaseMediaSkeleton = EntrySkeletonType<BaseMediaFields, 'media'>;
39
41
 
@@ -403,6 +405,7 @@ type LinkResolverFunction<TResult extends IInternalLink = IInternalLink> = (cont
403
405
  type LinkResolverMap = Map<string, LinkResolverFunction>;
404
406
  type BaseConverterContext = {
405
407
  videoPrefix: string;
408
+ maskResolver?: (maskName: string) => string | undefined;
406
409
  linkResolver: LinkResolverMap;
407
410
  contentResolver: Map<string, (context: ConverterContext, entry: Entry<BaseContent, DefaultChainModifier, string>) => unknown>;
408
411
  navigationItemResolver: typeof baseNavigationItemConverter;
package/dist/index.js CHANGED
@@ -719,14 +719,26 @@ function convertMediaEntryToVisual(context, entry) {
719
719
  if (!fields) return void 0;
720
720
  const baseVisual = lookupAsset(context, fields.asset);
721
721
  if (!baseVisual) return void 0;
722
- const { name, ...otherFields } = fields;
722
+ const { name, mask: maskDropdown, maskImage, ...otherFields } = fields;
723
+ let mask;
724
+ if (maskImage) {
725
+ const maskVisual = lookupAsset(context, maskImage);
726
+ if (maskVisual?.image?.type === "Svg image") {
727
+ mask = maskVisual.image.svgSrc;
728
+ } else if (maskVisual?.image?.type === "Picture") {
729
+ mask = maskVisual.image.src;
730
+ }
731
+ } else if (maskDropdown && context.maskResolver) {
732
+ mask = context.maskResolver(maskDropdown);
733
+ }
723
734
  const metadata = {
724
735
  name: makeContentfulTitle(name, sys.id),
725
736
  ...otherFields
726
737
  };
727
738
  const visual = {
728
739
  ...baseVisual,
729
- id: sys.id
740
+ id: sys.id,
741
+ mask
730
742
  };
731
743
  if (baseVisual.image) {
732
744
  visual.image = {