chore(react/type_widget): bring back scroll to end

This commit is contained in:
Elian Doran
2025-09-20 11:37:57 +03:00
parent e576fa03da
commit 6ef468adc4
3 changed files with 7 additions and 19 deletions

View File

@@ -149,20 +149,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
widget.focus(); widget.focus();
} }
async scrollToEndEvent({ ntxId }: EventData<"scrollToEnd">) {
if (this.noteContext?.ntxId !== ntxId) {
return;
}
await this.refresh();
const widget = this.getTypeWidget();
await widget.initialized;
if (widget.scrollToEnd) {
widget.scrollToEnd();
}
}
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) { async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
if (this.isNoteContext(noteContext.ntxId)) { if (this.isNoteContext(noteContext.ntxId)) {
await this.spacedUpdate.updateNowIfNecessary(); await this.spacedUpdate.updateNowIfNecessary();

View File

@@ -131,6 +131,13 @@ function CodeEditor({ note, parentComponent, ntxId, containerRef: externalContai
resolve(refToJQuerySelector(containerRef)); resolve(refToJQuerySelector(containerRef));
}); });
useTriliumEvent("scrollToEnd", () => {
const editor = codeEditorRef.current;
if (!editor) return;
editor.scrollToEnd();
editor.focus();
});
return <CodeMirror return <CodeMirror
{...editorProps} {...editorProps}
editorRef={codeEditorRef} editorRef={codeEditorRef}

View File

@@ -57,9 +57,4 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
this.codeEditor.focus(); this.codeEditor.focus();
} }
scrollToEnd() {
this.codeEditor.scrollToEnd();
this.codeEditor.focus();
}
} }