@contentful/field-editor-markdown 1.0.1 → 1.0.2

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.
@@ -22,6 +22,7 @@ import Markdown from 'markdown-to-jsx';
22
22
  import DOMPurify from 'dompurify';
23
23
  import inRange from 'lodash-es/inRange';
24
24
  import isObject from 'lodash-es/isObject';
25
+ import { toExternal } from '@contentful/hostname-transformer';
25
26
  import extend from 'lodash-es/extend';
26
27
  import isString from 'lodash-es/isString';
27
28
  import isFinite from 'lodash-es/isFinite';
@@ -3597,10 +3598,17 @@ function makeAssetLink(asset, _ref) {
3597
3598
 
3598
3599
  if (isObject(file) && file.url) {
3599
3600
  var title = get(asset, ['fields', 'title', localeCode]) || get(asset, ['fields', 'title', fallbackCode || '']) || get(asset, ['fields', 'title', defaultLocaleCode]) || fileNameToTitle(file.fileName);
3601
+ var assetDomainMap = {
3602
+ images: 'images.ctfassets.net',
3603
+ assets: 'assets.ctfassets.net',
3604
+ downloads: 'downloads.ctfassets.net',
3605
+ videos: 'videos.ctfassets.net'
3606
+ };
3607
+ var fileUrl = toExternal(file.url, assetDomainMap);
3600
3608
  return {
3601
3609
  title: title,
3602
3610
  asset: asset,
3603
- url: file.url,
3611
+ url: fileUrl,
3604
3612
  // is normally localized and we should not warn about this file
3605
3613
  isLocalized: Boolean(localizedFile),
3606
3614
  // was fallback value used
@@ -3608,7 +3616,7 @@ function makeAssetLink(asset, _ref) {
3608
3616
  // it means we used a default locale - we filter empty values
3609
3617
  isFallback: Boolean(fallbackFile),
3610
3618
  // todo: tranform using fromHostname
3611
- asMarkdown: "![" + title + "](" + file.url + ")"
3619
+ asMarkdown: "![" + title + "](" + fileUrl + ")"
3612
3620
  };
3613
3621
  } else {
3614
3622
  return null;