mirror of
https://github.com/usememos/memos.git
synced 2024-12-21 02:01:55 +03:00
feat: handle esc keyboard event for editor (#288)
This commit is contained in:
parent
0d6114e25e
commit
5e7db4631e
@ -239,6 +239,12 @@ const MemoEditor: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleKeyDown = (event: React.KeyboardEvent) => {
|
||||
if (event.key === "Escape") {
|
||||
state.fullscreen && handleFullscreenBtnClick();
|
||||
}
|
||||
};
|
||||
|
||||
const handleTagSeletorClick = useCallback((event: React.MouseEvent) => {
|
||||
if (tagSeletorRef.current !== event.target && tagSeletorRef.current?.contains(event.target as Node)) {
|
||||
editorRef.current?.insertText(`#${(event.target as HTMLElement).textContent} ` ?? "");
|
||||
@ -287,7 +293,10 @@ const MemoEditor: React.FC = () => {
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={`memo-editor-container ${mobileEditorStyle} ${isEditing ? "edit-ing" : ""} ${state.fullscreen ? "fullscreen" : ""}`}>
|
||||
<div
|
||||
className={`memo-editor-container ${mobileEditorStyle} ${isEditing ? "edit-ing" : ""} ${state.fullscreen ? "fullscreen" : ""}`}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<div className={`tip-container ${isEditing ? "" : "!hidden"}`}>
|
||||
<span className="tip-text">{t("editor.editing")}</span>
|
||||
<button className="cancel-btn" onClick={handleCancelEditing}>
|
||||
|
Loading…
Reference in New Issue
Block a user