Trim text coming out of CompositionInput

This commit is contained in:
Ken Powers 2019-10-21 17:57:05 -04:00 committed by Scott Nonnenberg
parent dd1f9b055f
commit 94dde6f799

View file

@ -245,7 +245,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()
@ -397,7 +400,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]
);