mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-29 16:54:53 +02:00
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) => {
|
const form = _.mapValues(this.state.form, (field) => {
|
||||||
if (field instanceof RichTextEditor.EditorValue) {
|
if (field instanceof RichTextEditor.EditorValue) {
|
||||||
console.log('YESS');
|
|
||||||
return field.toString('html');
|
return field.toString('html');
|
||||||
} else {
|
} else {
|
||||||
return field;
|
return field;
|
||||||
|
@ -71,7 +71,7 @@ class TextEditor extends React.Component {
|
|||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
if (this.refs.editor) {
|
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';
|
import Validator from 'lib-app/validations/validator';
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ class LengthValidator extends Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validate(value, form) {
|
validate(value, form) {
|
||||||
if (value instanceof EditorState) {
|
if (value instanceof RichTextEditor.EditorValue) {
|
||||||
value = value.getCurrentContent().getPlainText();
|
value = value.getEditorState().getCurrentContent().getPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.length < this.minlength) return this.getError(this.errorKey);
|
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';
|
import i18n from 'lib-app/i18n';
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ class Validator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validate(value, form) {
|
validate(value, form) {
|
||||||
if (value instanceof EditorState) {
|
if (value instanceof RichTextEditor.EditorValue) {
|
||||||
value = value.getCurrentContent().getPlainText()
|
value = value.getEditorState().getPlainText()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.length === 0) return this.getError('ERROR_EMPTY');
|
if (value.length === 0) return this.getError('ERROR_EMPTY');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user