fix: change getAsset to not return a promise (#3232)
* fix: change getAsset to not return a promise * fix: update markdown widget per getAsset changes * test: fix editor component image test * docs: update getAsset docs
This commit is contained in:
@ -2,9 +2,9 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import styled from '@emotion/styled';
|
||||
import { List } from 'immutable';
|
||||
import { WidgetPreviewContainer, Asset } from 'netlify-cms-ui-default';
|
||||
import { WidgetPreviewContainer } from 'netlify-cms-ui-default';
|
||||
|
||||
const FileLink = styled(({ value: href, path }) => (
|
||||
const FileLink = styled(({ href, path }) => (
|
||||
<a href={href} rel="noopener noreferrer" target="_blank">
|
||||
{path}
|
||||
</a>
|
||||
@ -12,25 +12,24 @@ const FileLink = styled(({ value: href, path }) => (
|
||||
display: block;
|
||||
`;
|
||||
|
||||
const FileLinkAsset = ({ value, getAsset }) => {
|
||||
return <Asset path={value} getAsset={getAsset} component={FileLink} />;
|
||||
};
|
||||
|
||||
function FileLinkList({ values, getAsset }) {
|
||||
function FileLinkList({ values, getAsset, folder }) {
|
||||
return (
|
||||
<div>
|
||||
{values.map(value => (
|
||||
<FileLinkAsset key={value} value={value} getAsset={getAsset} />
|
||||
<FileLink key={value} path={value} href={getAsset(value, folder)} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function FileContent({ value, getAsset }) {
|
||||
function FileContent(props) {
|
||||
const { value, getAsset, field } = props;
|
||||
const folder = field.get('media_folder');
|
||||
|
||||
if (Array.isArray(value) || List.isList(value)) {
|
||||
return <FileLinkList values={value} getAsset={getAsset} />;
|
||||
return <FileLinkList values={value} getAsset={getAsset} folder={folder} />;
|
||||
}
|
||||
return <FileLinkAsset value={value} getAsset={getAsset} />;
|
||||
return <FileLink key={value} path={value} href={getAsset(value, folder)} />;
|
||||
}
|
||||
|
||||
const FilePreview = props => (
|
||||
|
Reference in New Issue
Block a user