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

pull/784/head^2
ChasLui 2 years ago committed by GitHub
parent 3c2cd43d28
commit b6fe4d914e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}

Loading…
Cancel
Save