ab685e8594
* 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
26 lines
685 B
JavaScript
26 lines
685 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { WidgetPreviewContainer } from 'netlify-cms-ui-default';
|
|
import { markdownToHtml } from './serializers';
|
|
|
|
class MarkdownPreview extends React.Component {
|
|
static propTypes = {
|
|
getAsset: PropTypes.func.isRequired,
|
|
resolveWidget: PropTypes.func.isRequired,
|
|
value: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const { value, getAsset, resolveWidget } = this.props;
|
|
if (value === null) {
|
|
return null;
|
|
}
|
|
|
|
const html = markdownToHtml(value, { getAsset, resolveWidget });
|
|
|
|
return <WidgetPreviewContainer dangerouslySetInnerHTML={{ __html: html }} />;
|
|
}
|
|
}
|
|
|
|
export default MarkdownPreview;
|