import React from 'react'; import PropTypes from 'prop-types'; import Select from 'react-select'; import AceEditor from 'react-ace'; import 'brace/mode/css'; import 'brace/theme/github'; import ModalTrigger from '../../components/ModalTrigger'; import { t } from '../../locales'; const propTypes = { initialCss: PropTypes.string, triggerNode: PropTypes.node.isRequired, onChange: PropTypes.func, templates: PropTypes.array, }; const defaultProps = { initialCss: '', onChange: () => {}, templates: [], }; class CssEditor extends React.PureComponent { constructor(props) { super(props); this.state = { css: props.initialCss, cssTemplateOptions: [], }; } changeCss(css) { this.setState({ css }, () => { this.props.onChange(css); }); } changeCssTemplate(opt) { this.changeCss(opt.css); } renderTemplateSelector() { if (this.props.templates) { return (