mirror of
https://github.com/usememos/memos.git
synced 2025-10-17 09:46:55 +08:00
feat: scrool to memo after editing (#907)
This commit is contained in:
parent
b8ab43aa25
commit
942e1f887b
1 changed files with 13 additions and 0 deletions
|
@ -295,6 +295,15 @@ const MemoEditor = () => {
|
|||
return resource;
|
||||
};
|
||||
|
||||
const scrollToEditingMemo = useCallback(() => {
|
||||
if (editorState.editMemoId) {
|
||||
const memoElements = document.getElementsByClassName(`memos-${editorState.editMemoId}`);
|
||||
if (memoElements.length !== 0) {
|
||||
memoElements[0].scrollIntoView({ behavior: "smooth" });
|
||||
}
|
||||
}
|
||||
}, [editorState.editMemoId]);
|
||||
|
||||
const handleSaveBtnClick = async () => {
|
||||
const content = editorRef.current?.getContent() ?? "";
|
||||
try {
|
||||
|
@ -341,6 +350,8 @@ const MemoEditor = () => {
|
|||
setEditorContentCache("");
|
||||
storage.remove(["editingMemoVisibilityCache"]);
|
||||
editorRef.current?.setContent("");
|
||||
|
||||
scrollToEditingMemo();
|
||||
};
|
||||
|
||||
const handleCancelEdit = () => {
|
||||
|
@ -351,6 +362,8 @@ const MemoEditor = () => {
|
|||
setEditorContentCache("");
|
||||
storage.remove(["editingMemoVisibilityCache"]);
|
||||
}
|
||||
|
||||
scrollToEditingMemo();
|
||||
};
|
||||
|
||||
const handleContentChange = (content: string) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue