Trim text coming out of CompositionInput
This commit is contained in:
parent
43ec99f5d8
commit
430b6377b0
1 changed files with 6 additions and 2 deletions
|
@ -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]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue