@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
|
@@ -7,7 +7,7 @@ import React, { useRef, useState, useEffect } from 'react';
|
|
|
7
7
|
import { css, cx } from 'emotion';
|
|
8
8
|
import tokens from '@contentful/f36-tokens';
|
|
9
9
|
import { ConstraintsUtils, CharCounter, CharValidation, FieldConnector, ModalDialogLauncher } from '@contentful/field-editor-shared';
|
|
10
|
-
import { Menu, Button, Tooltip, Flex, Paragraph, TextLink, ModalContent, Heading, Form, FormControl, TextInput, ModalControls, Text, Radio, Checkbox, EntityList } from '@contentful/f36-components';
|
|
10
|
+
import { Menu, Button, Tooltip, IconButton, Flex, Paragraph, TextLink, ModalContent, Heading, Form, FormControl, TextInput, ModalControls, Text, Radio, Checkbox, EntityList } from '@contentful/f36-components';
|
|
11
11
|
import { AssetIcon, ChevronDownIcon, MoreHorizontalIcon, HeadingIcon, FormatBoldIcon, FormatItalicIcon, QuoteIcon, ListBulletedIcon, ListNumberedIcon, LinkIcon, CodeIcon, HorizontalRuleIcon, ChevronRightIcon, ChevronLeftIcon } from '@contentful/f36-icons';
|
|
12
12
|
import transform from 'lodash-es/transform';
|
|
13
13
|
import throttle from 'lodash-es/throttle';
|
|
@@ -446,24 +446,20 @@ var ToolbarButton = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
446
446
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
447
447
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
448
448
|
|
|
449
|
-
|
|
449
|
+
return React.createElement(Tooltip, {
|
|
450
|
+
className: styles$1.tooltip,
|
|
451
|
+
placement: tooltipPlace,
|
|
452
|
+
content: tooltip
|
|
453
|
+
}, React.createElement(IconButton, Object.assign({}, otherProps, {
|
|
450
454
|
ref: ref,
|
|
451
455
|
className: cx(styles$1.button, className),
|
|
452
456
|
isDisabled: isDisabled,
|
|
453
457
|
onClick: onClick,
|
|
454
458
|
variant: variant,
|
|
455
|
-
size: "small"
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return React.createElement(Tooltip, {
|
|
460
|
-
className: styles$1.tooltip,
|
|
461
|
-
placement: tooltipPlace,
|
|
462
|
-
content: tooltip
|
|
463
|
-
}, button);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
return button;
|
|
459
|
+
size: "small",
|
|
460
|
+
icon: children,
|
|
461
|
+
"aria-label": tooltip
|
|
462
|
+
})));
|
|
467
463
|
});
|
|
468
464
|
ToolbarButton.displayName = 'ToolbarButton';
|
|
469
465
|
|
|
@@ -672,7 +668,8 @@ function DefaultMarkdownToolbar(props) {
|
|
|
672
668
|
testId: "markdown-action-button-zen",
|
|
673
669
|
variant: "secondary",
|
|
674
670
|
onClick: props.actions.openZenMode,
|
|
675
|
-
className: styles$1.zenButton
|
|
671
|
+
className: styles$1.zenButton,
|
|
672
|
+
tooltip: "Expand"
|
|
676
673
|
}, React.createElement(Zen, {
|
|
677
674
|
label: "Expand",
|
|
678
675
|
className: styles$1.icon
|
|
@@ -691,18 +688,20 @@ function ZenMarkdownToolbar(props) {
|
|
|
691
688
|
onSelectExisting: props.actions.linkExistingMedia,
|
|
692
689
|
onAddNew: props.actions.addNewMedia,
|
|
693
690
|
canAddNew: props.canUploadAssets
|
|
694
|
-
}), React.createElement(
|
|
691
|
+
}), React.createElement(IconButton, {
|
|
695
692
|
testId: "markdown-action-button-zen-close",
|
|
696
693
|
variant: "secondary",
|
|
697
694
|
size: "small",
|
|
698
695
|
className: cx(styles$1.zenButton, styles$1.zenButtonPressed),
|
|
699
696
|
onClick: function onClick() {
|
|
700
697
|
props.actions.closeZenMode();
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
698
|
+
},
|
|
699
|
+
icon: React.createElement(Zen, {
|
|
700
|
+
label: "Collapse",
|
|
701
|
+
className: styles$1.icon
|
|
702
|
+
}),
|
|
703
|
+
"aria-label": "Collapse"
|
|
704
|
+
}))));
|
|
706
705
|
}
|
|
707
706
|
var MarkdownToolbar = /*#__PURE__*/React.memo(function (props) {
|
|
708
707
|
if (props.mode === 'zen') {
|
|
@@ -3586,6 +3585,18 @@ function fileNameToTitle(str) {
|
|
|
3586
3585
|
return normalizeWhiteSpace(removeExtension(str).replace(/_/g, ' '));
|
|
3587
3586
|
}
|
|
3588
3587
|
|
|
3588
|
+
function replaceAssetDomain(fileUrl) {
|
|
3589
|
+
var assetDomainMap = {
|
|
3590
|
+
images: 'images.ctfassets.net',
|
|
3591
|
+
assets: 'assets.ctfassets.net',
|
|
3592
|
+
downloads: 'downloads.ctfassets.net',
|
|
3593
|
+
videos: 'videos.ctfassets.net'
|
|
3594
|
+
};
|
|
3595
|
+
return fileUrl.replace(/(images|assets|downloads|videos).contentful.com/, function (_, p1) {
|
|
3596
|
+
return assetDomainMap[p1];
|
|
3597
|
+
});
|
|
3598
|
+
}
|
|
3599
|
+
|
|
3589
3600
|
function makeAssetLink(asset, _ref) {
|
|
3590
3601
|
var localeCode = _ref.localeCode,
|
|
3591
3602
|
fallbackCode = _ref.fallbackCode,
|
|
@@ -3597,10 +3608,11 @@ function makeAssetLink(asset, _ref) {
|
|
|
3597
3608
|
|
|
3598
3609
|
if (isObject(file) && file.url) {
|
|
3599
3610
|
var title = get(asset, ['fields', 'title', localeCode]) || get(asset, ['fields', 'title', fallbackCode || '']) || get(asset, ['fields', 'title', defaultLocaleCode]) || fileNameToTitle(file.fileName);
|
|
3611
|
+
var fileUrl = replaceAssetDomain(file.url);
|
|
3600
3612
|
return {
|
|
3601
3613
|
title: title,
|
|
3602
3614
|
asset: asset,
|
|
3603
|
-
url:
|
|
3615
|
+
url: fileUrl,
|
|
3604
3616
|
// is normally localized and we should not warn about this file
|
|
3605
3617
|
isLocalized: Boolean(localizedFile),
|
|
3606
3618
|
// was fallback value used
|
|
@@ -3608,7 +3620,7 @@ function makeAssetLink(asset, _ref) {
|
|
|
3608
3620
|
// it means we used a default locale - we filter empty values
|
|
3609
3621
|
isFallback: Boolean(fallbackFile),
|
|
3610
3622
|
// todo: tranform using fromHostname
|
|
3611
|
-
asMarkdown: ""
|
|
3612
3624
|
};
|
|
3613
3625
|
} else {
|
|
3614
3626
|
return null;
|