lexical: fix ctrl+Enter

environments/review-main-yi2y9f/deployments/4032
Alex Gleason 1 year ago
parent 6c318a02ef
commit bc3662afc7
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -15,13 +15,18 @@ const StatePlugin = ({ composeId, handleSubmit }: IStatePlugin) => {
const [editor] = useLexicalComposerContext();
useEffect(() => {
if (handleSubmit) editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
if (event?.ctrlKey) {
handleSubmit();
return true;
}
return false;
}, 1);
if (handleSubmit) {
return editor.registerCommand(KEY_ENTER_COMMAND, (event) => {
if (event?.ctrlKey) {
handleSubmit();
return true;
}
return false;
}, 1);
}
}, [handleSubmit]);
useEffect(() => {
editor.registerUpdateListener(({ editorState }) => {
const isEmpty = editorState.read(() => $getRoot().getTextContent()) === '';
const data = isEmpty ? null : JSON.stringify(editorState.toJSON());

Loading…
Cancel
Save