Repository: usememos/memos
File: web/src/components/MemoEditor.tsx (TypeScript)

Code before:
    prevGlobalStateRef.current = editorState;
  }, [editorState.editMemoId]);

  const handleKeyDown = (event: React.KeyboardEvent) => {
    if (event.key === "Enter") {
      if (!editorRef.current) {
        return;
      }
      const cursorPosition = editorRef.current.getCursorPosition();
      const prevValue = editorRef.current.getContent().slice(0, cursorPosition);
      const prevRows = prevValue.split("\n");
      const prevRowValue = prevRows[prevRows.length - 1];
      if (prevRowValue === "- " || prevRowValue === "- [ ] " || prevRowValue === "- [x] " || prevRowValue === "- [X] ") {
        event.preventDefault();
        prevRows[prevRows.length - 1] = "";
        editorRef.current.setContent(prevRows.join("\n"));
      } else {
        if (prevRowValue.startsWith("- [ ] ") || prevRowValue.startsWith("- [x] ") || prevRowValue.startsWith("- [X] ")) {
          event.preventDefault();
          editorRef.current.insertText("", "\n- [ ] ");
        } else if (prevRowValue.startsWith("- ")) {
          event.preventDefault();
          editorRef.current.insertText("", "\n- ");
        }
      }
    }
    if (event.key === "Escape") {
      if (state.fullscreen) {
        handleFullscreenBtnClick();
      } else {
        handleCancelEdit();
      }
      return;
    }
    if (event.key === "Tab") {
      event.preventDefault();
      editorRef.current?.insertText(" ".repeat(TAB_SPACE_WIDTH));
      return;
    }
    if (event.ctrlKey || event.metaKey) {
      if (event.key === "Enter") {
        handleSaveBtnClick();
        return;
      }
      if (event.key === "b") {
        event.preventDefault();
        editorRef.current?.insertText("", "**", "**");
        return;
      }
      if (event.key === "i") {
        event.preventDefault();

Review comment (suggestion):
```suggestion
          event.preventDefault();
          editorRef.current.insertText("", "\n- ");
        }
      }
      return;
    }
```

Code after:
    prevGlobalStateRef.current = editorState;
  }, [editorState.editMemoId]);

  const handleKeyDown = (event: React.KeyboardEvent) => {
    if (event.key === "Enter") {
      if (!editorRef.current) {
        return;
      }
      const cursorPosition = editorRef.current.getCursorPosition();
      const prevValue = editorRef.current.getContent().slice(0, cursorPosition);
      const prevRows = prevValue.split("\n");
      const prevRowValue = prevRows[prevRows.length - 1];
      if (prevRowValue === "- " || prevRowValue === "- [ ] " || prevRowValue === "- [x] " || prevRowValue === "- [X] ") {
        event.preventDefault();
        prevRows[prevRows.length - 1] = "";
        editorRef.current.setContent(prevRows.join("\n"));
      } else {
        if (prevRowValue.startsWith("- [ ] ") || prevRowValue.startsWith("- [x] ") || prevRowValue.startsWith("- [X] ")) {
          event.preventDefault();
          editorRef.current.insertText("", "\n- [ ] ");
        } else if (prevRowValue.startsWith("- ")) {
          event.preventDefault();
          editorRef.current.insertText("", "\n- ");
        }
      }
      return;
    }
    if (event.key === "Escape") {
      if (state.fullscreen) {
        handleFullscreenBtnClick();
      } else {
        handleCancelEdit();
      }
      return;
    }
    if (event.key === "Tab") {
      event.preventDefault();
      editorRef.current?.insertText(" ".repeat(TAB_SPACE_WIDTH));
      return;
    }
    if (event.ctrlKey || event.metaKey) {
      if (event.key === "Enter") {
        handleSaveBtnClick();
        return;
      }
      if (event.key === "b") {
        event.preventDefault();
        editorRef.current?.insertText("", "**", "**");
        return;
      }
      if (event.key === "i") {