import PropTypes from 'prop-types';
import React from 'react';

import childrenFromHtml from '../../childrenFromHtml';
import RichText from '../../RichText';

/* Interface */
const propTypes = {
  /** <RichText> content to render */
  content: PropTypes.string.isRequired,
};

/* Defaults */
const defaultProps = {
  content: '',
};

/**
 * Renders content from the `storyshare/paragraph` block
 * @private
 * @param {Object} props - React component props.
 * @returns {Object} React element.
 */
export const Paragraph = ({ content }) => (
  <p>
    <RichText>
      { childrenFromHtml(content) }
    </RichText>
  </p>
);

Paragraph.defaultProps = defaultProps;
Paragraph.propTypes = propTypes;

export default Paragraph;
