Merge pull request #629 from esteemapp/editor/publish

fixed editor publish issue
This commit is contained in:
uğur erdal 2019-02-27 22:54:47 +03:00 committed by GitHub
commit 9e64f8a588
2 changed files with 30 additions and 7 deletions

View File

@ -58,6 +58,23 @@ export default class MarkdownEditorView extends Component {
}
}
componentDidUpdate(prevProps, prevState) {
const { text } = this.state;
const { isFormValid, handleIsFormValid } = this.props;
if (prevState.text !== text && !isFormValid) {
const nextText = text.replace(prevState.text, '');
if (nextText && nextText.length > 0) {
this._changeText(text);
if (handleIsFormValid) {
handleIsFormValid(text);
}
}
}
}
// Component functions
_changeText = (input) => {
const {
@ -147,7 +164,7 @@ export default class MarkdownEditorView extends Component {
iconType="FontAwesome"
name="image"
/>
{/* <View style={styles.clearButtonWrapper}>
<View style={styles.clearButtonWrapper}>
<IconButton
onPress={() => this.ClearActionSheet.show()}
size={20}
@ -155,7 +172,7 @@ export default class MarkdownEditorView extends Component {
iconType="FontAwesome"
name="trash"
/>
</View> */}
</View>
{/* TODO: After alpha */}
{/* <DropdownButton
style={styles.dropdownStyle}

View File

@ -39,7 +39,7 @@ class EditorScreen extends Component {
// Component Life Cycles
componentWillReceiveProps = (nextProps) => {
const { draftPost } = this.props;
const { draftPost, isUploading } = this.props;
if (nextProps.draftPost && draftPost !== nextProps.draftPost) {
this.setState({
@ -48,6 +48,10 @@ class EditorScreen extends Component {
},
});
}
if (isUploading !== nextProps) {
this._handleFormUpdate();
}
};
// Component Functions
@ -107,7 +111,7 @@ class EditorScreen extends Component {
}
};
_handleIsFormValid = () => {
_handleIsFormValid = (bodyText) => {
const { fields } = this.state;
const { isReply } = this.props;
let _isFormValid;
@ -118,9 +122,8 @@ class EditorScreen extends Component {
_isFormValid = fields
&& fields.title
&& fields.title.length > 0
&& fields.body
&& fields.body.length > 0
&& fields.tags.length > 0;
&& ((fields.body && fields.body.length > 0 && fields.tags.length > 0)
|| (bodyText && bodyText.length > 0));
}
this.setState({ isFormValid: _isFormValid });
@ -215,6 +218,9 @@ class EditorScreen extends Component {
componentID="body"
draftBody={fields && fields.body}
handleOnTextChange={this._setWordsCount}
handleFormUpdate={this._handleFormUpdate}
handleIsFormValid={this._handleIsFormValid}
isFormValid={isFormValid}
handleOpenImagePicker={handleOnImagePicker}
intl={intl}
uploadedImage={uploadedImage}