mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: scrool to memo after editing (#907)
This commit is contained in:
@ -295,6 +295,15 @@ const MemoEditor = () => {
|
|||||||
return resource;
|
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 handleSaveBtnClick = async () => {
|
||||||
const content = editorRef.current?.getContent() ?? "";
|
const content = editorRef.current?.getContent() ?? "";
|
||||||
try {
|
try {
|
||||||
@ -341,6 +350,8 @@ const MemoEditor = () => {
|
|||||||
setEditorContentCache("");
|
setEditorContentCache("");
|
||||||
storage.remove(["editingMemoVisibilityCache"]);
|
storage.remove(["editingMemoVisibilityCache"]);
|
||||||
editorRef.current?.setContent("");
|
editorRef.current?.setContent("");
|
||||||
|
|
||||||
|
scrollToEditingMemo();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancelEdit = () => {
|
const handleCancelEdit = () => {
|
||||||
@ -351,6 +362,8 @@ const MemoEditor = () => {
|
|||||||
setEditorContentCache("");
|
setEditorContentCache("");
|
||||||
storage.remove(["editingMemoVisibilityCache"]);
|
storage.remove(["editingMemoVisibilityCache"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToEditingMemo();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContentChange = (content: string) => {
|
const handleContentChange = (content: string) => {
|
||||||
|
Reference in New Issue
Block a user