feat(media): add external media library support, Uploadcare integration (#1602)
This commit is contained in:
@ -1,11 +1,36 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styled from 'react-emotion';
|
||||
import { List } from 'immutable';
|
||||
import { WidgetPreviewContainer } from 'netlify-cms-ui-default';
|
||||
|
||||
const FilePreview = ({ value, getAsset }) => (
|
||||
<WidgetPreviewContainer>
|
||||
{value ? <a href={getAsset(value)}>{value}</a> : null}
|
||||
</WidgetPreviewContainer>
|
||||
const FileLink = styled(({ value, getAsset }) => (
|
||||
<a href={getAsset(value)} rel="noopener noreferrer" target="_blank">
|
||||
{value}
|
||||
</a>
|
||||
))`
|
||||
display: block;
|
||||
`;
|
||||
|
||||
function FileLinkList({ values, getAsset }) {
|
||||
return (
|
||||
<div>
|
||||
{values.map(value => (
|
||||
<FileLink key={value} value={value} getAsset={getAsset} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function FileContent({ value, getAsset }) {
|
||||
if (Array.isArray(value) || List.isList(value)) {
|
||||
return <FileLinkList values={value} getAsset={getAsset} />;
|
||||
}
|
||||
return <FileLink value={value} getAsset={getAsset} />;
|
||||
}
|
||||
|
||||
const FilePreview = props => (
|
||||
<WidgetPreviewContainer>{props.value ? <FileContent {...props} /> : null}</WidgetPreviewContainer>
|
||||
);
|
||||
|
||||
FilePreview.propTypes = {
|
||||
|
Reference in New Issue
Block a user