mirror of
https://github.com/zadam/trilium.git
synced 2025-11-05 04:45:47 +01:00
chore(react/type_widget): bring back scroll to end
This commit is contained in:
@@ -149,20 +149,6 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
||||
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">) {
|
||||
if (this.isNoteContext(noteContext.ntxId)) {
|
||||
await this.spacedUpdate.updateNowIfNecessary();
|
||||
|
||||
@@ -131,6 +131,13 @@ function CodeEditor({ note, parentComponent, ntxId, containerRef: externalContai
|
||||
resolve(refToJQuerySelector(containerRef));
|
||||
});
|
||||
|
||||
useTriliumEvent("scrollToEnd", () => {
|
||||
const editor = codeEditorRef.current;
|
||||
if (!editor) return;
|
||||
editor.scrollToEnd();
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
return <CodeMirror
|
||||
{...editorProps}
|
||||
editorRef={codeEditorRef}
|
||||
|
||||
@@ -57,9 +57,4 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
||||
this.codeEditor.focus();
|
||||
}
|
||||
|
||||
scrollToEnd() {
|
||||
this.codeEditor.scrollToEnd();
|
||||
this.codeEditor.focus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user