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();
|
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();
|
||||||
|
|||||||
@@ -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}
|
||||||
|
|||||||
@@ -57,9 +57,4 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
|
|||||||
this.codeEditor.focus();
|
this.codeEditor.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToEnd() {
|
|
||||||
this.codeEditor.scrollToEnd();
|
|
||||||
this.codeEditor.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user