Trim text coming out of CompositionInput

This commit is contained in:
Ken Powers 2019-11-13 18:35:44 -05:00 committed by Scott Nonnenberg
parent 43ec99f5d8
commit 430b6377b0

View file

@ -265,7 +265,10 @@ export const CompositionInput = ({
const updateExternalStateListeners = React.useCallback(
(newState: EditorState) => {
const plainText = newState.getCurrentContent().getPlainText();
const plainText = newState
.getCurrentContent()
.getPlainText()
.trim();
const cursorBlockKey = newState.getSelection().getStartKey();
const cursorBlockIndex = editorStateRef.current
.getCurrentContent()
@ -417,7 +420,8 @@ export const CompositionInput = ({
const { current: state } = editorStateRef;
const text = state.getCurrentContent().getPlainText();
const emojidText = replaceColons(text);
onSubmit(emojidText);
const trimmedText = emojidText.trim();
onSubmit(trimmedText);
},
[editorStateRef, onSubmit]
);