Unverified Commit b6fe4d91 authored by ChasLui's avatar ChasLui Committed by GitHub

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

parent 3c2cd43d
...@@ -179,7 +179,12 @@ const MemoEditor = () => { ...@@ -179,7 +179,12 @@ const MemoEditor = () => {
} }
if (!isShiftKey && event.key === "Tab") { if (!isShiftKey && event.key === "Tab") {
event.preventDefault(); event.preventDefault();
const selectedContent = editorRef.current.getSelectedContent();
const cursorPosition = editorRef.current.getCursorPosition();
editorRef.current.insertText(" ".repeat(TAB_SPACE_WIDTH)); editorRef.current.insertText(" ".repeat(TAB_SPACE_WIDTH));
if (selectedContent) {
editorRef.current.setCursorPosition(cursorPosition + 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