Unverified Commit 3c2cd43d authored by ChasLui's avatar ChasLui Committed by GitHub

fix: shortcuts should exclude the shift judgment (#796)

* fix: Shortcuts should exclude the shift judgment

* fix: eslint
parent 2658b1fd
...@@ -102,7 +102,9 @@ const MemoEditor = () => { ...@@ -102,7 +102,9 @@ const MemoEditor = () => {
return; return;
} }
if (event.ctrlKey || event.metaKey) { const isMetaKey = event.ctrlKey || event.metaKey;
const isShiftKey = event.shiftKey;
if (!isShiftKey && isMetaKey) {
if (event.key === "Enter") { if (event.key === "Enter") {
handleSaveBtnClick(); handleSaveBtnClick();
return; return;
...@@ -134,7 +136,7 @@ const MemoEditor = () => { ...@@ -134,7 +136,7 @@ const MemoEditor = () => {
} }
} }
if (event.key === "Enter") { if (!isShiftKey && event.key === "Enter") {
const cursorPosition = editorRef.current.getCursorPosition(); const cursorPosition = editorRef.current.getCursorPosition();
const contentBeforeCursor = editorRef.current.getContent().slice(0, cursorPosition); const contentBeforeCursor = editorRef.current.getContent().slice(0, cursorPosition);
const rowValue = last(contentBeforeCursor.split("\n")); const rowValue = last(contentBeforeCursor.split("\n"));
...@@ -169,13 +171,13 @@ const MemoEditor = () => { ...@@ -169,13 +171,13 @@ const MemoEditor = () => {
} }
return; return;
} }
if (event.key === "Escape") { if (!isShiftKey && event.key === "Escape") {
if (state.fullscreen) { if (state.fullscreen) {
handleFullscreenBtnClick(); handleFullscreenBtnClick();
} }
return; return;
} }
if (event.key === "Tab") { if (!isShiftKey && event.key === "Tab") {
event.preventDefault(); event.preventDefault();
editorRef.current.insertText(" ".repeat(TAB_SPACE_WIDTH)); editorRef.current.insertText(" ".repeat(TAB_SPACE_WIDTH));
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment