Ivan - Frontend - Fix react-rte validation issues [skip ci]
This commit is contained in:
parent
a0c5b30d0c
commit
c737c7a9a1
|
@ -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;
|
||||
|
|
|
@ -71,7 +71,7 @@ class TextEditor extends React.Component {
|
|||
|
||||
focus() {
|
||||
if (this.refs.editor) {
|
||||
this.refs.editor.focus();
|
||||
this.refs.editor._focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue