@contentful/field-editor-markdown 1.0.0 → 1.0.4
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/CHANGELOG.md +22 -0
- package/dist/field-editor-markdown.cjs.development.js +15 -2
- package/dist/field-editor-markdown.cjs.development.js.map +1 -1
- package/dist/field-editor-markdown.cjs.production.min.js +1 -1
- package/dist/field-editor-markdown.cjs.production.min.js.map +1 -1
- package/dist/field-editor-markdown.esm.js +15 -2
- package/dist/field-editor-markdown.esm.js.map +1 -1
- package/dist/utils/insertAssetLinks.d.ts +1 -0
- package/package.json +7 -7
|
@@ -3586,6 +3586,18 @@ function fileNameToTitle(str) {
|
|
|
3586
3586
|
return normalizeWhiteSpace(removeExtension(str).replace(/_/g, ' '));
|
|
3587
3587
|
}
|
|
3588
3588
|
|
|
3589
|
+
function replaceAssetDomain(fileUrl) {
|
|
3590
|
+
var assetDomainMap = {
|
|
3591
|
+
images: 'images.ctfassets.net',
|
|
3592
|
+
assets: 'assets.ctfassets.net',
|
|
3593
|
+
downloads: 'downloads.ctfassets.net',
|
|
3594
|
+
videos: 'videos.ctfassets.net'
|
|
3595
|
+
};
|
|
3596
|
+
return fileUrl.replace(/(images|assets|downloads|videos).contentful.com/, function (_, p1) {
|
|
3597
|
+
return assetDomainMap[p1];
|
|
3598
|
+
});
|
|
3599
|
+
}
|
|
3600
|
+
|
|
3589
3601
|
function makeAssetLink(asset, _ref) {
|
|
3590
3602
|
var localeCode = _ref.localeCode,
|
|
3591
3603
|
fallbackCode = _ref.fallbackCode,
|
|
@@ -3597,10 +3609,11 @@ function makeAssetLink(asset, _ref) {
|
|
|
3597
3609
|
|
|
3598
3610
|
if (isObject(file) && file.url) {
|
|
3599
3611
|
var title = get(asset, ['fields', 'title', localeCode]) || get(asset, ['fields', 'title', fallbackCode || '']) || get(asset, ['fields', 'title', defaultLocaleCode]) || fileNameToTitle(file.fileName);
|
|
3612
|
+
var fileUrl = replaceAssetDomain(file.url);
|
|
3600
3613
|
return {
|
|
3601
3614
|
title: title,
|
|
3602
3615
|
asset: asset,
|
|
3603
|
-
url:
|
|
3616
|
+
url: fileUrl,
|
|
3604
3617
|
// is normally localized and we should not warn about this file
|
|
3605
3618
|
isLocalized: Boolean(localizedFile),
|
|
3606
3619
|
// was fallback value used
|
|
@@ -3608,7 +3621,7 @@ function makeAssetLink(asset, _ref) {
|
|
|
3608
3621
|
// it means we used a default locale - we filter empty values
|
|
3609
3622
|
isFallback: Boolean(fallbackFile),
|
|
3610
3623
|
// todo: tranform using fromHostname
|
|
3611
|
-
asMarkdown: ""
|
|
3612
3625
|
};
|
|
3613
3626
|
} else {
|
|
3614
3627
|
return null;
|