Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: incorrect cursor when text is selected in range (#797)

ChasLuib6fe4d914e53
diff --git a/web/src/components/MemoEditor.tsx b/web/src/components/MemoEditor.tsx
index 12455cbd0..7e852e2bc 100644
--- a/web/src/components/MemoEditor.tsx
+++ b/web/src/components/MemoEditor.tsx
@@ -179,7 +179,12 @@ const MemoEditor = () => {
}
if (!isShiftKey && event.key === "Tab") {
event.preventDefault();
+ const selectedContent = editorRef.current.getSelectedContent();
+ const cursorPosition = editorRef.current.getCursorPosition();
editorRef.current.insertText(" ".repeat(TAB_SPACE_WIDTH));
+ if (selectedContent) {
+ editorRef.current.setCursorPosition(cursorPosition + TAB_SPACE_WIDTH);
+ }
return;
}