Ivan - Frontend - Fix react-rte validation issues [skip ci]

This commit is contained in:
ivan 2016-09-13 19:39:39 -03:00
parent a0c5b30d0c
commit c737c7a9a1
4 changed files with 7 additions and 8 deletions

View File

@ -158,7 +158,6 @@ class Form extends React.Component {
const form = _.mapValues(this.state.form, (field) => {
if (field instanceof RichTextEditor.EditorValue) {
console.log('YESS');
return field.toString('html');
} else {
return field;

View File

@ -71,7 +71,7 @@ class TextEditor extends React.Component {
focus() {
if (this.refs.editor) {
this.refs.editor.focus();
this.refs.editor._focus();
}
}
}

View File

@ -1,4 +1,4 @@
import {EditorState} from 'draft-js';
import RichTextEditor from 'react-rte-browserify';
import Validator from 'lib-app/validations/validator';
@ -11,8 +11,8 @@ class LengthValidator extends Validator {
}
validate(value, form) {
if (value instanceof EditorState) {
value = value.getCurrentContent().getPlainText();
if (value instanceof RichTextEditor.EditorValue) {
value = value.getEditorState().getCurrentContent().getPlainText();
}
if (value.length < this.minlength) return this.getError(this.errorKey);

View File

@ -1,4 +1,4 @@
import {EditorState} from 'draft-js';
import RichTextEditor from 'react-rte-browserify';
import i18n from 'lib-app/i18n';
@ -20,8 +20,8 @@ class Validator {
}
validate(value, form) {
if (value instanceof EditorState) {
value = value.getCurrentContent().getPlainText()
if (value instanceof RichTextEditor.EditorValue) {
value = value.getEditorState().getPlainText()
}
if (value.length === 0) return this.getError('ERROR_EMPTY');