-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Hello, when I trying get markdown from onChange event by Editor I has double breaks in text.
I want save markdown to another key in my state and save its to database.
What I doing wrong?
<div className={`editor ${this.state.hasFocus ? 'hasFocus' : ''}`}
onClick={() => { this.editor.focus() }} >
<Editor
onFocus={() => this.setState({hasFocus: true})}
onBlur={e => this.validationDescriptionCheck(e)}
editorState={this.state.editorState}
onChange={this.onChange}
plugins={plugins}
ref={(element) => { this.editor = element; }}
/>
<EmojiSuggestions/>
<InlineToolbar/>
{this.state._description === false ?
<div className="invalid-feedback">{this.state._descriptionMsg}</div> : null}
</div> onChange = (editorState) => {
const markdown = stateToMarkdown(editorState.getCurrentContent());
this.setState({
editorState,
formData: {
...this.state.formData,
description: markdown
}
});
};And my submitHandler:
submitHandler(e) {
e.preventDefault();
const { actions } = this.props;
if(this.validate()) {
let data = this.state.formData;
let service = new Service(data);
//TODO удалить
if(!service.createdAt || service.createdAt === null)
service.createdAt = moment().format('YYYY-MM-DD HH:mm');
if(this.state.edit === true)
actions.updateServiceAction(service);
else
actions.addServiceAction(service);
} else {
actions.error("Данные заполнены не корректно или неполностью");
}
}When I call submitHandler I has multiple line-breaks in my string and next save form added another breaks
example first save

next save

If I save in my formData plaintext(not markdown) all works properly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels