import React from 'react';
import { mergeObject } from '../utils';
import { getNodeStyle } from '../utils/style';
import { PREFIX_CLS } from '../config';
import { plugin } from './jscss';
import './style/index';

const prefixCls = `${PREFIX_CLS}-rich-text`;

export default options => {
  const { data } = options;
  const { style, props } = mergeObject(plugin, data);
  const { text } = props;
  return (
    <div
      style={getNodeStyle(style)}
      className={prefixCls}
      // eslint-disable-next-line react/no-danger
      dangerouslySetInnerHTML={{
        __html: text,
      }}
    />
  );
};
