feat: add shortcut to edit the previous memo (#3122)

* Add shortcut to edit the previous memo

* Fix compilation

* Update web/src/components/MemoEditor/index.tsx

Co-authored-by: boojack <stevenlgtm@gmail.com>

---------

Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Dubzer
2024-03-27 16:46:29 +03:00
committed by GitHub
parent 2ebea4dba9
commit a0846c2818
2 changed files with 20 additions and 4 deletions

View File

@ -37,6 +37,7 @@ interface Props {
relationList?: MemoRelation[];
autoFocus?: boolean;
onConfirm?: (memoId: number) => void;
onEditPrevious?: () => void;
}
interface State {
@ -144,7 +145,7 @@ const MemoEditor = (props: Props) => {
const isMetaKey = event.ctrlKey || event.metaKey;
if (isMetaKey) {
if (event.key === "Enter") {
handleSaveBtnClick();
void handleSaveBtnClick();
return;
}
@ -161,6 +162,12 @@ const MemoEditor = (props: Props) => {
}
return;
}
if (!!props.onEditPrevious && event.key === "ArrowDown" && !state.isComposing && editorRef.current.getContent() === "") {
event.preventDefault();
props.onEditPrevious();
return;
}
};
const handleMemoVisibilityChange = (visibility: Visibility) => {