Merge pull request #539 from esteemapp/bugfix/#468

Fixed #468
This commit is contained in:
uğur erdal 2019-02-07 11:13:17 +03:00 committed by GitHub
commit 537cc5e877
5 changed files with 21 additions and 17 deletions

View File

@ -26,7 +26,7 @@ export default ({ getState, item, setState }) => {
setState({ text: newText }, () => {
setTimeout(() => {
setState({ selection: newSelection });
setState({ newSelection });
}, 300);
});
};

View File

@ -36,6 +36,6 @@ export default ({
};
}
setState({ text: newText }, () => {
setState({ selection: newSelection });
setState({ newSelection });
});
};

View File

@ -13,15 +13,14 @@ export default ({ getState, item, setState }) => {
} else {
newPosition = selection.end + item.wrapper.length * 2;
}
const extra = {
selection: {
newSelection: {
start: newPosition,
end: newPosition,
},
};
setState({ text: newText }, () => {
setTimeout(() => {
setState({ ...extra });
}, 25);
setState({ ...extra });
});
};

View File

@ -42,7 +42,7 @@ export default ({ getState, item, setState }) => {
);
}
const extra = {
selection: {
newSelection: {
start: newPosition,
end: newPosition,
},

View File

@ -24,6 +24,7 @@ export default class MarkdownEditorView extends Component {
this.state = {
text: props.draftBody || '',
selection: { start: 0, end: 0 },
newSelection: null,
};
}
@ -79,21 +80,25 @@ export default class MarkdownEditorView extends Component {
};
_handleOnSelectionChange = (event) => {
this.setState({
selection: event.nativeEvent.selection,
});
const { newSelection } = this.state;
if (newSelection) {
this.setState({
selection: newSelection,
newSelection: null,
});
} else {
this.setState({
selection: event.nativeEvent.selection,
});
}
};
_getState = () => {
this.setState({
selection: {
start: 1,
end: 1,
},
});
return this.state;
};
_renderPreview = () => {
const { text } = this.state;
@ -180,7 +185,7 @@ export default class MarkdownEditorView extends Component {
id: isReply ? 'editor.reply_placeholder' : 'editor.default_placeholder',
})}
placeholderTextColor="#c1c5c7"
selection={Platform.OS === 'ios' ? selection : undefined}
selection={selection}
selectionColor="#357ce6"
style={styles.textWrapper}
underlineColorAndroid="transparent"