@contentful/field-editor-markdown 1.0.1 → 1.0.5
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 +34 -22
- 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 +35 -23
- package/dist/field-editor-markdown.esm.js.map +1 -1
- package/dist/utils/insertAssetLinks.d.ts +1 -0
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.0.5](https://github.com/contentful/field-editors/compare/@contentful/field-editor-markdown@1.0.4...@contentful/field-editor-markdown@1.0.5) (2021-12-23)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- markdown buttons ([#968](https://github.com/contentful/field-editors/issues/968)) ([9803b98](https://github.com/contentful/field-editors/commit/9803b98c25d92df6148686ffe2749a77f7efdbb9))
|
|
11
|
+
|
|
12
|
+
## [1.0.4](https://github.com/contentful/field-editors/compare/@contentful/field-editor-markdown@1.0.3...@contentful/field-editor-markdown@1.0.4) (2021-12-20)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @contentful/field-editor-markdown
|
|
15
|
+
|
|
16
|
+
## [1.0.3](https://github.com/contentful/field-editors/compare/@contentful/field-editor-markdown@1.0.2...@contentful/field-editor-markdown@1.0.3) (2021-12-06)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
- replace @contentful/hostname-transformer ([#950](https://github.com/contentful/field-editors/issues/950)) ([871ca34](https://github.com/contentful/field-editors/commit/871ca345f1c53e4d579f58e5ee32c67830ad1b7f))
|
|
21
|
+
|
|
22
|
+
## [1.0.2](https://github.com/contentful/field-editors/compare/@contentful/field-editor-markdown@1.0.1...@contentful/field-editor-markdown@1.0.2) (2021-12-03)
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
- markdown upload asset domain url to ctfasset.net [] ([#946](https://github.com/contentful/field-editors/issues/946)) ([21ef606](https://github.com/contentful/field-editors/commit/21ef606e941feff1e8db1189c9cb48f9a82728a0))
|
|
27
|
+
|
|
6
28
|
## [1.0.1](https://github.com/contentful/field-editors/compare/@contentful/field-editor-markdown@1.0.0...@contentful/field-editor-markdown@1.0.1) (2021-11-17)
|
|
7
29
|
|
|
8
30
|
### Bug Fixes
|
|
@@ -453,24 +453,20 @@ var ToolbarButton = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
453
453
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
454
454
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
455
455
|
|
|
456
|
-
|
|
456
|
+
return React__default.createElement(f36Components.Tooltip, {
|
|
457
|
+
className: styles$1.tooltip,
|
|
458
|
+
placement: tooltipPlace,
|
|
459
|
+
content: tooltip
|
|
460
|
+
}, React__default.createElement(f36Components.IconButton, Object.assign({}, otherProps, {
|
|
457
461
|
ref: ref,
|
|
458
462
|
className: emotion.cx(styles$1.button, className),
|
|
459
463
|
isDisabled: isDisabled,
|
|
460
464
|
onClick: onClick,
|
|
461
465
|
variant: variant,
|
|
462
|
-
size: "small"
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
return React__default.createElement(f36Components.Tooltip, {
|
|
467
|
-
className: styles$1.tooltip,
|
|
468
|
-
placement: tooltipPlace,
|
|
469
|
-
content: tooltip
|
|
470
|
-
}, button);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
return button;
|
|
466
|
+
size: "small",
|
|
467
|
+
icon: children,
|
|
468
|
+
"aria-label": tooltip
|
|
469
|
+
})));
|
|
474
470
|
});
|
|
475
471
|
ToolbarButton.displayName = 'ToolbarButton';
|
|
476
472
|
|
|
@@ -679,7 +675,8 @@ function DefaultMarkdownToolbar(props) {
|
|
|
679
675
|
testId: "markdown-action-button-zen",
|
|
680
676
|
variant: "secondary",
|
|
681
677
|
onClick: props.actions.openZenMode,
|
|
682
|
-
className: styles$1.zenButton
|
|
678
|
+
className: styles$1.zenButton,
|
|
679
|
+
tooltip: "Expand"
|
|
683
680
|
}, React__default.createElement(Zen, {
|
|
684
681
|
label: "Expand",
|
|
685
682
|
className: styles$1.icon
|
|
@@ -698,18 +695,20 @@ function ZenMarkdownToolbar(props) {
|
|
|
698
695
|
onSelectExisting: props.actions.linkExistingMedia,
|
|
699
696
|
onAddNew: props.actions.addNewMedia,
|
|
700
697
|
canAddNew: props.canUploadAssets
|
|
701
|
-
}), React__default.createElement(f36Components.
|
|
698
|
+
}), React__default.createElement(f36Components.IconButton, {
|
|
702
699
|
testId: "markdown-action-button-zen-close",
|
|
703
700
|
variant: "secondary",
|
|
704
701
|
size: "small",
|
|
705
702
|
className: emotion.cx(styles$1.zenButton, styles$1.zenButtonPressed),
|
|
706
703
|
onClick: function onClick() {
|
|
707
704
|
props.actions.closeZenMode();
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
705
|
+
},
|
|
706
|
+
icon: React__default.createElement(Zen, {
|
|
707
|
+
label: "Collapse",
|
|
708
|
+
className: styles$1.icon
|
|
709
|
+
}),
|
|
710
|
+
"aria-label": "Collapse"
|
|
711
|
+
}))));
|
|
713
712
|
}
|
|
714
713
|
var MarkdownToolbar = /*#__PURE__*/React__default.memo(function (props) {
|
|
715
714
|
if (props.mode === 'zen') {
|
|
@@ -3593,6 +3592,18 @@ function fileNameToTitle(str) {
|
|
|
3593
3592
|
return normalizeWhiteSpace(removeExtension(str).replace(/_/g, ' '));
|
|
3594
3593
|
}
|
|
3595
3594
|
|
|
3595
|
+
function replaceAssetDomain(fileUrl) {
|
|
3596
|
+
var assetDomainMap = {
|
|
3597
|
+
images: 'images.ctfassets.net',
|
|
3598
|
+
assets: 'assets.ctfassets.net',
|
|
3599
|
+
downloads: 'downloads.ctfassets.net',
|
|
3600
|
+
videos: 'videos.ctfassets.net'
|
|
3601
|
+
};
|
|
3602
|
+
return fileUrl.replace(/(images|assets|downloads|videos).contentful.com/, function (_, p1) {
|
|
3603
|
+
return assetDomainMap[p1];
|
|
3604
|
+
});
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3596
3607
|
function makeAssetLink(asset, _ref) {
|
|
3597
3608
|
var localeCode = _ref.localeCode,
|
|
3598
3609
|
fallbackCode = _ref.fallbackCode,
|
|
@@ -3604,10 +3615,11 @@ function makeAssetLink(asset, _ref) {
|
|
|
3604
3615
|
|
|
3605
3616
|
if (isObject(file) && file.url) {
|
|
3606
3617
|
var title = get(asset, ['fields', 'title', localeCode]) || get(asset, ['fields', 'title', fallbackCode || '']) || get(asset, ['fields', 'title', defaultLocaleCode]) || fileNameToTitle(file.fileName);
|
|
3618
|
+
var fileUrl = replaceAssetDomain(file.url);
|
|
3607
3619
|
return {
|
|
3608
3620
|
title: title,
|
|
3609
3621
|
asset: asset,
|
|
3610
|
-
url:
|
|
3622
|
+
url: fileUrl,
|
|
3611
3623
|
// is normally localized and we should not warn about this file
|
|
3612
3624
|
isLocalized: Boolean(localizedFile),
|
|
3613
3625
|
// was fallback value used
|
|
@@ -3615,7 +3627,7 @@ function makeAssetLink(asset, _ref) {
|
|
|
3615
3627
|
// it means we used a default locale - we filter empty values
|
|
3616
3628
|
isFallback: Boolean(fallbackFile),
|
|
3617
3629
|
// todo: tranform using fromHostname
|
|
3618
|
-
asMarkdown: ""
|
|
3619
3631
|
};
|
|
3620
3632
|
} else {
|
|
3621
3633
|
return null;
|