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