Skip to content

Instantly share code, notes, and snippets.

@andrerpena
Created February 13, 2018 06:34
Show Gist options
  • Save andrerpena/d0d7202ec61f730bb461cb99ad8341a4 to your computer and use it in GitHub Desktop.
Save andrerpena/d0d7202ec61f730bb461cb99ad8341a4 to your computer and use it in GitHub Desktop.
import * as React from "react";
import * as ReduxForm from "redux-form";
interface MarkdownEditorProps extends ReduxForm.WrappedFieldProps {
}
interface MarkdownEditorState {
}
export class MarkdownEditor extends React.Component<MarkdownEditorProps, MarkdownEditorState> {
handleValueChange = (value: ReactMdeTypes.Value) => {
const {onChange} = this.props.input;
onChange(value as any);
}
render() {
const {meta: {invalid, touched}, input: {name, value}} = this.props;
return (
<div className={`markdown-editor ${invalid ? "invalid" : ""}`}>
<ReactMde
textAreaProps={{id: name, name, rows: 20}}
value={value}
onChange={this.handleValueChange}
commands={ReactMdeCommands.getDefaultCommands()}
visibility={{preview: false}}
/>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment