From c737c7a9a1d5f46eba4b681c533516ec6fb41265 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 13 Sep 2016 19:39:39 -0300 Subject: [PATCH] Ivan - Frontend - Fix react-rte validation issues [skip ci] --- client/src/core-components/form.js | 1 - client/src/core-components/text-editor.js | 2 +- client/src/lib-app/validations/length-validator.js | 6 +++--- client/src/lib-app/validations/validator.js | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/src/core-components/form.js b/client/src/core-components/form.js index 204a4e04..32e5935f 100644 --- a/client/src/core-components/form.js +++ b/client/src/core-components/form.js @@ -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; diff --git a/client/src/core-components/text-editor.js b/client/src/core-components/text-editor.js index 0b8eb253..d1787913 100644 --- a/client/src/core-components/text-editor.js +++ b/client/src/core-components/text-editor.js @@ -71,7 +71,7 @@ class TextEditor extends React.Component { focus() { if (this.refs.editor) { - this.refs.editor.focus(); + this.refs.editor._focus(); } } } diff --git a/client/src/lib-app/validations/length-validator.js b/client/src/lib-app/validations/length-validator.js index 3951c31e..82c277b9 100644 --- a/client/src/lib-app/validations/length-validator.js +++ b/client/src/lib-app/validations/length-validator.js @@ -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); diff --git a/client/src/lib-app/validations/validator.js b/client/src/lib-app/validations/validator.js index b02ab078..b253bc18 100644 --- a/client/src/lib-app/validations/validator.js +++ b/client/src/lib-app/validations/validator.js @@ -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');