mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 19:05:59 +01:00
chore(react): finalize note title porting
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
|
||||||
import SpacedUpdate from "../services/spaced_update.js";
|
|
||||||
import appContext, { type EventData } from "../components/app_context.js";
|
|
||||||
import branchService from "../services/branches.js";
|
|
||||||
import shortcutService from "../services/shortcuts.js";
|
|
||||||
|
|
||||||
export default class NoteTitleWidget extends NoteContextAwareWidget {
|
|
||||||
|
|
||||||
private $noteTitle!: JQuery<HTMLElement>;
|
|
||||||
private deleteNoteOnEscape: boolean;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.deleteNoteOnEscape = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
doRender() {
|
|
||||||
this.$widget = $(TPL);
|
|
||||||
this.$noteTitle = this.$widget.find(".note-title");
|
|
||||||
this.$noteTitle.on("blur", () => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
|
|
||||||
if (this.isNoteContext(noteContext.ntxId)) {
|
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async beforeNoteContextRemoveEvent({ ntxIds }: EventData<"beforeNoteContextRemove">) {
|
|
||||||
if (this.isNoteContext(ntxIds)) {
|
|
||||||
await this.spacedUpdate.updateNowIfNecessary();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -48,6 +48,7 @@ export default function NoteTitleWidget() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
|
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
|
||||||
}, []);
|
}, []);
|
||||||
|
useTriliumEventBeta([ "beforeNoteSwitch", "beforeNoteContextRemove" ], () => spacedUpdate.updateNowIfNecessary());
|
||||||
|
|
||||||
// Manage focus.
|
// Manage focus.
|
||||||
const textBoxRef = useRef<HTMLInputElement>(null);
|
const textBoxRef = useRef<HTMLInputElement>(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user